Computers can be used to help…
solve problems. However, before a problem can be tackled, the problem itself, and the ways in which it could be solved, needs to be understood.
What does computational thinking allow us to do?
It allows us to take a complex problem, understand what the problem is and develop possible solutions. These solutions can then be presented in a way that a computer, a human, or both, can understand.
Three important elements of computational thinking…
Computational thinking involves…
taking a complex problem and breaking it down into a series of small, more manageable problems. Each of these smaller problems can then be looked at individually.
Algorithm
Identified simple steps to fix a complex problem that a computer carries out
Decomposition involves…
breaking down a complex problem or system into smaller parts that are more manageable and easier to understand.
If a problem is not decomposed…
It is much harder to solve
Algorithmic thinking is
the ability to create a step-by-step solution. It involves designing clear instructions (algorithms) that allow for a task to be solved
Why is algorithmic thinking important?
It helps:
Algorithmic thinking involves other key computational skills, like…
Abstraction is…
the process of filtering out - essentially ignoring - the characteristics of problems that are not needed in order to concentrate on those that are needed. It is also the filtering out of specific details. From this, an idea of what is to be solved can be created.
Abstraction allows us to
create a general idea of what the problem is and how to solve it. The process instructs us to remove all specific detail and any patterns that will not help us solve our problem. This helps us form our idea of the problem. This idea is known as a ‘model’.
Casting
Converting one data type to another, for example converting an integer to a real number
Input sanitisation
Cleaning up data entered by removing non-standard characters
Binary search key points
• List must be sorted
• Divide and Conquer algorithm
Order this list with a binary search:
Ali Ben Carl Joe Ken Lara Mo
We are looking for the name Mo.
Ali Ben Carl Joe Ken Lara Mo
Examine the middle (Joe)
Joe != Mo
Mo is above Joe in the alphabet, so look at the ones above Joe
Ken Lara Mo
Lara is the middle, but Lara != Mo
However, Mo is above Lara in the alphabet
So look at any items above Lara.
There is only one item left, and it is Mo.
How many times do you have to make a comparison in a binary search with 16 items in the worst and best case scenario?
Best: 1 (if it’s in the middle)
Worst: 5 (n+1), where n is number of times we can halve 16
In a linear search…
You look at every item one by one, going through the list, until you find the first of the desired item and it will stop, not looking for more.
What is the max number of comparisons to be made in a linear search of 10 items?
10 (n)
How complex is a binary search compared to linear search, in terms of the algorithm and programming?
It is longer and more complex
If a binary search has no middle what do you do?
You pick the leftmost option
What if the item is not in the list?
It will not be found or error.
Advantages and disadvantages of binary search compared to linear
Advantages:
- it is a shorter process usually
Disadvantages:
- it is complex to code
- the list must be sorted
What symbol is: +
Add