Computer Knowledge
Data Structures and Algorithms
1,256 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
-
Pipeline parallelism
-
Costly in terms of space and time
-
Removes duplicates on the key specified
-
None of the above
B
Correct answer
Explanation
Sort components are resource-intensive because they must collect all records before sorting, often require disk spillover for large datasets, and perform expensive comparison operations across the entire dataset.
-
Linked list
-
Twisted pair
-
Circular buffer
-
Sparse matrix
B
Correct answer
Explanation
A twisted pair is a type of copper wiring used for telecommunications, not a computer science data structure. The other options (linked list, circular buffer, sparse matrix) are all legitimate data structures used in programming.
-
p is a pointer to a 10 element integer array
-
p is a 10-element array of pointers to integer quantity
-
p is a pointer to an integer quantity
-
None of the above
B
Correct answer
Explanation
In int *p[10], the array operator [ ] has higher precedence than *. This means p is an array of 10 elements, where each element is a pointer to an integer. int (*p)[10] would be a pointer to an array.
-
p is a pointer to a 10 element integer array
-
p is a pointer to an integer quantity
-
p is a 10-element array of pointers to an integer
-
None of the above
A
Correct answer
Explanation
The parentheses override default operator precedence. Because *p is grouped together, p is declared as a pointer. It points to an array of 10 integers. Without parentheses, int *p[10] would be an array of 10 pointers.
-
Subscript refers to the array occurrence while index is the displacement (in no of bytes) from the beginning of the array.
-
An index can only be modified using PERFORM, SEARCH & SET.
-
Need to have index for a table in order to use SEARCH, SEARCH ALL.
-
None of the above
D
Correct answer
Explanation
All statements are true. A subscript represents the occurrence number, while an index represents the displacement. An index can only be modified using PERFORM, SEARCH, and SET. An index is required on a table to use SEARCH or SEARCH ALL. Thus, none of the statements are false.
-
The start value of the sequence is always 1.
-
The sequence always increments by 1.
-
The minimum value of an ascending sequence defaults to 1.
-
The maximum value of descending sequence defaults to 1.
C
Correct answer
Explanation
In database sequences (such as Oracle), the default minimum value for an ascending sequence is 1. The start value and increment can be customized, and descending sequences default to a different maximum value.
-
Index Sequential
-
Via Set
-
Calc
-
Direct
D
Correct answer
Explanation
In mainframe database systems like IDMS, accessing a record directly via its database key (Direct) is the fastest access method because it bypasses indexes, sets, and calculation algorithms entirely.
A
Correct answer
Explanation
In Java, ArrayList operations are generally faster than Vector because ArrayList is unsynchronized (not thread-safe) while Vector is synchronized. The synchronization overhead in Vector makes it slower for single-threaded operations. This is a key reason ArrayList was introduced in Java 1.2 as a modern alternative to the legacy Vector class.
-
Binary Tree
-
Hash Table
-
Stack
-
None of the Above
B
Correct answer
Explanation
Hash tables provide O(1) average time complexity for key-based lookups, making them ideal for scenarios requiring fast data retrieval by key. Binary trees have O(log n) lookup time, while stacks follow LIFO order and don't support efficient key-based access.
-
Binary Tree
-
Hash Table
-
Stack
-
None of the Above
A
Correct answer
Explanation
A stack is a Last-In, First-Out (LIFO) data structure. When you push 1, 3, and 5 onto the stack in that order, 5 is the last element added and therefore the first element to be popped out.
-
Binary Tree
-
Hash Table
-
Stack
-
None of the Above
B
Correct answer
Explanation
Hash tables provide average O(1) lookup time due to direct indexing through hash functions. Binary trees provide O(log n) lookup. Stacks provide O(1) but only for LIFO access, not general retrieval. Hash tables are fastest on average for general data retrieval.
-
Quicksort
-
Linear Search
-
Bubble Sort
-
none of the above
B
Correct answer
Explanation
For 200,000 elements: Quicksort is O(n log n) ≈ 3.6M operations, Linear Search is O(n) = 200K operations, and Bubble Sort is O(n²) = 40B operations. Linear search is fastest, so you'd wait the least time for it.
-
Sorter
-
Connected Lookup
-
Expression
-
Unconnected Lookup
A
Correct answer
Explanation
In Informatica, an Active transformation changes the number of rows passing through it. The Sorter transformation is active because it can change the row order and, based on configuration, can filter rows (like using 'distinct' sort which removes duplicates). Lookup (both connected and unconnected) and Expression are passive transformations as they maintain the same number of rows.
-
Union
-
Intersect
-
Minus
-
None of above
D
Correct answer
Explanation
Set operations UNION, INTERSECT, and MINUS (or EXCEPT) all have equal precedence in SQL. They are evaluated left to right when chained together. None of them has higher priority than the others, making 'None of above' the correct answer.