Computer Knowledge

Data Structures and Algorithms

1,518 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. 2

  2. 3

  3. 4

  4. 6

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

Inserting 10, 1, 3, 5, 15, 12, 16 into a BST creates a tree where 10 is the root, 1 is the left child, 3 is the right child of 1, 5 is the right child of 3, 15 is the right child of 10, 12 is the left child of 15, and 16 is the right child of 15. The longest path from the root (10) to a leaf (5 or 16) has 3 edges (10-1-3-5).

Multiple choice
  1. 9, 10, 15, 22, 23, 25, 27, 29, 40, 50, 60, 95

  2. 9, 10, 15, 22, 40, 50, 60, 95, 23, 25, 27, 29

  3. 29, 15, 9, 10, 25, 22, 23, 27, 40, 60, 50, 95

  4. 95, 50, 60, 40, 27, 23, 22, 25, 10, 9, 15, 29

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

Option (1) is correct.

Multiple choice
  1. the number of leaf nodes in the tree

  2. the number of nodes in the tree

  3. the number of internal nodes in the tree

  4. the height of the tree

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

The function recursively calculates the maximum depth of the tree. For each node, it returns 1 plus the maximum of the heights of its left and right subtrees, which is the definition of tree height.

Multiple choice
  1. By accessing the last element of the list.

  2. By accessing any element from the list.

  3. By traversing the list in left or right direction from node.

  4. None of these

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

When a linked list is connected doubly, i.e doubly linked list in which each node contains the address of next as well as previous node is very efficient other than we transverse the list from any direction of side of any node. 

Multiple choice
  1. tape movement is confined to one direction

  2. it has no finite state control

  3. it has the capability to remember arbitrary long sequences of input symbols

  4. none of these

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

A Turing Machine (TM) has an infinite tape that allows it to read, write, and move in both directions, providing it with memory that is not limited by the number of states. FSMs have a fixed, finite amount of memory determined by their state count.

Multiple choice
  1. 4

  2. 5

  3. 8

  4. 2

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

Quadratic probing uses the sequence (h(k) + i^2) mod m. Starting at 4 with m=8, the sequence is 4, (4+1) mod 8 = 5, (4+4) mod 8 = 0 (or 8 if 1-indexed), (4+9) mod 8 = 5, (4+16) mod 8 = 4. Since the probe sequence repeats, locations like 2, 3, 6, and 7 are never reached.

Multiple choice
  1. evaluate an arithmetic expression in postfix form

  2. implement recursion

  3. convert a given arithmetic expression in infix form to its equivalent postfix form

  4. allocate resources (like CPU) by the operating system

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

Stacks are LIFO structures used for expression evaluation, recursion, and syntax parsing. CPU scheduling typically uses queues (like round-robin) or priority queues, not stacks.

Multiple choice
  1. analysis of modules

  2. top - down design

  3. organizational structure

  4. none of the above

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

HIPO (Hierarchy plus Input-Process-Output) charts are a design tool used to represent the functional hierarchy of a system, supporting a top-down design approach.