Which data structure is used to implement recursive function calls?
A Array
B Stack
C Linked List
D Queue
A stack is used to store function calls during recursion. The stack stores the return address, local variables, and the execution state of the function, allowing the program to return to the correct position after a function call finishes.
Which type of data structure is a linked list?
A Linear
B Graph
C Tree
D Non-linear
A linked list is a linear data structure consisting of nodes, where each node stores data and a reference (link) to the next node in the sequence. Unlike arrays, linked lists do not have fixed memory locations and can grow dynamically.
What is the main advantage of a doubly linked list over a singly linked list?
A Static size
B Faster search
C Bi-directional traversal
D Better memory usage
A doubly linked list allows traversal in both directions, forwards and backwards, thanks to each node having references to both its next and previous nodes. This gives more flexibility compared to a singly linked list, which can only be traversed in one direction.
Which sorting algorithm has the best average time complexity?
A Quick Sort
B Selection Sort
C Merge Sort
D Bubble Sort
Merge Sort has an average time complexity of O(n log n), which makes it more efficient for large datasets compared to other algorithms like Bubble Sort and Selection Sort, which have O(n²) time complexity.
What does BFS stand for in graph algorithms?
A Breadth First Search
B Binary First Search
C Best First Search
D Balanced First Search
BFS stands for Breadth First Search, a graph traversal algorithm that explores all neighbors at the present depth level before moving on to nodes at the next depth level. It is used for finding the shortest path in unweighted graphs.
What type of tree is balanced and maintains a height difference of at most one between subtrees?
A B-Tree
B AVL Tree
C Binary Tree
D Red-Black Tree
An AVL tree is a self-balancing binary search tree where the height difference between the left and right subtrees of any node is at most one. This balance ensures O(log n) time complexity for operations like insertion and deletion.
Which operation is used to insert an element in a priority queue?
A Push
B Insert
C Enqueue
D Insert with priority
In a priority queue, elements are inserted with a specified priority. Unlike standard queues, the elements are dequeued based on priority, not the order in which they were added, ensuring that higher priority elements are processed first.
Which data structure uses hashing to store data?
A Queue
B Linked List
C Hash Table
D Binary Tree
A hash table uses a hash function to map keys to indices in an array, allowing for fast access to values. The hashing technique provides average time complexity of O(1) for search, insert, and delete operations.
What is the main characteristic of a circular linked list?
A Has no end
B Multiple nodes
C Fixed size
D Doubly linked
In a circular linked list, the last node points back to the first node, forming a loop. This structure allows traversal to continue indefinitely, which is useful in applications where the list needs to cycle repeatedly.
Which tree structure is used for fast searching and dynamic data insertion?
A Trie
B Binary Search Tree
C AVL Tree
D Heap
A Binary Search Tree (BST) allows for fast searching and dynamic data insertion. By maintaining an ordered structure, it ensures that search, insertion, and deletion operations can be done in O(log n) time in a balanced BST.
Which of these is the most efficient searching algorithm for an unsorted array?
A Hash Search
B Binary Search
C Linear Search
D Jump Search
Linear search is the only algorithm that works on an unsorted array. It checks each element sequentially until the target is found or the entire array is traversed, giving it a time complexity of O(n).
Which operation is commonly associated with a stack data structure?
A Pop
B Peek
C Push
D All of the above
A stack supports the operations of push (adding an element), pop (removing an element), and peek (viewing the top element) based on the Last In First Out (LIFO) principle.
What is the worst-case time complexity of Quick Sort?
A O(n²)
B O(n log n)
C O(n)
D O(log n)
Quick Sort has an average time complexity of O(n log n), but its worst-case time complexity is O(n²) when the pivot selection results in unbalanced partitions. This happens when the array is already sorted or nearly sorted.
What type of data structure is a binary heap?
A List
B Tree
C Queue
D Graph
A binary heap is a complete binary tree where each parent node follows the heap property (max‐heap or min‐heap). It is commonly used to implement priority queues, ensuring that the root contains the highest (or lowest) priority element.
What is a Trie data structure mainly used for?
A Sorting
B Pathfinding
C Searching
D String matching
A Trie is a tree-like data structure used primarily for efficient string matching. It allows for quick retrieval of strings and prefixes, often used in applications such as autocomplete and dictionary implementations.