Sorting and Searching

Sorting

Sorting needed to speed up searching operation. Sorting : Ascennding or Descending.

Simple sorting :
1.Bubble sort : compare 2 neighboring values and swap if necessery.
2.Selection sort : find the smallest, after finished it swap.
3.Insertion sort

Inetrmediate sorting:
1.Quick sort
2.Merge sort : is a sorting algorithm based on the divide-and-conquer algorithm.
divide: divide the input data in two disjoint subsets. conquer: combine the solutions for each subset into a solution

Searching

Search is the process of finding a particular element of an array or finding a value that matches a certain key value. Key must be unique, means there must not be any same key in the data.

Types of searching:
1.Linear SearchLinear search compares each element of the array with the search key.
the program will have to compare the search key with half the elements of the array.
2.Binary Search : For large arrays because it is more efficient.
3.Interpolation Search : Performed on the sorted data. Technique is done with the approximate location of the data.




Samuel Xavier Widjaja
2201737412
binus.ac.id

Comments