Docsity

Data Structures and Algorithms, Exams of Data Structures and Algorithms

Toggle sidebar
bg1
Data Structures and
Algorithms
Determine the time and space complexities of a linear search. - ANStime
complexity: O(n)
space complexity O(n)
Evaluate the following algorithms in terms of its efficiency, correctness, and
clarity. Explain your answer in 3-5 sentences. - ANStalk about the efficiency
and correctness
For the recursive factorial function output shown below, which lines of output
would reflect the backward phase? - ANS4,5,6
How could the code be altered to print the sum of the first 6 terms in the
sequence, 7n + 1? - ANSdef sum(n):
if n == 0:
return 0
else:
return 7 * n + 1 + sum(n - 1)
result = sum(6)
print(result)
In 1-2 sentences, explain the purpose and outcome of the iterative control
structure. - ANSHCF
In 3-5 sentences, describe one disadvantage each for list, array, and queue
data structures. - ANSshouldnt be too hard
pf3

Partial preview of the text

Download Data Structures and Algorithms and more Exams Data Structures and Algorithms in PDF only on Docsity!

Data Structures and

Algorithms

Determine the time and space complexities of a linear search. - ANStime complexity: O(n) space complexity O(n) Evaluate the following algorithms in terms of its efficiency, correctness, and clarity. Explain your answer in 3-5 sentences. - ANStalk about the efficiency and correctness For the recursive factorial function output shown below, which lines of output would reflect the backward phase? - ANS4,5, How could the code be altered to print the sum of the first 6 terms in the sequence, 7n + 1? - ANSdef sum(n): if n == 0: return 0 else: return 7 * n + 1 + sum(n - 1) result = sum(6) print(result) In 1-2 sentences, explain the purpose and outcome of the iterative control structure. - ANSHCF In 3-5 sentences, describe one disadvantage each for list, array, and queue data structures. - ANSshouldnt be too hard

In 3-5 sentences, explain the algorithm. - ANScountdown In creating a model for a data abstraction for the concept of a pen, what would be the most appropriate attributes? - ANStype and color Students are discussing variations of algorithms to find Fibonacci numbers, like fib(6). What is the best possible time complexity that they can get for this algorithm? - ANSO(n^2) Suppose you are examining a set of raw medical data that includes the side effects of a specific drug. You are interested in finding out which side effects occur the most often. What would be an appropriate algorithm to find this data? - ANSbubble sort Suppose you are writing a program that requires you take different paths depending on the response to a prompt. The prompt has more than two acceptable responses. Which of the following structures would be most appropriate? - ANSif...then...else The programming team knows they need to create a program that will use a linear data structure to complete large amounts of data manipulation very quickly. Which data structure is most appropriate? - ANSlinked list Two students are discussing the best algorithm to use to see if a specific element is in a sorted data set. Which classic algorithm should they choose?

  • ANSbinary search What is the output of the greatest common divisor function gcd (27, 12)? - ANS