





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






Midterm Exam 1
Homework h4 due 10 pm Friday, February 28th
Program p2 due 10 pm Sunday, March 9th
Last Time Complexity
Today Complexity
Next Time Read: Stacks and Queues
problem size (N) = dominant operation =
What is the complexity of each algorithm below?
Algorithm 1: call out each name, have student come forward & pick up
best-case:
worst-case:
Algorithm 2: hand pile to first student, student searches through papers & takes hers/his, pass pile to next student who does likewise
best-case:
worst-case:
Algorithm 3: sort the papers alphabetically, hand pile to first student who does binary search, pass to next student who does likewise
Small Problem Size
Same Complexity
Space Requirements
Problem size N =?
Array:
Singly-Linked List:
Circular Singly-Linked List:
Doubly-Linked List:
Circular Doubly-Linked List:
"Naïve" Approach
"Shadow Array" Improvement
Ease of Implementation
Array:
Singly-Linked List:
Circular Singly-Linked List:
Doubly-Linked List:
Circular Doubly-Linked List: