Dept. of Immigration & Passport, MoHA
Post: Sub-Assistant Maintenance Engineer
গ্রুপ-কঃ CSE, Exam Date: 13/10/2022 Subject Code: 105, Exam Taker: BPSC
A Max Heap is a complete binary tree where each parent node has a value greater than or equal to its children. The largest value is always at the root of the tree. Max Heaps are used to quickly find or manage the largest value in a group of data.
Properties of a Max Heap:
Binary Tree Structure:
A Max Heap is a complete binary tree. This means all levels are fully filled, except maybe the last one, which is filled from left to right.Heap Property:
Each node’s value is smaller than or equal to its parent’s value. The largest value is at the root of the tree.
Heap Sort Algorithm
HeapSort(arr)
- BuildMaxHeap(arr)
- For i = length(arr) to 2:
- Swap arr[1] with arr[i]
- heap_size[arr] = heap_size[arr] – 1
- MaxHeapify(arr, 1)
- End
BuildMaxHeap(arr)
- heap_size(arr) = length(arr)
- For i = length(arr)/2 to 1:
- MaxHeapify(arr, i)
- End
MaxHeapify(arr, i)
- L = left(i)
- R = right(i)
- If L ≤ heap_size[arr] and arr[L] > arr[i]:
- largest = L
- Else:
- largest = i
- If R ≤ heap_size[arr] and arr[R] > arr[largest]:
- largest = R
- If largest ≠ i:
- Swap arr[i] with arr[largest]
- MaxHeapify(arr, largest)
- End
Main Limitations of Depth First Search (DFS):
Depth First Search (DFS) is a graph traversal algorithm that explores as far as possible along each branch before backtracking.
Limitations of DFS:
- May Not Find Shortest Path: DFS does not guarantee the shortest path in an unweighted graph.
- Infinite Loop in Cyclic Graph: Without proper visited tracking, DFS may enter an infinite loop.
- High Memory in Deep Trees: Recursive DFS may cause stack overflow if the graph/tree is very deep.
- Time Complexity: In worst case, it explores all vertices and edges (O(V + E)).
Solutions to Overcome These Issues:
- Use Visited Array: Keep track of visited nodes to avoid infinite loops.
- Use Breadth First Search (BFS): For shortest path in unweighted graph, BFS is better.
- Use Iterative Deepening DFS (IDDFS): Combines benefits of DFS and BFS to avoid deep recursion problem.
- Limit Depth: Use Depth-Limited Search to control infinite depth.
Exam Point:DFS may not give shortest path and can face infinite loop or stack overflow issues. These can be solved using visited array, BFS, IDDFS, or depth limit techniques.
Depth First Search (DFS)-এর প্রধান সীমাবদ্ধতা:
Depth First Search (DFS) হলো একটি graph traversal algorithm, যা একটি branch ধরে যতদূর সম্ভব এগিয়ে যায় এবং পরে backtrack করে।
DFS-এর সীমাবদ্ধতা:
- Shortest Path নিশ্চিত করে না: Unweighted graph-এ DFS shortest path খুঁজে পায় না।
- Cyclic Graph-এ Infinite Loop: Visited node track না করলে infinite loop হতে পারে।
- Deep Tree-এ Stack Overflow: Recursive DFS বেশি গভীর হলে stack overflow হতে পারে।
- Time Complexity: Worst case-এ সব vertex ও edge explore করতে হয় (O(V + E))।
সমাধানের উপায়:
- Visited Array ব্যবহার: Visited node সংরক্ষণ করে infinite loop প্রতিরোধ করা।
- Breadth First Search (BFS) ব্যবহার: Shortest path পাওয়ার জন্য BFS ব্যবহার করা।
- Iterative Deepening DFS (IDDFS): DFS ও BFS-এর সুবিধা একত্রে ব্যবহার করা।
- Depth Limit নির্ধারণ: Depth-Limited Search ব্যবহার করে গভীরতা নিয়ন্ত্রণ করা।
Exam Point:DFS shortest path দেয় না এবং infinite loop বা stack overflow হতে পারে; visited array, BFS, IDDFS বা depth limit ব্যবহার করে সমস্যা সমাধান করা যায়।
A 4-bit ring counter is designed using flip-flops, where the output of the last flip-flop is fed back to the input of the first flip-flop. The counter operates based on the clock pulses and the overriding input (ORI).
Block Diagram:

Working Principle:
The overriding input (ORI) and the clock signal determine the operation of the ring counter. The ORI is connected to the Pre-set (PR) of the first flip-flop (FF-0) and the Clear (CLR) of the remaining flip-flops (FF-1, FF-2, FF-3). The operation can be summarized as follows:
- When ORI = low, the output of FF-0 is set to 1, while the outputs of FF-1, FF-2, and FF-3 are cleared to 0. This initializes the counter.
- When ORI = high, the negative edge of the clock signal shifts the 1 to the next flip-flop, forming a ring pattern.
- The process repeats, with the 1 circulating through the flip-flops in sequence.
State Table:

Explanation of the State Table:
- When ORI is low, the output of FF-0 is 1, and the other flip-flops are 0. The clock pulse is irrelevant in this state.
- When ORI is high, the 1 shifts to the next flip-flop on the negative edge of the clock pulse.
- The process continues, with the 1 cycling through FF-0, FF-1, FF-2, and FF-3 in sequence.
Operating Modes of NMOS Transistor
An NMOS transistor operates in different regions depending on the applied voltages: VGS (Gate-Source Voltage) and VDS (Drain-Source Voltage). The three main operating regions are:

1. Cutoff Region (OFF State)
- Condition: VGS < Vth
- No conductive channel is formed between Drain and Source.
- The transistor remains OFF.
- Drain Current (ID): Approximately 0.
2. Linear / Ohmic Region
- Condition: VGS > Vth and VDS < (VGS − Vth)
- A conductive channel is formed.
- The transistor behaves like a controlled resistor.
- Drain Current:
ID = k’ (W/L) [(VGS − Vth)VDS − VDS2/2]
where k’ = μnCox, W = channel width, L = channel length.
3. Saturation Region (Active Mode)
- Condition: VGS > Vth and VDS ≥ (VGS − Vth)
- The channel is pinched off near the Drain.
- The transistor acts as a current source.
- Drain Current:
ID = (k’/2) (W/L) (VGS − Vth)2
NMOS Transistor-এর Operating Modes
NMOS transistor বিভিন্ন voltage-এর উপর নির্ভর করে তিনটি অঞ্চলে কাজ করে। প্রধান ভোল্টেজ হলো VGS (Gate-Source Voltage) এবং VDS (Drain-Source Voltage)।

১. Cutoff Region (OFF State)
- শর্ত: VGS < Vth
- Drain ও Source-এর মধ্যে কোনো channel তৈরি হয় না।
- Transistor OFF থাকে।
- Drain Current (ID): প্রায় 0।
২. Linear / Ohmic Region
- শর্ত: VGS > Vth এবং VDS < (VGS − Vth)
- Conductive channel তৈরি হয়।
- Transistor একটি নিয়ন্ত্রিত resistor-এর মতো আচরণ করে।
- Drain Current:
ID = k’ (W/L) [(VGS − Vth)VDS − VDS2/2]
এখানে k’ = μnCox, W = channel width, L = channel length।
৩. Saturation Region (Active Mode)
- শর্ত: VGS > Vth এবং VDS ≥ (VGS − Vth)
- Drain-এর কাছে channel pinch-off হয়।
- Transistor current source-এর মতো কাজ করে।
- Drain Current:
ID = (k’/2) (W/L) (VGS − Vth)2
SDLC (Software Development Life Cycle):
SDLC is a structured process used to develop high-quality software in a systematic way. It includes phases such as planning, analysis, design, implementation, testing, deployment, and maintenance.
Design Phase in SDLC:
The Design phase converts system requirements into a detailed system architecture and technical blueprint that will guide the development team.
Main Activities of the Design Phase:
- System Architecture Design: Define the overall structure of the system (e.g., client-server, layered architecture).
- Database Design: Design tables, relationships, schema, and data flow.
- Interface Design: Design User Interface (UI) and system interfaces (API).
- Module Design: Divide the system into modules and define their responsibilities.
- Data Structure Design: Specify data structures required for processing.
- Security Design: Plan authentication, authorization, and data protection mechanisms.
- Documentation: Prepare design documents such as HLD (High-Level Design) and LLD (Low-Level Design).
SDLC (Software Development Life Cycle):
SDLC হলো একটি কাঠামোবদ্ধ প্রক্রিয়া যার মাধ্যমে ধাপে ধাপে মানসম্মত software তৈরি করা হয়। এতে planning, analysis, design, implementation, testing, deployment এবং maintenance ধাপ অন্তর্ভুক্ত থাকে।
SDLC-এর Design Phase:
Design phase-এ system requirement-এর ভিত্তিতে system-এর কাঠামো ও technical blueprint তৈরি করা হয়, যা development টিমকে নির্দেশনা দেয়।
Design Phase-এর প্রধান কার্যাবলি:
- System Architecture Design: System-এর সামগ্রিক কাঠামো নির্ধারণ (যেমন client-server, layered architecture)।
- Database Design: Table, relationship, schema এবং data flow নির্ধারণ করা।
- Interface Design: User Interface (UI) ও system interface (API) ডিজাইন করা।
- Module Design: System-কে বিভিন্ন module-এ ভাগ করে তাদের দায়িত্ব নির্ধারণ করা।
- Data Structure Design: প্রয়োজনীয় data structure নির্ধারণ করা।
- Security Design: Authentication, authorization এবং data protection পরিকল্পনা করা।
- Documentation: HLD (High-Level Design) ও LLD (Low-Level Design) document প্রস্তুত করা।
Difference between SMTP and IMAP in Email Communication:
| Basis | SMTP | IMAP |
|---|---|---|
| Full Form | Simple Mail Transfer Protocol | Internet Message Access Protocol |
| Purpose | Used to send emails from client to server or between mail servers. | Used to receive and manage emails from the mail server. |
| Function | Handles outgoing mail. | Handles incoming mail. |
| Storage | Does not store emails permanently. | Stores emails on the server. |
| Example Use | Sending an email via Gmail. | Reading emails from Gmail inbox. |
Explanation:
SMTP is responsible for sending emails, while IMAP allows users to access and manage their emails from the server without downloading them permanently.
Email Communication-এ SMTP এবং IMAP-এর পার্থক্য:
| ভিত্তি | SMTP | IMAP |
|---|---|---|
| Full Form | Simple Mail Transfer Protocol | Internet Message Access Protocol |
| Purpose | Email পাঠানোর জন্য ব্যবহৃত হয় (client থেকে server বা server থেকে server)। | Email গ্রহণ ও পরিচালনার জন্য ব্যবহৃত হয়। |
| Function | Outgoing mail পরিচালনা করে। | Incoming mail পরিচালনা করে। |
| Storage | Email স্থায়ীভাবে সংরক্ষণ করে না। | Email server-এ সংরক্ষণ করে। |
| উদাহরণ | Gmail থেকে email পাঠানো। | Gmail inbox থেকে email পড়া। |
ব্যাখ্যা:
SMTP email পাঠানোর জন্য ব্যবহৃত হয়, আর IMAP server-এ সংরক্ষিত email পড়া ও পরিচালনার জন্য ব্যবহৃত হয়।
Deadlock:
Deadlock is a situation in an operating system where two or more processes are waiting indefinitely for resources held by each other, and none of them can proceed.Conditions for Deadlock (Coffman Conditions):
There are four necessary conditions for a deadlock to occur:
1) Mutual Exclusion:
At least one resource must be held in a non-shareable mode (only one process can use it at a time).
2) Hold and Wait:
A process holding at least one resource is waiting to acquire additional resources held by other processes.
3) No Preemption:
Resources cannot be forcibly taken from a process; they must be released voluntarily.
4) Circular Wait:
A circular chain of processes exists where each process is waiting for a resource held by the next process in the chain.
Deadlock:
Deadlock হলো Operating System-এ এমন একটি অবস্থা, যেখানে দুই বা ততোধিক process একে অপরের resource-এর জন্য অনির্দিষ্ট সময় অপেক্ষা করে এবং কেউই এগোতে পারে না।
Deadlock-এর শর্তসমূহ (Coffman Conditions):
Deadlock ঘটার জন্য ৪টি প্রয়োজনীয় শর্ত একসাথে থাকতে হবে:
১) Mutual Exclusion:
কমপক্ষে একটি resource non-shareable হতে হবে, অর্থাৎ এক সময়ে একটি process ব্যবহার করতে পারবে।
২) Hold and Wait:
একটি process একটি resource ধরে রেখে অন্য resource-এর জন্য অপেক্ষা করবে।
৩) No Preemption:
কোনো process-এর কাছ থেকে জোরপূর্বক resource কেড়ে নেওয়া যাবে না।
৪) Circular Wait:
Process-গুলোর মধ্যে একটি চক্র (cycle) তৈরি হবে, যেখানে প্রত্যেকে অন্যের resource-এর জন্য অপেক্ষা করছে।
Purpose of the Keyword “protected” in Object-Oriented Programming:
In Object-Oriented Programming (OOP), the protected access modifier is used to restrict access to class members (variables and methods). A protected member can be accessed within the same class and by subclasses through inheritance, but not from outside the class hierarchy.
Purpose:
- Supports Inheritance
- Provides controlled access
- Enhances data security while allowing reuse
Example (Java):
class Animal { protected String name; protected void display() { System.out.println("Animal name: " + name); } } class Dog extends Animal { void setName(String n) { name = n; } } public class Test { public static void main(String[] args) { Dog d = new Dog(); d.setName("Tommy"); d.display(); } }Explanation:The variable name and method display() are protected. They are accessible in the subclass Dog but not directly from outside unrelated classes.
Object-Oriented Programming-এ “protected” keyword-এর উদ্দেশ্য:
OOP-এ protected একটি access modifier, যা class-এর member (variable ও method)-এর access সীমাবদ্ধ করে। Protected member একই class ও inheritance-এর মাধ্যমে child class থেকে access করা যায়, কিন্তু class hierarchy-এর বাইরে সরাসরি access করা যায় না।
উদ্দেশ্য:
- Inheritance সমর্থন করা
- Controlled access প্রদান করা
- Data security বজায় রেখে reuse নিশ্চিত করা
উদাহরণ (Java):
class Animal { protected String name; protected void display() { System.out.println("Animal name: " + name); } } class Dog extends Animal { void setName(String n) { name = n; } } public class Test { public static void main(String[] args) { Dog d = new Dog(); d.setName("Tommy"); d.display(); } }ব্যাখ্যা:name variable ও display() method protected হওয়ায় child class Dog থেকে access করা যায়, কিন্তু অন্য unrelated class থেকে সরাসরি access করা যায় না।
Exam Point:protected keyword একই class ও তার subclass-কে access দেয়, যা inheritance সমর্থন করে এবং data নিরাপত্তা বজায় রাখে।
#include <stdio.h> // function to count digits int countDigits(int num) { static int count = 0; if (num > 0) { count++; countDigits(num / 10); } else { return count; } } int main() { int number; int count = 0; printf("Enter a positive integer number: "); scanf("%d", &number); count = countDigits(number); printf("Total digits in number %d is: %d\n", number, count); return 0; }
