Docsity

Data Structures and Algorithms Practice, Exams of Data Structures and Algorithms

Toggle sidebar
bg1
Data Structures and
Algorithms Practice
A group of students is searching the internet for information on dog breeds.
They start noticing a lot of advertising about dog food and dog accessories.
The algorithm that controls the ads they are seeing is most likely of which
type? - ANSartificial intelligence algorithm
An algorithm runs according to the function 4n2+ 2n + 14n2+ 2n + 1. What
is the Big O notation for the time complexity of the function? - ANSO(n2)
Describe what type of data structure you would be using if you needed to
extract information on a client using an ID or account number? - ANSarray
Determine the time and space complexities of a merge sort. - ANStime
complexity: O(n⋅log(n))
space complexity: O(n)
How many lines will be in the fourth stage of the Cantor dust fractal? The
first stage is a single solid line. The second stage has the middle third
removed and has two solid lines - ANS8
In the recursive Python code below, what section of code represents the base
case?
def recursion(k): if(k > 0): result = k + recursion(k - 1) else: result = 0 return
result recursion(4) - ANSelse: result = 0
pf3

Partial preview of the text

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

Data Structures and

Algorithms Practice

A group of students is searching the internet for information on dog breeds. They start noticing a lot of advertising about dog food and dog accessories. The algorithm that controls the ads they are seeing is most likely of which type? - ANSartificial intelligence algorithm An algorithm runs according to the function 4n2+ 2n + 14n2+ 2n + 1. What is the Big O notation for the time complexity of the function? - ANSO(n2) Describe what type of data structure you would be using if you needed to extract information on a client using an ID or account number? - ANSarray Determine the time and space complexities of a merge sort. - ANStime complexity: O(n⋅log(n)) space complexity: O(n) How many lines will be in the fourth stage of the Cantor dust fractal? The first stage is a single solid line. The second stage has the middle third removed and has two solid lines - ANS In the recursive Python code below, what section of code represents the base case? def recursion(k): if(k > 0): result = k + recursion(k - 1) else: result = 0 return result recursion(4) - ANSelse: result = 0

The following function finds the power of two described by the number being passed to the recursive function "double". def double(n): if n == 0: return 1 else: return double(n - 1) + double(n - 1) print(double(4)) Hence the result of the above code would be 24=1624=16. How could the code be modified to find the power of three? - ANSdef double(n): if n == 0: return 1 else: return double(n - 1) + double(n - 1) + double(n - 1) print(double(4)) The following is a recursive Python function: def mystery(n): if n == 1: return 3 else: return mystery(n - 1) + 3 Which mathematical function is defined recursively by this Python function? - ANS3⋅n Which of the following best describes a key in cryptography? - ANSA key is a piece of information used to encode or decode cryptographic data. Which of the following best describes an abstraction? - ANSAbstraction hides the details and shows the required information. Which of the following best explains the role of iteration in a program? - ANSIt is a repetitive function. Which of the following data structures hold key-value pairs - ANSmaps Which of the following data structures is it impossible to create multiple objects in due to its capacity limitations? - ANSstack