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

Multiple choice technology architecture
  1. int [] myList = {"1", "2", "3"};

  2. int [] myList = (5, 8, 2);

  3. int myList [] [] = {4,9,7,0};

  4. int myList [] = {4, 3, 7};

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology architecture
  1. Collection

  2. List

  3. Set

  4. Map

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology architecture
  1. Var x = new Array(50);

  2. Var x = new Array[50];

  3. Var x = Array(50);

  4. Var x = Array[50];

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology architecture
  1. Collection

  2. List

  3. Set

  4. Map

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. RANGE

  2. INTERVAL

  3. LIST

  4. HASH

  5. VIRTUAL

  6. REFERENCE

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology testing
  1. Redim Retain arr(s)

  2. Redim Preserve arr(s)

  3. Redim Persist arr(s)

  4. Redim CarryForward arr(s)

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology testing
  1. 2

  2. 1

  3. 3

  4. No index is required for referencing an element in a 2D array. Index is applicable only for 1D arrays.

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology testing
  1. collection_obj.element(0)

  2. collection_obj.Item(0)

  3. collection_obj.node(0)

  4. No such property

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology
  1. Sort merge

  2. Ordered

  3. Stable sort

  4. none of the above

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology packaged enterprise solutions
  1. Spin-Off

  2. Sub-Flow

  3. Swim Lane

  4. Split-forEach

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology packaged enterprise solutions
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology
  1. Entire

  2. Round Robin

  3. Hash

  4. Random

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology
  1. Normal

  2. Sparse

  3. Both

  4. None of the Above

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology
  1. unique sort

  2. stable sort

  3. bubble sort

  4. sync sort

Reveal answer Fill a bubble to check yourself
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.