Algorithms Flashcards
What is an algorithm?
A sequence of instructions that can be followed to carry out a particular task
What is abstraction?
Removing unnecessary detail from a problem
What is decomposition?
Breaking a problem down into a number of smaller sub-problems, so that each sub problem accomplishes an identifiable task
How does a linear search work?
Works by looking at each value of the list in turn until it finds the item it is looking for
What are the pros and cons of a linear search?
It is slow, but it is easy to program and can work with an unordered
list
How does a binary search work?
Compares the middle value in the list against the value which is being attempted to be found. It then halfs the list
What are the pros and cons of a binary search?
It is fast, but can only work with ordered lists
How does a bubble sort work?
Sort takes list of unordered values and putting them into the correct order by comparing two neighbouring numbers. Each run through the bubble sort is called a pass. The bubble sort is complete when a pass finished without any
swaps being made
How does a merge sort work?
Repeatedly divides a list into two until all the elements are separated individually. Pairs of lists
are then compared, placed into order and combined. The process is then repeated until the list is recompiled as a whole
What are the pros and cons of the merge sort?
More complex to program than the bubble sort, but much faster