Algorithms Flashcards
What is Abstraction?
Removing any unnecessary details/information from a problem in order to solve it
What is decomposition?
Breaking down a problem into smaller, simpler steps/stages
What is an algorithm?
A series of steps that a program has to perform in order to solve a problem
look at this list of integers:
12 34 54 76 89 13 24
using a linear search, how many items would you have to check to reach the value 13
I would have to check 6 values until I reach the value 13
Why wouldn’t a binary search work on the following data?
cow , apple , moose , dog , bird
Because the data is not in the correct order/ is not in order
complete a binary search on this data to find the value 450
12 34 56 78 99 102 345 450 567
- start from the middle value 99,is smaller than the value needed therefore values 12 to 99 are removed from the list
- Next is value 450, its been found!
How does a bubble sort work?
a bubble sort repeatedly goes through a list, comparing each pair of adjacent elements. If they are in the wrong order they are swapped.
What is an insertion sort?
An sorting algorithm that sorts one item of data at a time, repeats this process until the list is sorted