2.1 Algorithms Flashcards
1
Q
Abstraction
A
Removing unimportant parts of a problem in order to concentrate on those that are important
2
Q
Decomposition
A
Breaking down a problem into smaller more manageable ones
3
Q
Algorithmic thinking
A
An approach to solving problems by the use of algorithms (sequence of steps that lead to a solution)
4
Q
Structured diagram
A
A hierarchical diagram that shows how a problem is broken down into sub-sections/sub-tasks
5
Q
Why is a structured diagram used?
A
To show how a program is decomposed
6
Q
Linear search
A
- Look at the first item in the list
- Check if the item is equal to the search term
- If the current item is the same as the search term, the item has been found. Otherwise, move to the next item in order.
- Repeat from step 2 and 3 until the last item in the list has been reached
- If the end of the list has been reached and the search term has not been found, then the search term is not in the list and the algorithm can stop.
7
Q
Binary search prerequisite
A
List must be ordered
8
Q
Binary search
A
- Select the midpoint
- Check if searched value is equal to midpoint value (not compare). If so, the search will stop
- If the searched value is larger, discard the left half; if it is smaller, discard the right
- Repeat steps 1-3 until item found or remaining list is of size 1 and item not found
9
Q
Bubble sort
A
- Start with the leftmost item
- Compare this item with the one next to it
- If the one next to it is less, swap the items
- Repeat for all the other items
- At the end of one pass through the list, the largest item is at the end of the list
- Repeat the process until the items are sorted
10
Q
Merge sort
A
- Divided the unsorted list in two
- Continue to divide these lists into two until there is just one item in each list
- Read item from list A
- Read item from list B
- Write smaller to output list
- Read next item from the list that held the smaller value
- Repeat until all items written to output list
- Repeat 3-7 until only one list is remaining
11
Q
What does linear sort do?
A
- This algorithm sorts one data item at a time
- The list is split to sorted set/part and unsorted set/part
12
Q
Linear sort
A
- One item is taken from the unsorted set, and placed in the correct position in the sorted set
- This is repeated until there are no more unsorted items in the list