Computer Knowledge
Data Structures and Algorithms
1,518 Questions
Data Structures and Algorithms form the core of computer science, focusing on arrays, linked lists, trees, and sorting mechanisms. These concepts are essential for solving complex computational problems efficiently. Test takers preparing for technical and administrative IT exams will find these questions highly relevant.
Array OperationsLinked List ApplicationsSorting AlgorithmsTree Data StructuresMultilevel IndexingAlgorithm Time Complexity
Data Structures and Algorithms Questions
-
29 numbers
-
30 numbers
-
31 numbers
-
28 numbers
-
no number
B
Correct answer
Explanation
It contains 5 rows and 6 column. So, it can store 30 numbers.
D
Correct answer
Explanation
This is the correct choice because there are 3 constructors of HashMap class. These are:
HashMap(): creates a Map with default initial capacity and load factor
HashMap(int initialCap, float load): creates a Map with default specified initial capacity and load factor
HashMap(m : Map): creates a Map with existing Map
C
Correct answer
Explanation
This is the correct choice because there are 4 constructors of HashTable class in Java collections framework. These constructors are:
1) Hashtable(): constructs a new, empty hashtable with a default initial capacity (11) and load factor (0.75)
2) Hashtable(int initialCapacity): constructs a new, empty hashtable with the specified initial capacity and default load factor (0.75)
3) Hashtable(int initialCapacity, float loadFactor): constructs a new, empty hashtable with the specified initial capacity and the specified load factor
4) Hashtable(Map t): constructs a new hashtable with the same mappings as the given map
C
Correct answer
Explanation
This is the correct answer. There are four constructors of TreeMap. These are:
TreeMap(): It creates an empty Map.
TreeMap(Comparator comp): The second form constructs an empty tree-based map that will be sorted by using the Comparator comp.
TreeMap(Map m): The third form initialises a tree map with the entries from m, which will be sorted by using the natural order of the keys.
TreeMap(SortedMap sm): The fourth form initialises a tree map with the entries from sm, which will be sorted in the same order as sm.
-
Bloom filter
-
Trie
-
Hash Map
-
Stack
-
None of the above
B
Correct answer
Explanation
Yes, trie data structure is the most efficient one to implement auto complete dictionary.
-
Only 1 and 2
-
Only 1
-
Only 2 and 3
-
Only 2
-
1, 2 and 3
B
Correct answer
Explanation
Statement 1 is true, whereas statement 2 is false as linked list size can be varied dynamically where as array size cannot. Statement 3 is also false as it is very easy to insert or remove elements from the linked list.
-
Both 1 and 2
-
Only 1
-
Only 2
-
Only 2 and 3
-
1, 2 and 3
D
Correct answer
Explanation
Statements 1 and 2 are true because the time complexity for searching an element in binary search tree is O(log n) and the time complexity for searching an element in binary tree is O(n). Statement 3 is false as time complexity for searching an element in binary tree and binary search tree can be determined.
-
C B A D
-
B C D A
-
A D B C
-
A D C B
-
None of these
B
Correct answer
Explanation
yes of the given time complexities the one with time O(log log n) is smallest because logarithm of a number is significantly small, here we are applying another logarithm which makes it much smaller, the next smaller will be O(log n) followed by O(n) and O(1) which makes it B C D A
-
Linear search
-
Binary search
-
Hash based search (Hashing)
-
Tree based search
-
None of the above
C
Correct answer
Explanation
yes, hashing or hash based search is used to find the element in O(1). Hashing generates a unique code which is used to look for an element in the data structure
-
Descending order of inserted elements
-
Random order of inserted elements
-
Ascending order of inserted elements
-
The order in which the elements are inserted
-
None of the above
C
Correct answer
Explanation
yes in order traversal of binary search tree gives ascending order of inserted elements. the in order pattern is as followsleft->root->right. So when we traverse it goes to the last element in the left sub tree and display it and then its root and its right sibling. this pattern is applied recursively.
B
Correct answer
Explanation
Yes, this is true as the node which has no ancestors is the root node because root node itself is the ancestor of all the remaining nodes in the tree.
-
Linked list
-
Queue
-
Stack
-
Tree
-
None of these
C
Correct answer
Explanation
yes, Stack is a data structure which has a characteristic feature of Last in First Out
-
Only 1
-
Only 2
-
Both 1 and 2
-
Neither 1 or 2
-
None of the above
A
Correct answer
Explanation
yes quick sort in worst case behaves as bubble sort whose time complexity is O(n2)
merge sort even in the worst case has time complexity of O(nlog n), so statement 2 is false
-
Symbol table construction
-
Spell checker
-
Auto complete feature
-
Implementing recursion
-
None of these
A
Correct answer
Explanation
yes, to implement a symbol table a tree data structure is necessary.A symbol- table mechanism must allow us to add new entries and find existing entries efficiently so a tree data structure is best suited
-
Queue
-
Stack
-
Dequeue
-
Hash map
-
None of these
C
Correct answer
Explanation
yes dequeue supports insertion or deletion of elements from head or back.dequeue stands for double ended queue