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
Document preview thumbnail
Preview 2 out of 10 pages
Exam (elaborations)

EECS 281 FINAL QUESTIONS WITH CORRECT ANSWERS

Document preview thumbnail
Preview 2 out of 10 pages

EECS 281 FINAL QUESTIONS WITH CORRECT ANSWERS

Content preview

EECS 281 FINAL QUESTIONS WITH CORRECT
ANSWERS



Hashing Basic Functionality Complexity - ans-
xz xz xz xz xzxz




Efficient: Insert O(1), Search O(1), Remove O(1)
xz xz xz xz xz xz




Inefficient: Sort, Kth largest, Joint/Merge xz xz xz xz




Hashing Load Factor - ans-Alpha = α = N/M xz xz xz xzxz xz xz xz xz




N is number of keys in table
xz xz xz xz xz xz




M is size of table
xz xz xz xz




Need to keep below 0.5 so functions are efficient.
xz xz xz xz xz xz xz xz




Hashing Load Factor - Separate Chaining - ans-
xz xz xz xz xz xz xzxz




Load factor, α, is average number of items per table entry
xz xz xz xz xz xz xz xz xz xz




Hashing Load Factor - Open Addressing - ans-Load factor, α, is percent of table filled
xz xz xz xz xz xz xzxz xz xz xz xz xz xz xz




Hashing Insert Complexity - ans-O(1) if duplicates are allowed
xz xz xz xzxz xz xz xz xz




O(α) if no duplicates allowed.
xz xz xz xz




Reasoning: Need to search for item to see if it already exists. Search is expensive.
xz xz xz xz xz xz xz xz xz xz xz xz xz xz




Hashing Search Complexity - ans-O(α) xz xz xz xzxz




Need to hash for the key but then need to linear search table if rehashing or chain if separat
xz xz xz xz xz xz xz xz xz xz xz xz xz xz xz xz xz xz




e chaining
xz




Hashing Remove Complexity - ans- xz xz xz xzxz




O(α). Need to search for item before removing it. Could be even worse depending on separ
xz xz xz xz xz xz xz xz xz xz xz xz xz xz xz




ate chaining container.
xz xz




Hashing Complexity - Normal Vector - ans-Insert and Search both O(α)
xz xz xz xz xz xzxz xz xz xz xz




Hashing Complexity - Sorted Vector - ans-Insert is O(α) and Search is O(log α)
xz xz xz xz xz xzxz xz xz xz xz xz xz xz




Hashing Complexity - Binary Tree - ans-Insert and search O(log a).
xz xz xz xz xz xzxz xz xz xz xz




Large memory over head to maintain tree.
xz xz xz xz xz xz




Hashing Linear vs Quadratic Probing Complexity - ans-
xz xz xz xz xz xz xzxz




Number of probes for hit and for miss grow exponentially with α for both.
xz xz xz xz xz xz xz xz xz xz xz xz xz

, Quadratic has slightly slower growth for both hit and miss. xz xz xz xz xz xz xz xz xz




Number of probes for hit < number of probes for miss
xz xz xz xz xz xz xz xz xz xz




Dynamic Hashing Summary - ans-When α ≥ 0.5, grow table size (M) and rehash.
xz xz xz xzxz xz xz xz xz xz xz xz xz xz




Keeps load factor α low, but occasional expensive regrow operation
xz xz xz xz xz xz xz xz xz




Dynamic Hashing Amortized Complexity - ans-O(M) - Linear
xz xz xz xz xzxz xz xz




1) Initial inserts have cost until α ≥ 0.5
xz xz xz xz xz xz xz xz




=> Max 2.5 probes for insertion hit/miss if α ≤ 0.5
xz xz xz xz xz xz xz xz xz xz




=> Insert M/α -1 keys before α exceeds 0.5
xz xz xz xz xz xz xz xz




=> 2.5 * (M/α -1) = O(M)
xz xz xz xz xz xz




2) Grow and rebuild table
xz xz xz xz




=> Max 1.5 probes for insertion hit/miss if α ≤ 0.25
xz xz xz xz xz xz xz xz xz xz




=> 1.5 * M/2 = O(M)
xz xz xz xz xz




Thus 2O(M) = O(M) = Linear amortized cost.... O(1)!
xz xz xz xz xz xz xz xz




Simple Tree - ans-Acyclic, connected graph.
xz xz xzxz xz xz xz




Undirected.

Rooted Tree - ans-Simple Tree w/ selected vertex as root.
xz xz xzxz xz xz xz xz xz xz




Edges directed AWAY from root. xz xz xz xz




Internal Node - ans-A node with children xz xz xzxz xz xz xz




ordered tree - ans-A rooted tree in which all children of each vertex are ordered left to right.
xz xz xzxz xz xz xz xz xz xz xz xz xz xz xz xz xz xz




Binary Tree - ans-a tree in which each node has at most 2 children.
xz xz xzxz xz xz xz xz xz xz xz xz xz xz




Complete Binary Tree - ans-A binary tree with depth d where: xz xz xz xzxz xz xz xz xz xz xz




1) Depths 1,...,d-1 are all full
xz xz xz xz xz xz




(each level of the tree except the last is full)
xz xz xz xz xz xz xz xz xz




2) All internal nodes are to the left of external nodes at depth d-1
xz xz xz xz xz xz xz xz xz xz xz xz xz




(All leaves are at the second to last level or left most at the last level)
xz xz xz xz xz xz xz xz xz xz xz xz xz xz xz




Complete Binary Tree Implementation - ans-Root: Index 1 xz xz xz xz xzxz xz xz




Left Child of node i = 2*i
xz xz xz xz xz xz




Right child of node i = 2*i+1
xz xz xz xz xz xz




Inefficient use of space for sparse trees xz xz xz xz xz xz




Binary Tree Insert Complexity - ans-Best: O(1)
xz xz xz xz xzxz xz




Worst: O(n) xz

Document information

Uploaded on
June 22, 2026
Number of pages
10
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$12.49

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.
VICTORYSUCCESS
3.0
(2)
Sold
16
Followers
0
Items
2227
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