Which of the following describes a stable sorting algorithm?

Prepare for the Leaving Certificate Computer Science Test with a mix of flashcards and multiple choice questions, each designed to enhance learning. Discover tips and resources for success. Ace your exam with confidence!

A stable sorting algorithm is characterized by maintaining the relative order of equal elements in the sorted output. This means that if two elements are considered equal based on the sorting criteria, their order in the sorted list will reflect their original order from the input. This property is important in scenarios where the order carries additional significance, such as sorting records of student data by grade while retaining their order by name for students with the same grade.

For instance, if you have a list of employees sorted by department and you want to sort the same list by name while maintaining the initial department order for employees with the same name, a stable sorting algorithm ensures that the department order is preserved.

The other options touch on various aspects of sorting algorithms but do not specifically define stability. While some stable sorting algorithms might only make one comparison per element or use additional memory, these are not characteristics that define stability itself. Similarly, a stable sorting algorithm can be implemented in various ways, leading to in-place or not, depending on its design. Stability is a distinct concept primarily concerned with the ordering of equal elements in the sorted output.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy