1 - Fundamentals of Algorithms Flashcards
(39 cards)
What is an algorithm?
A set of instructions that describes how to solve a problem
Name two methods can be used to design algorithms
Pseudo-code and flowcharts
When designing algorithms with pseudo-code or flowcharts, what is the main focus?
The logic of the steps rather than the programming language
Why is the focus on logic rather than programming language in algorithm design?
Because programmers should be able to translate an algorithm into any programming language
What does it mean for an algorithm to be language independent?
It means the algorithm can be translated into any programming language, such as from Python to C++
What is decomposition?
Breaking a problem down into smaller, more manageable chunks
Which method of computational thinking is being primarily used here?
num ← USERINPUT
FOR number ← 1 TO 10
OUTPUT number * num
ENDFOR
Decomposition (using a loop to make it smaller and more manageable)
What is abstraction in programming?
The process of removing unnecessary detail from a problem to focus on the important parts
Why is abstraction useful?
It makes solving a problem easier by focusing only on relevant information
What is algorithmic thinking?
A logical way of solving problems by breaking them into clear, step-by-step instructions (algorithms)
What is pseudo-code?
A simple way of describing a set of instructions that resembles a programming language
What does the symbol ← mean in pseudo-code?
It means assignment — storing a value in a variable.
What is a variable in pseudo-code?
A named space in memory where data, such as user input, can be stored (e.g. num)
How are outputs shown in pseudo-code?
Using the word OUTPUT followed by the data to be shown (e.g. OUTPUT number * 10)
How would this pseudo-code appear in python?:
OUTPUT number * 10
print(number * 10)
What does an arrow represent in a flowchart?
The flow of control or direction from one step to another
What does a rectangle represent in a flowchart?
A process
What does a rectangle with double vertical lines represent in a flowchart?
A subroutine or function that is defined elsewhere
What does a parallelogram represent in a flowchart?
Input/Output
What does a diamond represent in a flowchart?
A decision point
What does an oval represent in a flowchart?
The start or end of a flowchart
What are inputs in a program?
Data entered into a program by the user or system, usually stored in variables
Why are outputs used in a program?
To communicate with the user (eg. display results or show further instructions)
What is a variable in programming?
A named location in memory used to store inputted data for use in the program