S1 Algorithms Flashcards
Define decomposition
Breaking down a complex problem down into small problems and solving each one individually
Define abstraction
Picking out the important bits of information from the problem, ignoring the specific details that don’t matter
Define algorithmic thinking
A logical way of getting from the problem to the solution. If the steps you take to solve a problem following algorithm then the can be reused and adapted to solve similar problems in the future
What is pseudo code?
Not an actual programming language but follows a similar structure and reads like one. The idea is that pseudocode clearly shows an algorithms steps without worrying about syntax.
Features and benefits of pseudo code
- Quick to write
- Easily converted to any programming language
- Code is valid as long as the person reading can follow and understand
In a flowchart what does this shape mean ⚪
Start/ stop
In a flowchart what does this shape mean /___/
Input/output
In a flowchart what does this shape mean ⬜
Processes
In a flowchart what does this shape mean 🔷
Decision
In a flowchart what does this shape mean 🇮🇪
Subroutine
What are the four steps of the binary search algorithm?
1) Find the middle term in the ordered list
2) If this is the item you’re looking for then stop the search
3) If not compare the item you’re looking for with the middle term. If it comes before the middle item, get rid of the second half. If it comes after the middle item, get rid of the first half.
4) You’ll be left with a list that is half the size. Repeat steps 1 - 3 until you have found the item
What are the four steps of the linear search?
1) Look at the first value in the unordered list
2) If this is the item you’re looking for then stop the search
3) If not then look at the next item in the list
4) Repeat steps 2 - 3 until you’ve found the item, or you have reached the end of the list
What are the differences between a linear and binary search?
- linear is simpler but less effective (doesn’t matter though, if list is small)
- linear can be used on any list (doesn’t need to be ordered)
- For large ordered lists run time of binary search would be much faster.
What are the 5 steps of the bubble sort algorithm?
1) Look at the first 2 items in the list
2) If they’re in the right order, you don’t have to do anything. If they’re in the wrong order, swap them.