What is an algorithm?
A sequence of steps that can be followed to complete a task.
What is a computer program?
An implementation (application) of an algorithm.
What is decomposition?
The process of breaking down a complex problem into sub-problems or more manageable chunks, so each sub-problem accomplishes an identifiable task.
* This makes the problem easier to understand.
What is abstraction?
Abstraction is the process of removing unnecessary detail from a problem.
* This SIMPLIFIES the problem
What makes an algorithm efficient?
How does the linear search algorithm work?
Why is it important to use a meaningful identifier name?
What are the advantages of using the structured approach/ subroutines?
What should the conditions of an algorithm be?
What is pseudocode?
Flowcharts:
The linear search algorithm:
The binary search algorithm:
Compare the bubble sort and merge sort algorithm.
What is a variable?
Define constant.
Advantages of using a constant:
1) You only have to change the value of the constant once in the source code. If we didn’t have the constant we’d have to hunt through the program to find all the places where we’d written 4 and change them to the new number.
2) It makes sure that our program is consistent as we only have to enter the value once.
3) If lots of people are working on the same program it stops mistakes happening.
4) It also makes your code more readable. For example if you are writing a program to calculate with circles it is much easier to have a constant called PI than to have to keep typing 3.1415…
How do you identify a constant?
A constant has an ALL UPERCASE VARIABLE name.
What are the three main constructs?
Iteration- indefinite loop (condition controlled loop):
Which condition controlled loop is adavntageous and why?
The REPEAT…UNTIL loop
* Th same effect is achieved with both WHILE…ENDWHILE and REPEAT…UNTIL loop
* But the REPEAT…UNTIL loop allows the program to enter the loop, gain an input, then test the condition at the end
* The WHILE…ENDWILE loop will keep running UNTIL the the conditio is met, but the REPEAT…UNNTIL loop only runs when the condition is met.
* This makes it more efficient.
What are the two types of indefinite loop?
What is an exaple of a pre-controlled loop.
WHILE count < 5
count ← count + 1
ENDWHILE
What is an example of a post-controlled loop.
REPEAT
count ← count + 1
UNTIL count < 5