1/110
Flashcard practice set covering module 02 on algorithms, flowcharts, control structures, Donald Knuth's properties, and exercises.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
How is an algorithm defined in general terms?
A sequence of activities to be processed for getting desired output from a given input.
How does Webopedia define an algorithm?
A formula or set of steps for solving a particular problem.
What two essential characteristics must a set of rules have to be considered an algorithm according to Webopedia?
They must be unambiguous and have a clear stopping point.
What condition regarding time must be met for an algorithm to yield an output?
The algorithm must stop after a finite time.
What two elements should be identified before writing an algorithm for a problem?
What the inputs to the algorithm are and what expected output is required after running it.
What symbol is used for Addition when writing algorithms in this material?
The symbol +.
What symbol is used for Subtraction when writing algorithms?
The symbol −.
What symbol is used for Multiplication when writing algorithms?
The symbol ∗.
What symbol is used for Division when writing algorithms?
The symbol /.
What symbol is used for assignment operations when writing algorithms?
The symbol ←.
In the algorithm notation, what does the statement a←x∗3 mean?
A will have a value of x×3.
What is the input to the algorithm for finding the area of a circle of radius r?
Radius r of the Circle.
What is the expected output for the algorithm finding the area of a circle?
Area of the Circle.
What is Step 1 of the algorithm to find the area of a circle of radius r?
Step 1: Read // input the Radius r of the Circle.
What is Step 2 calculation of the algorithm to find the area of a circle of radius r?
Step 2: Area←PI×r×r // calculation of area.
What is Step 3 of the algorithm to find the area of a circle?
Step 3: Print Area.
What are the inputs to the algorithm that reads two numbers and finds their sum?
First number and Second number.
What is the expected output of the algorithm that reads two numbers and finds their sum?
Sum of the two numbers.
What is Step 1 of the algorithm for finding the sum of two numbers?
Step 1: Start.
What is Step 2 of the algorithm for finding the sum of two numbers?
Step 2: Read num1 // input the first num1.
What is Step 3 of the algorithm for finding the sum of two numbers?
Step 3: Read num2 // input the second num2.
What is Step 4 of the algorithm for finding the sum of two numbers?
Step 4: Sum←num1+num2 // calculation of sum.
What is Step 5 of the algorithm for finding the sum of two numbers?
Step 5: Print Sum.
What is Step 6 of the algorithm for finding the sum of two numbers?
Step 6: End.
What is the input for the algorithm that converts temperature from Fahrenheit to Celsius?
Temperature in Fahrenheit F.
What is the expected output for the temperature conversion algorithm?
Temperature in Celsius C.
What is Step 1 of the algorithm to convert temperature from Fahrenheit to Celsius?
Step 1: Start.
What is Step 2 of the algorithm to convert temperature from Fahrenheit to Celsius?
Step 2: Read Temperature in Fahrenheit F.
What formula is evaluated in Step 3 of the temperature conversion algorithm?
C←(95)×(F−32)
What is Step 4 of the algorithm to convert temperature from Fahrenheit to Celsius?
Step 4: Print Temperature in Celsius: C.
What is Step 5 of the algorithm to convert temperature from Fahrenheit to Celsius?
Step 5: End.
What are the three classification types of control structures for algorithms and flowcharts?
Are Sequence, Branching, and Loop structures sufficient for all algorithm purposes?
Yes, these three control structures are sufficient for all purposes.
How is the Sequence control structure defined?
It is exemplified by a sequence of statements placed one after the other, where the one above or before another gets executed first.
Which flowchart box shape usually contains a sequence of statements?
The rectangular process box.
What does Branching refer to in algorithms?
A binary decision based on some condition.
What construct usually represents Branching in pseudo-codes and programs?
The 'if-then' construct.
What flowchart symbol represents a decision in Branching?
The diamond-shaped decision box.
By what other name is the Branching control structure known?
The selection structure.
What are the inputs to Problem-1 (finding the greater number between two numbers)?
Number 1 (A) and Number 2 (B).
What is the expected output of Problem-1 (finding the greater number between two numbers)?
Greater number between A and B.
What is Step 3 in the algorithm to find the greater number between A and B?
Step 3: If A greater than B then C=A.
What is Step 4 in the algorithm to find the greater number between A and B?
Step 4: If B greater than A then C=B.
What are the inputs to Problem-2 (finding the largest value of any three numbers)?
Number 1 (A), Number 2 (B), and Number 3 (C).
What is Step 3 in the algorithm to find the largest value of three numbers (A, B, C)?
Step 3: If (A≥B) and (A≥C) then Max=A.
What is Step 4 in the algorithm to find the largest value of three numbers (A, B, C)?
Step 4: If (B≥A) and (B≥C) then Max=B.
What is Step 5 in the algorithm to find the largest value of three numbers (A, B, C)?
Step 5: If (C≥A) and (C≥B) then Max=C.
How is the Loop control structure defined?
It allows a statement or a sequence of statements to be repeatedly executed based on some loop condition.
Which constructs represent unbounded loops and bounded loops respectively in most programming languages?
'while' constructs for unbounded loops and 'for' constructs for bounded loops.
What is an unbounded loop?
A loop whose number of iterations depends on the eventuality that the termination condition is satisfied.
What is a bounded loop?
A loop whose number of iterations is known before-hand.
What flowchart feature hints the presence of a loop?
A back arrow.
What is a single trip around a loop known as?
An iteration.
What mistake occurs if the loop termination condition is never satisfied after finite iterations?
It ends up as an infinite loop.
What is another name for the Loop control structure?
The repetition structure.
In the algorithm to calculate even numbers between 0 and 99, what initial value is assigned to I in Step 2?
I←0.
In the algorithm to calculate even numbers between 0 and 99, what operation is performed in Step 4?
I←I+2.
In the algorithm to calculate even numbers between 0 and 99, what condition is checked in Step 5?
If (I≤98) then go to step 3.
What is the dual purpose of Problem 2 on Page 5 regarding even numbers between 1000 and 2000?
It generates even numbers between 1000 and 2000, prints them, and prints their total sum.
In line 2 of the algorithm generating even numbers between 1000 and 2000, what are the initial variable assignments?
I←1000 and S←0.
In line 4 of the algorithm generating even numbers between 1000 and 2000, how is the sum variable S updated?
S←S+I.
In line 5 of the algorithm generating even numbers between 1000 and 2000, how is the counter variable I updated?
I←I+2.
What control logic is used in line 6 of the algorithm generating even numbers between 1000 and 2000?
If (I≤2000) then go to line 3 Else go to line 7.
Who authored the list of five properties for an algorithm mentioned in the module?
Donald Ervin Knuth.
What are the five properties of an algorithm given by Donald Ervin Knuth?
1) Finiteness, 2) Definiteness, 3) Input, 4) Output, 5) Effectiveness.
What does the property of Finiteness require of an algorithm?
An algorithm must always terminate after a finite number of steps.
What does the property of Definiteness require of an algorithm?
Each step of an algorithm must be precisely defined and unambiguous for each activity.
What does the property of Input mean for an algorithm?
Beginning values or quantities associated with activities are given to the algorithm before it begins.
What is the difference between an intermediate result and an end result in an algorithm?
An intermediate result is obtained at an intermediate stage of operation, while an end result is obtained at the end of the algorithm.
What relation must the output of an algorithm have to its inputs?
The output must always have a specified relation to the inputs.
What does the property of Effectiveness state regarding algorithm operations?
Operations should be basic enough that in principle they can be done exactly and in a finite amount of time by a person using paper and pencil only.
What is the definition of a Flowchart?
A pictorial representation of an algorithm; a diagram which visually presents the flow of data through processing systems.
What two key details can one determine by looking at a flowchart?
The operations performed and the sequence of these operations in a system.
How many basic flowchart symbols are commonly used in flow charting assembly language programs?
Six basic symbols.
What are the six basic symbols listed for assembly language program flowcharts?
Terminal, Process, Input/Output, Decision, Connector, and Predefined Process.
How does a decision-making flowchart help human beings and business organizations?
It helps people to make a decision correctly and quickly.
How does a flowchart help optimize decision steps?
It allows removal of duplicated steps because all steps are visible in the flowchart.
What does the expression A>B represent in decision structures?
It is a logical expression that describes a condition we want to test.
In the IF-THEN-ELSE flowchart example on Page 9, what action is taken if A>B is true?
Print the value of A.
In the IF-THEN-ELSE flowchart example on Page 9, what action is taken if A>B is false?
Print the value of B.
What is the general pseudo-code format of an IF-THEN-ELSE structure?
if (condition) then True alternative else False alternative endif
What is meant by NESTED IFS?
When one of the alternatives within an IF-THEN-ELSE statement involves a further IF-THEN-ELSE statement.
In the Nested IF algorithm reading three numbers (N1,N2,N3), what is Step 1?
Step 1: Input N1,N2,N3.
In the Nested IF algorithm, if N1>N2 is true and N1>N3 is true, what is assigned to MAX?
MAX←N1.
In the Nested IF algorithm, if N1>N2 is true but N1>N3 is false, what is assigned to MAX?
MAX←N3.
In the Nested IF algorithm, if N1>N2 is false and N2>N3 is true, what is assigned to MAX?
MAX←N2.
In the Nested IF algorithm, if N1>N2 is false and N2>N3 is false, what is assigned to MAX?
MAX←N3.
What is the objective of Exercise 01 on Page 11?
Determine and output whether number N is even or odd.
In Exercise 01, what is Step 2 of the algorithm?
Step 2: Set remainder as N(mod2).
In Exercise 01, under what condition is number N classified as even?
If remainder is equal to 0.
What is the objective of Exercise 02 on Page 12?
Draw an algorithm and flowchart to log in to Facebook account.
In Exercise 02, what is Step 1 of the algorithm?
In Exercise 02, what operation type is assigned to Step 2 ("facebook Home page loads")?
PROCESS.
In Exercise 02, what operation type is assigned to Step 3 ("Enter your Email ID and Password")?
I/O (Input/Output).
In Exercise 02, if the Email ID and Password validation step is NO, what action occurs?
Log in error (PROCESS) and go to step 3.
In Exercise 02, if the Email ID and Password validation step is YES, what action occurs?
Display Facebook Account (I/O) and Stop.
What is the goal of Exercise 03 on Page 13?
Find Even number in between 1 to 50.
In Exercise 03, what initial value is assigned to I in Step 2?
I=1.
In Exercise 03, what is the exit condition in Step 3?
IF (I>50) THEN GO TO Step-7 END IF.
In Exercise 03, what condition determines if I is displayed in Step 4?
IF ((I(mod2)) = 0) THEN Display I END IF.