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

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

পরীক্ষা৪৯তম বিসিএস ⎯ কম্পিউটার সায়েন্স (CSE) [৯৭১]তারিখতারিখ অনির্ধারিতসময়30 minutes
মোট প্রশ্ন৪৮
সিলেবাস
Exam 6 Asymptotic notations; complexity analysis; Basic algorithms: divide & conquer, greedy, dynamic programming; Graph algorithms: shortest path, spanning trees; Approximation and parallel algorithms [Source: Class–4 and relevant books]
ঘনত্ব
উত্তর
উত্তরিতবর্তমানপুনরায় দেখুনঅসম্পূর্ণ

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

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

.
Which of the following is TRUE about asymptotic notations?
  1. They compare exact execution time
  2. They only apply for small input sizes 
  3. They describe growth rates as n → ∞
  4. They are machine dependent
ব্যাখ্যা

Answer: C

Asymptotic notations are mathematical tools used to describe the running time or space requirement of an algorithm as the input size (n) grows very large (n → ∞).

They focus only on growth rate, i.e., how fast the runtime increases as input size increases.

Asymptotic analysis studies growth as input size approaches infinity.

.
Which of the following is not a reason to use asymptotic notations?
  1.  To estimate algorithm performance for very large inputs 
  2.  To calculate exact runtime in milliseconds 
  3. To decide which algorithm is more efficient
  4.  To analyze worst-case growth of functions
ব্যাখ্যা

Answer: B
Asymptotic analysis does not calculate exact runtime, only growth trends.

Other options are valid uses.

.
Which of the following is the correct definition of Big-O notation?
  1. Lower bound on growth rate
  2. Tight bound on growth rate
  3. Average bound on growth rate
  4. Upper bound on growth rate
ব্যাখ্যা

Answer: D

Big-O provides an asymptotic upper bound (worst-case growth).

Eg: f(n) = 3n2 + 5n + 2 → O(n2).

.
Which of the following best describes O(1)?
  1. Constant time
  2. Linear time
  3. Polynomial time
  4. Logarithmic time
ব্যাখ্যা

Answer: A

O(1) = constant → independent of input size.
Example: accessing an array element.

.
Which of the following is true?
  1. O(2n) < O(n!) < O(n3)
  2. O(n2) < O(n log n) < O(n3)
  3. O(1) < O(log n) < O(n) < O(n2)
  4. O(log n) < O(1) < O(n2)
ব্যাখ্যা

Answer: C
Growth hierarchy: 1 < log n < n < n log n < n² < n³ < 2ⁿ < n!
O(1) → Flat line
log n → Slow rise
n → Straight line
n log n → Slightly faster than linear
n² → Steep curve
2ⁿ → Explodes rapidly
n! → Even faster than exponential

.
Which function dominates as n → ∞?
  1. n log n 
  2. n2
  3. √n
  4. n log2 n
ব্যাখ্যা

 Answer: B
Explanation: n2 grows faster than √n and log variations.

.
Which notation gives the tightest possible bound?
  1. Big-O
  2. Big-Ω
  3. Little- ο
  4. Big-Θ
ব্যাখ্যা

Answer: D
Explanation: Big-Θ provides tight bounds (both upper and lower simultaneously).

(Big-O): Upper bound (worst case).
Ω (Big-Omega): Lower bound (best case).
Θ (Big-Theta): Tight bound.
o (Little-o): Strictly smaller growth.
ω (Little-omega): Strictly larger growth.

.
Which of the following is a classic example of a divide and conquer algorithm?
  1. Dijkstra’s algorithm
  2. Merge Sort
  3. Prim’s algorithm
  4. Bellman-Ford
ব্যাখ্যা

Answer: B
Merge Sort divides the array into halves, sorts recursively, and merges results → classic divide and conquer

.
Which of the following is not a Divide and Conquer algorithm?
  1. Merge Sort
  2. Binary Search
  3. Quick Sort
  4. Bubble Sort
ব্যাখ্যা

Answer: D
A Divide & Conquer (D&C) algorithm does three things:

Divide: Split the problem of size n into smaller subproblems (often 2 halves).
Conquer: Solve each subproblem recursively.
Combine: Merge the sub-results into the full answer.
Merge sort, Binary search and Quick sort algorithm are based on Divide & Conquer

 Bubble sort is iterative (comparison-based), not divide-and-conquer.

১০.
Divide and Conquer method works by:
  1. Dividing a problem into smaller independent subproblems
  2. Solving subproblems iteratively
  3. Combining all results linearly
  4. None of the above
ব্যাখ্যা

Answer: A
Explanation: Divide and Conquer   → Divide → Solve (recursively) → Combine.

১১.
In Quick Sort, the worst-case occurs when:
  1. Pivot divides array equally
  2. Pivot is the middle element
  3. Pivot is always the smallest/largest element
  4. Array is random
ব্যাখ্যা

Answer: C
Explanation: If pivot is smallest/largest → highly unbalanced recursion → O(n²).

Best Case / Average Case: Pivot divides the array almost equally each time.
Example: size n = 16, pivot splits into 8 + 7.

Recurrence: T(n) = 2T(n/2) + Θ(n)  
                          ⇒ Θ(n log n)

Depth of recursion = log n, each level costs Θ(n).
        Total = Θ(n log n).

Worst Case (Pivot = smallest/largest element)

Suppose pivot is always the smallest element:

Left side = 0 elements, Right side = n−1 elements.

Example: Sorting [1, 2, 3, 4, 5] with pivot = smallest.

Recurrence becomes: T(n) = T(n−1) + Θ(n)

Partitioning costs Θ(n). Then we recurse on n−1 elements.

T(n) = T(n−1) + n  
     = T(n−2) + (n−1) + n  
     = …  
     = Θ(1 + 2 + 3 + … + n)  
     = Θ(n²)

১২.
Which sorting algorithm always requires O(n log n) time?
  1. Insertion Sort
  2. Selection Sort
  3. Merge Sort
  4. Quick Sort
ব্যাখ্যা

Answer: C
Merge sort always divides and merges in O(n log n), regardless of input.

Quick Sort : average Θ(n log n) but worst-case Θ(n²) (pivot-dependent).

Selection Sort: always Θ(n²) — no divide step.

Insertion Sort : worst Θ(n²), best O(n) (nearly sorted arrays).

So Merge Sort is the only one of the four that always runs in Θ(n log n).

১৩.
Which is faster in practice for large datasets?
  1. Merge Sort
  2. Bubble Sort
  3. Heap Sort
  4. Quick Sort
ব্যাখ্যা

Answer: D Quick Sort is faster in practice for large database

Average time complexity: Θ(n log n), same as Merge Sort and Heap Sort.

Cache-friendly: Works mostly in-place (good memory locality).

Low constant factors: Less overhead compared to Merge Sort’s extra arrays and Heap Sort’s swaps.
On the other hand
Merge Sort: Guarantees O(n log n), but needs extra space (O(n)) and has more overhead.

Heap Sort: O(n log n) worst-case, but more comparisons and less cache-efficient → slower in practice.

Bubble Sort: Always O(n²), far too slow for large datasets.

১৪.
Dynamic Programming (DP) is mainly used for:
  1. Greedy problems
  2. Problems with overlapping subproblems and optimal substructure
  3. Divide and Conquer problems only
  4. Graph traversal only
ব্যাখ্যা

Answer: B
Dynamic Programming (DP) is effective when the problem has overlapping subproblems (same subproblem appears multiple times) and optimal substructure (solution can be composed from sub-solutions).

১৫.
Which of the following is an example of a Dynamic Programming (DP) problem?
  1. Binary Search
  2. Quick Sort
  3. Merge Sort
  4. Fibonacci Numbers
ব্যাখ্যা

 Answer: D
Fibonacci Numbers is an example of a Dynamic Programming. Fibonacci computation has overlapping subproblems. Memorization or tabulation avoids redundant computations.
Where, Binary search, Quick sort, Merge sort are the example Divide and Conquer approach.

১৬.
Which of the following problems can be solved by DP?
  1. Longest Common Subsequence (LCS)
  2. 0/1 Knapsack Problem
  3. Matrix Chain Multiplication
  4. All of the above
ব্যাখ্যা

Answer: D
Explanation: All these problems have optimal substructure and overlapping subproblems, suitable for DP.

১৭.
What is the main idea behind Dynamic Programming?
  1. Divide problem into unrelated subproblems
  2. Solve each subproblem once and reuse results
  3. Always reduce time complexity to O(1)
  4. Store all possible solutions regardless of need
ব্যাখ্যা

Answer: B
DP is about solving overlapping subproblems once, storing results (memoization or tabulation), and reusing them to avoid recomputation. This reduces exponential problems (like Fibonacci recursion) to polynomial.

১৮.
Which is not a property of DP?
  1. Optimal substructure
  2. Overlapping subproblems
  3. Greedy-choice property
  4. Tabulation/Memoization
ব্যাখ্যা

Answer: C
 Greedy-choice is used in greedy algorithms, not DP.

১৯.
Which of the following is NOT NP-Hard?
  1. Travelling Salesman Problem (TSP)
  2.  0/1 Knapsack Problem 
  3. Graph Coloring
  4. Hamiltonian Cycle
ব্যাখ্যা

Answer: B) 0/1 Knapsack Problem
Explanation: 0/1 Knapsack (decision) is NP-Complete (in NP), not NP-Hard whereas remaining three are NP- hard .

২০.
Which of the following best describes the space complexity of an algorithm?
  1. Number of registers used
  2. Hard disk space
  3. Amount of memory required during execution
  4. Number of CPUs required
ব্যাখ্যা

Answer: C
Explanation: Space complexity = memory needed for input, variables, recursion, etc.

২১.
Which of the following is a property of NP-Complete problems?
  1. Easy to solve and, hard to verify
  2. Hard to solve, easy to verify
  3. Easy to solve and verify
  4. mpossible to verify
ব্যাখ্যা

Answer: B) Hard to solve, easy to verify

P: Easy to solve, easy to verify.
NP-Complete: The hardest problems in NP but easy to verify (both NP + NP-Hard).
NP-Hard: Harder than NP, not always verifiable in polynomial time.



২২.
Identify the approach followed in Floyd Warshall’s algorithm? 
  1. Linear Programming
  2. Gready Techneique
  3. Dynamic Programming
  4. Backtracking
ব্যাখ্যা

Answer - B) The approach followed in Floyd Warshall’s algorithm is dynamic programming.

২৩.
Which of the following best describes the greedy method?
  1. Solve subproblems independently and combine.
  2. Make the locally best choice at each step, hoping it leads to a global optimum.
  3. Try every possible solution and pick the best.
  4. Use backtracking to prune the search space.
ব্যাখ্যা

 Answer: B
Explanation: Greedy algorithms repeatedly make a local optimal choice (a greedy choice) and never reconsider it. They work when local choices lead to a global optimum (via greedy-choice property + optimal substructure).
Option
A is divide & conquer;
C is brute-force;
D is backtracking.

২৪.
Which of the following MST algorithms are greedy algorithms?
  1. Kruskal only
  2. Prim only
  3. Both Kruskal and Prim
  4. Neither
ব্যাখ্যা

 Answer: C
Explanation: Both Kruskal (pick smallest-weight edges that don’t form a cycle) and Prim (grow a tree by adding smallest-weight edge crossing the cut) are greedy. Correctness proofs use cut and cycle properties (exchange arguments). Typical complexities: Kruskal O(E log E), Prim with heap O(E log V).

২৫.
To main measures of the efficiency of an algorithm are?  
  1. Time and space complexity
  2. Data and Space
  3. Processor and Memory
  4. Coplexity and Capacity
ব্যাখ্যা

Answer - A) Time and space complexity are the main measures of the efficiency of an algorithm.

২৬.
Greedy algorithm is not guaranteed to work for:
  1. Activity Selection Problem
  2. Huffman Coding
  3. 0/1 Knapsack Problem
  4. Minimum Spanning Tree
ব্যাখ্যা

Answer: C
Explanation: 0/1 Knapsack requires Dynamic Programming because greedy may fail; fractional Knapsack is solvable greedily.

২৭.
In Huffman coding, how are nodes combined?
  1. Two largest weights
  2. Two smallest weights
  3. Any two weights
  4. Random nodes
ব্যাখ্যা

Answer: B
Explanation: Huffman coding combine two nodes with smallest frequency iteratively → ensures minimal total cost.
example:
| Symbol | Frequency |
| ------ | --------- |
| A      | 5             |
| B      | 9             |
| C      | 12          |
| D      | 13         |
| E      | 16         |
| F      | 45         |

Pick 5 (A) and 9 (B) → combine to 14
Pick 12 (C) and 13 (D) → combine to 25
Pick 14 and 16 (E) → combine to 30
Pick 25 and 30 → combine to 55
Pick 45 (F) and 55 → root = 100
Resulting Huffman tree minimizes total weighted path length.

২৮.
Branch and Bound (B&B) is primarily used to solve:
  1. Greedy problems
  2. Sorting problems
  3. Graph traversal problems
  4. Optimization problems
ব্যাখ্যা

Answer: B
Explanation: Branch and Bound (B&B) is designed for combinatorial optimization problems, like Travelling Salesman, Knapsack, etc.

২৯.
Which search strategy can be used in Branch & Bounch?
  1. Depth-First Search (DFS)
  2. Breadth-First Search (BFS)
  3. Best-First Search (priority based on bound
  4. All of the above
ব্যাখ্যা

Answer: D
Explanation: B&B is flexible. DFS uses less memory, BFS explores level by level, and best-first explores nodes with the best bound first (often faster).

৩০.
What is a potential limitation of Branch & Bounch?
  1. It may still be slow if the bound is not tight
  2. Cannot solve optimization problems
  3. Always uses greedy choices
  4. Does not guarantee optimal solution
ব্যাখ্যা

Answer: A
Explanation: B&B reduces search but may still explore many nodes if the bound is weak (not tight) or the branching factor is large. Proper bound calculation is crucial for efficiency.

৩১.
The Gift Wrapping algorithm (Jarvis March) finds:
  1. Minimum Spanning Tree
  2. Convex Hull
  3. Shortest Path
  4. Voronoi Diagram
ব্যাখ্যা

Answer: B
Explanation: Jarvis March constructs convex hull by wrapping points → O(nh), h = number of hull points

৩২.
Which of the following is true for computational geometry?
  1. Sorting points is not needed
  2. Geometry problems often require O(n3) time
  3. Sweep line technique is commonly used
  4. Brute force is always better
ব্যাখ্যা

Answer: C
Explanation: Sweep line technique is widely used in line intersection, closest pair, and other geometric problems.

৩৩.
What is a graph?
  1. A set of numbers
  2. A collection of vertices and edges connecting some pairs of vertices
  3. A linear list
  4. A tree only
ব্যাখ্যা

 Answer: B
Explanation: A graph ?= (?, ?) consists of vertices (nodes) and edges connecting pairs of vertices. Trees are a special type of graph.

৩৪.
Which of the following represents a connected undirected graph?
  1. Every vertex has a path to every other vertex
  2. Each edge has a direction
  3. No vertex is connected
  4. Only one vertex
ব্যাখ্যা

 Answer: A
Explanation: In a connected undirected graph, there is a path between every pair of vertices.

৩৫.
BFS stands for:
  1. Breadth-First Search
  2. Binary First Search
  3. Backward Flow Search
  4. Base-Final Search
ব্যাখ্যা

Answer: A
BFS explores all vertices at the current level before moving to the next level.

৩৬.
Which of the following correctly describes BFS and DFS difference?
  1. BFS uses stack, DFS uses queue
  2. BFS explores level by level, DFS explores depth first 
  3. BFS is recursive only
  4. DFS finds shortest path in weighted graph
ব্যাখ্যা

Answer: B
Explanation: BFS is level-order, DFS goes deep along a path first.

৩৭.
Which algorithm is used to detect a cycle in a directed graph?
  1. BFS only
  2. DFS with recursion stack
  3. Dijkstra
  4. Prim
ব্যাখ্যা

Answer: B
Explanation: DFS maintains recursion stack; a back edge indicates a cycle.

৩৮.
A spanning tree of a connected graph is:
  1. A tree containing all vertices and minimum edges
  2. A cycle in the graph
  3. A tree containing all vertices and exactly V-1 edges
  4. A tree containing exactly E edges
ব্যাখ্যা

Answer: C
Explanation: A spanning tree connects all vertices without cycles exactly V-1 edges.

৩৯.
Kruskal’s algorithm works by:
  1. Selecting edges in decreasing order of weight
  2. Selecting edges in increasing order of weight without forming cycles
  3. Adding all edges
  4. Selecting vertices in order
ব্যাখ্যা

Answer: B
•    Kruskal = greedy algorithm → pick lightest edgeavoid cyclesbuild MST (Minimum Spanning Tree)

৪০.
Which algorithm is better for dense graphs?
  1. Kruskal's
  2. Prim's
  3. BFS
  4. DFS
ব্যাখ্যা

Answer: B
Explanation: Prim with adjacency matrix → O(V^2), efficient for dense graphs. Kruskal better for sparse graphs

৪১.
A graph can have how many different spanning trees at most?
  1. Only one
  2. At most V-1
  3. Depends on number of edges and connectivity
  4. Exactly E
ব্যাখ্যা

Answer: C
Explanation: Number of spanning trees depends on graph connectivity and edges; multiple MSTs possible if weights allow.

৪২.
Which of the following is true about Minimum Spaning Tree (MST)?
  1. MST contains all edges of the graph
  2. MST contains exactly V edges
  3. MST contains exactly V-1 edges and minimum total weight
  4. MST exists only for directed graphs
ব্যাখ্যা

Answer: C
Explanation: MST
Connects all vertices with V-1 edges (spanning), 
Has minimum possible total edge weight
Forms a tree (no cycles)

৪৩.
Bellman-Ford algorithm can handle
  1. Negative edge weights
  2. Negative cycles
  3. Only positive weights
  4. None of the above
ব্যাখ্যা

Answer: A
Explanation: Bellman-Ford handles negative weights, but not negative cycles for shortest path

৪৪.
What is the Max-Flow Problem?
  1. Finding the shortest path between two vertices
  2. Finding the maximum flow possible from source vertex to sink vertex in a network
  3. Sorting vertices by degree
  4. Counting edges in a graph
ব্যাখ্যা

Answer: B

 Max-Flow computes the largest possible flow from a source vertex to a sink vertex, respecting edge capacities.

৪৫.
Max-Flow Problem applies to:
  1. Sorting numbers
  2. Searching in arrays
  3. Graph coloring
  4. Routing, network bandwidth, scheduling
ব্যাখ্যা

Answer: D
Applications of Max-Flow problem include network design, traffic flow, bandwidth, matching problems, and resource allocation (scheduling)

৪৬.
 What will be the time complexity of the following code?
int value = 0;
for(int i=0;i<n;i++)
    for(int j=0;j<i;j++)
      value += 1;
  1. n
  2. (n + 1)
  3. n(n - 1)/2
  4. n(n + 1)
ব্যাখ্যা

Output: C ) n(n-1)/2
Explanation: First for loop will run for (n) times and another for loop will be run for (n-1) times as the inner loop will only run till the range i which is 1 less than n, 
so overall time will be n(n-1)/2.

৪৭.
Pseudocode is used in algorithm design because:
  1. It is faster than code
  2. It ignores language syntax and focuses on logic
  3. It is compiled directly
  4. It replaces algorithms
ব্যাখ্যা

 Answer: B
Pseudocode is a simplified representation of a program's logic, written in plain English to make it easy to understand. Pseudocode helps design logic without worrying about syntax.

৪৮.
The time complexity of an algorithm depends on:
  1. Input size
  2. Programming language
  3. Compiler speed
  4. Operating system
ব্যাখ্যা

 Answer: A
Complexity is measured as a function of input size (n).