Introduction to Sorting by R4R Team

What is sorting ?
Sorting refers to ordering data in an increasing or decreasing fashion according to some linear relationship among the data items.

Why Sorting ?
We doing sorting on the data because after sorting, searching of item is easy.

Advantage of Sorting ?
We data is not sort, then we perform linear search that takes O(n) time, while after sorting we perform binary search that takes O(log(n)) time.

Different Sorting Sorting Algorithms:
Bubble sort
Insertion Sort
Selection Sort
Merge Sort
Quick Sort

Type of sorting :
On the basis of memory consumption, sorting are of two type
1. Internal sorting : In internal sorting the data that has to be sorted will be in the main memory always, implying faster access. Complete sorting will happen in main memory.
Example-Insertion sort, quick sort, heap sort, radix sort.

2. External Sorting: In external sorting it will on disks, outside main memory. It can be because the data is huge and cannot be stored in main memory. While sorting the data will pulled over in chunks from disk to main memory. Later all the sorted data will be merged and stored back to disk, where it can fit. External merge sort can be used here.

On the basis of data
1. stable sorting:
A sorting algorithm is said to be stable if it maintains the relative order of numbers/records in the case of tie.

2. unstable sorting:
A sorting algorithm is said to be unstable if it is not maintains the relative order of numbers/records in the case of tie.




Leave a Comment:
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!