What is sorting? Types of Sortings

 

What is sorting? Types of Sorting's


  • Sorting Algorithms are methods of reorganizing a large number of items into some specific order such as highest to lowest, or vice-versa, or even in some alphabetical order.

  • These algorithms take an input list/array, processes it (i.e, performs some operations on it) and produce the sorted list.


  • Sorting arranges data in a sequence which makes searching easier.

  • The most common example we experience every day is 

    • Telephone Directory

    • Dictionary

    • sorting clothes or 

    • other items on an e-commerce website either by lowest-price to highest, or list by popularity,

    •  or some other order.


There are two different categories in sorting:

  • Internal sorting: If the input data is such that it can be adjusted in the main memory at once, it is called internal sorting.

  • External sorting: If the input data is such that it cannot be adjusted in the memory entirely at once, it needs to be stored in a hard disk, floppy disk, or any other storage device. This is called external sorting.

The two main criteria to judge which algorithm is better than the other have been:

  1. Time taken to sort the given data.

  2. Memory Space required to do so


Stability of Sorting Algorithms

Stability is mainly important when we have key value pairs with duplicate keys possible (like people names as keys and their details as values). And we wish to sort these objects by keys

Def.:

A sorting algorithm is said to be stable if two objects with equal keys appear in the same order in sorted output as they appear in the input array to be sorted.


  • Some Sorting Algorithms are stable by nature, such as Bubble Sort, Insertion Sort, Merge Sort, Count Sort etc.


  • Selection sort, quick sort, heap sort etc are unstable sorting algorithms.


No comments

JavaFX Scene Builder

  This is an article about the JavaFX Scene Builder. You will get a short introduction about the installation and usage of the software. The...