1. Create an array of 10 random integers
  2. Start with an empty list
  3. Choose the i-th element from the array and insert it into the appropriate position in the list
  4. Repeat for all elements in the array
  5. Copy the sorted list into an array and output it
  6. Check that the resulting array is sorted

Solution

  • Recall the merge sort algorithm that we implemented in class. We used recursion for our implementation.
  1. Try to implement merge sort without recursion. This is quite tricky to do in practice. So think before you implement your algorithm. Do not look for solutions in Google!
  2. Check that your algorithm is correct by running it on an array of 10 random integers.

Solution

 
Back to top
courses/fall2011/598z/lab/week12.txt · Last modified: 2011/12/01 11:16 by vishy
 
 
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0