wiki:k2014/demot/demo2english
Last modified 2 years ago Last modified on 2015-09-11 12:19:21

Demot » Demo 2, 27.1.2014

Task 1, different sorting

We have a sorting algorithm for k-sized words (assuming you are having k-sized words written on paper):

0. i = k
1. Put the paper to a corresponding pile depending of its i:th letter
   (there's a pile for letter A, B and so forth) 
2. i = i - 1
3. Gather the piles so that the topmost pile will be the pile of A's
4. if i > 0, continue from step 1.
5. Names are in order.

If each of the names would have 10 letters, what would be the complexity of this sorting algorithm?(How many times each of the notes would be looked at.)

Task 2, Binary search

Try binary search on a phone book with 3 different names(some might be in the phonebook and some not). Take note that you have to keep splitting through the last page also to find the correct name.

Is the complexity the same as it is supposed to be? (Around 7 searches)

Task 4*, Red cards to the other side

Do not use already done algorithms (make your own). There are cards in a row on the table. You're supposed to make an algorithm that will move all the red cards to the left side and black cards to the right.

Task 5, Next date

The dates are in the form dd.mm. Write an english algorithm (not java-program) that increases the date by one. TDD: Write enough different examples of different special cases.