Hi i will share the notes i obtain from my lecture
Sorting can be done 2 ways, ascending or descending.
I learnt 5 ways of sorting :
- bubble sort
- selection sort
- insertion sort
- quick sort
- merge sort
Bubble,selection and insertion all took a lot of time to do that is because they compare every single array element with the other.
while quick and merge sort are faster and they use recursive function to do them.
Searching is an action to retrieve information based on particular key from saved information
Key is used to differentiate between one data and the other, Key must be unique so there is no duplicate key inside a data.
Several searching methods are : Linear, Binary, Interpolation
- Linear search : compares each element inside an array with the key
- Binary search : find data using its binary, but the data needs to be sorted first
- Interpolation data : also works on sorted array, searching technique is done with the approximate location of data.
No comments:
Post a Comment