Podcast
Questions and Answers
In a linear/sequential search in an unordered linked list, what happens when a match is not found during insertion?
In a linear/sequential search in an unordered linked list, what happens when a match is not found during insertion?
- The item replaces the closest key in the linked list.
- The search terminates without any changes to the list.
- The item is added to the front of the linked list. (correct)
- The item is added to the end of the linked list.
What is the time complexity of inserting an element into an unordered array using a linear search approach?
What is the time complexity of inserting an element into an unordered array using a linear search approach?
- O(N log N)
- O(log N)
- O(1)
- O(N) (correct)
In a binary search algorithm on a sorted array, what is the role of the 'rank' helper function?
In a binary search algorithm on a sorted array, what is the role of the 'rank' helper function?
- To find the key that is closest in value to the target key.
- To determine the number of keys less than the target key. (correct)
- To sort the array before searching.
- To randomly select an index to check for the key.
A binary search is used on a sorted array to find a specific element. After several iterations, the search range is narrowed down to a single element. What does this indicate?
A binary search is used on a sorted array to find a specific element. After several iterations, the search range is narrowed down to a single element. What does this indicate?
What is a primary disadvantage of using binary search implementation on an ordered array, especially when inserting new elements?
What is a primary disadvantage of using binary search implementation on an ordered array, especially when inserting new elements?
What is the time complexity of Binary Search and Insert operations respectively, in an ordered array?
What is the time complexity of Binary Search and Insert operations respectively, in an ordered array?
What is the primary goal of a hash function?
What is the primary goal of a hash function?
Under what condition can searching in a hash table be reduced from O(n) to O(1)?
Under what condition can searching in a hash table be reduced from O(n) to O(1)?
In the context of direct addressing hash tables, what is a key requirement for the number of places, 'm,' in the hash table relative to the number of keys, 'k'?
In the context of direct addressing hash tables, what is a key requirement for the number of places, 'm,' in the hash table relative to the number of keys, 'k'?
What is a significant disadvantage of using direct addressing hash tables when dealing with a large universe of possible keys?
What is a significant disadvantage of using direct addressing hash tables when dealing with a large universe of possible keys?
What is the key problem addressed by hash functions that incorporate collision resolution techniques?
What is the key problem addressed by hash functions that incorporate collision resolution techniques?
Which characteristic is most important when selecting a value for 'm' (the size of the hash table) in the division method of modular hashing?
Which characteristic is most important when selecting a value for 'm' (the size of the hash table) in the division method of modular hashing?
What is the primary purpose of separate chaining in hash table implementations?
What is the primary purpose of separate chaining in hash table implementations?
In separate chaining, what is the process for searching for a specific key?
In separate chaining, what is the process for searching for a specific key?
If a hash table using separate chaining has an array of size 'm' and stores 'k' keys, what is the condition that prompts the array to double in size?
If a hash table using separate chaining has an array of size 'm' and stores 'k' keys, what is the condition that prompts the array to double in size?
Which of the following is a characteristic of linear probing?
Which of the following is a characteristic of linear probing?
In quadratic probing, how is the next probe position calculated after a collision at index h(x)?
In quadratic probing, how is the next probe position calculated after a collision at index h(x)?
What is the primary requirement for the secondary hash function, $h_2(k)$, in double hashing?
What is the primary requirement for the secondary hash function, $h_2(k)$, in double hashing?
Which of the following is true regarding hashing analysis?
Which of the following is true regarding hashing analysis?
What is the definition of a 'tree' in the context of data structures?
What is the definition of a 'tree' in the context of data structures?
Which statement accurately describes the 'depth' of a node in a tree?
Which statement accurately describes the 'depth' of a node in a tree?
In a binary search tree (BST), what is the key property regarding the arrangement of nodes?
In a binary search tree (BST), what is the key property regarding the arrangement of nodes?
In a Binary Search Tree (BST) what is the first step in searching for an element?
In a Binary Search Tree (BST) what is the first step in searching for an element?
In a BST, if the value to be inserted is less than the current node, which of the following operations is performed?
In a BST, if the value to be inserted is less than the current node, which of the following operations is performed?
What is the key disadvantage of using a binary search tree (BST) as a data structure?
What is the key disadvantage of using a binary search tree (BST) as a data structure?
What determines the shape of a binary search tree (BST)?
What determines the shape of a binary search tree (BST)?
What is the number of comparisons that may be performed for search/insert equal in a BST?
What is the number of comparisons that may be performed for search/insert equal in a BST?
To find the minimum value from the BST, which of the following step is appropriate?
To find the minimum value from the BST, which of the following step is appropriate?
Which characteristic is used to implement size(), return the count at the root for BST?
Which characteristic is used to implement size(), return the count at the root for BST?
Which of the following steps are performed while deleting the minimum key:?
Which of the following steps are performed while deleting the minimum key:?
In the context of deleting a node from a BST, what action is taken in the 'Case 0' scenario?
In the context of deleting a node from a BST, what action is taken in the 'Case 0' scenario?
To delete a node with key $k$ in a BST and it has one child under which of the following cases is it found and what happens?
To delete a node with key $k$ in a BST and it has one child under which of the following cases is it found and what happens?
In what scenario is the 'successor' of a node relevant during deletion in a Binary Search Tree (BST)?
In what scenario is the 'successor' of a node relevant during deletion in a Binary Search Tree (BST)?
Which performance metric improves when balancing the tree?
Which performance metric improves when balancing the tree?
For a 2-3 tree, how many keys are there per node?
For a 2-3 tree, how many keys are there per node?
During 2-3 tree insertion on a 2-node, what action should be performed?
During 2-3 tree insertion on a 2-node, what action should be performed?
While performing 2-3 tree insertion to a 3-node then 4-node will be generated, under what condition such action occurs and it splits into three 2-nodes?
While performing 2-3 tree insertion to a 3-node then 4-node will be generated, under what condition such action occurs and it splits into three 2-nodes?
Flashcards
Linear Search in a Linked List
Linear Search in a Linked List
Scan each key in a linked list until a match is found.
Sequential Search Complexity
Sequential Search Complexity
The time complexity of searching an unordered array using sequential search.
Insert Complexity in Unordered Array
Insert Complexity in Unordered Array
The time complexity of inserting into an unordered array.
Binary Search Data Structure
Binary Search Data Structure
Signup and view all the flashcards
Rank Helper Function
Rank Helper Function
Signup and view all the flashcards
Binary Search Time Complexity
Binary Search Time Complexity
Signup and view all the flashcards
Insert Time Complexity for Ordered Array
Insert Time Complexity for Ordered Array
Signup and view all the flashcards
Hash Table Objective
Hash Table Objective
Signup and view all the flashcards
Hash Table
Hash Table
Signup and view all the flashcards
Direct Addressing
Direct Addressing
Signup and view all the flashcards
Collision
Collision
Signup and view all the flashcards
Division Method Hash Function
Division Method Hash Function
Signup and view all the flashcards
Hashing Integer
Hashing Integer
Signup and view all the flashcards
Separate Chaining
Separate Chaining
Signup and view all the flashcards
Linear Probing
Linear Probing
Signup and view all the flashcards
Probing Hash Function
Probing Hash Function
Signup and view all the flashcards
Collision Resolution
Collision Resolution
Signup and view all the flashcards
Type of Probe Sequences
Type of Probe Sequences
Signup and view all the flashcards
Quadratic Probing hash function
Quadratic Probing hash function
Signup and view all the flashcards
Double Hashing Algorithm
Double Hashing Algorithm
Signup and view all the flashcards
Best and Average Case
Best and Average Case
Signup and view all the flashcards
Separate chaining
Separate chaining
Signup and view all the flashcards
Definition of a Tree
Definition of a Tree
Signup and view all the flashcards
Root
Root
Signup and view all the flashcards
Forest
Forest
Signup and view all the flashcards
Degree Deg (e)
Degree Deg (e)
Signup and view all the flashcards
Leaf Node
Leaf Node
Signup and view all the flashcards
Depth D (e)
Depth D (e)
Signup and view all the flashcards
H (e)
H (e)
Signup and view all the flashcards
Binary Search Trees
Binary Search Trees
Signup and view all the flashcards
Search
Search
Signup and view all the flashcards
Binary Search Tree
Binary Search Tree
Signup and view all the flashcards
BST Search –Implem
BST Search –Implem
Signup and view all the flashcards
Put Associate
Put Associate
Signup and view all the flashcards
Shapes depend
Shapes depend
Signup and view all the flashcards
BST Table.
BST Table.
Signup and view all the flashcards
Nodes data
Nodes data
Signup and view all the flashcards
Signup and view all the flashcards
Rotation
Rotation
Signup and view all the flashcards
A BST SUCH
A BST SUCH
Signup and view all the flashcards
Study Notes
- Covers search algorithms, including linear search, binary search, and hash tables
- Touches on 2-3 trees and Left-Leaning Red-Black Trees (LLRBT) as balanced search tree options
Search Applications
- Various applications use specific search types
- Dictionaries use search to find definitions by word
- Book indexes use search to identify relevant pages by term
- File sharing uses search to locate songs by name
- Financial accounts systems use search to process transactions by account number
- Web search engines use search to find web pages by keywords
Linear/Sequential Search
- Involves maintaining an unordered linked list of key-value pairs
- Requires scanning through all keys until a match is located
- For insertion, if a match is found keys will be scanned, otherwise the new node is added to the front
- The complexity of sequential search in an unordered array is O(N)
- The complexity of inserting into an unordered array is O(N)
Binary Search
- This search algorithm maintains an ordered array of key-value pairs
- Utilizes a 'rank' helper function to determine the number of keys less than k
- Determines the index position of a key if it exists in the array, and if the key is present in the array or the appropriate insertion point if it doesn't
- Binary search has a search complexity of O(log N) in an ordered array
- Insertion complexity in an ordered array is O(N), considering the need to shift elements
- Inserting a key requires shifting all greater keys over
Hash Tables
- An efficient data structure for dynamic sets, supporting simple operations like insert/put, search/get, and delete
- Generalized field structure suitable for applications like Google search and caching
- In the worst-case scenario with linked lists, searching can be O(n)
Direct Addressing Hash Table
- Best used with a relatively small set of keys
- Given a hash table H[0,..., m-1] with m places, m >= k
- Hash Function: h(k) → k maps key k to index k
- Advantage: offers simple implementation of insert, search, and delete
- Disadvantage: impractical for a large number of keys, as the actual number of keys observed k, may be very small compared to the table size m, wasting space
- Solutions of this include using a hash function with collision resolution, separate chaining, and probing
Hash Function with Collision
- Restricts the size of the hash table by mapping a set of possible keys to a smaller set m
- Problem with Collisions: Two distinct keys being hashed onto the same hash code
- E.g., the Mod7 function makes any integer key to the range [0 … 6], Mod7(15)=1, Mod7(22)=1
Design of Good Hash Functions
- Objective is to achieve a good distribution of the search key k to the index range of the hash table H, without underlying assumptions about a probability distribution
Division Method / Modular Hashing
- The hash function h is defined as h(k) = k mod m, where m is the size of the hash table H
- For instance, if m = 12 and k = 100, then h(100) = 4
- Good candidates for m are prime numbers
Separate Chaining
- Also known as open hashing or closed addressing
- Uses an array of size m < k linked lists
- Hash: Maps a key to an integer i between 0 to m-1
- Insert: Puts the new node at the front of the ith chain if it's not already there
- Search: Needs to search only the ith chain
Separate Chaining - Resizing
- The goal is to keep the average length of the list k/m constant
- Double the size of array M when k/m >= 8
- Halve the size of array M when k/m <= 2
- Need to rehash all keys when resizing
Further Topics in Search Algorithm
- Terminologies of tree structures such as 'forests', 'degree of node', 'leaf node', 'depth of node', 'height of node'
- BST
- Balanced search tree
- 2-3 tree and related transformations and properties
- Red-black trees and "glue" nodes
Note that there is no material related to deletion of hash table entries or separate chaining entries in this study guide. Probing, quadratic and double hashing, and complexity analysis are also missing.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.