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

Data Structures & Algorithms Exam Questions And Answers

Document preview thumbnail
Preview 2 out of 13 pages

DATA STRUCTURES & ALGORITHMS EXAM QUESTIONS AND ANSWERS

Content preview

DATA STRUCTURES & ALGORITHMS
EXAM QUESTIONS AND ANSWERS



Search structures - Correct Answers -Data structures oriented to searches

• Array-based structures (array and std::vectors)
• Linked lists (any variant)
• Binary search trees, AVL trees, and skip lists.

hash table - Correct Answers -is a data structure that stores a collection of unique
search keys and associated values (or pointers) directly in the cells of the array

Handling *Collisions* The problem - Correct Answers -Definition: There is a collision
involving the keys k1 and k2 when both k1 and k2 are determined to belong at the same
index

Two approaches to handle collisions: - Correct Answers -Allow more than one key to
reside in the same place
Separate chaining

Store keys in an alternative location Open Addressing

Handling Collisions: Separate Chaining - Correct Answers -It allows more than one key
to be stored at the same index in the array

Approach
• Each cell in the array will be a singly-linked list
• It has no size limit

Handling Collisions: Separate Chaining: Common Operations: The lookup algorithm -
Correct Answers -The lookup algorithm
• Get key's hash => use % to get index
• Search the linked list at that index

Handling Collisions: Separate Chaining: Common Operations: The insertion algorithm -
Correct Answers -Lookup

Add a new node in the linked list (front or tail)

, Handling Collisions Separate Chaining: Analysis: - Correct Answers -Hash functions
runs in Θ(1) time

Bottle neck => Linked list

Approaches
• Efficiency of hashing/indexing
• Capacity of the hash table (re-hashing).

Hash Function Design
Goals: We look for two qualities: - Correct Answers -Fast to compute.
It needs to be called in every common operation.
It should not depend on the number of keys in the table (n).

It spreads the keys evenly in the hash table.
It maintains an even number of elements in each linked list

Handling Collisions: Open Addressing - Correct Answers -It allows keys to be stored
somewhere other than where the hash function says they belong

Handling Collisions: Open Addressing: Approach - Correct Answers -Find an alternative
index to store the key

Handling Collisions: Open Addressing: Advantages over Separate Chaining: - Correct
Answers -It does not use dynamic memory allocation.

It actually uses less memory, as we don't need linked lists.

Handling Collisions Open Addressing: Linear probing - Correct Answers -Insertion
algorithm:
Hash the key => get the index i with %

If index i is empty => Insert the key into i

Otherwise, probe backward to i-1, i-2, and so on.

If we reach index 0 => wrap around, stating from the index s.

Handling Collisions Open Addressing: Analysis of Linear probing - Correct Answers -
Primary clustering: Clusters grow and performance degrades
quickly

We consider length of the array's clusters
• Sequences of contiguous cells in use.

Larger clusters => higher changes to hit one during insertion

Document information

Uploaded on
July 28, 2025
Number of pages
13
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$13.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.
millyphilip
3.7
(562)
Sold
3010
Followers
1964
Items
47650
Last sold
1 hour 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