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
  1. 10

  2. 9

  3. 11

  4. 8

  5. 4

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

This is correct. since with insertion and inorder traversal the rightmost key will be referred last. During insertion since 11 comes second last and only 10 comes after that which will be the left key of 11 so inorder traversal will visit 11 key only at the end.

Multiple choice
  1. Treemax(T)

  2. Successor(T, k)

  3. Predecessor(T, k)

  4. Treemin(T)

  5. Root[T]

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

This is the correct answer since when both right and left child node of the node to be deleted is not null, then the predecessor of the current node should be connected to the parent node

Multiple choice
  1. a DO WHILE...LOOP

  2. a FOR...NEXT loop

  3. two nested FOR...NEXT loops

  4. a DO UNTIL...LOOP statement

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

A two-dimensional array has rows and columns, requiring two separate loops to access all elements systematically. The outer loop iterates through rows, while the inner loop iterates through columns. This nested structure ensures every element in the 2D grid is processed exactly once.

Multiple choice
  1. bubble sort

  2. binary search

  3. sequential search

  4. merge sort

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

Binary search works by repeatedly dividing the sorted list in half and examining the middle element. If the middle element is the target, the search ends. Otherwise, the search continues in the half where the target must exist. This makes binary search extremely efficient for large datasets.

Multiple choice
  1. contrasting

  2. first and last

  3. even numbered

  4. adjacent

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

Bubble sort is named because it works by repeatedly stepping through the list, comparing adjacent elements and swapping them if they're in the wrong order. This process causes smaller values to 'bubble up' to the top of the list like bubbles rising in water, hence the algorithm's name.

Multiple choice
  1. It searches an array by starting at the middle and working out in both the directions.

  2. It compares adjacent array elements, exchanging them if they are out of order.

  3. It searches an array from beginning to the end, until the specified element is located.

  4. It combines two sorted arrays into a single sorted array.

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

Sequential search, also called linear search, examines each element in order from the beginning until it finds the target or reaches the end. It's simple but relatively slow for large lists. Unlike binary search, it doesn't require the list to be sorted beforehand.

Multiple choice
  1. bubble sort

  2. shell sort

  3. binary search

  4. sequential search

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

Shell sort improves on bubble sort by comparing elements that are far apart, then gradually reducing the gap between compared elements. This creates independent sublists that are sorted separately. The gap sequence determines how these sublists are formed and is key to the algorithm's efficiency.

Multiple choice
  1. 1/2 the length of the array

  2. 1/2 of the first gap

  3. 1/2 of the third gap

  4. 1/2 of itself

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

Shell sort uses a sequence of diminishing gaps to compare and sort elements. A common gap sequence starts with N/2, then N/4, N/8, and so on. Each successive gap is typically half the previous one, eventually reaching gap=1 which is equivalent to a final bubble sort pass.

Multiple choice
  1. backtracking

  2. greedy

  3. dynamic programing

  4. linear programing

  5. divide and conquer

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

Divide and Conquer is an algorithm design paradigm, based on recursion and is used for the Quicksort in which the original problem is divided in to the sub problems and are solved recursively.