Skip to content

Commit f70afb6

Browse files
committed
Exercises
1 parent cc41c4d commit f70afb6

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

src/algorithms/extra-info/MSDRadixSortInfo.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,17 @@ Sort)
2525
The coding of partition used in AIA is based on the coding in quicksort.
2626
Compare and contrast the two. What other approaches to coding partition
2727
could be used?
28+
29+
In quicksort, the maximum stack size depends greatly on the order of the
30+
input data. For MSD radix sort, what influence does the input order have
31+
(if any), and why?
32+
33+
Compare and contrast the behaviour of quicksort and MSD radix sort when
34+
there are many duplicate keys. When is quicksort better (if ever)? When
35+
is MSD radix sort better (if ever)?
36+
37+
In quicksort, the runtime generally is not affected by the size of the
38+
numbers being sorted: we can square each number and the run time is
39+
the same. For the AIA version of MSD radix sort, what is the expected
40+
affect on run time if we square each number in the input?
41+

src/algorithms/extra-info/QSM3Info.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,12 @@ an array element) was written so as to minimise the number of instructions
3535
executed by the hardware. Hardware has changed a lot since then! Look
3636
into some more recent efficient ways of coding partition.
3737

38+
Give two examples of input to quicksort which best cases for median
39+
of three partitioning but are worst cases for the simple version of
40+
quicksort.
41+
42+
Can you construct a worst case input for median of three quicksort for
43+
the number 1 to 12? For example, the first call to partition takes
44+
the median of 3, 2 and 1, the second takes the median of 5, 4 and 3,
45+
the next has 7, 6 and 5 etc.
46+

src/algorithms/extra-info/StraightRadixSortInfo.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,13 @@ Geeks for Geeks Links: [**(Straight/LSD) Radix Sort**][G4GLink] and
2121
[G4GLink]: https://www.geeksforgeeks.org/radix-sort/
2222
[G4GLink2]: https://www.geeksforgeeks.org/counting-sort/
2323

24+
## Exercises/Exploration
25+
26+
In *counting sort*, temporary array **B** is filled by scanning array
27+
**A** from right to left. If it was scanned from left to right, array
28+
**B** would still end up sorted on the digit in question. What would
29+
the affect be on the radix sorting if left to right scanning was used?
30+
31+
Look up how sorting punched cards has been done historically. Card
32+
sorting machines used LSD radix sorting! How could you sort a deck of
33+
playing cards using LSD radix sorting?

0 commit comments

Comments
 (0)