Week 7
Sunil Tripathi
K200295
Again similar to Week 5 or 6.
Use Set 24 Priority Queues slides 39-52 and act out Set 24 DemoHeapsort
Q.1 Consider the data PRACTISEHEAP, build a max heap and then apply heapsort.
Homework Exercises
1. Slide 52 provides a useful summary of the different sorting algorithms.
For each algorithm, provide an application from real life for which you think the
algorithm might be the most suitable sort for that application. Consider, the speed of
the algorithm, the space the algorithm requires, stability, the size of the data in the
problem, the speed of your computer, etc.
Answers
Sorting algorithm Application
Selection sort Sorting flash cards
Sorting for short lists, 30 people weights
Insertion sort
It is not that much related to real world. It
Shell sort makes advantages because it does not use
additional memory. So, the cases where an
additional memory not available, shell sort
is a good answer.
Merge sort For e-commerce applications
Timsort It is based on insertion sort and merge sort,
so the applications for e-commerce Tim
sort is good choice
Quicksort It does not need additional memory;
commercial applications use quick sort.
Heap sort Real time embedded systems where less
space available.