Unit 6 - Algorithms Flashcards
What is an algorithm?
An algorithm is a sequence of steps that can be followed to complete a task.
What is abstraction?
Removing unnecessary detail from a problem so that you can focus on the essentials.
What is decomposition?
Involves breaking down a large problem into smaller sub-problems.
What is binary search?
Involves ‘Divide and Conquer’
The list is halved and halved until what you want is found.
It has to be sorted before carrying out the search.
What is linear search?
Examining the list one by one.
You can do this if the list is unsorted. If it is, you can do a binary search.
This method is not that efficient.
What is bubble sort?
Each item is compared to the one next to it on the list. If it is bigger, it swaps places.
At the end of one pass, the largest item would be on the list.
This is repeated until the items are sorted
What are the two algorithms that you need to search a list?
Binary and Linear search.
What is insertion sort?
This algorithm sorts one data at a time.
One item is taken from the list and put in the correct position
This is repeated until the list is not unsorted.
What is merge sort?
This is much more efficient than bubble sort.
Divide the unsorted list into sub lists, each containing 1 item
Repeatedly merge two sub lists at a time to produce new sub lists until there is only one left.
This would be the sorted sub-list
Put in order the fastest to slowest of sorting algorithms:
Merge Sort
Insertion Sort
Bubble Sort
What is a variable?
A variable is a location in memory in which you can temporarily store text or numbers.
What are the three basic ways of controlling the flow of a program?
Sequence
Selection
Iteration