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
C
Correct answer
Explanation
PHP defines arrays and objects as compound data types because they contain multiple values or properties, unlike scalar types.
-
Inmemory scan
-
Sort and dedup
-
Rollup
-
All of the above
A
Correct answer
Explanation
In-memory deduplication uses a hash set to track seen records, operating in O(n) time with a single pass. Sort-based dedup requires O(n log n) for sorting plus a pass to remove duplicates. Rollup performs aggregation, not duplicate removal. With sufficient memory, in-memory is fastest.
-
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.
B
Correct answer
Explanation
Java arrays are strongly typed - they can only store elements of one declared type. A primitive array like int[] can hold only integers, while an Object[] can hold different types but only those within the same inheritance hierarchy. An array cannot store arbitrary different types like an integer, a string, and a boolean together.
-
Intermediate level
-
Header level
-
Data level
-
Binary level
A
Correct answer
Explanation
SQL Server indexes use a B-tree structure with multiple levels: the root level at the top, intermediate levels that branch between root and leaves, and the leaf level containing actual data or data pointers. 'Intermediate level' is the correct structural term for non-leaf levels between root and leaf.
-
Reference on Stack
-
Reference on Heap
-
Reference on Stack and the Data it points to on Heap
-
None of the Above
C
Correct answer
Explanation
For reference types in C#, the reference variable itself is stored on the stack (holding the memory address), whereas the actual object instance and its data are allocated on the garbage-collected heap.
-
BITMAP
-
B-TREE
-
FUNCTION BASED
-
None
B
Correct answer
Explanation
B-TREE is the default index type in Oracle and most relational databases. When you create an index without specifying the type, B-TREE is used. Bitmap indexes and function-based indexes require explicit specification.
-
Color
-
example
-
No base type
-
Both (A) and (B)
A
Correct answer
Explanation
In the array declaration Color[] example = new Color[20], Color is the base type (component type) of the array. The variable name is example, but the array's base type - the type of elements it stores - is Color. Every array in Java has a base type that specifies what kind of objects it can hold.
-
OrderedDictionary class
-
ListDictionary class
-
HybridDictionary class
-
Hashtable class
C
Correct answer
Explanation
The HybridDictionary class is optimized for both small and large collections by starting as a lightweight ListDictionary when the collection has few items, and automatically switching to a Hashtable as the collection grows. ListDictionary is only fast for small lists, while Hashtable has higher overhead.
-
Using Redim Keyword
-
Using Preserve Keyword
-
Using Reserve Keyword
-
None of the above
B
Correct answer
Explanation
The Preserve keyword in VB.NET is used with ReDim to resize an array while retaining existing values. Without Preserve, ReDim would create a new array and lose all existing data. Options A and C are not valid keywords for this purpose.
-
Using Redim Keyword
-
Using Preserve Keyword
-
Using Reserve Keyword
-
None of the above
B
Correct answer
Explanation
The Preserve keyword in VB.NET is used with ReDim to resize an array while retaining existing values. Without Preserve, ReDim would create a new array and lose all existing data. Options A and C are not valid keywords for this purpose.
B
Correct answer
Explanation
Each execution of the array constructor [1, 2] creates a new, unique array reference. When used as hash keys, these references stringify to distinct strings (like 'ARRAY(0x...)'), resulting in two separate key-value pairs in the hash.
-
a. duplicate rows are sorted based on the case.
-
b. You can configure the Sorter transformation to treat output rows as distinct.
-
c. The Integration Service rejects duplicate rows compared during the sort operation.
-
d.none of the above
B
Correct answer
Explanation
The Sorter transformation can be configured with the 'Distinct' output option to treat output rows as distinct, removing duplicates during the sort operation. When enabled, the Sorter uses the sort key columns to identify and eliminate duplicate rows, passing only unique rows to downstream transformations. This is more efficient than using an Aggregator or Expression transformation after sorting to remove duplicates. The other options are incorrect: duplicates are not rejected, they can be eliminated; there's no case-based duplicate sorting behavior.
-
By calling ReverseSort()
-
By calling SortReverse()
-
By calling Descend()
-
By calling Sort() and then Reverse() methods
D
Correct answer
Explanation
Standard arrays in languages like C# or JavaScript do not have direct methods like ReverseSort or Descend. Sorting in descending order is typically accomplished by sorting in ascending order first and then reversing the array.