A bit late i guess but better late than never, that day we learn about Sorting and Searching.
Sorting
- Bubble Sort
for inside of for
algo ex :
void Bubble(int *DataArr, int n)
{
int i, j;
for(i=1; i=i; j–)
if(DataArr[j-1] > DataArr[j])
Swap(&DataArr[j-1],&DataArr[j]);
}
- Selection Sort
from smallest index to the biggest
Algo Ex:
for(i=0; i<=N-2; i++){ /* N=number of data */
for(j=i; j<=N-1; j++){
Note the index of smallest value between A[j] s/d A[N-1],
Save it in variable k.
Swap A[i] with A[k].
}
}
- Insertion Sort
- Quick Sort -> Recursive func.
- Merge Sort
Searching
- Linear Search
- Binary Search -> Usually for Mass amount of data
- Interpolation Search -> Same as Binary usually for Mass amount of data
welp that’s sum it all bubble and sort is the easiest so i just take a note only about those two