Problem Solving Flashcards
What is algorithmic thinking?
Algorithmic thinking is a way of solving problems by producing algorithms.
What is an algorithm?
An algorithm is a reusable set of instructions (a series of steps) to solve a given problem.
How do we represent algorithms in computing?
In computing, we often represent algorithms using pseudocode or flow diagrams.
How do we interpret algorithms?
Look out for identifiers, identify inputs and outputs, examine output messages and looking for comments.
What are identifiers?
Identifiers are the names of variables, constants and subroutines. These give clues bout the purpose of an algorithm.
What are comments?
Comments are descriptions of the code. They often state the purpose of the algorithm. They are often the clearest way to identify an algorithm.
What is pseudocode?
Pseudocode is a way to write out algorithms using code-like statements. It is intended to be very readable, and easy to understand.
What is the purpose of pseudocode?
Pseudocode is not an actual programming language, it is used to plan algorithms, focusing on the logic and steps rather than language-specific syntax.
What are flow charts?
Flow charts are used to visually represent the steps that make up an algorithm.
What are ovals used for in flow charts?
An oval is used for the start and end of a program.
What are rectangles used for in flow charts?
A rectangle is used to represent a process.
What are parallelograms used for in flow charts?
A parallelogram is used to represent an input or an output.
What are diamonds used for in flow charts?
A diamond is used to represent a decision.
Why do the diamonds have labelled arrows coming out of it in flow charts?
A diamond/decision has two labelled arrows coming out of it to represent what happens if the condition in the diamond was true or false. ‘Yes’ arrows are for true, and ‘No’ arrows are for false.
What are the common mistakes in programming?
Incorrect identifiers - such as lowercase and uppercase letters and similar looking character like 0 and O.
Incorrect operators - like less than signs put in the wrong way.
Missing processes - like when line of codes are forgotten.
What is a search algorithm?
A search algorithm is a set of instructions for finding a specific item of data within a data set.
What are examples of search algorithms?
Linear search and binary search.
What is the concept of linear search?
If you were looking for a specific piece of paper in a stack of papers, then one way to find it would be to work from the top of the stack to the bottom, checking each paper on the way.
How does linear search work in a program?
Check the first item in the dataset:
If it is what we are looking for, return it.
This is repeated for the rest of the items.
If the end of the data is reached, then the item was not in our data set.
What are the pros and cons of linear search?
Pros - very easy to implement
Cons - slow on a long list
What is the concept of binary search?
If you try to find a certain page in a book, it’s unlikely that you check every page. You are more likely to split the book in two and see if the page you need is before or after the split, and repeat.
How does binary search work in a program?
Find the middle of the dataset. If the middle value is > the target: Repeat on the first half of dataset. If the middle value is < the target: Repeat on the second half of dataset. If the middle value is the target: The target has been found. Stop repeating when the size of the dataset is zero.
What are the pros and cons of binary search?
Pros - faster than linear search on a large dataset
Cons - dataset must be sorted before starting
What is a sort algorithm?
A sort algorithm is a set of instructions to arrange a dataset into a particular order.