2. SORTING
Sorting is refers to the operation or technique of arranging and
rearranging sets of data in some specific order.
A collection of records called a list where every record is having
one or more fields.
The fields which contains unique value for each record, is
termed as the key field.
For example, a phone number directory can be thought of as a
list where each record has three fields – ‘name’ of the person,
‘address’ of those person, and their ‘phone numbers’.
Being unique phone number can work as a key to locate any
record in the list.
Sorting is also used to represent data in more readable
formats.
3. CATEGORIES OF SORTING
• The techniques of sorting can be divided into two
categories. These are:
1. Internal Sorting
2. External Sorting
• Internal Sorting: If all the data that is to be sorted
can be adjusted at a time in main memory, the
internal sorting method is being performed.
• External Sorting: When the data that is to be
sorted cannot be accommodated in the memory
at the same time and some has to be kept in
auxiliary memory such as hard disk, floppy disk,
magnetic tapes etc, then external sorting methods
are performed.
5. DIVIDE AND CONQUER
• An algorithm is only called divide and conquer if it contains two
or more recursive calls
• The divide and conquer strategy used to
make a more efficient search algorithm
can also be applied to sorting
It is used in Merge Sort and Quick Sort.
6. DIVIDE AND CONQUER (CONT.)
Divide : Divide the problem P into P1 , P2,……Pk sub
problems until P is smaller one
Conquer : the sub-problems by solving them recursively
Combine : the solutions of sub problems to create a
solution to the original problem