Which of the following sorting algorithms are (or are not) considered greedy algorithms? quick, insertion, selection, heap and merge. Justify your answers.
Expert Answer
GREEDY ALGORITHM :
Greedy algorithm is an algorithmic paradigm that follows the problem solving heuristic of making the locally optimal choice at each stage with the hope of finding a global optimum.
MERGE SORT:
The merge sort is considered as a greedy algorithm because ,the merge sort is a sorting technique based on divide and conquer technique . with worst-case time complexity being o(n log n),it is one the most respected algorithm .
merge sort first divides the array in to equal halves and then combines them in a sorted manner.
QUICK SORT:
It is also used on the principle of Divide and conquer.quick sort is an algorithm of choice in so many situations,it is to implement.It consumes relatively fewer resources during execution.It is in place since it uses only a small auxillary stack .It has an extremly short inner loop .
HEAP SORT:
Heap is a comparison based sorting ,it is depend up on binary heap data structure.it is similar to selection sort where we fisrt find the maximum element and place the maximum element at the end. It is do not apparoch on the greedy algorthim.
SELECTION SORT:
Selection sort is a method of choice for sorting files with very large objects and small keys .The worst case occurs if the array is already sorted in a desending order and we want to sort in assending order.It is also the comparsion based sorting method so the greddy apporach is not possible.
INSERTION SORT:
Insertion sort is a very smiple method to sort in an assending or desending order.
It compared with the thechnique how cards are sorted at the time of playing a game,it is also do not depend on the greedy algorithms .