Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

CS160 MIDTERM ACTUAL EXAM PREP 2026 ALL QUESTIONS AND CORRECT DETAILED ANSWERS ALREADY A GRADED WITH EXPERT FEEDBACK |NEW AND REVISED

Rating
-
Sold
-
Pages
31
Grade
A+
Uploaded on
14-02-2026
Written in
2025/2026

CS160 MIDTERM ACTUAL EXAM PREP 2026 ALL QUESTIONS AND CORRECT DETAILED ANSWERS ALREADY A GRADED WITH EXPERT FEEDBACK |NEW AND REVISED

Institution
CS160
Course
CS160

Content preview

1|Page



CS160 MIDTERM ACTUAL EXAM PREP
2026 ALL QUESTIONS AND CORRECT
DETAILED ANSWERS ALREADY A
GRADED WITH EXPERT FEEDBACK
|NEW AND REVISED




1. In most statically typed languages, which error is caught at compile time
rather than at run time?
A. Null pointer dereference.
B. Type mismatch between variable and assigned value.
C. Division by zero with dynamic input.
D. Array index out of bounds when index computed at runtime.
Static type systems detect incompatible types during compilation,
preventing assignment/type errors before execution.
2. Which data structure provides O(1) average-time amortized push and pop at
the end?
A. Singly linked list head operations.
B. Binary search tree.
C. Dynamic array (e.g., amortized array list) append/pop at end.
D. Heap.
Dynamic arrays resize occasionally so amortized cost per append/pop at
the end is O(1).
3. Which sorting algorithm has worst-case time complexity O(n^2) and is in-
place?
A. Merge sort.
B. Insertion sort (and selection sort/quick sort worst case).
C. Heap sort.
D. Tim sort.

,2|Page


Insertion sort performs O(n^2) comparisons/swaps in worst case and sorts
in place using constant extra memory.
4. What is the output of this pseudocode?

for i in 1..3:
for j in 1..i:
print(i)

A. 1 2 3
B. 1 2 2 3 3 3
C. 1 1 2 2 3 3
D. 3 3 3 2 2 1
Inner loop prints i j times: prints one 1, two 2s, three 3s yielding 1 2 2 3 3 3.

5. Which Big-O characterizes binary search on a sorted array of length n?
A. O(n)
B. O(n log n)
C. O(log n)
D. O(1)
Binary search halves the search range each step, giving logarithmic time
complexity.
6. Which structure is best for implementing breadth-first search on a graph?
A. Stack.
B. Priority queue.
C. Queue.
D. Hash table.
BFS explores neighbors level by level using a FIFO queue to process
vertices in order discovered.
7. In object-oriented programming, which principle restricts direct access to
internal object state?
A. Polymorphism.
B. Encapsulation.
C. Inheritance.
D. Abstraction only.
Encapsulation hides internal details and exposes a public interface,
controlling access to state.
8. Which SQL clause filters rows after grouping with GROUP BY?
A. WHERE
B. JOIN
C. HAVING

,3|Page


D. ORDER BY
HAVING applies predicates to aggregated groups; WHERE filters
individual rows before grouping.
9. What is the primary purpose of a hash function in a hash table?
A. To sort keys.
B. To map keys to bucket indices uniformly for fast lookup.
C. To compress data for storage.
D. To encrypt sensitive values.
Hash functions compute indices to store and retrieve keys in near-constant
time when collisions are minimal.
10.Which of the following best describes stack overflow in recursion?
A. Only when integer overflow occurs.
B. When the call stack grows beyond available memory due to too many
nested calls.
C. When heap memory is exhausted.
D. When variables exceed CPU registers.
Excessive recursive depth consumes stack frames until stack memory is
exhausted causing overflow.
11.Which algorithmic paradigm divides the problem into subproblems, solves
them, and combines results?
A. Greedy.
B. Divide and conquer.
C. Dynamic programming only.
D. Backtracking.
Divide and conquer splits the problem (e.g., merge sort, quicksort), solves
recursively, then merges solutions.
12.Which complexity class describes problems solvable in polynomial time?
A. NP-complete.
B. EXP.
C. P.
D. Undecidable.
Class P contains decision problems that have deterministic polynomial-
time algorithms.
13.In a singly linked list, deleting a node given only a pointer to that node (not
the head) can be done by:
A. Rewiring previous pointer without traverse.
B. Copying next node's data into the node and removing next node (if
next exists).
C. Immediately freeing memory without modification.
D. Swapping head and node.

, 4|Page


Without head access, you can overwrite current node with next node and
delete next—cannot if node is tail.
14.Which HTTP method is idempotent by definition?
A. POST only.
B. GET and PUT (both idempotent; POST is not).
C. CONNECT.
D. TRACE only.
GET and PUT are idempotent: repeated identical requests have same
effect; POST may create multiple resources.
15.Which statement about pointers/references is true?
A. References allow pointer arithmetic in safe languages.
B. Pointers store memory addresses; dereferencing accesses the value at
that address.
C. References and values are identical at runtime in all languages.
D. Pointers are always type-agnostic without casts.
Pointers hold addresses; dereferencing reads/writes memory at the pointed
location; semantics vary by language.
16.What does SQL injection exploit?
A. Poor hashing of passwords.
B. Lack of input validation allowing attacker-supplied SQL to be
executed.
C. Disk fragmentation.
D. Incorrect timestamps.
SQL injection occurs when unsanitized user input is concatenated into
SQL, enabling arbitrary queries.
17.Which of these is a stable sorting algorithm?
A. Heapsort.
B. Quick sort.
C. Merge sort (stable when implemented to preserve order).
D. Selection sort.
Merge sort preserves relative order of equal elements if implemented
appropriately, hence stable.
18.In a CPU scheduling context, which algorithm minimizes average waiting
time for nonpreemptive scheduling with known burst times?
A. Round robin.
B. Shortest Job First (SJF).
C. First-come, first-served always.
D. Priority with random ties.
SJF schedules shortest job next, minimizing average waiting time when
job lengths are known.

Written for

Institution
CS160
Course
CS160

Document information

Uploaded on
February 14, 2026
Number of pages
31
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$22.49
Get access to the full document:

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


Also available in package deal

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.
impressivetutor Chamberlain College Of Nursing
Follow You need to be logged in order to follow users or courses
Sold
645
Member since
3 year
Number of followers
377
Documents
3291
Last sold
4 hours ago

Are you having problems with your exams. There are better ways to cope with that. Exams,notes,case studies,Testbanks and many more are available here. The ability to not know something is the knowledge to know something better. Good luck in your studies. Hit me up if you need anything else.

4.8

1816 reviews

5
1639
4
40
3
50
2
57
1
30

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

Working on your references?

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

Working on your references?

Frequently asked questions