Flashcards
Searching and Sorting Algorithms
Cards in this deck (5)
- 1Linear SearchCheck first value
IF it is the value you're looking for:
- Celebrate and stop
ELSE:
- Move on to the next value
REPEAT UNTIL all elements are checked - 2Binary SearchPut list in order
Take middle value (halve total number of values)
Compare to value you're looking for
IF it is the value your looking for:
- Celebrate and stop
ELIF larger than value you're looking for:
- Take values to left of middle value
ELSE:
- Take values to right of middle value
REPEAT UNTIL you either find the value you're looking for or get to the last value and don't find it - 3Bubble SortTake first and second element from list
Compare them
IF element 1 > 2:
- Swap them
ELSE:
- Keep same
Repeat (Move on to next pair of list):
- IF no more elements:
- Go to first step
- ELSE:
- Go to second step
UNTIL moved through entire list and not made any changes - 4Insertion SortElement 1 is a "sorted" list
Rest of elements are an "unsorted" list
Compare first item in "unsorted" list to each element in sorted list
IF it's smaller:
- Put in front of element (move others along)
ELIF it's larger:
- Compare with next element
ELIF there are no more elements in "sorted" list:
- Put in final position
REPEAT UNTIL all elements in "unsorted" list are in "sorted" list - 5Merge SortSplit list into individual list (each element is on its own)
Merge lists in pairs, starting with smallest
Merge the lists
Keep merging until it is in order
Information
- Description
- Year 10 Computing Flashcards on Searching and Sorting Algorithms, created by Darshan Datta on 26/06/2017.
- Created by
- Darshan Datta
- Views
- 0
- Tags
- Rating