filmov
tv
DSA Quiz: Sorting Secrets
Показать описание
Stable Sorting Algorithm: A sorting algorithm is said to be stable if it preserves the relative order of elements with equal keys. That is, if two elements have the same value, they appear in the same order in the sorted array as they appeared in the input array.
Merge Sort: Merge Sort is stable because, during the merging process, if two elements are equal, the one from the left subarray is always placed before the one from the right subarray. This preserves their relative order.
Merge Sort: Merge Sort is stable because, during the merging process, if two elements are equal, the one from the left subarray is always placed before the one from the right subarray. This preserves their relative order.