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 programming languages
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

In Ruby, the index method (also called find_index) returns the position of the first occurrence of the specified element in the array. For days.index("Saturday"), this would return 5 (zero-indexed) or 6 (one-indexed position), which is the correct way to find an element's index.

Multiple choice technology programming languages
  1. A list of hashes which contains a list

  2. A hash of hashes which contains a list

  3. A list of list which contains another list

  4. A list of arrays and hashes containing lists

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Without seeing the actual structure code, based on the correct answer being 'A list of hashes which contains a list', this describes a Perl data structure where you have an outer array (list), each element is a hashref, and each hash contains a key whose value is an arrayref (list). This is common in Perl for representing structured data like database query results or nested configurations.

Multiple choice technology mainframe
  1. Binary Search

  2. Sequential Search

  3. Both a and b

  4. None

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The correct answer is A (Binary Search). When the number of records is large and the input is already sorted, binary search is the most efficient with O(log n) time complexity. Sequential search has O(n) complexity and becomes very slow for large datasets. Binary search repeatedly divides the search interval in half, making it exponentially faster than linear search for sorted data.

Multiple choice technology mainframe
  1. Using Index to access

  2. Using subscript to access

  3. Both a and b

  4. None of the above

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The correct answer is A (Using Index to access). In COBOL and similar languages, accessing array elements using an index is more efficient than using subscripts. Indexes use binary addressing and direct memory access, while subscripts may require additional calculations or conversions. For performance-critical code involving repeated array access, index-based access is the preferred method.

Multiple choice technology
  1. Merge Sort

  2. Bubble Sort

  3. Selection Sort

  4. Quick Sort

Reveal answer Fill a bubble to check yourself
A,D Correct answer
Explanation

Divide and conquer algorithms recursively break problems into smaller subproblems, solve them independently, and combine results. Merge Sort divides array into halves then merges. Quick Sort partitions around a pivot and recursively sorts partitions.

Multiple choice technology
  1. Quick sort partition algorithm is not in-place.

  2. Radix sort is stable.

  3. In merge sort, maximum complexity is involved in Merge sub-procedure.

  4. In quick sort, after recursive calls to partition algorithms, merging is not needed.

Reveal answer Fill a bubble to check yourself
A Correct answer
Multiple choice technology programming languages
  1. the outermost loop

  2. the innermost loop

  3. all loops are executed the same number of times

  4. cannot be determined without knowing the size of the loops

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In nested loops, the innermost loop executes the most times because it completes all its iterations for each iteration of every outer loop. For example, in loops with 3, 4, and 5 iterations, the innermost runs 3×4×5=60 times.

Multiple choice technology databases
    1. Bit map indexes are used on low-cardinality columns(having low distinct values) 2.B-tree indexes are most effective for high-cardinality data(only for unique columns)
  1. B-tree indexes cannot be used in environments typically have large amounts of data and ad hoc queries

  2. bitmap indexes can be created on partitioned tables

  3. All of the above

Reveal answer Fill a bubble to check yourself
D Correct answer