M2S1 Flashcards
Q: What is an algorithm?
A: An algorithm is a procedure or formula for solving a problem, based on conducting a sequence of specified actions.
Q: How can an algorithm be expressed?
A: An algorithm can be expressed using pseudocode or flowcharts.
Q: What is the purpose of planning an algorithm?
A: To transform the problem’s input into its output.
Q: In the IPO chart, what does “Process” represent?
A: The processing part involves recording instructions to manipulate the input items to achieve the desired output.
Q: What should each instruction in an algorithm begin with?
A: Each instruction should start with a verb.
Q: What is typically the first instruction in an algorithm?
A: To enter the input items into the computer.
Q: What do most algorithms end with?
A: An instruction to display, print, or store the output items.
Q: What do the terms “display,” “print,” and “store” refer to?
A: They refer to showing output on the computer screen, sending it to a printer, and saving it to a file on a disk, respectively.
Q: Why is pseudocode called “false code”?
A: Because it has no syntax like any programming language and cannot be compiled or interpreted by a computer.
Q: What does pseudocode represent?
A: It is an implementation of an algorithm using plain English annotations and informative text.
Q: Are there standardized forms of pseudocode?
A: No, pseudocode is not standardized, and each programmer may have their own version, though some similarities exist.
Q: What keywords indicate common input-output and processing operations in pseudocode?
A: Keywords such as INPUT, OUTPUT, PRINT, and COMPUTE are commonly used.
Q: How is the order of execution determined in pseudocode?
A: The order of execution is assumed to be from top to bottom, unless control structures, functions, or exception handling are used.
Q: What does the keyword “START” signify in pseudocode?
A: It marks the beginning of the pseudocode.
Q: How do you retrieve data from the user in pseudocode?
A: By using keywords like INPUT, ENTER, READ, or GET.
Q: What is the purpose of the keyword “COMPUTE” in pseudocode?
A: It is used to calculate the result of an expression.
Q: What does “IF - THEN - ENDIF” represent?
A: It is a conditional statement used to evaluate expressions and execute instructions based on the evaluation result.
Q: What are common looping keywords in pseudocode?
A: WHILE, FOR, and DO are common looping keywords.
Q: What is the role of the “FOR” keyword in pseudocode?
A: It is used to create a loop that iterates over a set range or collection.
Q: How is the sum of three numbers displayed using a FOR loop in pseudocode?
SET sum = 0
FOR numberCounter = 1 to 3
INPUT number
CALCULATE sum := sum + number
END FOR
PRINT sum
Q: What does the keyword “INCREMENT” do in pseudocode?
A: It increases the value of a variable by a specified amount.
Q: How does a WHILE loop function in pseudocode?
A: It repeats a sequence of instructions while a specified condition remains true.
Q: How can an algorithm calculate a tip based on a total bill and tip percentage?
A: By multiplying the total bill by the tip percentage.
Q: What is the structure of the pseudocode for displaying the lowest and highest of two integers?
A: It uses an IF-ELSE statement to compare the integers and display the result.