পরীক্ষা আর্কাইভ

৪৯তম বিসিএস ⎯ কম্পিউটার সায়েন্স (CSE) [৯৭১]

পরীক্ষা৪৯তম বিসিএস ⎯ কম্পিউটার সায়েন্স (CSE) [৯৭১]তারিখতারিখ অনির্ধারিতসময়30 minutes
মোট প্রশ্ন৫০
সিলেবাস
Exam 5 Tree structures: binary trees, BST; Graphs: representation, traversal; Sorting: merge, radix, quick, heap. [Source: Class–3 and relevant books]
ঘনত্ব
উত্তর
উত্তরিতবর্তমানপুনরায় দেখুনঅসম্পূর্ণ

৪৯তম বিসিএস ⎯ কম্পিউটার সায়েন্স (CSE) [৯৭১]

৪৯তম বিসিএস ⎯ কম্পিউটার সায়েন্স (CSE) [৯৭১] · তারিখ অনির্ধারিত · ৫০ প্রশ্ন

.
What is the maximum number of children that a binary tree node can have?
  1. 0
  2. 1
  3. 2
  4. 3
সঠিক উত্তর:
2
উত্তর
সঠিক উত্তর:
2
ব্যাখ্যা

Answer: C
Explanation: In a binary tree, a node can have atmost 2 nodes (i.e.) 0,1 or 2 left and right child.

.
The following tree is an example for?
  1. Binary tree
  2. Binary search tree
  3.  AVL tree
  4. Heap tree
সঠিক উত্তর:
Binary tree
উত্তর
সঠিক উত্তর:
Binary tree
ব্যাখ্যা

A binary tree is a hierarchical data structure in which each node has at most two children: a left child and a right child. The topmost node is called the root.
A node with no children is called a leaf.
The height of a tree is the number of edges on the longest path from the root to a leaf.

Binary trees can be:
Full Binary Tree: Every node has 0 or 2 children.
Complete Binary Tree: All levels are filled except possibly the last, which is filled from left to right.
Perfect Binary Tree: All internal nodes have 2 children, and all leaves are at the same depth.
Balanced Binary Tree: The height difference between left and right subtrees of every node is at most 1

.
Height of an empty tree is?
  1. 1
  2. 0
  3. - 1
  4. Undefined
সঠিক উত্তর:
- 1
উত্তর
সঠিক উত্তর:
- 1
ব্যাখ্যা

Answer: C

Explanation:
Convention: height of Single node tree = height 0 
Empty tree = height -1.

.
The following tree represents?

  1. Perfect binary tree
  2. Complete binary tree
  3. Binary search tree
  4. Full binary tree
সঠিক উত্তর:
Full binary tree
উত্তর
সঠিক উত্তর:
Full binary tree
ব্যাখ্যা

Full Binary Tree: is a special type of binary tree in which every parent node/internal node has either 2 or 0 children.

Perfect Binary Tree is a type of binary tree in which every internal node has exactly two child nodes and all the leaf nodes are at the same level.
A complete binary tree
is just like a full binary tree, but with two major differences
Every level must be completely filled
All the leaf elements must lean towards the left.
The last leaf element might not have a right sibling i.e. a complete binary tree doesn't have to be a full binary tree.

.
Which is the properties of a Binary Search Tree (BST)?
  1. All values in the left subtree are less than the node’s value.
  2. All values in the right subtree are greater than the node’s value.
  3. Both the left and right subtrees of a node are also BSTs.
  4. all the above
সঠিক উত্তর:
all the above
উত্তর
সঠিক উত্তর:
all the above
ব্যাখ্যা

Properties of a BST:
For every node:
All values in the left subtree are less than the node’s value.
All values in the right subtree are greater than the node’s value.
Both the left and right subtrees of a node are also BSTs.
Example:
        10
       /  \
      5    15
     / \     \
    2   7     20

Left of 10 → {5, 2, 7} are all less than 10.
Right of 10 → {15, 20} are all greater than 10.

.
Each node of a binary tree consists of?
  1. data item & address of left child
  2. address of right child & address of left child
  3. data item , address of left child & address of right child
  4. None of the above
সঠিক উত্তর:
data item , address of left child & address of right child
উত্তর
সঠিক উত্তর:
data item , address of left child & address of right child
ব্যাখ্যা

A binary tree is a tree data structure in which each parent node can have at most two children. Each node of a binary tree consists of three items:
1.data item
2.address of left child
3.address of right child

.
Applications of Binary Tree?
  1. For easy and quick access to data
  2. To implement heap data structure
  3. Syntax tree
  4. All of the above
সঠিক উত্তর:
All of the above
উত্তর
সঠিক উত্তর:
All of the above
ব্যাখ্যা

Binary Tree Applications

1. For easy and quick access to data
2. In router algorithms
3. To implement heap data structure
4. Syntax tree

.
Which of the following tree is the valid binary search tree?
  1. ক) 
  2. খ)
  3. গ)   
  4. ঘ) 
সঠিক উত্তর:
গ)   
উত্তর
সঠিক উত্তর:
গ)   
ব্যাখ্যা

Properties of a BST:
For every node:
All values in the left subtree are less than the node’s value.
All values in the right subtree are greater than the node’s value.
Both the left and right subtrees of a node are also BSTs.
No duplicate value

Example:
        10
       /  \
      5    15
     / \     \
    2   7     20

Left of 10 → {5, 2, 7} are all less than 10.
Right of 10 → {15, 20} are all greater than 10.

.
Which of the following is true for a Binary Search Tree?
  1. Left child ≤ Parent, Right child ≥ Parent
  2. Left child < Parent, Right child > Parent
  3. Inorder traversal of BST is always sorted
  4. Both B and C
সঠিক উত্তর:
Both B and C
উত্তর
সঠিক উত্তর:
Both B and C
ব্যাখ্যা

In BST, left subtree values are strictly less than the node, and right subtree values are greater → (B).
An inorder traversal (Left → Root → Right) always produces a sorted sequence → (C).

Example:
        10
       /  \
      5    15
     / \     \
    2   7     20

Left of 10 → {5, 2, 7} are all less than 10.
Right of 10 → {15, 20} are all greater than 10.

১০.
What is the time complexity of searching in a BST (average and worst case)?
  1. O(1)
  2. O(log n) in average, O(n) in worst
  3. O(n) in all cases
  4. O(log n) in all cases
সঠিক উত্তর:
O(log n) in average, O(n) in worst
উত্তর
সঠিক উত্তর:
O(log n) in average, O(n) in worst
ব্যাখ্যা

Answer: B

In a balanced BST, search complexity is O(log n) (like binary search).
In a skewed BST (all nodes in a line), search degrades to O(n).

১১.
Which traversal of BST gives nodes in sorted order?
  1. Preorder
  2. Postorder
  3. Inorde
  4. Level orde
সঠিক উত্তর:
Inorde
উত্তর
সঠিক উত্তর:
Inorde
ব্যাখ্যা

Answer: C
Inorder traversal (Left → Root → Right) visits nodes in increasing order of keys in a BST.Example:
        10
       /  \
      5    15
     / \     \
    2   7     20
2→ 5→ 7→ 10→ 15→ 20

১২.
Following is the sequence of visiting nodes in a binary tree:
In-Order Traversal: C, D, B, F, E, A, H, I, G
Pre-Order Traversal: A, B, C, D, E, F, G, H, I
Which is the root node?
  1. E
  2. A
  3. G
  4. C
সঠিক উত্তর:
A
উত্তর
সঠিক উত্তর:
A
ব্যাখ্যা

In a pre-order traversal, the very first node visited is always the root. 
 pre-order sequence is: A, B, C, D, E, F, G, H, I
So the root must be A.

১৩.
Following is the sequence of visiting nodes in a binary tree:
In-Order Traversal: C, D, B, F, E, A, H, I, G
Pre-Order Traversal: A, B, C, D, E, F, G, H, I
Which nodes belong to left subtree?
  1. H, I, G
  2. F, G, H, I
  3. A, B, C, D
  4. C, D, B, F, E
সঠিক উত্তর:
C, D, B, F, E
উত্তর
সঠিক উত্তর:
C, D, B, F, E
ব্যাখ্যা

Here,
In-Order Traversal: C, D, B, F, E, A, H, I, G
Pre-Order Traversal: A, B, C, D, E, F, G, H, I

In a pre-order traversal, the very first node visited is always the root. So the root must be A.
In-Order Traversal sequence is Left→ Root→ Right
hence A is
the root then nodes of Left subtree will be→C, D, B, F, E

So answer is D

১৪.
What happens when we insert elements in ascending order into a BST?
  1. Perfectly balanced tree
  2. Skewed tree
  3. Full binary tree
  4. Heap-like structure
সঠিক উত্তর:
Skewed tree
উত্তর
সঠিক উত্তর:
Skewed tree
ব্যাখ্যা

Answer: B
If we insert: 1, 2, 3, 4, 5

A skewed binary tree is a pathological/degenerate tree in which the tree is either dominated by the left nodes or the right nodes. Thus, there are two types of skewed binary tree: left-skewed binary tree and right-skewed binary tree.

১৫.
If we insert 50, 30, 20, 40, 70, 60, 80 into a BST, what is its inorder traversal?
  1. 20, 30, 40, 50, 60, 70, 80
  2. 50, 30, 20, 40, 70, 60, 80
  3. 80, 70, 60, 50, 40, 30, 20
  4. 30, 20, 50, 40, 70, 60, 80
সঠিক উত্তর:
20, 30, 40, 50, 60, 70, 80
উত্তর
সঠিক উত্তর:
20, 30, 40, 50, 60, 70, 80
ব্যাখ্যা

Answer: A 
Explanation: Inorder traversal gives elements in sorted order.
Inorder traversal
(Left → Root → Right) visits nodes in increasing order of keys in a BST.Example:
        10
       /  \
      5    15
     / \     \
    2   7     20
2→ 5→ 7→ 10→ 15→ 20

১৬.
A full binary tree has 7 leaf nodes. What is the minimum height of the tree?
  1. 2
  2. 3
  3. 4
  4. 5
সঠিক উত্তর:
3
উত্তর
সঠিক উত্তর:
3
ব্যাখ্যা

Answer: B ) 3
In a full binary tree, each non-leaf node has exactly 2 children.
A tree with height h can have at most 2h leaf nodes.
For L leaves, the minimum possible height is:
hmin⁡=⌈log⁡2(L)⌉
Here, L=7 then hmin⁡=⌈log⁡2(7)⌉=2.807=3
So, the tree must have height = 3 (i.e., 4 levels including the root ,Level=h+1).

১৭.
In a BST, searching for the maximum element requires visiting:
  1. Leftmost path
  2. Rightmost path
  3. Root only
  4. All nodes
সঠিক উত্তর:
Rightmost path
উত্তর
সঠিক উত্তর:
Rightmost path
ব্যাখ্যা

Answer: B 
Explanation: Max element is always at the rightmost leaf in a BST.

১৮.
Which pair of traversals is sufficient to uniquely construct a binary tree?
  1. In-order and Pre-order
  2. In-order and Post-order
  3. Pre-order and Post-order
  4. Level-order and Post-order
সঠিক উত্তর:
In-order and Post-order
উত্তর
সঠিক উত্তর:
In-order and Post-order
ব্যাখ্যা

Answer: A) 

To reconstruct a tree uniquely, we need in-order plus either pre-order or post-order.
Pre-order gives the root first, and in-order divides nodes into left and right subtrees.
In-order + Post-order also works, but in-order + Pre-order is the most common.
Pre-order + Post-order cannot uniquely reconstruct (example: skewed trees).

১৯.
A complete binary tree of height 3 has how many nodes at minimum and maximum?
  1. Min = 4, Max = 15
  2. Min = 8, Max = 15
  3. Min = 8, Max = 16
  4. Min = 7, Max = 16
সঠিক উত্তর:
Min = 8, Max = 15
উত্তর
সঠিক উত্তর:
Min = 8, Max = 15
ব্যাখ্যা

Answer B

A complete binary tree is filled level by level, left to right.
Height = 3 → number of levels =h+1= 3+1= 4.
Maximum nodes in height h = 2h+1−1=24−1=15
Minimum nodes = last level has at least 1 node →2h= 23=8
So, Min = 8, Max = 15.

২০.
Given the sequence: 10, 5, 1, 7, 40, 50
This is most likely the result of which traversal for a Binary Search Tree (BST)?
  1. In-order
  2. Pre-order
  3. Post-order
  4. Level-order
সঠিক উত্তর:
Pre-order
উত্তর
সঠিক উত্তর:
Pre-order
ব্যাখ্যা

Answer: B

In a BST:
In-order traversal → always sorted ascending. ( left→ root → right)
Given sequence is not sorted.
Check pre-order:
Root = 10, then left subtree = {5, 1, 7}, right subtree = {40, 50}.
Sequence fits pre-order pattern (root → left → right).
Post-order traversal (left → right→ root).

২১.
Pre-order: A, B, D, E, C, F.
In-order: D, B, E, A, C, F.
How many leaf nodes are in the tree?
  1. 2
  2. 3
  3. 4
  4. 5
সঠিক উত্তর:
3
উত্তর
সঠিক উত্তর:
3
ব্যাখ্যা

Answer:  B
here, Pre-order: A, B, D, E, C, F  that means Root=A
         In-order: D, B, E, A, C, F that means left sub tree is( D, B, E) and  right sub tree is( C, F)
Construct tree →

 Leaves are D, E, F → 3 leaves (having no child)

২২.
A perfect binary tree with 31 nodes has how many leaf nodes?
  1. 15
  2. 30
  3. 16
  4. 18
সঠিক উত্তর:
16
উত্তর
সঠিক উত্তর:
16
ব্যাখ্যা

Answer: C

A perfect binary tree is a type of binary tree in which every internal node has exactly two child nodes and all the leaf nodes are at the same level. Perfect tree → half the nodes are leaves.
Formula:
Leaves = (n + 1)/2 = (31+1)/2 = 16.

২৩.
Given post-order: D, E, B, F, C, A
what is the pre-order?
  1. A, B, D, E, C, F
  2. A, C, F, B, D, E
  3. B, D, E, C, F, A
  4. A, B, C, D, E, F
সঠিক উত্তর:
A, B, D, E, C, F
উত্তর
সঠিক উত্তর:
A, B, D, E, C, F
ব্যাখ্যা

Answer:  A 

Post-order traversal (left → right→ root ) it ends with root A.
Left subtree (D, E, B), Right subtree (F, C).
Pre-order is (root → left → right) = A, B, D, E, C, F.

২৪.

If we delete 50 (root) from the BST above, which node will replace it?
  1. 40
  2. 70
  3. 60
  4. 80
সঠিক উত্তর:
60
উত্তর
সঠিক উত্তর:
60
ব্যাখ্যা

Answer: C) 60
Deletion of node with 2 children → replace with in-order successor (smallest in right subtree).
Right subtree root = 70, smallest node = 60.

২৫.
Which of the following trees is both complete and full?
  1. Skewed tree
  2. Perfect binary tree
  3. Strict binary tree
  4. AVL tree
সঠিক উত্তর:
Perfect binary tree
উত্তর
সঠিক উত্তর:
Perfect binary tree
ব্যাখ্যা

Answer: B

Perfect binary tree = all internal nodes have 2 children & all leaves are at same level.
Hence both full (every node has 0/2 children) and complete (all levels filled). 

২৬.
What type of tree is a binary heap?
  1. Full Binary Tree
  2. Complete Binary Tree
  3. Perfect Binary Tree
  4. Balanced Binary Tree
সঠিক উত্তর:
Complete Binary Tree
উত্তর
সঠিক উত্তর:
Complete Binary Tree
ব্যাখ্যা

Answer: B

A binary heap is a complete binary tree (all levels filled except possibly the last, filled from left to right).

২৭.
Which of the following is true for a Max-Heap?
  1. Parent < Left child, ≥ Right child
  2. Parent = Children
  3. Parent ≤ Children
  4. Parent ≥ Children
সঠিক উত্তর:
Parent ≥ Children
উত্তর
সঠিক উত্তর:
Parent ≥ Children
ব্যাখ্যা

Answer: D

In Max-Heap, each parent’s value is greater than or equal to its children.
Conversely, Min-Heap → Parent ≤ Children.

২৮.
Which of the following sorting algorithms uses a heap?
  1. Quick Sort
  2. Merge Sort
  3. Heap Sort
  4. Selection Sort
সঠিক উত্তর:
Heap Sort
উত্তর
সঠিক উত্তর:
Heap Sort
ব্যাখ্যা

Answer: C

Heap Sort:
1.Build Max-Heap.
2.Extract max repeatedly.
3. O(n log n).

২৯.
What is the best use case of a heap?
  1. Binary search
  2. Sorting
  3. Graph traversals
  4. Priority Queue
সঠিক উত্তর:
Priority Queue
উত্তর
সঠিক উত্তর:
Priority Queue
ব্যাখ্যা

Answer: C

Heaps are primarily used for priority queues.
Efficient insert O(log n) and extract max/min O(log n).

৩০.
Which heap operation is most useful in Dijkstra’s algorithm?
  1. Insert
  2. Extract-Min
  3. Delete
  4. Merge
সঠিক উত্তর:
Extract-Min
উত্তর
সঠিক উত্তর:
Extract-Min
ব্যাখ্যা

Answer: B

Dijkstra’s Algorithm repeatedly extracts the minimum distance vertex → requires Extract-Min operation from a Min-Heap / Priority Queue.

৩১.
In an array representation of a heap, index of left child of node at i is:
  1. 2i
  2. i/2
  3. i − 1
  4. 2i + 1
সঠিক উত্তর:
2i + 1
উত্তর
সঠিক উত্তর:
2i + 1
ব্যাখ্যা

for a node at index i:(first element at index 0)

Left child is at index 2i + 1
Right child is at index 2i + 2
Parent is at index (i − 1) / 2 (integer division)
Example:
Array = [10, 20, 30, 40, 50] (heap structure)

Root 10 at i = 0

Left child → 2*0 + 1 = 1 → element = 20
Right child → 2*0 + 2 = 2 → element = 30
Node 20 at i = 1

Left child → 2*1 + 1 = 3 → element = 40
Right child → 2*1 + 2 = 4 → element = 50
So, Answer = 2i + 1 → Option D

৩২.
Huffman coding is mainly used in:
  1. Searching
  2. Sorting
  3. Data Compression
  4. Encryption
সঠিক উত্তর:
Data Compression
উত্তর
সঠিক উত্তর:
Data Compression
ব্যাখ্যা

Answer: C

 Huffman coding is an algorithm used for lossless data compression.
It assigns shorter binary codes to more frequent symbols and longer binary codes to less frequent symbols.
This reduces the overall size of data without losing any information.

Huffman coding = lossless data compression.
Used in ZIP files, JPEG, MP3.

৩৩.
Which of the following is not a standard graph representation?
  1. Adjacency Matrix
  2. Adjacency List
  3. Incidence Matrix
  4. Binary Heap
সঠিক উত্তর:
Binary Heap
উত্তর
সঠিক উত্তর:
Binary Heap
ব্যাখ্যা

Answer: D

Explanation:

Graphs are usually stored as Adjacency Matrix, Adjacency List, or Incidence Matrix.
Binary Heap is unrelated (used in priority queues).

৩৪.
A spanning tree of a graph G is:
  1. Subgraph that contains all vertices and is a tree
  2. Subgraph that contains all edges
  3. Graph with minimum degree
  4. Graph with maximum weight
সঠিক উত্তর:
Subgraph that contains all vertices and is a tree
উত্তর
সঠিক উত্তর:
Subgraph that contains all vertices and is a tree
ব্যাখ্যা

Answer: A

A Spanning Tree of a graph is a subgraph that:
1. Includes all the vertices of the graph.
2. Is a tree (i.e., no cycles, connected).
3. Uses the minimum number of edges needed to connect all vertices.
If the original graph has V vertices, then any spanning tree will always have (V − 1) edges.

৩৫.
Which algorithm is used to find a Minimum Spanning Tree (MST)?
  1. Dijkstra’s algorithm
  2. Kruskal’s algorithm
  3. Prim’s algorithm
  4. Both B & C
সঠিক উত্তর:
Both B & C
উত্তর
সঠিক উত্তর:
Both B & C
ব্যাখ্যা

Answer: D

Minimum Spanning Tree (MST):
A spanning tree with the minimum total edge weight (when edges have weights).
Famous algorithms:
Prim’s Algorithm
Kruskal’s (greedy)  Algorithm

৩৬.
Insertion sort has best case time complexity of:
  1. O(n2)
  2. O(nlogn)
  3. O(n)
  4. O(1)
সঠিক উত্তর:
O(n)
উত্তর
সঠিক উত্তর:
O(n)
ব্যাখ্যা

Answer: C
Insertion Sort 
Insertion sort builds the sorted list one element at a time.
For each element, it compares backward with already sorted elements and inserts it in the right place.
 
Why the Best Case is O(n)?
When array is already sorted:
For each element, insertion sort checks just once and sees it’s already in order.
So, only n comparisons (no swaps).
Hence time = linear (O(n)).
 Best Case: O(n)
Worst Case: O(n2)
Average Case: O(n2)

৩৭.
Which sorting algorithm selects the minimum element and puts it in correct place?
  1. Selection Sort
  2. Insertion Sort
  3. Bubble Sort
  4. Merge Sort
সঠিক উত্তর:
Selection Sort
উত্তর
সঠিক উত্তর:
Selection Sort
ব্যাখ্যা

Answer: A
Selection sort Repeatedly select the smallest element from the unsorted portion and put it at the correct position in the sorted portion.
Process:
1. Find the minimum element in the array.
2. Swap it with the element at the beginning.
3. Repeat for the next unsorted part until the whole array is sorted.
That’s why it’s called Selection Sortit selects the minimum (or maximum) each time.

Example: Array = [29, 10, 14, 37, 13]
Pass 1: Smallest = 10, swap with 29 → [10, 29, 14, 37, 13]
Pass 2: Smallest in remaining = 13, swap with 29 → [10, 13, 14, 37, 29]
Pass 3: Smallest in remaining = 14 (already in place).
Pass 4: Smallest in remaining = 29, swap with 37 → [10, 13, 14, 29, 37]

Time Complexity

Best case, worst case, average case: O(n2).

৩৮.
Merge Sort is based on which paradigm?
  1. Greedy
  2. Divide and Conquer
  3. Dynamic Programming
  4. Brute Force
সঠিক উত্তর:
Divide and Conquer
উত্তর
সঠিক উত্তর:
Divide and Conquer
ব্যাখ্যা

Answer: B

Merge Sort → Divide and Conquer: 
Merge Sort is a recursive sorting algorithm.
It works by the Divide and Conquer paradigm.
 
Divide and Conquer Paradigm:
Divide: Split the array into two halves.
Conquer: Recursively sort each half.
Combine: Merge the two sorted halves into one sorted array.

৩৯.
Which sorting algorithm is NOT comparison-based?
  1. Quick Sort
  2. Merge Sort
  3. Radix Sort
  4. Heap Sort
সঠিক উত্তর:
Radix Sort
উত্তর
সঠিক উত্তর:
Radix Sort
ব্যাখ্যা

Answer: C
Radix Sort is a non-comparative sorting algorithm.
It works by sorting numbers digit by digit, starting from the least significant digit (LSD) to the most significant digit (MSD) (or vice versa).
Unlike comparison-based algorithms (Merge, Quick, Heap, etc.), Radix Sort does not compare elements directly.

 How Radix Sort Works (LSD Method)
Let’s say we want to sort:
[170, 45, 75, 90, 802, 24, 2, 66]

Step 1: Sort by least significant digit (1’s place)
→ [170, 90, 802, 2, 24, 45, 75, 66]

Step 2:
Sort by 10’s place
→ [802, 2, 24, 45, 66, 170, 75, 90]

Step 3:
Sort by 100’s place
→ [2, 24, 45, 66, 75, 90, 170, 802]

৪০.
Which algorithm is best when input is almost sorted?
  1. Merge Sort
  2. Quick Sort
  3. Insertion Sort
  4. Radix Sort
সঠিক উত্তর:
Insertion Sort
উত্তর
সঠিক উত্তর:
Insertion Sort
ব্যাখ্যা

Answer: C
Insertion sort works by inserting each element into its correct position in the already “sorted part” of the array.
If the array is already sorted or nearly sorted, each element is already close to where it should be.
That means very few comparisons and shifts are needed.
Best-case time complexity: O(n) → excellent for nearly sorted arrays.

৪১.
Hashing is primarily used for:
  1. Sorting
  2. Searching
  3. Compression
  4. Encryption
সঠিক উত্তর:
Searching
উত্তর
সঠিক উত্তর:
Searching
ব্যাখ্যা

Answer: B
Hashing is used for fast searching in O(1) average time.

৪২.
Hash table stores data in:
  1. Arrays
  2. Linked lists
  3. Trees
  4. Both A and B
সঠিক উত্তর:
Both A and B
উত্তর
সঠিক উত্তর:
Both A and B
ব্যাখ্যা

Answer: D
Hash tables use arrays for direct access, but chaining with linked lists for collisions.

৪৩.
What is a collision in hashing?
  1. Same key maps to same index
  2. Different keys map to same index
  3. Two arrays overlap
  4. None
সঠিক উত্তর:
Different keys map to same index
উত্তর
সঠিক উত্তর:
Different keys map to same index
ব্যাখ্যা

Answer: B

Collision: When two keys hash to the same location.

৪৪.
Double hashing reduces:
  1. Primary clustering
  2. Secondary clustering
  3. Both A & B
  4. None
সঠিক উত্তর:
Secondary clustering
উত্তর
সঠিক উত্তর:
Secondary clustering
ব্যাখ্যা

Answer: B

Double hashing avoids secondary clustering (keys with same initial position).

৪৫.
If a heap has 127 nodes, how many leaf nodes are there?
  1. 63
  2. 31
  3. 64
  4. 32
সঠিক উত্তর:
64
উত্তর
সঠিক উত্তর:
64
ব্যাখ্যা

Answer: B

৪৬.
The Huffman coding for characters with equal frequencies results in:
  1. Balanced binary tree
  2. Skewed binary tree
  3. Star-shaped tree
  4. None
সঠিক উত্তর:
Balanced binary tree
উত্তর
সঠিক উত্তর:
Balanced binary tree
ব্যাখ্যা

Huffman Coding
Huffman coding builds an optimal prefix-free binary tree based on character frequencies.
Process:

1.Pick two lowest-frequency nodes.
2.Merge them into a new node (sum of frequencies).
3.Repeat until only one root remains.
 
Step 2: What if all frequencies are equal
Suppose we have characters {A, B, C, D} with equal frequency (say frequency = 5 each).
Huffman algorithm doesn’t “favor” any one character.
It will combine them in pairs evenly, so the resulting tree is balanced.

৪৭.
If a graph has n vertices and (n - 1)(n - 2)/2 edges, it is:
  1. Tree
  2. Complete Graph minus a star
  3. Connected Graph
  4. Complete Graph
সঠিক উত্তর:
Connected Graph
উত্তর
সঠিক উত্তর:
Connected Graph
ব্যাখ্যা

Answer: C 
A complete graph is definitely connected.
Removing up to n − 2 edges can still leave it connected.
Here we remove exactly n − 1 edges, so we need to check connectivity. Even after removing n−1n-1n−1 edges, the graph is still connected (not necessarily complete, not necessarily a tree).

৪৮.
Which algorithm is not greedy?
  1. Kruskal’s
  2. Prim’s
  3. Dijkstra’s
  4. Floyd-Warshall
সঠিক উত্তর:
Floyd-Warshall
উত্তর
সঠিক উত্তর:
Floyd-Warshall
ব্যাখ্যা

Answer: D

Kruskal’s → Greedy 
Prim’s → Greedy 
Dijkstra’s → Greedy 
Floyd–WarshallDynamic Programming (NOT Greedy).

৪৯.
Which algorithm is better for external sorting?
  1. Merge Sort
  2. Quick Sort
  3. Insertion Sort
  4. Heap Sort
সঠিক উত্তর:
Merge Sort
উত্তর
সঠিক উত্তর:
Merge Sort
ব্যাখ্যা

External Sorting:
External sorting is used when the data is too large to fit into main memory (RAM) and must be sorted using secondary storage (like disk/SSD).
Example: Sorting terabytes of data (like database queries, search engine indexing).
External sorting must minimize disk I/O operations (since disk access is slow compared to RAM).
 
Data can be divided into chunks that fit into memory.
Each chunk is sorted internally (using normal sort).
Sorted chunks are merged efficiently using multi-way merging.
Merge operation is sequential → very efficient for disk access.
This method is called External Merge Sort.

৫০.
Topological sorting is possible only in:
  1. Directed Cyclic Graph
  2. Directed Acyclic Graph (DAG)
  3. Undirected Graph
  4. Weighted Graph
সঠিক উত্তর:
Directed Acyclic Graph (DAG)
উত্তর
সঠিক উত্তর:
Directed Acyclic Graph (DAG)
ব্যাখ্যা

Answer B
Topological Sorting

Topological Sort is an ordering of vertices in a directed graph such that for every directed edge u→vu \to vu→v, u comes before v in the ordering.
Example use case:

Task scheduling (where some tasks must be done before others).
Step 2: Conditions for Topological Sorting
It works only on a Directed Acyclic Graph (DAG) because:

Directed: The order matters (must respect edge direction).
Acyclic: If there’s a cycle, no valid ordering exists.

Example: In a cycle A → B → C → A, who comes first? Impossible.