M2S1 Flashcards

1
Q

Q: What is an algorithm?

A

A: An algorithm is a procedure or formula for solving a problem, based on conducting a sequence of specified actions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Q: How can an algorithm be expressed?

A

A: An algorithm can be expressed using pseudocode or flowcharts.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Q: What is the purpose of planning an algorithm?

A

A: To transform the problem’s input into its output.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Q: In the IPO chart, what does “Process” represent?

A

A: The processing part involves recording instructions to manipulate the input items to achieve the desired output.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Q: What should each instruction in an algorithm begin with?

A

A: Each instruction should start with a verb.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Q: What is typically the first instruction in an algorithm?

A

A: To enter the input items into the computer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Q: What do most algorithms end with?

A

A: An instruction to display, print, or store the output items.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Q: What do the terms “display,” “print,” and “store” refer to?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Q: Why is pseudocode called “false code”?

A

A: Because it has no syntax like any programming language and cannot be compiled or interpreted by a computer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Q: What does pseudocode represent?

A

A: It is an implementation of an algorithm using plain English annotations and informative text.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Q: Are there standardized forms of pseudocode?

A

A: No, pseudocode is not standardized, and each programmer may have their own version, though some similarities exist.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Q: What keywords indicate common input-output and processing operations in pseudocode?

A

A: Keywords such as INPUT, OUTPUT, PRINT, and COMPUTE are commonly used.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Q: How is the order of execution determined in pseudocode?

A

A: The order of execution is assumed to be from top to bottom, unless control structures, functions, or exception handling are used.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Q: What does the keyword “START” signify in pseudocode?

A

A: It marks the beginning of the pseudocode.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Q: How do you retrieve data from the user in pseudocode?

A

A: By using keywords like INPUT, ENTER, READ, or GET.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Q: What is the purpose of the keyword “COMPUTE” in pseudocode?

A

A: It is used to calculate the result of an expression.

17
Q

Q: What does “IF - THEN - ENDIF” represent?

A

A: It is a conditional statement used to evaluate expressions and execute instructions based on the evaluation result.

18
Q

Q: What are common looping keywords in pseudocode?

A

A: WHILE, FOR, and DO are common looping keywords.

19
Q

Q: What is the role of the “FOR” keyword in pseudocode?

A

A: It is used to create a loop that iterates over a set range or collection.

20
Q

Q: How is the sum of three numbers displayed using a FOR loop in pseudocode?

A

SET sum = 0
FOR numberCounter = 1 to 3
INPUT number
CALCULATE sum := sum + number
END FOR
PRINT sum

21
Q

Q: What does the keyword “INCREMENT” do in pseudocode?

A

A: It increases the value of a variable by a specified amount.

21
Q

Q: How does a WHILE loop function in pseudocode?

A

A: It repeats a sequence of instructions while a specified condition remains true.

21
Q

Q: How can an algorithm calculate a tip based on a total bill and tip percentage?

A

A: By multiplying the total bill by the tip percentage.

21
Q

Q: What is the structure of the pseudocode for displaying the lowest and highest of two integers?

A

A: It uses an IF-ELSE statement to compare the integers and display the result.

21
Q

Q: What does the CASE statement do in pseudocode?

A

A: It evaluates an input variable and executes corresponding actions based on its value.

21
Q

Q: In a DO-WHILE loop, when does the condition get checked?

A

A: The condition is checked after executing the loop’s body at least once.

21
Q

Q: How do you initialize values in pseudocode?

A

A: By using the keyword SET or INIT.

22
Q

Q: What operators are commonly used in pseudocode for arithmetic operations?

A

A: Operators like +, −, ×, /, and mod are commonly used.

23
Q

Q: How does the pseudocode format differ from programming languages?

A

A: Pseudocode does not follow strict syntax rules and is more flexible, focusing on logic and flow rather than exact coding syntax.

24
Q

Q: What is the output of the following pseudocode?

SET sum = 0
FOR numberCounter = 1 to 3
INPUT number
CALCULATE sum := sum + number
END FOR
PRINT sum

A

A: It outputs the sum of three numbers entered by the user.