hai!
How to sort numbers in java using logical OR operator??
8 Replies  2445 Views  Last Post: 30 December 2009  08:14 PM
Replies To: sorting numbers in java
#2
Re: sorting numbers in java
Posted 30 December 2009  12:32 AM
Do you have more details on the assignment/task to do? We can't just provide help without some effort from you. Provide details and we will be happy to help you!
BTW, welcome to DIC! I suggest you post in the "Introduce yourself" forum in order for the members to greet you
BTW, welcome to DIC! I suggest you post in the "Introduce yourself" forum in order for the members to greet you
#4
Re: sorting numbers in java
Posted 30 December 2009  01:38 AM
wiki sorting algorithms
#5
Re: sorting numbers in java
Posted 30 December 2009  10:04 AM
sacstate2600, on 30 Dec, 2009  04:38 AM, said:
wiki sorting algorithms
+1. Wikipedia is a very good resource for this type of thing.
@OP: Just FYI, most sorting algorithms don't use the logical or operator (at least none that I can think of). They instead sort elements based on their relation to other elements (comparisonswap sorts), which is a very common method that you'll find easy to implement. Some of these algorithms include Insertion Sort, Selection Sort, and Bubblesort. If you're up for a challenge, you may consider looking at Mergesort or Quicksort. Good luck!
(Also, just a note, we don't give out source code for requests like "Sorting routine using logical or operator." If you have a specific question, we are happy to help. Just remember, the more effort you show, the more helpful we can be.)
#6
Re: sorting numbers in java
Posted 30 December 2009  01:49 PM
The closest thing I can think up at the moment is radix sort.
The algorithm works by processing individual digits.
The algorithm works by processing individual digits.
#7
Re: sorting numbers in java
Posted 30 December 2009  02:19 PM
skaoth, on 30 Dec, 2009  04:49 PM, said:
The closest thing I can think up at the moment is radix sort.
The algorithm works by processing individual digits.
The algorithm works by processing individual digits.
In all honesty, the OR operator doesn't work well in sorting algorithms because it leaves room for elements to fall out of place. Sorting algorithms should be very specific about the order for sorting. The only example I can think of where you might use the OR operator would be in the implementation of the Comparable interface (compareTo() method) for Objects. For example, if you are trying to sort elements in inventory by priority for ordering, you may need to specify which conditions take precedence; and sometimes, varying magnitudes of multiple attributes may toggle the priority. In these cases though, I prefer to use a quantitative system of some sort so that you have a method for comparison. Following the inventory example, this quantitative system would probably be the money earned in the given time period (usually the timeframe between orders).
#8
Re: sorting numbers in java
Posted 30 December 2009  02:32 PM
radix sort doesn't use the OR operator.
It is a very specific sort that is meant for integers. It is similar to bucket sort. It exploits the fact that integers can be 32 or 64 bits. Given this the algorithm attempts to provide faster than n lg n sorting.
I only make the reference to this because it is common to use bit shifting in the implementation, and potentially the confusion between bit shifting and logical OR.
It is a very specific sort that is meant for integers. It is similar to bucket sort. It exploits the fact that integers can be 32 or 64 bits. Given this the algorithm attempts to provide faster than n lg n sorting.
I only make the reference to this because it is common to use bit shifting in the implementation, and potentially the confusion between bit shifting and logical OR.
#9
Re: sorting numbers in java
Posted 30 December 2009  08:14 PM
skaoth, on 30 Dec, 2009  05:32 PM, said:
radix sort doesn't use the OR operator.
It is a very specific sort that is meant for integers. It is similar to bucket sort. It exploits the fact that integers can be 32 or 64 bits. Given this the algorithm attempts to provide faster than n lg n sorting.
I only make the reference to this because it is common to use bit shifting in the implementation, and potentially the confusion between bit shifting and logical OR.
It is a very specific sort that is meant for integers. It is similar to bucket sort. It exploits the fact that integers can be 32 or 64 bits. Given this the algorithm attempts to provide faster than n lg n sorting.
I only make the reference to this because it is common to use bit shifting in the implementation, and potentially the confusion between bit shifting and logical OR.
Really, any person who doesn't understand the meaning of the word OR (as it is the exact same in the context of programming as well as in real life) shouldn't be working with sorting routines. They should probably be in kindergarten or the first grade instead. I also think that even if you didn't know what bitshifting is, just by virtue of that it should be difficult to confuse it with the OR operator.
Page 1 of 1
