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
-
int [] myList = {"1", "2", "3"};
-
int [] myList = (5, 8, 2);
-
int myList [] [] = {4,9,7,0};
-
int myList [] = {4, 3, 7};
D
Correct answer
Explanation
Option D shows correct Java array syntax: int myList[] = {4, 3, 7}; - this declares an int array, initializes with values. Option A is wrong because String array literals cannot be assigned to int array. Option B uses wrong syntax (parentheses instead of braces). Option C declares 2D array but provides 1D initialization.
-
Continuous
-
Sequence
-
Sort
-
None
A
Correct answer
Explanation
In the Continuous funneling method, data from input links is processed as it becomes available without maintaining any specific order. This makes the output sequence unpredictable compared to Sequence or Sort methods.
C
Correct answer
Explanation
A Set is designed to store unique elements and automatically prevents duplicates. Unlike Lists, Sets do not allow duplicate values. Maps store key-value pairs rather than single elements. When uniqueness is the requirement and lookup speed is not critical, a Set is the appropriate choice.
-
Var x = new Array(50);
-
Var x = new Array[50];
-
Var x = Array(50);
-
Var x = Array[50];
A
Correct answer
Explanation
In JavaScript, arrays are created using the Array constructor with parentheses: new Array(50). Option B uses square brackets which is incorrect syntax for the constructor. Option C is missing the 'new' keyword. Option D has both errors - missing 'new' and using square brackets. The array literal syntax [50] would also be valid but isn't listed.
D
Correct answer
Explanation
A Map stores key-value pairs and ensures keys are unique - attempting to store a duplicate key replaces the old entry, effectively preventing duplicates. Collection and List allow duplicates, Set prevents duplicates but doesn't offer key-value mapping. Since the requirement is uniqueness and searching isn't a priority, Map is most suitable.
-
RANGE
-
INTERVAL
-
LIST
-
HASH
-
VIRTUAL
-
REFERENCE
A,C,D
Correct answer
Explanation
RANGE partitions data based on value ranges (e.g., dates or numeric ranges). LIST partitions data based on discrete value lists. HASH distributes data uniformly using a hash algorithm. INTERVAL is an extension of RANGE, not a parent type. VIRTUAL and REFERENCE are not partitioning schemes.
-
Redim Retain arr(s)
-
Redim Preserve arr(s)
-
Redim Persist arr(s)
-
Redim CarryForward arr(s)
B
Correct answer
Explanation
In VBScript, when you resize a dynamic array using Redim, the existing values are normally lost. The Preserve keyword retains the existing values when resizing. Redim Retain, Persist, and CarryForward are not valid VBScript keywords for this purpose.
-
2
-
1
-
3
-
No index is required for referencing an element in a 2D array. Index is applicable only for 1D arrays.
A
Correct answer
Explanation
A 2-dimensional array requires exactly 2 indices - one for the row and one for the column. Each index specifies a position along one of the dimensions. Option D is incorrect because 2D arrays definitely need indices; option B (1 index) is for 1D arrays, and option C (3 indices) would be for 3D arrays.
-
collection_obj.element(0)
-
collection_obj.Item(0)
-
collection_obj.node(0)
-
No such property
B
Correct answer
Explanation
In VBScript with XML DOM, the Item property (not element or node) is the indexed property used to retrieve child nodes from a collection. The syntax collection_obj.Item(0) retrieves the first item from the collection (note that in some contexts this may be 0-indexed or 1-indexed depending on the specific collection type). Options A and C use incorrect property names that are not valid DOM collection methods.
-
Sort merge
-
Ordered
-
Stable sort
-
none of the above
A,B
Correct answer
Explanation
Sort Merge collects sorted data from multiple partitions. Ordered collection reads all records from one partition before moving to the next. Both are collection methods. Stable Sort is not a standard DataStage collection method.
-
Spin-Off
-
Sub-Flow
-
Swim Lane
-
Split-forEach
D
Correct answer
Explanation
Split-forEach is the flow shape designed to iterate over elements in an embedded list, spawning a separate flow execution for each item. Spin-Off creates subprocesses but not specifically for list iteration, while Sub-Flow calls another flow and Swim Lane is for organizational grouping.
B
Correct answer
Explanation
This statement is false because backward chaining only calculates values when they are explicitly requested. If a property is rarely accessed, backward chaining performs better than forward chaining, which recalculates values every time an input changes, potentially causing unnecessary overhead.
-
Entire
-
Round Robin
-
Hash
-
Random
B
Correct answer
Explanation
Round Robin partitioning yields the most even distribution by systematically cycling records through each partition (1 to partition A, 2 to B, 3 to C, repeat). This guarantees even distribution regardless of data characteristics. Hash can create skew if key distribution is uneven, Random may cluster, and Entire duplicates all data to every partition.
-
Normal
-
Sparse
-
Both
-
None of the Above
C
Correct answer
Explanation
DataStage supports two types of lookup in parallel jobs: Normal lookup (loads entire reference dataset into memory) and Sparse lookup (queries the database for each key value). Both are valid approaches depending on your data volume and performance requirements.
-
unique sort
-
stable sort
-
bubble sort
-
sync sort
A
Correct answer
Explanation
DataStage supports unique sort, which removes duplicate records based on key columns while maintaining one instance of each unique record. Stable sort (which preserves original order) is not a DataStage option. The sorting functionality focuses on data deduplication and ordering rather than stability.