100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

Technology Algorithms Exam Questions and Answers Fully Solved Latest Version

Rating
-
Sold
-
Pages
9
Grade
A+
Uploaded on
03-08-2025
Written in
2025/2026

Technology Algorithms Exam Questions and Answers Fully Solved Latest Version An algorithm will be used to decide whether every number in a list is either a 4 or a 5. There are two proposals for the algorithm: Algorithm 1: Set only45 to false. Iterate through each number in the list. If the number is not equal to 4 and not equal to 5, set only45 to false. Otherwise, set only45 to true. Algorithm 2: Set only45 to true. Iterate through each number in the list. If the number is not equal to 4 and not equal to 5, set only45 to false. Which of these statements are true about these algorithms? I. Algorithm 1 does not work on lists where a number other than 4 and 5 occurs before the last number. II. Algorithm 2 does not work on lists which contain entirely 4s or entirely 5s.An algorithm will be used to decide whether every number in a list is either a 4 or a 5. There are two proposals for the algorithm: Algorithm 1: Set only45 to false. Iterate through each number in the list. If the number is not eq - AnswersI only he goal of the procedure computeAverage is to calculate the average of a list of numbers, ignoring any 0 values. For example, if given the list [0, 1, 3, 5], it should return the number 3. PROCEDURE computeAverage(numbers) { total ← 0 count ← 0 FOR num IN numbers { IF (num ≠ 0) { total ← total + num count ← count + 1 } ELSE { RETURN total/count } } RETURN total/count } A programmer tests the procedure with various inputs and finds multiple cases where it does not produce the expected output. Which calls to computeAverage() return an incorrect average? - AnswerscomputeAverage([22, 0, 49, 8]) computeAverage([22, 9, 0, 17]) The two algorithms below are both intended to calculate the product of squares from 1 to n, where n is any positive integer. For example, if n is 333, the algorithms should calculate a product of 363636, from 1^2 times 2^2 times 3^212×22×321, squared, times, 2, squared, times, 3, squared. Algorithm 1: i ← n product ← 0 REPEAT n TIMES { product ← product * (i * i) i ← i - 1 } Algorithm 2: i ← 0 product ← 1 REPEAT n TIMES { product ← product * (i * i) i ← i + 1 } Which statements best describe the behavior of the algorithms? - AnswersNeither algorithm calculates the correct product. A programmer develops the procedure makeNumsList() to generate lists of numbers starting at start and ending with end. For example, makeNumsList(4, 7) should return [4, 5, 6, 7]. PROCEDURE makeNumsList(start, end) { numsList ← [] numTimes ← (end - start) + 1 num ← 1 REPEAT numTimes TIMES { APPEND(numsList, num) num ← num + 1 } RETURN numsList } The programmer tests it with makeNumsList(1, 4) and sees a return value of [1, 2, 3, 4]. Can the programmer conclude that the procedure works correctly for all inputs? - AnswersNo, they've only verified that it works for that test case. Additional analysis and reasoning is necessary. An algorithm will be used to calculate the difference between the smallest and largest values in a list. For the list of [10, 3, 5, 6], it should calculate a difference of 7. There are two proposals for the algorithm: Algorithm 1: Set minVal to the first value in the list and maxVal to the last value in the list. Iterate through each number in the list. If the number is greater than maxVal, store it in maxVal. If the number is less than minVal, store it in minVal. After loop, set maxDiff to the difference between maxVal and minVal. Algorithm 2: Set minVal to 1000 and maxVal to 0. Iterate through each number in the list. If the number is greater than maxVal, store it in maxVal. If the number is less than minVal, store it in minVal. After loop, set maxDiff to the difference between maxVal and minVal. - AnswersII only The goal of the procedure longestWord is to return the longest word in a given list of words. For example, if it's given the list ["superhero", "captain", "marvel"], it should return "superhero" as the longest word. PROCEDURE longestWord(words) { maxWordLen ← 0 maxWord ← "" FOR word IN words { IF (LENGTH(word) > maxWordLen) { maxWord ← word maxWordLen ← LENGTH(word) RETURN maxWord } } RETURN maxWord } A programmer tests the procedure with various inputs and finds that there are multiple cases where it does not produce the expected output. Which calls to longestWord() do not actually return the longest word? -

Show more Read less
Institution
Technology Algorithms
Course
Technology Algorithms









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Technology Algorithms
Course
Technology Algorithms

Document information

Uploaded on
August 3, 2025
Number of pages
9
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

Technology Algorithms Exam Questions and Answers Fully Solved Latest Version 2025-2026

An algorithm will be used to decide whether every number in a list is either a 4 or a 5.

There are two proposals for the algorithm:

Algorithm 1: Set only45 to false. Iterate through each number in the list. If the number is not equal to 4
and not equal to 5, set only45 to false. Otherwise, set only45 to true.

Algorithm 2: Set only45 to true. Iterate through each number in the list. If the number is not equal to 4
and not equal to 5, set only45 to false.

Which of these statements are true about these algorithms?

I. Algorithm 1 does not work on lists where a number other than 4 and 5 occurs before the last number.

II. Algorithm 2 does not work on lists which contain entirely 4s or entirely 5s.An algorithm will be used to
decide whether every number in a list is either a 4 or a 5.

There are two proposals for the algorithm:

Algorithm 1: Set only45 to false. Iterate through each number in the list. If the number is not eq -
AnswersI only

he goal of the procedure computeAverage is to calculate the average of a list of numbers, ignoring any 0
values. For example, if given the list [0, 1, 3, 5], it should return the number 3.

PROCEDURE computeAverage(numbers) { total ← 0 count ← 0 FOR num IN numbers { IF (num ≠ 0)
{ total ← total + num count ← count + 1 } ELSE { RETURN total/count } } RETURN total/count }

A programmer tests the procedure with various inputs and finds multiple cases where it does not
produce the expected output.

Which calls to computeAverage() return an incorrect average? - AnswerscomputeAverage([22, 0, 49, 8])

computeAverage([22, 9, 0, 17])

The two algorithms below are both intended to calculate the product of squares from 1 to n, where n is
any positive integer.

For example, if n is 333, the algorithms should calculate a product of 363636, from 1^2 \times 2^2
\times 3^212×22×321, squared, times, 2, squared, times, 3, squared.

Algorithm 1:

i ← n product ← 0 REPEAT n TIMES { product ← product * (i * i) i ← i - 1 }

Algorithm 2:

, i ← 0 product ← 1 REPEAT n TIMES { product ← product * (i * i) i ← i + 1 }

Which statements best describe the behavior of the algorithms? - AnswersNeither algorithm calculates
the correct product.

A programmer develops the procedure makeNumsList() to generate lists of numbers starting at start
and ending with end. For example, makeNumsList(4, 7) should return [4, 5, 6, 7].

PROCEDURE makeNumsList(start, end) { numsList ← [] numTimes ← (end - start) + 1 num ← 1 REPEAT
numTimes TIMES { APPEND(numsList, num) num ← num + 1 } RETURN numsList }

The programmer tests it with makeNumsList(1, 4) and sees a return value of [1, 2, 3, 4].

Can the programmer conclude that the procedure works correctly for all inputs? - AnswersNo, they've
only verified that it works for that test case. Additional analysis and reasoning is necessary.

An algorithm will be used to calculate the difference between the smallest and largest values in a list.
For the list of [10, 3, 5, 6], it should calculate a difference of 7.

There are two proposals for the algorithm:

Algorithm 1: Set minVal to the first value in the list and maxVal to the last value in the list. Iterate
through each number in the list. If the number is greater than maxVal, store it in maxVal. If the number
is less than minVal, store it in minVal. After loop, set maxDiff to the difference between maxVal and
minVal.

Algorithm 2: Set minVal to 1000 and maxVal to 0. Iterate through each number in the list. If the number
is greater than maxVal, store it in maxVal. If the number is less than minVal, store it in minVal. After loop,
set maxDiff to the difference between maxVal and minVal. - AnswersII only

The goal of the procedure longestWord is to return the longest word in a given list of words. For
example, if it's given the list ["superhero", "captain", "marvel"], it should return "superhero" as the
longest word.

PROCEDURE longestWord(words) { maxWordLen ← 0 maxWord ← "" FOR word IN words { IF
(LENGTH(word) > maxWordLen) { maxWord ← word maxWordLen ← LENGTH(word) RETURN
maxWord } } RETURN maxWord }

A programmer tests the procedure with various inputs and finds that there are multiple cases where it
does not produce the expected output.

Which calls to longestWord() do not actually return the longest word? - AnswerslongestWord(["crown",
"diamond", "castle"])

longestWord(["frog", "seagull", "mermaid"])

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
TutorJosh Chamberlain College Of Nursing
View profile
Follow You need to be logged in order to follow users or courses
Sold
332
Member since
1 year
Number of followers
16
Documents
28211
Last sold
1 day ago
Tutor Joshua

Here You will find all Documents and Package Deals Offered By Tutor Joshua.

3.6

53 reviews

5
18
4
14
3
12
2
0
1
9

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions