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
-
Width
-
Depth
-
Leaf node
-
None of these
A
Correct answer
Explanation
Width of a tree refers to the maximum no. of nodes in the tree structure.
-
Linear data structure
-
Complex data structure
-
Non-linear data structure
-
Simple data structure
-
None of the above
A
Correct answer
Explanation
An array is a linear data structure.
-
sort(int[] a)
-
indexOf(Object o)
-
copyOfRange(double[] orr, int fr, int t)
-
Both 1 and 2
-
Both 2 and 3
B
Correct answer
Explanation
indexOf(Object o) method is present in the ArrayList class in Java.
-
ceilingKey(K key)
-
remove(KeyStroke key)
-
ceilingEntry(K key)
-
Both 1 and 2
-
Both 1 and 3
E
Correct answer
Explanation
Methods given in option 1 and option 3 belong to ConcurrentSkipListMap class.
-
object next( )
-
boolean hasNext( )
-
void remove( )
-
boolean hasPrevious( )
-
Both (3) and (4)
D
Correct answer
Explanation
This is the method of ListIterator interface and returns true if there is a previous element. Otherwise, it returns false.
-
Comparator comparator( )
-
SortedMap subMap(Object start, Object end)
-
SortedMap tailMap(Object start)
-
SortedMap headMap(Object end)
-
Set entrySet( )
E
Correct answer
Explanation
This is the method of Map interface.
-
Stack
-
Queue
-
Tree
-
Linked List
-
De-queue
A
Correct answer
Explanation
A stack is a LIFO data-structure. LIFO stands for Last In First Out. The element which enters last, is the first to get out of the stack.
-
The sort-merge join
-
The nested loops join
-
This depends on some sort parameter values
-
This depends on the number of rows in each table
B
Correct answer
Explanation
When OPTIMIZER_MODE is set to FIRST_ROWS, Oracle's cost-based optimizer prioritizes returning the first rows quickly rather than minimizing total resource usage. A nested loops join is typically preferred over sort-merge join in FIRST_ROWS mode because it can start returning rows immediately without waiting for the entire sorting operation to complete, making it more responsive for interactive queries.
-
Linear search is slow as compared to binary search.
-
Linear search requires sorted data.
-
Linear search is not efficient with large data.
-
The complexity of binary search is O(log n).
-
Only (1), (3) and (4) are true.
E
Correct answer
Explanation
Yes, these statements are true.
-
Quick sort requires additional memory as compared to merge sort.
-
The average case complexity of merge sort is the same as quick sort.
-
The worst case complexity of quick sort and merge sort are also the same.
-
All of the above
-
Only (2) and (3).
B
Correct answer
Explanation
Both have the same complexity O(N log N), where N is the number of comparisons.
-
Linkedlist
-
Hashset
-
Vector
-
Queue
-
ArrayList
B
Correct answer
Explanation
Hashset is derived from Set interface, which does not allow duplicacy.
-
Arithmetic expression representation and evaluation
-
Lexical analysis phase of compiler
-
Syntax analysis
-
Both (2) and (3)
-
(1), (2) and (3) all are true
E
Correct answer
Explanation
Yes, all the three options are the applications of tree data structure.
-
B Tree can be used in database.
-
In B+ Tree, the root may be either leaf or an internal node with two or more children.
-
In B Tree of order m, every node has at most m children.
-
Both (2) and (3).
-
(1), (2) and (3) all are true.
E
Correct answer
Explanation
This is the correct choice.
-
TreeSet class ensures that the elements will be sorted in the natural ascending order.
-
HashSet class does not maintain the order of the elements.
-
HashSet ensures that the elements have no duplicacy.
-
Both (2) and (3).
-
(1), (2) and (3) all are true.
-
Prints: false,false,false
-
Prints: false,false,true
-
Prints: false,true,false
-
Prints: true,false,false
D
Correct answer
Explanation
The Vector.elements method returns an Enumeration over the elements of the vector. Vector implements the List interface and extends AbstractList so it is also possible to get an Iterator over a Vector by invoking the iterator or listIteratormethod.