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)

2026 new COEN 352 Midterm Practice - Yan Liu Style 50 complete practice questions with full solutions and reasoning Concordia University

Rating
-
Sold
-
Pages
16
Grade
A+
Uploaded on
17-06-2026
Written in
2025/2026

2026 new COEN 352 Midterm Practice - Yan Liu Style 50 complete practice questions with full solutions and reasoning Concordia University

Institution
COEN 352
Course
COEN 352

Content preview

2026 new COEN 352 Midterm Practice - Yan Liu
Style 50 complete practice questions with full
solutions and reasoning Concordia University

50 complete practice questions with full solutions and reasoning.

Coverage: Chapter 3 asymptotic analysis, Chapter 4 lists/stacks/queues, and Chapter 7 sorting algorithms. Includes
algorithm analysis, trace questions, true/false, design comparisons, and integrated stack/queue/sorting questions.

How to use this file: Do the Question first without looking. Then read Full solution. Then read Reason / exam logic because
that is the part that teaches what to write on a midterm.




Difficulty note: Questions 21-50 are marked CHALLENGING. They are designed to force execution/tracing, not just
memorization.




Quick Reference Sheet Before Starting
Pattern Detailed idea Simplified
One constant statement T(n)=c1 Θ(1)
One loop 0 to n-1 T(n)=c1*n+c2 Θ(n)
Two full nested loops T(n)=c1*n^2+c2*n+c3 Θ(n^2)
Triangular nested loop 1+2+...+n=n(n+1)/2 Θ(n^2)
Doubling/halving loop 1,2,4,...,n or n,n/2,...,1 Θ(log n)
Geometric inner work 1+2+4+...+n < 2n Θ(n)
Mergesort T(n)=2T(n/2)+Θ(n) Θ(n log n)
Quicksort best/avg balanced partitions Θ(n log n)
Quicksort worst 0 and n-1 partitions Θ(n^2)




Practice Questions
1. Meaning of T(n), c1, c2, and Θ [BASIC]
Question: For the code below, explain what T(n), c1, c2, and Θ(n) represent. Do not only give the final answer;
explain each symbol.

int sum = 0;
for (int i = 0; i < n; i++) {
sum++;
}
Full solution: T(n) is the total amount of work done by the algorithm when the input size is n. The loop runs n times.
The repeated work inside one loop iteration is represented by c1, so the loop contributes c1*n. The fixed work
outside the loop, such as initializing sum, is represented by c2. Therefore T(n) = c1*n + c2. When simplifying to
asymptotic notation, constants are ignored, so the growth is Θ(n).

Reason / exam logic: Yan Liu usually wants you to separate the detailed cost function from the simplified growth
rate. c1 and c2 are unknown constants; you do not calculate them. They represent fixed machine-independent

,operation costs.



2. Largest element position [BASIC]
Question: For largest(A), the loop checks A[1] to A[n-1]. Give T(n), Θ, best case, and worst case.

, static int largest(int[] A) {
int currLarge = 0;
for (int i = 1; i < A.length; i++) {
if (A[currLarge] < A[i]) currLarge = i;
}
return currLarge;
}
Full solution: Let n = A.length. The loop starts at i = 1 and stops at i = n-1, so it runs n-1 times. Each iteration does
constant work: an if comparison and maybe an assignment. Thus T(n) = c1(n-1) + c2. This simplifies to Θ(n). Best
case is Θ(n), worst case is Θ(n), and average case is Θ(n).

Reason / exam logic: The position of the largest value does not stop the loop early. Even if the largest is at index 0,
the code still checks every remaining element.



3. Sequential search cases [BASIC]
Question: Analyze sequential search. Give best, worst, and average case with the condition that causes each one.

static int search(int[] A, int k) {
for (int i = 0; i < A.length; i++) {
if (A[i] == k) return i;
}
return A.length;
}
Full solution: Best case: the key is at index 0, so only one comparison is done: Θ(1). Worst case: the key is absent
or at the last index, so n comparisons are done: Θ(n). Average successful search: if the key is equally likely to be at
any position, the expected number of comparisons is (1+2+...+n)/n = (n+1)/2, so Θ(n).

Reason / exam logic: Best case does not mean n=1. Keep n fixed, then choose the easiest input of size n.



4. Single loop with final value trap [BASIC]
Question: Find T(n) and Θ. Also explain why the final value of sum is not the running time.

int sum = 0;
for (int i = 1; i <= n; i++) {
sum += n;
}
Full solution: The loop runs n times. The body is constant time, even though it adds n each time. T(n) = c1*n + c2,
so Θ(n). The final value of sum is n^2, but the algorithm did only n loop iterations.

Reason / exam logic: Complexity counts how many operations happen, not how large the computed value
becomes.



5. Nested square loop [BASIC]
Question: Give the exact summation, T(n), and Θ.

int count = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
count++;
}
}
Full solution: The outer loop runs n times. For each outer iteration, the inner loop runs n times. Total count++
operations = n*n = n^2. A cost form is T(n)=c1*n^2+c2*n+c3. Therefore Θ(n^2).

Written for

Institution
COEN 352
Course
COEN 352

Document information

Uploaded on
June 17, 2026
Number of pages
16
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$17.99
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

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.
smartzone Liberty University
View profile
Follow You need to be logged in order to follow users or courses
Sold
3388
Member since
6 year
Number of followers
2295
Documents
14677
Last sold
2 days ago
AMAIZING EDUCATION WORLD

GET ALL KIND OF EXAMS ON THIS PAGE ,COMPLETE TEST BANKS,SUMMARIES,STUDY GUIDES,PROJECT PAPERS,ASSIGNMENTS,CASE STUDIES, YOU CAN ALSO COMMUNICATE WITH THE SELLER FOR ANY PRE-ORDER,ORDER AND ETC.

3.6

612 reviews

5
271
4
96
3
108
2
32
1
105

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