An array is a linear data structure that stores elements of the same data type in a contiguous block of memory. The elements can be accessed using an index. The size of the array is fixed at the time of its creation.
Which data structure follows Last In First Out (LIFO) principle?
A Stack
B Array
C Queue
D Tree
A stack is a linear data structure that follows the Last In First Out (LIFO) principle. This means the last element added to the stack is the first one to be removed. Common operations are push (add) and pop (remove).
What does the term “heap” refer to in data structures?
A Binary Tree
B Priority Queue
C Linked List
D Tree
A heap is a specialized binary tree used to implement priority queues. In a heap, the value of each node is ordered with respect to its children, typically either in max‐heap or min‐heap order, ensuring that the highest or lowest priority element is at the root.
Which operation is not supported by a queue data structure?
A Peek
B Enqueue
C Dequeue
D Random Access
A queue supports enqueue (insert an element) and dequeue (remove an element), and peek (view the front element). However, random access, where elements can be accessed directly by index, is not supported by a queue because it follows FIFO (First In First Out) order.
What is a binary search tree (BST)?
A Directed Graph
B Binary Tree with ordered nodes
C Doubly Linked List
D Balanced Tree
A Binary Search Tree (BST) is a binary tree where each node has at most two children, and the left child is smaller than the parent node, while the right child is greater. This ordering allows for efficient searching, insertion, and deletion of elements.
Which of the following is a key characteristic of a Disjoint Set Union (DSU) structure?
A Only supports find operations
B Stores elements in a tree
C Supports both union and find operations
D Supports only union operations
The Disjoint Set Union (DSU) supports two main operations: union (to combine two sets) and find (to find the representative of the set an element belongs to). This is essential for network connectivity and connected components in graphs.
Which data structure is used to efficiently implement the union-find algorithm in network connectivity?
A Disjoint Set Union (DSU)
B Stack
C Linked List
D Array
Disjoint Set Union (DSU) is used to efficiently manage and track the connected components in a network. It supports quick union and find operations, often enhanced with techniques like path compression and union by rank.
Which of the following is a feature of a Fenwick Tree (Binary Indexed Tree)?
A Supports only range updates
B Uses more memory than segment trees
C Supports arbitrary range queries
D Supports range queries and point updates
A Fenwick Tree (Binary Indexed Tree) supports range queries and point updates efficiently, in O(log n) time. It is ideal for cumulative frequency tables, and its space complexity is O(n).
What is the key advantage of using dynamic memory allocation in programming?
A Improved code readability
B Faster execution
C Better space management
D Fixed size allocation
Dynamic memory allocation allows memory to be allocated at runtime, enabling more flexible use of memory. It helps avoid wasting space by allocating memory based on actual needs, unlike static memory allocation, which uses fixed sizes.
In which situation would you use a Skip List over a regular linked list?
A When memory usage is not a concern
B For faster search, insertion, and deletion
C For better memory utilization
D For faster insertion of elements
A Skip List provides faster search, insertion, and deletion operations compared to a regular linked list by using multiple levels of linked lists, enabling O(log n) time complexity for these operations, whereas linked lists operate in O(n) time.
What is the main drawback of using a Bloom Filter?
A False positives
B High memory consumption
C Fixed size
D It cannot be resized
The main drawback of a Bloom Filter is that it may produce false positives, meaning it might incorrectly report that an element is in the set. However, it will never produce false negatives, making it useful for fast, probabilistic membership testing.
Which of the following is a key application of Suffix Trees in string processing?
A Sorting data
B Finding the longest repeated substring
C Efficiently searching for patterns
D Counting occurrences of a substring
Suffix Trees are used for efficient string matching, pattern searching, and finding substrings. They store all suffixes of a string, allowing for fast searching and substring queries, making them crucial for tasks like pattern matching in text processing.
What is the main disadvantage of using a segment tree?
A High space complexity
B Inefficient for dynamic data
C Slow updates
D Slow queries
Segment Trees have a space complexity of O(n log n), which can be a disadvantage when working with large datasets. While they are efficient for range queries, the memory usage can be significant compared to simpler data structures.
What is the main advantage of using a Trie over a hash table for storing strings?
A Fixed size
B Supports prefix queries
C Efficient memory usage
D Faster search
Tries are particularly advantageous when you need to support prefix queries. They allow for efficient retrieval of all strings with a given prefix, making them ideal for applications like autocomplete and spell checking.
Which of the following data structures is ideal for implementing a set in a programming language with fast lookups and insertions?
A Queue
B Array
C Linked List
D Hash Table
A Hash Table is ideal for implementing sets as it allows fast lookup, insertion, and deletion operations with an average time complexity of O(1), making it efficient for membership tests and set operations in many applications.