Quiz - Week 1 - Lab - Algorithms
Quiz - Week 1 - Lab - Algorithms
Points 50
Questions 15
Allowed Attempts 2
Instructions
The quiz:
This lab is open book and it is encouraged that you learn through
researching. The final question in this lab is a question where you will write
an algorithm (in pseudocode) to solve a given scenario.
Submit this assignment by 11:59 p.m. (ET) on Monday of Module 1: Week 1.
TAKE THE QUIZ AGAIN
Attempt History
Question 1
1.5 / 1.5 pts
____ operations provide the computing agent with data values from the outside world that it may use in
later instructions.
Ingoing
Outgoing
Input
Output
IncorrectQuestion 2
0 / 1.5 pts
Examples of control operations would be _______ and _______.
Question 3
1.5 / 1.5 pts
____ statements are the “question-asking” operations of an algorithm.
Primitive
Iterative
Sequential
Conditional
Question 4
1.5 / 1.5 pts
The ____ loop is an example of a posttest loop.
do/while
do
while
if/then/else
Question 5
1.5 / 1.5 pts
A ____ is a collection of useful, prewritten algorithms.
primitive
binary
set
library
Question 6
1.5 / 1.5 pts
____ is an example of a natural language.
C
Java
English
Perl
Question 7
1.5 / 1.5 pts
A purely ____ algorithm is sometimes termed a straight-line algorithm.
sequential
conditional
iterative
control
Question 8
1.5 / 1.5 pts
In a posttest loop, the continuation condition is tested at the ____ through the loop.
PartialQuestion 9
2.25 / 3 pts
Run through the following algorithm and determine if 1996 was a leap year
YEAR = 1996
Get YEAR
STEP 1 If YEAR is equally divisible by 4; Result: True
Then Go To STEP 2;
Else Go To STEP 5
STEP 2 If YEAR is equally divisible by 100; Result: False
Then Go To STEP 3;
Else Go To STEP 4
STEP 3 If YEAR is equally divisible by 400; Result: True
Then Go To STEP 4;
Else Go To STEP 5
STEP 4 Print “The year is a Leap Year.” And Go To STEP 6
STEP 5 Print “The year is not a Leap Year.” And Go To STEP 6
STEP 6 Stop
The final output of this run is : This is a Leap
Answer 1:
True
Answer 2:
False
Answer 3:
True
Answer 4:
This is a Leap
Question 10
3 / 3 pts
Run through the following algorithm and determine if 2000 was a leap year
YEAR = 2000
Get YEAR
STEP 1 If YEAR is equally divisible by 4; Result: True
Then Go To STEP 2;
Else Go To STEP 5
STEP 2 If YEAR is equally divisible by 100; Result: True
Then Go To STEP 3;
Else Go To STEP 4
STEP 3 If YEAR is equally divisible by 400; Result: True
Then Go To STEP 4;
Else Go To STEP 5
STEP 4 Print “The year is a Leap Year.” And Go To STEP 6
STEP 5 Print “The year is not a Leap Year.” And Go To STEP 6
STEP 6 Stop
The final output of this run is : This is a Leap
Answer 1:
True
Answer 2:
True
Answer 3:
True
Answer 4:
This is a Leap
Question 11
3 / 3 pts
This algorithm will multiple a number by repeatedly adding the value of A the
number of times stated in the value of B.
For example, if A = 10 and B = 3, This algorithm will perform the following :
10 + 10 + 10 = 30
Tip: Notice that this only added the value of A 3 times but in your response,
you will see it shows up to 4 iterations.
If this happens in any of these exercises, the proper answer would be
"Loop Ended" for both Count and Product.
A=4 B=4
Get A
Get B
STEP 1 If A or B = 0
Then Set Product to = 0 and Go To STEP 3
Else Set Count to 0 and Set Product to 0 and Go To STEP 2
STEP 2 While Count <B
Set Product to (Product + A)
Set Count to (Count + 1)
End of Loop;
STEP 3 Print the value of Product
STEP 4 Stop
After Iteration 1:
Count equals 1
Product equals 4
After Iteration 2:
Count equals 2
Product equals 8
After Iteration 3:
Count equals 3
Product equals 12
After Iteration 4:
Count equals 4
Product equals 16
Answer 1:
1
Answer 2:
4
Answer 3:
2
Answer 4:
8
Answer 5:
3
Answer 6:
12
Answer 7:
4
Answer 8:
16
Question 12
3 / 3 pts
This algorithm will multiple a number by repeatedly adding the value of A the
number of times stated in the value of B.
For example, if A = 10 and B = 3, This algorithm will perform the following :
10 + 10 + 10 = 30
Tip: Notice that this only added the value of A 3 times but in your response,
you will see it shows up to 4 iterations.
If this happens in any of these exercises, the proper answer would be
"Loop Ended" for both Count and Product.
A=5 B=4
Get A
Get B
STEP 1 If A or B = 0
Then Set Product to = 0 and Go To STEP 3
Else Set Count to 0 and Set Product to 0 and Go To STEP 2
STEP 2 While Count < B
Set Product to (Product + A)
Set Count to (Count + 1)
End of Loop;
STEP 3 Print the value of Product
STEP 4 Stop
After Iteration 1:
Count equals 1
Product equals 5
After Iteration 2:
Count equals 2
Product equals 10
After Iteration 3:
Count equals 3
Product equals 15
After Iteration 4:
Count equals 4
Product equals 20
Answer 1:
1
Answer 2:
5
Answer 3:
2
Answer 4:
10
Answer 5:
3
Answer 6:
15
Answer 7:
4
Answer 8:
20
Question 13
3 / 3 pts
Run through the following sorting algorithm and determine the largest
number.
Assume at the start of this sequence the variables are set as follows:
List_Size = 5
o Num-1 = 12
o Num-2 = 8
o Num-3 = 5
o Num-4 = 16
o Num-5 = 1
Answer 1:
12
Answer 2:
12
Answer 3:
16
Answer 4:
16
Question 14
3 / 3 pts
Run through the following sorting algorithm and determine the largest
number.
Assume at the start of this sequence the variables are set as follows:
List_Size = 5
o Num-1 = 6
o Num-2 = 8
o Num-3 = 5
o Num-4 = 16
o Num-5 = 18
Answer 1:
8
Answer 2:
8
Answer 3:
16
Answer 4:
18
Question 15
Not yet graded / 20 pts
Write an algorithm (in pseudocode) for the following Scenario.
You will need to build a program that provides retirement estimates based
on user inputs. Your algorithm will ask the user to provide the following
information:
Full Name
Current Age
Desired Retirement Age
Current Retirement Savings
Amount You Need to Retire
The program will need to determine the years remaining until retirement and
how much is needed to reach the investment goal.
Finally, it will print a message to the screen that says:
The name,
How long until you reach retirement age and
How much is needed to be saved between now and then
Your Answer:
Get Full Name, Current Age, Desired Retirement Age, Current Retirement
Savings, Amount You Need to Retire
IF Current Age < Desired Retirement Age, THEN set Length to Retirement
Age = Desired Retirement Age-Current Age, ELSE Print 'Congratulations, you
are old enough to retire!'
IF Amount You Need to Retire < Current Retirement Savings, THEN set
Savings Needed to Retire = Amount You Need to Retire-Current Retirement
Savings, ELSE Print 'Congratulations, you have enough to retire!'
Print 'Full Name, Length to Retirement Age, Savings Needed to Retire'