Unit 1 - Computational Thinking Flashcards
What are errors?
An error is something that disrupts the program or occurs unintentionally within it, it can also cause an unwanted outcome in the program even if it still runs
What are three types of errors
Syntax Error
Runtime Error
Logic Error
What is a syntax error?
This is a grammatical error in the code, it can be caused by things such as a missing bracket, colon or a misspelled word
What is a runtime error?
This is something that stops the code whilst it is running or prevents it from running all together
What is a broke error?
This occurs when a program is running and is asked to perform an impossible task such as multiplying something by zero
What is a logic error?
This occurs when there is a fault in the logic or structure of the program - it does not usually cause the program to stop completely but it can cause an unexpected result from the computer
Where did the term ‘computer bug’ get its name?
In 1947 a group of computer scientists noticed unexpected results coming from their machines, they found that it was due to a moth trapped inside of a one machine and they were forced to literally ‘debug’ the machines
What is a trace table?
A black table into which you can input the results of a program each time you run through it
Why are trace tables helpful?
They allow us to predict the results of a programme and identify errors in it without actually running it
Why are flowcharts helpful?
They allow programmers to see the distinct steps which need to be carried out in order to reach a desired outcome and layout the structure of the code
What pseudocode?
Pseudocode is a cross between a programming language such as python and English
Why is pseudocode useful?
It can be understood by most people even if they do not understand coding so we can communicate complicated concepts effectively
Why do you need to be careful when using pseudocode?
Everyone writes pseudocode differently but you need to ensure that your rules are consistent throughout .e.g. you cannot decide that all variables are written in capitals halfway through
Why are search algorithms used?
They enable a program to identify a specific value in an array easily
Explain how the binary search algorithm works
- The array must be sorted in ascending numerical order
- Identify the midpoint
- If Midpoint = Required Index, print
- If Midpoint > Required Index THEN End Of Array = Midpoint -1
- If Midpoint < Required Index THEN Start Of Array = Midpoint +1
- Go back to step two and LOOP until Required Index is identified
State one advantage and three disadvantages of the binary search search algorithm
Advantages:
1. Quicker for longer arrays and more efficient than a linear search
Disadvantages:
1. It is harder to program
2. It takes time to reorder it if an item is removed or added
3. It requires the array to be sorted
Explain how the linear search algorithm works
The computer will iterate through each item in the array until it identified the required index
State three advantages and two disadvantages of the linear search algorithm
Advantages:
1. Does not require items to be sorted therefore saves time
2. It is not affected by insertions or deletions
3. Works quicker on small lists, especially on today’s computers
Disadvantages:
1. Takes a long time on larger arrays
2. The item may be one of the last ones in the list
Describe the bubble sort algorithm
Two items in an array are compared, if the first is larger than the second they are swapped so that they are in ascending numerical order; the program then iterates through the array multiple times in order to sort every number into the same order
Describe the merge sort algorithm
The array is split into couplets, if those two numbers are not in ascending numerical order they are switched. They are then merged with another couplet and the same process repeats so that the whole array is combined again and in ascending numerical order
What are operators?
Built in commands in python that allow us to perform specific function
What are the three types of operator?
Logical, relation and arithmetic