Strand sort: Difference between revisions

Content deleted Content added
Heldw (talk | contribs)
Heldw (talk | contribs)
Bolded the steps to make it more readable
Line 7:
Based off of the description of the algorithm provided in the book''IT enabled practices and emerging management paradigms''.
 
'''Step 1:''' Start with a list of numbers: {13, 7, 19, 6, 25, 29, 1, 4 }
 
'''Step 2:''' Next move the first element of the list into a new sub-list:  sub-list contains {13}
 
'''Step 3:''' Then iterate through the original list and compare each number to 13 until there is a number greater than 13.
 
2 < 13 so 7 is not added to the sub-list. 19 > 13 so 19 is added to the list.
 
'''Step 4:''' Now compare 19 with the remaining elements in the original list until there is a number greater than 19.  
 
6 < 19 so 6 is not added to the list. 25 > 19 so 25 is added to the sub-list.
 
'''Step 5:''' Now compare 25 to the remaining elements in the original list until there is a number greater than 25.
 
29 > 25 so 29 is added to the sub-list.
 
'''Step 6:''' Now compare 29 to the remaining elements in the original list until there is a number greater than 29.
 
29 > 1 so 1 is not added to the sub-list. 29 > 4 so 4 is not added to the sub-list.
 
'''Step 7:''' Merge the sub-list into a new list, called solution-list.
 
After step 7, the original list contains {7, 6, 1, 4}
Line 33:
The sub-list is empty, and the solution list contains {13, 19, 25, 19}
 
'''Step 8:''' Move the first element of the original list into sub-list: sub-list contains {7}
 
'''Step 9:''' Iterate through the original list and compare each number to 7 until there is a number greater than 7.
 
6 < 7 so 6 is not added to the sub-list. 1 < 7 so 1 is not added to the sub-list. 4 < 7 so 4 is not added to the sub list.
 
'''Step 10:''' Merge sub-list with solution-list. Now sub-list is empty and solution-list contains: {7, 13, 19, 25, 19}.
 
'''Step 11:'''  Move the first element of the original list into sub-list. Sub-list contains {6}
 
'''Step 12:''' Iterate through the original list and compare each number to 6 until there is a number greater than 6.
 
1 < 6 so 1 is not added to the sub-list. 4 < 6 so 4 is not added to the sub-list.
 
'''Step 13:''' Since there are no more elements in the original list to compare {6} to, the sub-list is merged with the solution list.
 
The solution list now contains: {6, 7, 13, 19, 25, 19}.
 
'''Step 14:'''  Move the first element of the original list into sub-list. Sub-list contains {1}
 
'''Step 15:'''  Iterate through the original list and compare each number to 1 until there is a number greater than 1.
 
4 > 1 so 4 is added to the sub-list.
 
'''Step 16:'''  Since there are no more elements in the original list to compare {4} to, the sub-list is merged with the solution list.
 
The solution list now contains: {1,4, 6, 7, 13, 19, 25, 19}. There are now more elements in the original list, and all of the elements in the solution list have successfully been sorted into increasing numerical order.