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
B
Correct answer
Explanation
DES (Data Encryption Standard) has two primary versions: the original DES and Triple DES (3DES). Triple DES was developed to address DES's vulnerability by applying the cipher three times with different keys, effectively strengthening the encryption.
-
- Use of an index
-
- Lack of duplicates
-
- Use of non-unique keys
-
- Use of unique keys
-
a. arr.length
-
b. arr.length - 1
-
c. arr.size
-
d. arr.size - 1
-
e. arr.length()
A
Correct answer
Explanation
In Java, 'length' is a public final field of an array object that stores the number of elements. Unlike Strings (which use length()) or Collections (which use size()), arrays use the '.length' property.
-
Push and unshift
-
Push and shift
-
Pop and push
-
Shift and unshift
C
Correct answer
Explanation
The delete() function in Perl removes a key-value pair from a hash. There is no built-in 'unhash' or 'rub' function in Perl, and 'remove' is not a standard Perl function for hash operations.
-
Sorter
-
Connected Lookup
-
Expression
-
Unconnected Lookup
A
Correct answer
Explanation
Active transformations change the number of rows passing through them. The Sorter transformation is active because it changes the row order. In contrast, Expression transformations are passive (same number of input and output rows), and Lookup transformations can be active or passive depending on whether they're connected or unconnected.
-
Pipeline parallelism
-
Costly in terms of space and time
-
Removes duplicates on the key specified
-
None of the above
B
Correct answer
Explanation
Sorting is a resource-intensive operation in data processing (such as Ab Initio). It is costly in terms of temporary disk space and CPU time because it requires comparing and reorganizing all records.
-
B-tree index used for table having completely unique colum
-
REVERSE key index used for oracle parallel serve
-
BIT MAP index is used for low cardinality
-
None of these
A,B,C
Correct answer
Explanation
B-tree indexes are ideal for unique columns, reverse key indexes are designed to avoid contention in Oracle Parallel Server (RAC) environments, and bitmap indexes are highly efficient for columns with low cardinality.
-
multidimensional arrays are allowed. The maximum number of dimensions is 15.
-
the elements in an array can only be of the numeric datatype
-
a reference towards an element in an array is done by means of a subscript. The first occurrence of an element in an array has subscript 0.
-
arrays are used to read in DB2 tables
A
Correct answer
Explanation
PL I permits arrays with up to 15 dimensions and elements can be any data type not just numeric. Array subscripts start at 1 by default, not 0, and arrays are memory structures not directly tied to DB2.
-
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
Statement A correctly distinguishes subscript (array occurrence number) from index (byte displacement). Statement B is true - index manipulation requires PERFORM VARYING, SEARCH, or SET statements. Statement C is true - SEARCH/SEARCH ALL require an indexed table. Since A, B, C are all true, 'None of the above' (D) is the correct false statement.
-
LinkedHashMap
-
LinkedHashSet
-
TreeSet
-
HashMap
-
HashSet
-
Hashtable
A,D,F
Correct answer
Explanation
The question asks for classes that store key/value pairs, replace old entries on duplicates, and offer constant-time performance. LinkedHashMap, HashMap, and Hashtable implement the Map interface (storing key/value pairs) and provide constant-time performance. LinkedHashSet, TreeSet, and HashSet are Set implementations, not Maps.
-
ArrayList
-
LinkedHashMap
-
LinkedHashSet
-
LinkedList
-
TreeMap
-
Vector
D
Correct answer
Explanation
A FIFO queue requires efficient add-at-end and remove-from-front operations. LinkedList provides O(1) for both operations. ArrayList requires O(n) for front removal. LinkedHashMap/LinkedHashSet/TreeMap don't provide queue semantics. Vector has same issues as ArrayList. Option D (LinkedList) is optimal.
-
AVG
-
COUNT
-
MAX
-
STDDEV
-
LENGTH
-
All the above.
A,B,C,D
Correct answer
Explanation
SQL GROUP functions (also called aggregate functions) perform calculations on sets of rows and return a single result. AVG, COUNT, MAX, and STDDEV are all GROUP functions that compute statistics across multiple rows. LENGTH, however, is a single-row function that operates on individual string values, not groups. The option 'All the above' is incorrect because it includes LENGTH which doesn't belong to GROUP functions.
-
Merge sort
-
Heap sort
-
Counting sort
-
Bubble sort
C
Correct answer
Explanation
With infinite memory, Counting sort achieves O(n + k) time complexity where k is the range of values. Since we have infinite memory and are sorting natural numbers, Counting sort is optimal. Comparison sorts like Merge sort and Heap sort are O(n log n), while Bubble sort is O(n^2).
D
Correct answer
Explanation
Merge sort consistently performs at O(n log n) time complexity across all cases - best, average, and worst. This is because it always divides the array in half (log n levels) and merges n elements at each level. The n log n complexity is its fundamental characteristic.