• 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 4 out of 107 pages
Exam (elaborations)

Cs311 Midterm Data Structures & Algorithms | Comprehensive Exam Prep, Practice Questions And Correct Answers

Document preview thumbnail
Preview 4 out of 107 pages

Prepare for the CS311 midterm with comprehensive practice questions and correct answers covering essential Data Structures and Algorithms concepts. Review topics such as arrays, linked lists, stacks, queues, trees, graphs, hashing, recursion, searching, sorting, algorithm analysis, time and space complexity, Big-O notation, and fundamental problem-solving techniques. This exam-focused resource provides targeted practice to reinforce programming and algorithmic concepts, strengthen problem-solving skills, identify areas requiring additional review, and build confidence for the CS311 midterm examination.

Content preview

CS 311 MIDTERM
DATA STRUCTURES & ALGORITHMS
COMPREHENSIVE PREP


Exam-Style Practice Questions
Correct Answers · Rationales · Explanations


COMPLEXITY · ITERATORS · OPERATORS · OWNERSHIP

MASTER THEOREM · TRADE-OFFS · LOWER BOUNDS


Arrays · Lists · Sorting · Searching · C++ Essentials


QUICK · CLEAR · PROFESSIONAL

,CS 311 MIDTERM | DATA STRUCTURES & ALGORITHMS Comprehensive Prep



PRACTICE SET 1
1. Printing the last item in an array whose size is known is Θ of what?
A. Θ(n)
B. Θ(1)
C. Θ(log n)
D. Θ(n log n)
Correct Answer: B
Rationale:
Random-access: index n−1 in constant time.
Size known ⇒ no traversal needed.

2. Printing the last item in a singly linked list whose size is known is typically:
A. Θ(1) always with only a head pointer
B. Θ(n) if only a head pointer is available (must walk the list)
C. Θ(log n)
D. Θ(n²)
Correct Answer: B
Rationale:
Singly linked lists do not support random access.
Even knowing size, you still traverse from the head unless a tail pointer exists.

3. Finding an item with a given value in a sorted array (binary search) is:
A. Θ(n)
B. Θ(log n)
C. Θ(1)
D. Θ(n log n)
Correct Answer: B
Rationale:
Each step halves the search space.
Comparison model, sorted random-access array.

4. Sorting a linked list with a comparison-based method is generally:
A. Θ(1)
B. Θ(n log n) with a good algorithm (e.g., merge sort adapted to lists)
C. Θ(log n)
D. Impossible
Correct Answer: B
Rationale:
Merge sort works well on linked lists (no random access needed for merging).
Comparison lower bound Ω(n log n) still applies.




Page 2

,CS 311 MIDTERM | DATA STRUCTURES & ALGORITHMS Comprehensive Prep



PRACTICE SET 2
5. Sorting an array with Insertion Sort is:
A. Θ(1)
B. Θ(n²) in the worst and average cases
C. Θ(n log n) always
D. Θ(log n)
Correct Answer: B
Rationale:
Nested loops; ~n²/4 comparisons on average.
Best case Θ(n) when already sorted.

6. Θ notation describes:
A. Only upper bounds
B. Tight asymptotic bounds (both O and Ω)
C. Only lower bounds
D. Exact operation counts for all n
Correct Answer: B
Rationale:
f is Θ(g) if f is both O(g) and Ω(g).
Commonly used for “the” order of an algorithm.

7. Binary search requires which property of the input?
A. Unsorted linked list
B. Sorted random-access sequence
C. Only a hash table
D. Unsorted array with no order
Correct Answer: B
Rationale:
Halving depends on order and indexable midpoints.
Linked lists make mid-finding expensive.

8. The comparison-based sorting lower bound is:
A. Ω(n)
B. Ω(n log n)
C. Ω(log n)
D. Ω(n²)
Correct Answer: B
Rationale:
Decision-tree argument: n! leaves need height ≥ log■(n!).
Stirling ⇒ ~n log n.




Page 3

, CS 311 MIDTERM | DATA STRUCTURES & ALGORITHMS Comprehensive Prep



PRACTICE SET 3
9. Vector src = {0,10,20,30,40,50,60,70}. std::copy(begin(src)+2, begin(src)+5, begin(dest)) copies:
A. 0, 10, 20
B. 20, 30, 40
C. 30, 40, 50
D. 50, 60, 70
Correct Answer: B
Rationale:
Half-open range [first, last): indices 2,3,4.
Values 20, 30, 40.

10. C++ iterators to the end of a range are:
A. Inclusive of the last element in the half-open convention
B. One past the last element (half-open [begin, end))
C. Always null
D. Random only
Correct Answer: B
Rationale:
Standard library algorithms use half-open ranges.
end is not dereferenced.

11. Random-access iterators support:
A. Only ++ and *
B. +, -, indexing, and constant-time jumps
C. Only bidirectional movement
D. No comparison
Correct Answer: B
Rationale:
vector and deque iterators are random-access.
list iterators are only bidirectional.

12. std::copy requires the destination to have:
A. No capacity concerns ever
B. Sufficient space or use of inserters for growing containers
C. Only empty state
D. Reverse iterators always
Correct Answer: B
Rationale:
copy does not resize automatically.
back_inserter can grow a vector.




Page 4

Document information

Uploaded on
September 29, 2026
Number of pages
107
Written in
2026/2027
Type
Exam (elaborations)
Contains
Questions & answers
$15.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.
DrExamVault
4.5
(12)
Sold
63
Followers
1
Items
3979
Last sold
20 hours ago



Why students choose Stuvia

Created by fellow students, verified by reviews

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

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight 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 smashed 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