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
-
70 80 100
-
100 80 70
-
100 70 80
-
1 2 3
C
Correct answer
Explanation
By default, Perl's sort function performs a standard ASCII-betical (lexicographical) comparison. When sorting the strings '100', '80', and '70', '100' comes first because its leading character '1' is ASCII-ordered before '7' and '8', yielding 100 70 80.
-
Delete
-
Push
-
Pop
-
Shift
-
Unshift
A
Correct answer
Explanation
The delete function is specifically designed to remove a key-value pair from a hash (associative array). push/pop/shift/unshift are array operations that don't apply to hashes. delete is the correct and idiomatic way to remove hash elements.
-
splice (@array, 0, 1);
-
splice (@array, @array-1, 1);
-
splice (@array, scalar(@array), 0, @sublist);
-
splice (@array, 0, 0, @sublist);
C
Correct answer
Explanation
push appends @sublist to the end of @array. splice(@array, scalar(@array), 0, @sublist) inserts @sublist at position equal to the array's length (the end), without removing any elements (0 elements removed).
A
Correct answer
Explanation
COBOL SORT statement supports sorting on multiple keys using ASCENDING/DESCENDING KEY syntax with multiple field names separated by commas.
-
BALANCED TREE
-
BITMAP
-
FUNCTIONAL
-
BINARY TREE
A
Correct answer
Explanation
Oracle's default and most common indexing system is B-Tree (Balanced Tree) indexing. Bitmap indexing is an optional feature in Oracle used for low-cardinality columns, not the default. Functional indexing exists but is not a separate indexing system - it's just indexing on function results. Binary tree is not a standard Oracle indexing term.
-
length(array)
-
unbound(array)
-
ubound(array)
-
count(array)
C
Correct answer
Explanation
In VBScript (used by QTP), UBound(array) returns the highest index of an array, which equals length minus one for zero-based arrays. LBound returns the lowest index, typically zero.
-
Vector is Not Synchronized, but ArrayList is Synchronized.
-
Vector is faster than ArrayList
-
Vector has default size of 10 but ArrayList has no default size.
-
ArrayList is Thread-Safe, but Vector is not.
-
One or Two AMP operation depends on the base row location
-
Always two AMP operation irrespective of the base row location
-
Many AMP operation
-
All AMP operation
A
Correct answer
Explanation
A Unique Secondary Index typically involves a two-AMP operation: one AMP to access the index subtable (which contains the PI value), then a second AMP to retrieve the base row using that PI value. However, if the index row and base row happen to reside on the same AMP, it becomes a single-AMP operation. The exact number depends on row location.
-
Algorithm
-
Logarithm
-
Boolean Algebra
-
Syntax
A
Correct answer
Explanation
An Algorithm is a step-by-step sequential process that a computer follows to perform computations or solve problems. Logarithm is a mathematical function, Boolean Algebra deals with logical operations, and Syntax refers to language structure rules. Only Algorithm correctly describes a computational procedure.
-
Collections.reverseSort(list, new MyComparator());
-
Collections.sort(list, new MyComparator());
-
Collections.sort(list, new InverseComparator(
-
Collections.sort(list, Collections.reverseOrder(
D
Correct answer
Explanation
Collections.reverseOrder() accepts a Comparator and returns a new Comparator that imposes the reverse ordering. When passed to Collections.sort(), it sorts the list in the opposite order of the original comparator. This is the standard way to reverse sort order in Java.
C
Correct answer
Explanation
The <=> operator (spaceship operator) is Perl's numeric comparison operator, returning -1, 0, or 1. It's the standard way to sort numerically: sort { $a <=> $b } @array. The cmp operator is for string comparison, while < and > are simple comparison operators not typically used directly in sort.
-
unshift
-
delete
-
shift
-
move
C
Correct answer
Explanation
The shift function removes and returns the first element of an array, shortening the array by one. It's commonly used to process array elements sequentially. unshift adds to the beginning, delete removes hash elements, and move is not a built-in Perl function.
-
work on first eleemnt of array
-
work on last element of array
-
works on all elements of array
-
wont work on array
C
Correct answer
Explanation
When chomp is used on an array (@array), it operates on ALL elements, removing trailing newlines from each one. It doesn't just work on first or last element. This is a useful feature for cleaning up multiple lines at once. The option 'wont work on array' is incorrect.
-
INDEXED STANDARD ACCESS METHOD
-
INTERNAL SEQUENCE ACCESS METHOD
-
INDEXED SEQUENTIAL ACCESS METHOD
-
INDEXED SEQUENCE ACCESS METHOD
C
Correct answer
Explanation
ISAM stands for Indexed Sequential Access Method, which is a file organization method that allows both sequential and direct access to records using an index structure.