An algorithm is called stable if elements that are of the sa

An algorithm is called stable if elements that are of the same value do not change their order after the sorting. Is Merge-sort stable? Find a way to make any sorting algorithm stable (you can add additional data to every number).

Solution

Answer:

a) Yes , Merge sort is stable algorithm.

b) We can make stable algorithm by the way we code. It can be done by making comparison part change

like in some algorithms, there we just use < instead use <= ... but this condition changes algorithm.

 An algorithm is called stable if elements that are of the same value do not change their order after the sorting. Is Merge-sort stable? Find a way to make any

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site