• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 8 pages
Exam (elaborations)

Dsa Midterm Review Exam Questions & Answers

Document preview thumbnail
Preview 2 out of 8 pages

DSA MIDTERM REVIEW EXAM QUESTIONS & ANSWERS

Content preview

DSA MIDTERM REVIEW EXAM
QUESTIONS & ANSWERS



What is the worst case computational complexity of the following code snippet in terms
of Big O notation?

int sum = 0
for (int i=0; i<n; i++)
for (int j=0; j<i; j++)
sum = sum+j; - Correct Answers -O(n^2) (n squared)

What is the computational complexity of the following code snippet?

int result = 0
for (int i = 0; i < n; i++)
for (int j = i; j > 0; j--)
result += 1; - Correct Answers -O(n^2)

What is the worst case computational complexity of the following code snippet in terms
of Big O notation?

int x = 1
while (x < n)
x *= 2 - Correct Answers -O(log n)

What is the worst case computational complexity of the following code snippet in terms
of Big O notation?

result = 0
for (int i = 0; i < n; i++)
result += i;
for (int j = 1; j < m; j *= 2)
result *= j; - Correct Answers -O(n + log m)

Which of the following functions T(n), belongs to the family of O(n^3*(log2n)) - Correct
Answers -n^3*(log2(log2n))
n^2+n+5000
1000000
n^3

, n^3*(log3n)


Which of the following statements about linked lists and arrays are TRUE? - Correct
Answers --Both data structures can use iterators
-Both are linear data types

What is the computational complexity of deleting an element, e from a doubly linked list
with tail in the worst case in terms of Big O notation? Assume the list has n items. -
Correct Answers -O(n)

Which of the following container(s) is/are List ADT implementation(s) in C++? [Select all
that apply] - Correct Answers --Array
-Forward List
-Vector

What is the worst case computational complexity of the following code snippet in terms
of Big O notation?
result = 0
for (i=0; i<10; i++)
for (j=0; j<i; j++)
result += i*j; - Correct Answers -O(1)

An algorithm's runtime is given by T(n, m) = 3m^3+4m^3*log2⁡m+3n^2+n+100. -
Correct Answers -O(m^3*log2(m)+n^2)

Which family/families does the following function T(n) = n^5*log2(n) belong to? Check
all that apply. - Correct Answers -Ω(10000)
O(2000n^5+2000^n)
O(n^5log3(n))

Which of the following are FALSE? Select all that apply. - Correct Answers --The best
case time complexity of linear search is O(1) and occurs when there is just one element
in an array
-If the growth rate for algorithm A can be represented by T(n) = n and the growth rate for
algorithm B can be represented by U(n) = log(n) we can say that algorithm A is faster
than algorithm B.

Examine the following code snippets below and determine which has a slower growth
rate. Consider "c" to be a positive integer constant (c > 1) :

Snippet A:
for(int i = 0; i < n; i++){
for(int j = n; j > 0; j /= c){
print("Hello");}}

Document information

Uploaded on
March 26, 2026
Number of pages
8
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$12.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

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.
millyphilip
3.7
(560)
Sold
2991
Followers
1963
Items
46798
Last sold
4 days ago



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

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions