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. internal nodes on extended tree

  2. external nodes on extended tree

  3. vanished on extended tree

  4. None of above

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

When extending a binary tree by adding external nodes for missing children, all original nodes become internal nodes of the extended tree. This is by definition: internal nodes have children (original or null placeholders), while new external nodes are the added leaf placeholders.

Multiple choice technology architecture
  1. ABFCDE

  2. ADBFEC

  3. ABDECF

  4. ABDCEF

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

Given post-order DEBFCA of a binary tree, the root is A (last visited). From preorder ABDECF, A's left subtree is B-D-E and right is F-C. Post-order shows left subtree post-order is D-E-B, meaning B is root of left subtree with D and E as children. This uniquely determines the structure yielding preorder ABDECF.

Multiple choice technology architecture
  1. Values in a node is greater than every value in left sub tree and smaller than right sub tree

  2. Values in a node is greater than every value in children of it

  3. Both of above conditions applies

  4. None of above conditions applies

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

In a min-heap or max-heap, the key property is that each node's value is greater than (max-heap) or less than (min-heap) all values in its subtree. This parent-child relationship must hold down the entire tree, not just comparing with one subtree or sibling.

Multiple choice technology architecture
  1. Stacks

  2. Queues

  3. Deques

  4. Binary search tree

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

A queue is a FIFO (First-In-First-Out) data structure where deletions occur only at the front and insertions only at the rear. This is fundamental to queue behavior - elements are processed in arrival order. Stacks use LIFO, deques allow operations at both ends, and BSTs don't enforce positional insertion/deletion.

Multiple choice technology architecture
  1. Input-restricted deque

  2. Output-restricted deque

  3. Priority queues

  4. None of above

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

An input-restricted deque allows deletions from both ends but restricts insertions to only one end. This is a specialized deque variant - unlike standard deques (full operations at both ends) or output-restricted deques (opposite restriction). Priority queues use different ordering principles entirely.

Multiple choice technology architecture
  1. Deque

  2. Priority

  3. Tree

  4. All of above

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

Trees are the standard data structure for representing hierarchical relationships because each node can have multiple children, forming a parent-child hierarchy. Deques (double-ended queues) are linear structures for adding/removing from both ends, not hierarchies. Priority queues are for ordered access by priority, not hierarchy. Option C is correct.

Multiple choice technology architecture
  1. Complete binary tree

  2. Binary search tree

  3. Extended binary tree

  4. None of above

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

An extended binary tree (also called a full binary tree or proper binary tree) is defined as a binary tree where every node has either 0 or 2 children - never just 1 child. A complete binary tree fills all levels except possibly the last, which must be left-filled. A binary search tree is ordered by key values, not by child count. Option C is correct.

Multiple choice technology architecture
  1. linear arrays

  2. linked lists

  3. both of above

  4. none of above

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

Linear arrays are indexed structures because they allow direct access to any element using its index in constant time O(1). The index is used to calculate the memory address directly. Linked lists are sequential structures that require traversal from the head to access a specific element, making them non-indexed.

Multiple choice technology architecture
  1. The list must be sorted

  2. there should be the direct access to the middle element in any sublist

  3. There must be mechanism to delete and/or insert elements in list

  4. none of above

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

Binary search requires the search space/list to be sorted and allows random access to the middle element to achieve logarithmic time complexity. It does not require a mechanism to insert or delete elements; in fact, binary search is often performed on static arrays.

Multiple choice technology architecture
  1. must use a sorted array

  2. requirement of sorted array is expensive when a lot of insertion and deletions are needed

  3. there must be a mechanism to access middle element directly

  4. binary search algorithm is not efficient when the data elements are more than 1000.

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

Binary search has O(log n) time complexity, which remains efficient even for large datasets. The efficiency depends on the logarithmic growth rate, not on a fixed number like 1000. Options A, B, and C are actual limitations: binary search requires sorted data and direct access to the middle element, which can be expensive to maintain with frequent insertions/deletions.

Multiple choice technology architecture
  1. tables arrays

  2. matrix arrays

  3. both of above

  4. none of above

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

Two-dimensional arrays are commonly referred to as both tables (for tabular data representation) and matrices (especially in mathematical contexts involving rows and columns). Both terms describe the same conceptual structure of data arranged in a grid format with rows and columns.

Multiple choice technology architecture
  1. LOC(Array[5]=Base(Array)+w(5-lower bound), where w is the number of words per memory cell for the array

  2. LOC(Array[5])=Base(Array[5])+(5-lower bound), where w is the number of words per memory cell for the array

  3. LOC(Array[5])=Base(Array[4])+(5-Upper bound), where w is the number of words per memory cell for the array

  4. None of above

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

The address of any array element is calculated as: Base Address + (Index - Lower Bound) × Word Size. For the 5th element, this is LOC(Array[5]) = Base(Array) + w(5 - lower bound), where w represents bytes per memory cell. Options B and C are incorrect because they omit the word size multiplier or use wrong bounds.

Multiple choice technology architecture
  1. Linked lists

  2. Stacks

  3. Queues

  4. Deque

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

A deque (double-ended queue) specifically allows insertion and deletion at both ends. Stacks only allow operations at one end (LIFO), queues restrict insertion to rear and deletion to front (FIFO), and linked lists allow insertion/deletion anywhere but not with the same efficiency at both ends as a deque.