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
-
(1, 5, 10)
-
(1, 10, 5)
-
(10, 5, 1)
-
(5, 10, 1)
B
Correct answer
Explanation
Perl's sort function defaults to lexicographic (string) comparison, not numeric. The strings '10', '5', '1' sort as '1' < '10' < '5' because '1' < '5' alphabetically. So @b becomes (1, 10, 5). Option A is incorrect because it assumes numeric sorting.
-
Columns specified in condition
-
Columns specified other than the condition
-
Primary key
-
Foreign key
A
Correct answer
Explanation
In Informatica Lookup transformations, the columns used in the lookup condition are cached in the index cache for fast searching. Other columns go to the data cache. This optimization improves lookup performance by indexing on the join/condition columns.
-
HASH
-
MODULUS
-
RANGE
-
RANDOM
C
Correct answer
Explanation
Interval partitioning is an extension of range partitioning where Oracle automatically creates new partitions at specified intervals when data exceeds existing ranges. It inherits the range-based concept of partitioning data along a continuous spectrum (dates or numbers) but automates the partition boundary creation.
-
sort @a
-
sort {$1 <=> $2} @a
-
sort {$a <=> $b} @a
-
sort {$_[0] <=> $_[1]} @a
C
Correct answer
Explanation
Perl uses the spaceship operator <=> inside a block to perform numerical comparisons for sorting, using the special package variables $a and $b. The default sort function performs ASCII-alphabetical sorting, while using $1 and $2 or $_[0] and $_[1] inside the sort block is syntactically incorrect.
B
Correct answer
Explanation
Pivot tables are a powerful feature available in spreadsheet applications like Excel. They can definitely be created to summarize and analyze data. The statement 'cannot be created' is false.
-
set
-
ConcurrentSkipListSet
-
Hashmap
-
Queue
B
Correct answer
Explanation
SortedSet is an interface in Java. ConcurrentSkipListSet is a concrete class that implements the SortedSet interface, providing a thread-safe sorted set implementation based on a skip list data structure. HashMap and Queue are unrelated to SortedSet implementation.
-
Normaliser
-
Joiner
-
Either a or b
-
None of the above
A
Correct answer
Explanation
The Normalizer transformation in Informatica is specifically designed to create multiple occurrences from a single input row. It denormalizes data by expanding columns into multiple rows, which is exactly what the question describes. Joiner transformations are for combining data from different sources, not for creating multiple occurrences.
-
Sorted input option
-
Using the table with more rows as master
-
Both a and b
-
Either a or b
A
Correct answer
Explanation
The 'Sorted input' option in a Joiner transformation significantly improves performance because it allows Informatica to use a more efficient merge join operation instead of a nested loop join. The smaller table should be used as master, so option B is incorrect.
-
a.where style='RANCH' or 'SPLIT' or 'TWOSTORY';
-
a.where style in 'RANCH' or 'SPLIT' or 'TWOSTORY';
-
a.where style in (RANCH, SPLIT, TWOSTORY);
-
a.where style in ('RANCH','SPLIT','TWOSTORY');
D
Correct answer
Explanation
In SAS, the IN operator compares a variable to a list of target values. The list of character values must be enclosed in parentheses, separated by commas or spaces, and each string must be quoted individually. Other options either use invalid syntax or omit necessary quotes.
-
O(n2)
-
O(log n)
-
O(nlogn)
-
O(n2 logn)
C
Correct answer
Explanation
The average-case time complexity of Quick Sort is O(n log n), which occurs when the pivot consistently divides the array into reasonably balanced partitions. Distractors like O(n^2) represent the worst-case complexity, while O(log n) is too low and O(n^2 log n) is inefficient.
-
O(n)
-
O(log n)
-
O(n^2)
-
O(n log n)
C
Correct answer
Explanation
Bubble Sort has a time complexity of O(n^2) in both average and worst cases because it uses nested loops - each element may need to be compared with every other element. In the best case (already sorted), it can be O(n) with optimization, but its standard complexity is quadratic. Option A is for linear algorithms, B for logarithmic, and D for efficient sorts like merge sort.
C
Correct answer
Explanation
PHP defines arrays and objects as compound data types because they contain multiple values or properties, unlike scalar types.
-
EquiJoin
-
FullouterJoin
-
LeftOuterJoin
-
RightOuterJoin
C
Correct answer
Explanation
In DataStage, when you configure a join stage without specifying the join type, it defaults to a Left Outer Join. This means all records from the left input link are included, and matching records from the right link are included where available. Equi-join requires exact matches on both sides, Full Outer includes all records from both sides, and Right Outer prioritizes the right input.
-
Binary Tree
-
Hash Table
-
Stack
-
Queue
B
Correct answer
Explanation
Hash tables provide the fastest average-case data retrieval at O(1) time complexity, assuming a good hash function and minimal collisions. Binary trees are O(log n), while stacks and queues are O(n) for searching since you must traverse elements sequentially.
-
Bubble Sort
-
Quick Sort
-
Merge Sort
-
Radix Sort
A
Correct answer
Explanation
For the nearly-sorted array [1,2,3,5,4], Bubble Sort only needs one pass to swap 5 and 4, completing in O(n) time. More complex sorts like Quick Sort have overhead that makes them slower for small, nearly-sorted datasets. This illustrates that 'fastest' depends on initial data state.