String hashing MCQsBy: Prof. Dr. Fazal Rehman | Last updated: May 14, 2025 40 Score: 0 Attempted: 0/40 Subscribe 1. : What is the primary purpose of string hashing? (A) To sort strings (B) To convert strings into fixed-size integers (C) To compare strings directly (D) To store strings in a database 2. : Which of the following is a common use of string hashing? (A) Data compression (B) Pattern matching (C) String sorting (D) File encryption 3. : What is a hash function? (A) A function that converts data into a binary format (B) A function that maps input data of arbitrary size to fixed-size values (C) A function that encrypts data (D) A function that sorts data 4. : Which property is crucial for a good hash function? (A) It should be linear (B) It should minimize collisions (C) It should be easy to compute (D) Both B and C 5. : What is a collision in the context of hashing? (A) When two strings hash to different values (B) When two different strings hash to the same value (C) When the hash function fails (D) When a string is empty 6. : Which of the following is a common approach to handle collisions? (A) Deleting the entry (B) Open addressing (C) Ignoring the collision (D) Using a longer string 7. : What is a rolling hash? (A) A hash function that rehashes the entire string for each new substring (B) A hash function that updates its value incrementally (C) A hash function that uses random values (D) A hash function used for encryption 8. : In string hashing, what is the purpose of a modulus operation? (A) To increase the hash value (B) To reduce the hash value to fit within a certain range (C) To sort the string (D) To concatenate strings 9. : What is the time complexity of computing a hash for a string of length n using a simple polynomial hash function? (A) O(1) (B) O(n) (C) O(n log n) (D) O(n²) 10. : What is one disadvantage of using a naive hash function? (A) It is too complex to implement (B) It may produce too many collisions (C) It is inefficient for short strings (D) It requires too much memory 11. : Which of the following hash functions is commonly used for string hashing? (A) SHA-256 (B) MD5 (C) Rabin-Karp hash (D) All of the above 12. : In the context of string hashing, what does “perfect hashing” mean? (A) A hash function that uses no memory (B) A hash function that never produces collisions (C) A hash function that is always faster than others (D) A hash function that sorts strings 13. : What is a common application of string hashing in databases? (A) Data retrieval (B) Data insertion (C) Data sorting (D) Data deletion 14. : What does the term “load factor” refer to in hashing? (A) The ratio of stored entries to the total number of slots in a hash table (B) The size of the input string (C) The number of collisions in a hash table (D) The efficiency of a hash function 15. : Which of the following is NOT a characteristic of a good hash function? (A) Deterministic (B) Uniform distribution (C) Complex calculations (D) Fast computation 16. : How does a cryptographic hash function differ from a regular hash function? (A) It is slower to compute (B) It is not deterministic (C) It is easier to reverse (D) It is only used for strings 17. : What is the result of applying a hash function to an empty string? (A) A random value (B) A predefined constant (C) Zero (D) A null value 18. : Which hashing technique would be most efficient for large datasets with frequent insertions and deletions? (A) Separate chaining (B) Open addressing (C) Double hashing (D) Perfect hashing 19. : What happens if two strings hash to the same value using a hash function? (A) The hash function is ineffective (B) A collision occurs (C) The strings are identical (D) The hash function is reset 20. : Which of the following is a simple example of a hash function? (A) Summing the ASCII values of characters (B) Reversing the string (C) Sorting the characters (D) Finding the length of the string 21. : In string hashing, what does a “hash table” refer to? (A) A data structure that stores hash values (B) A mapping of keys to values (C) A fixed-size array used for storing hashed strings (D) All of the above 22. : What is the primary benefit of using a hashing technique in programming? (A) It simplifies data storage (B) It improves data retrieval speed (C) It increases memory usage (D) It enhances data security 23. : What does it mean to “rehash” a hash table? (A) To apply a new hash function to existing entries (B) To increase the size of the hash table (C) To delete all entries (D) To compress the data 24. : Which of the following is an example of a hash collision resolution technique? (A) Chaining (B) Appending (C) Overwriting (D) Sorting 25. : What is a disadvantage of separate chaining for collision resolution? (A) Increased memory usage (B) Slower performance (C) Higher load factor (D) Limited to fixed-size tables 26. : How does a hash table maintain efficiency? (A) By using a larger size than needed (B) By keeping the load factor below a certain threshold (C) By allowing dynamic resizing (D) By using complex hash functions 27. : What is the time complexity of searching for an element in a well-distributed hash table? (A) O(1) (B) O(n) (C) O(log n) (D) O(n log n) 28. : Which hash function is based on polynomial rolling? (A) MD5 (B) Rabin-Karp (C) SHA-256 (D) Linear probing 29. : What type of data structure is often used to implement separate chaining? (A) Array (B) Linked list (C) Stack (D) Queue 30. : What is a major disadvantage of open addressing? (A) It uses too much memory (B) It can lead to clustering (C) It is slower than separate chaining (D) It cannot handle collisions 31. : In which scenario would you prefer string hashing? (A) When exact string matching is required (B) When sorting strings (C) When counting distinct strings (D) When concatenating strings 32. : What is the significance of the hash value? (A) It uniquely identifies an entry in a hash table (B) It determines the string length (C) It specifies the original string (D) It serves as an encrypted value 33. : How does the choice of a hash function impact performance? (A) It has no effect on performance (B) A poor choice can lead to many collisions and slower performance (C) A good choice guarantees constant time operations (D) Both B and C 34. : What would be an ideal characteristic of a hash function? (A) It should be easy to reverse (B) It should produce similar hash values for similar inputs (C) It should spread out hash values uniformly (D) It should depend heavily on the input format 35. : What is a potential issue with using a simple additive hash function? (A) It can lead to poor distribution of hash values (B) It is too complex to implement (C) It is not deterministic (D) It requires too much memory 36. : In string hashing, what does “dynamic resizing” refer to? (A) Adjusting the hash function (B) Changing the size of the input strings (C) Modifying the size of the hash table based on load factor (D) Resizing strings to fit within the hash values 37. : What is a common method to enhance the efficiency of a hash table? (A) Using a fixed hash function (B) Ensuring a low load factor (C) Ignoring collisions (D) Using longer strings 38. : Which of the following best describes “universal hashing”? (A) A hash function that guarantees no collisions (B) A family of hash functions from which one is chosen at random (C) A hash function that is only applicable to integers (D) A hash function that uses no randomness 39. : What is the effect of a high load factor on a hash table? (A) Increased speed (B) More collisions and slower performance (C) Better memory utilization (D) Increased size 40. : What is a common application of rolling hash in algorithms? (A) String sorting (B) Text searching (C) Data compression (D) Data encryption Data Structures MCQs Basic Concepts Introduction to Data Structures Abstract Data Types (ADT) MCQs Complexity Analysis MCQs Time complexity MCQs Space complexity MCQs Big O, Big Ω, Big Θ notations MCQs Linear Data Structures MCQs Arrays MCQs One-dimensional arrays MCQs Multi-dimensional arrays MCQs Operations: traversal, insertion, deletion MCQs Linked Lists MCQs Singly linked list MCQs Doubly linked list MCQs Circular linked list MCQs Stacks MCQs Stack operations (push, pop, peek) MCQs Applications of stacks (expression evaluation, recursion) MCQs Queues MCQs Queue operations (enqueue, dequeue, front, rear) MCQs Types: Simple queue, circular queue, priority queue, deque MCQs Non-Linear Data Structures MCQs Trees MCQs Binary trees MCQs Binary Search Trees (BST) MCQs AVL Trees MCQs B-trees and B+ trees MCQs Tree traversal methods (in-order, pre-order, post-order) MCQs Heaps MCQs Min-heap MCQs Max-heap MCQs Heap operations (insertion, deletion, heapify) MCQs Applications of heaps (priority queues, heap sort) MCQs Graphs MCQs Graph representation (adjacency matrix, adjacency list) MCQs Graph traversal algorithms (DFS, BFS) MCQs Shortest path algorithms (Dijkstra’s, Bellman-Ford) MCQs Minimum Spanning Tree (Kruskal’s, Prim’s) MCQs Hashing MCQs MCQs Hash Tables Hash functions MCQs Collision resolution techniques (chaining, open addressing) MCQs Applications of hashing MCQs Sorting and Searching Algorithms MCQs Sorting Algorithms MCQs Bubble sort MCQs Selection sort MCQs Insertion sort MCQs Merge sort MCQs Quick sort MCQs Heap sort MCQs Searching Algorithms MCQs Linear search MCQs Binary search MCQs Interpolation search MCQs Miscellaneous Memory Management in data structures MCQs Dynamic memory allocation MCQs Garbage collection MCQs String Manipulation Algorithms MCQs Pattern matching (KMP, Rabin-Karp) MCQs String hashing MCQs Data Structures MCQs 1 Data Structures MCQs 2 Data Structures MCQs 3 Data Structures MCQs 4 Data Structures MCQs 5 Stacks Solved MCQs Queues MCQs pointer mcqs Array MCQs Related Posts:JS Javascript program to copy one string into another stringWhich of the following function is used to find the first occurrence of a string in another string?Hashing MCQs MCQsData Encryption and Hashing MCQs ASP.NETApplications of hashing MCQsString Manipulation Algorithms MCQs