What is an algorithm?
An algorithm is a finite sequence of precise, rigorous instructions used to solve a class of specific problems or perform a computation.
What is the difference between an algorithm and a heuristic?
An algorithm has well-defined correct or optimal results, while a heuristic is an approach to solving problems without such well-defined results, often used when no truly correct answer exists.
What are the three common ways to express an algorithm?
Flowcharts, pseudocode, and structured English (or natural language) are common ways to express algorithms.
What is a flowchart?
A flowchart is a diagram that uses standard symbols to visually represent the steps and decisions in an algorithm.
What is pseudocode?
Pseudocode is a simplified, informal way of writing an algorithm using plain language and some programming-like constructs, without strict syntax rules.
Why is precision important in an algorithm?
Precision is important because an algorithm must be unambiguous and exact so that it can be followed correctly by a computer or human, avoiding confusion.
What does it mean to trace an algorithm?
Tracing an algorithm means manually stepping through each instruction with sample inputs to check the output and verify correctness.
What is the standard symbol for a start/end in a flowchart?
A rounded rectangle (or oval) is used to represent the start and end of a flowchart.
What is the standard symbol for a process/instruction in a flowchart?
A rectangle is used to represent a process or instruction, such as a calculation or assignment.
What is the standard symbol for a decision in a flowchart?
A diamond is used to represent a decision point, where the flow can branch based on a condition.
What is the standard symbol for input/output in a flowchart?
A parallelogram is used to represent input or output operations.
What are the arrows in a flowchart used for?
Arrows indicate the flow of control, showing the sequence in which steps are executed.
What is a conditional in an algorithm?
A conditional is a statement that allows the algorithm to take different paths based on whether a condition is true or false.
What is the purpose of a loop in an algorithm?
A loop repeats a set of instructions multiple times until a condition is met or for a fixed number of iterations.
What is the difference between a variable and a constant in pseudocode?
A variable can change its value during execution, while a constant has a fixed value that does not change.
What does the term 'terminate' mean in the context of an algorithm?
An algorithm terminates when it stops after a finite number of steps, producing an output.
What is the origin of the word 'algorithm'?
The word 'algorithm' comes from the Latinization of the name of Persian mathematician al-Khwarizmi, 'Algoritmi'.
Name one ancient algorithm and its origin.
The Euclidean algorithm, described in Euclid's Elements (c. 300 BC), is an ancient algorithm for finding the greatest common divisor.
What is the Sieve of Eratosthenes?
It is an ancient algorithm for finding all prime numbers up to a given limit, described by Nicomachus.
What is a finite sequence of instructions?
It is a set of steps that has a definite beginning and end, with a limited number of steps.
What is the role of input in an algorithm?
Input is the data provided to the algorithm at the start, which it processes to produce output.
What is output in an algorithm?
Output is the result produced by the algorithm after processing the input.
What is an example of a non-deterministic algorithm?
A randomized algorithm that incorporates random input is non-deterministic, as its behavior may vary between runs.
What is the purpose of using flowcharts and pseudocode in algorithm design?
They help in planning, communicating, and testing algorithms before implementation in a programming language.