T÷lvunarfrŠ­i 2

Weekly note 9

Now we will start looking at simple sorting methods from Chapter 6 in the textbook. We will cover Selection sort, Insertion sort, and Bubble sort. These methods are easy to describe, but they are not very fast. We will analyse their performance, and then we will go onto a faster (but more complicated) method called Shell sort.

In the sections this week we will cover the last homework.

Problem set 8

Solve the following problems and put the solutions into your section teacher's box before noon monday March 14th. They will not accept solutions that arrive later.

  1. Exercise 5.79 on page 249 in the textbook.

  2. Exercise 1 on page 9 in CDSI.

  3. Exercise 2 a) and c) on page 9 in CDSI.

  4. Exercise 6.3 on page 272 in the textbook.

  5. Implement in C++ binary insertion sort, which is just like normal insertion sort, except we use binary search to find the right location of the next item in the sorted part of the array. Compare its speed to the insertion sort given in the textbook (Program 6.3) on large enough arrays containing random numbers.
    [Hint: See sample solution (only in icelandic) from last year. ]

Those that want more practice should try solving the following problems. Their solutions are all availableon the old homepages of the course. If you want an explanation of the solutions you can ask about them in your section.
hh (hja) hi.is, March 7th, 2005.