2.1 Flashcards
(22 cards)
What is abstraction?
Picking out important bits of information/details from the problem, ignoring the specific details that don’t matter
What is algorithmic thinking?
Logical thinking and thinking methodically
What is decomposition?
Breaking a complex problem down into smaller problems and solving each one individually
How do you write pseudocode? What are some ways you should write it
Write what you have to do in words but simply just important details. Variable = input"..." If...then Else Print
What does a oval mean in flow diagrams?
Start/stop
What does a parallelogram mean in a flow chart?
Input/output
What does a rectangle stand for in flow diagrams?
Processes -general instructions, processes and calculations
What does a diamond mean in a flow diagram?
Decision -yes or no
What does an arrow show in a flow diagram?
Show the direction you should follow
What’s an algorithm?
A precise sequence of instructions.
What’s computational thinking?
Computational thinking allows us to take a complex problem, understand what the problem is and develop solutions.
What’s linear search?
- Look at the first item in the list
- if this is the item you’re looking for stop
- if not carry on to the next item in the list
- repeat the 2 steps before until you find the item you were looking for or you’ve checked every item
What’s binary search?
- find the middle item in the ORDERED list
- if this is the item you’re looking for then stop the search
- if not then if your item is lower than the middle item you get rid of the second half of the list if it comes after the middle item you get rid of the first half of the list
- you’re left with a list half the size then repeat the 3 steps before and keep going until you find what you’re looking for
What’s the pros and cons of linear search?
Pros
-fairly simple to code
-the data does need to be in a set order
Cons
-slow to process large lists-worst case scenario is searching through the whole list
-not efficient, only works well with small lists
What’s the pros and cons of binary search?
Pros -more efficient -more suitable for larger lists Cons -list has to be ordered -more complicated to code
What’s a bubble sorting algorithms?
- look at the first two items in the list
- if they’re in the right order leave them if not swap them
- move on to the next pair the third and second and repeat the process
- repeat that process until you get to the end of the list the last item will now be correct and so it’s not included in the next pass through
- repeat going through the list until there are no swaps in a pass
What are the pros and cons of bubble sort?
Pros -simple to write the code for -doesn't use very much memory Cons -inefficient, slow -can't cope with really large lists
What’s merge sort?
- split the list in half again and again until each item is individual
- merge these individual items with one other sub list each time you merge these sub lists you order them
- repeat merging the sub lists until you’ve merged all of them together
What are the pros and cons of merge sort?
Pros
-more efficient and quicker than bubble and insertion for large lists
-consistent running no matter how ordered the original items are
Cons
-slower for small lists
-it uses more memory than any of the other sorting algorithms
What’s insertion sort?
- look at the second item in the list
- compare all the items before it and insert the item into the right place
- repeat step 2 until you get to the last item in the list and it has been inserted into the correct place
What are the pros and cons of insertion sort?
Pros
-easy to code, intuitive way of thinking about it
-copes very well with small lists, doesn’t require much additional memory
Cons
-doesn’t cope very well with large lists
-best case scenario requires n-1 comparisons
-worst case scenario requires n(n-1)/2 comparisons
What’re two advantages of problem decomposition?
- spend less time overall because of having a plan breaking down the bigger problem
- create functions that could be reused in a different problem
- different people can work on different aspects at the same time