Please enable JavaScript.
Coggle requires JavaScript to display documents.
Searches and Sorts - Coggle Diagram
Searches and Sorts
Insertion sort
-
-
-
An insertion sort compares values in turn, starting with the second value in the list. If this value is greater than the value to the left of it, no changes are made. Otherwise this value is repeatedly moved left until it meets a value that is less than it. The sort process then starts again with the next value. This continues until the end of the list is reached.
Merge sort
-
-
-
The list is repeatedly divided into two until all the elements are separated individually. Pairs of elements are then compared, placed into order and combined. The process is then repeated until the list is recompiled as a whole.
Linear Search
-
-
Example
-
-
-
-
If it matches, the value is found. End the search.
If not, increment the counter by 1 and go back to step 3 until there are no more items to
Binary search
-
Method
-
If the value held there is a match, the search ends.
If the value at the midpoint is less than the value to be found, the list is divided in half. The lower half of the list is ignored and the search keeps to the upper half of the list.
Otherwise, if the value at the midpoint is greater than the value to be found, the upper half of the list is ignored and the search keeps to the lower half of the list.
The search moves to the midpoint of the remaining items. Steps 2 through 4 continue until a match is made or there are no more items to be found.
-
Bubble sort
-
Method
-
Compare the first value in the list with the next one up. If the first value is bigger, swap the positions of the two values.
Move to the second value in the list. Again, compare this value with the next and swap if the value is bigger.
-
-
Each time the list finishes and goes back, it is called a pass
-