প্রITProstutiAssistant Programmer (AP) Log in

অধ্যায় ১

সমাধানকৃত বিগত প্রশ্ন: ২০২৩ ও ২০২৪

3 অংশ · 27 প্রশ্ন

Solved AP Papers — Combined 5 Bank 2023, Bangladesh Bank 2023, Combined 5 Bank 2024 (all BIBM)

BIBM-এর তিনটি Assistant Programmer লিখিত পরীক্ষার সব টেকনিক্যাল প্রশ্নের পূর্ণ মডেল উত্তর এখানে দেওয়া হলো। গণিত, ইংরেজি, অনুবাদ ও Focus Writing-এর সমাধান আলাদা অধ্যায়ে আছে। প্রশ্নগুলো পরীক্ষার্থীদের স্মৃতি থেকে সংকলিত, তাই কিছু জায়গায় ভাষা অসম্পূর্ণ ছিল। সেসব জায়গায় যে ব্যাখ্যা ধরে নেওয়া হয়েছে, তা উত্তরেই স্পষ্ট লেখা আছে।

কীভাবে ব্যবহার করবেন প্রথমে শুধু প্রশ্নের বক্সটি পড়ুন এবং ৬–৮ মিনিটে খাতায় নিজে উত্তর লিখুন। তারপর মডেল উত্তরের সঙ্গে মেলান। Heap, hashing ও LRU-র ধাপের টেবিল এবং কোড হাতে লিখে অনুশীলন করুন।

১.১Combined 5 Bank — Assistant Programmer (০৩.০২.২০২৩)

তথ্যবিবরণ
তারিখ০৩.০২.২০২৩
প্রশ্নকর্তাBIBM
ধরন৮০ MCQ (IT ৭৫ + গণিত ও GK ২৫); লিখিত ২০০ = IT ১৫০ + গণিত ৪টি (২০) + Focus ১০ + অনুবাদ B/E ২০
টপিকHeap, SQL join, UML class diagram, Function Point, array function, TLS, CRC, graph representation, browser security, LRU
প্রশ্ন ১ Combined 5 Bank AP 2023 Show the Max Heap after each of the following operations [a–j]. Also show which value is returned whenever the root is extracted: Insert 5, Insert 6, Insert 8, Extract-Root, Insert 4, Insert 11, Extract-Root, Insert 7, Extract-Root, Extract-Root.
নিয়ম মনে রাখুন Insert: নতুন মান array-এর শেষে বসান। তারপর sift-up করুন, অর্থাৎ parent (index ⌊(i−1)/2⌋) ছোট হলে swap।
Extract-Root: root (সর্বোচ্চ মান) ফেরত দিন। শেষ উপাদানটি root-এ এনে sift-down করুন, অর্থাৎ বড় child-এর সঙ্গে swap (children: 2i+1, 2i+2)।
ধাপঅপারেশনকী ঘটেHeap (array)ফেরত
aInsert 5খালি heap, 5 root হয়[5]—
bInsert 66 শেষে বসে; parent 5 < 6, তাই swap[6, 5]—
cInsert 8index 2-এ বসে; parent 6 < 8, তাই swap[8, 5, 6]—
dExtract-Root8 বের হয়; শেষের 6 root-এ আসে; child 5 < 6, তাই কিছু বদলায় না[6, 5]8
eInsert 4index 2-এ বসে; parent 6 > 4, তাই ঠিক আছে[6, 5, 4]—
fInsert 11index 3-এ বসে; parent 5-এর সঙ্গে swap, তারপর root 6-এর সঙ্গে swap[11, 6, 4, 5]—
gExtract-Root11 বের হয়; 5 root-এ আসে; বড় child 6-এর সঙ্গে swap[6, 5, 4]11
hInsert 7index 3-এ বসে; parent 5-এর সঙ্গে swap, তারপর root 6-এর সঙ্গে swap[7, 6, 4, 5]—
iExtract-Root7 বের হয়; 5 root-এ আসে; বড় child 6-এর সঙ্গে swap[6, 5, 4]7
jExtract-Root6 বের হয়; 4 root-এ আসে; child 5 > 4, তাই swap[5, 4]6
a) Insert 55[5] b) Insert 665[6, 5] c) Insert 8856[8, 5, 6] d) Extract → 865[6, 5] e) Insert 4654[6, 5, 4] f) Insert 1111645[11, 6, 4, 5] g) Extract → 11654[6, 5, 4] h) Insert 77645[7, 6, 4, 5] i) Extract → 7654[6, 5, 4] j) Extract → 654[5, 4]
চিত্র ১.১: প্রতিটি অপারেশনের পর Max Heap (লাল শিরোনাম = Extract, তীরের পরে ফেরত মান)

উত্তর: Extract-Root অপারেশনগুলো ক্রমানুসারে 8, 11, 7, 6 ফেরত দেয়। শেষে heap-এ থাকে [5, 4]।

প্রশ্ন ২ Combined 5 Bank AP 2023 A relational database has five tables: S(sid, A), T(tid, B), U(uid, C), R(sid, tid, D), Q(tid, uid, E). Primary keys are sid, tid, uid, (sid, tid) and (tid, uid) respectively. R implements a many-to-many relationship between S and T, and Q implements a many-to-many relationship between T and U. Write an SQL query that returns all records of the form (sid, uid), where sid is the key of an S-record, uid is the key of a U-record, and the two records are related through R and Q. Use SELECT, not SELECT DISTINCT.

যুক্তি: একটি S-record ও একটি U-record তখনই সম্পর্কিত, যখন একটি সাধারণ T-record (tid) থাকে, যেখানে R-এ (sid, tid) আছে এবং Q-তে (tid, uid) আছে। তাই R ও Q-কে tid-এর ওপর join করতে হবে।

-- সংক্ষিপ্ত রূপ (R.sid ও Q.uid foreign key, তাই S ও U join না করলেও চলে)
SELECT R.sid, Q.uid
FROM   R
JOIN   Q ON R.tid = Q.tid;

-- পূর্ণ রূপ (S ও U-তে সত্যিই record আছে কিনা তাও নিশ্চিত করে)
SELECT S.sid, U.uid
FROM   S
JOIN   R ON S.sid = R.sid
JOIN   Q ON R.tid = Q.tid
JOIN   U ON Q.uid = U.uid;
কেন DISTINCT নয়, আর তার ফল কী একই (sid, uid) জোড়া একাধিক tid-এর মাধ্যমে যুক্ত হলে ফলাফলে একাধিকবার আসবে (যেমন s1–t1–u1 ও s1–t2–u1)। প্রশ্নে DISTINCT নিষেধ, তাই এই পুনরাবৃত্তি গ্রহণযোগ্য। উত্তরে এক লাইনে এটা উল্লেখ করলে পরীক্ষক বুঝবেন আপনি join-এর আচরণ জানেন।
প্রশ্ন ৩ Combined 5 Bank AP 2023 Draw a class diagram for a book: a book is composed of several parts, which are composed of several chapters; chapters are composed of sections. A book has a publisher, publication date and an ISBN; a part has a title and a number; a chapter has a title, a number and an abstract; a section has a title and a number.

"Composed of" মানে Composition (ভরাট diamond ◆)। অংশটি সম্পূর্ণের বাইরে আলাদাভাবে টিকে থাকে না: বই মুছে ফেললে তার part, chapter ও section-ও মুছে যায়। Multiplicity হলো সম্পূর্ণের দিকে 1 এবং অংশের দিকে 1..* ("several")।

BookPartChapterSection - publisher: String- publicationDate: Date- isbn: String - title: String- number: int - title: String- number: int- abstract: String - title: String- number: int 11..*11..*11..* ◆ = Composition (whole–part, lifecycle dependent) · Book ◆→ Part ◆→ Chapter ◆→ Section
চিত্র ১.২: Book–Part–Chapter–Section class diagram (composition)

ব্যাখ্যা লিখুন: (১) চারটি class এবং প্রতিটির attribute; (২) সম্পর্কগুলো composition, কারণ chapter কেবল একটি part-এর ভেতরেই থাকে; (৩) প্রতিটি সম্পর্কের multiplicity 1 → 1..*। চাইলে operation যোগ করতে পারেন, যেমন Book.addPart() বা Chapter.getSections()।

প্রশ্ন ৪(ক) Combined 5 Bank AP 2023 A software project estimates the unadjusted function point (UFP) as 180, the value adjustment factor (VAF) as 0.87, and the performance (productivity) factor as 4. Find the required effort in person-days.
FP = UFP × VAF   |   Effort = FP ÷ Productivity (FP per person-day)

ধাপ ১: FP = 180 × 0.87 = 156.6
ধাপ ২: ধরে নিচ্ছি "performance factor 4" মানে productivity, অর্থাৎ ৪ FP প্রতি person-day।
Effort = 156.6 ÷ 4 = 39.15 ≈ 40 person-days

অনুমান স্পষ্ট লিখুন প্রশ্নে "performance factor"-এর একক দেওয়া নেই। যদি এর অর্থ "প্রতি FP-এ ৪ person-day" হয়, তাহলে Effort = 156.6 × 4 = 626.4 person-days। পরীক্ষার খাতায় এক লাইনে "Assuming productivity = 4 FP/person-day" লিখে প্রথম উত্তরটি দিন। VAF সাধারণত সূত্র থেকে আসে, VAF = 0.65 + 0.01 × ΣFi; এখানে তা সরাসরি দেওয়া আছে।
প্রশ্ন ৪(খ) Combined 5 Bank AP 2023 Write a function to find the smallest value in an array. The array is passed to the function as a parameter.

লজিক: প্রথম উপাদানকে min ধরুন। বাকি উপাদানগুলোর ওপর একবার লুপ চালান; কোনোটি min-এর চেয়ে ছোট হলে min আপডেট করুন। Time O(n), extra space O(1)।

/* C */
#include <stdio.h>

int findMin(int arr[], int n) {
    int min = arr[0];
    for (int i = 1; i < n; i++)
        if (arr[i] < min)
            min = arr[i];
    return min;
}

int main(void) {
    int a[] = {34, -7, 19, 0, 8};
    int n = sizeof(a) / sizeof(a[0]);
    printf("Smallest = %d\n", findMin(a, n));
    return 0;
}
/* Output: Smallest = -7 */
// Java
public class MinFinder {
    static int findMin(int[] arr) {
        if (arr == null || arr.length == 0)
            throw new IllegalArgumentException("empty");
        int min = arr[0];
        for (int i = 1; i < arr.length; i++)
            if (arr[i] < min) min = arr[i];
        return min;
    }

    public static void main(String[] args) {
        int[] a = {34, -7, 19, 0, 8};
        System.out.println("Smallest = " + findMin(a));
    }
}
// Output: Smallest = -7

C-তে array পাঠালে আসলে pointer যায়, তাই size (n) আলাদা parameter হিসেবে পাঠাতে হয়। Java-তে arr.length থেকে size পাওয়া যায়।

প্রশ্ন ৫(ক) Combined 5 Bank AP 2023 Suppose an attacker steals the private key of a website that uses Transport Layer Security (TLS) and remains undetected. What can the attacker do using the private key?

সার্ভারের certificate-এ যে public key আছে, তার জোড়া private key দিয়েই সার্ভার প্রমাণ করে "আমিই আসল সাইট"। এই key চুরি হলে আক্রমণকারী যা করতে পারে:

  1. সার্ভারের ছদ্মবেশ (Impersonation): আসল ও বৈধ certificate-সহ একটি ভুয়া সাইট চালাতে পারে। DNS spoofing, ARP spoofing বা ভুয়া Wi-Fi-এর মাধ্যমে ব্যবহারকারীকে সেখানে নিলে ব্রাউজার কোনো সতর্কবার্তা দেখাবে না।
  2. Active Man-in-the-Middle: ক্লায়েন্ট ও আসল সার্ভারের মাঝে বসে উভয় দিকের TLS সংযোগ নিজেই শেষ (terminate) করতে পারে। এতে password, OTP, কার্ড নম্বর পড়তে পারে, এবং লেনদেনের পরিমাণ বা গন্তব্য অ্যাকাউন্ট বদলে দিতে পারে।
  3. রেকর্ড করা ট্রাফিক ডিক্রিপ্ট করা (passive): সার্ভার RSA key exchange ব্যবহার করলে (TLS 1.2-এর non-forward-secret cipher suite) session key ক্লায়েন্টের পাঠানো premaster secret থেকে আসে, যা ওই public key দিয়ে এনক্রিপ্ট করা। তাই আগে রেকর্ড করা এবং ভবিষ্যতের সব সেশন ডিক্রিপ্ট করা যায়।
    (EC)DHE (Forward Secrecy, TLS 1.3-এ বাধ্যতামূলক) ব্যবহার হলে private key কেবল handshake-এ signing-এর কাজে লাগে। তখন অতীতের রেকর্ড করা ট্রাফিক ডিক্রিপ্ট করা যায় না, তবে active MitM (পয়েন্ট ২) তখনও সম্ভব।
  4. সার্ভারের নামে সই করা: একই key দিয়ে অন্য কিছুতে (যেমন code বা message) সই হয়ে থাকলে আক্রমণকারী সার্ভারের নামে জাল সই তৈরি করতে পারে।
প্রতিরোধ ও প্রতিকারকেন
Certificate অবিলম্বে revoke করা (CRL/OCSP) ও নতুন key pair তৈরি করাচুরি হওয়া key দিয়ে আর বিশ্বাসযোগ্যতা পাওয়া যাবে না
শুধু ECDHE/TLS 1.3 চালু রাখাForward secrecy নিশ্চিত হয়
Private key HSM-এ রাখাKey HSM থেকে বের করা যায় না
Certificate Transparency monitoringভুয়া certificate ধরা পড়ে
কম মেয়াদের certificate, নিয়মিত key rotationচুরি হলেও ক্ষতির সময়সীমা কম থাকে
প্রশ্ন ৫(খ) Combined 5 Bank AP 2023 In cyclic redundancy check (CRC), the generator chosen is 11101010111. What is the probability of detecting a burst error of length 10?

Generator-এ ১১টি বিট আছে, তাই এর degree r = 11 − 1 = 10 (CRC remainder ১০ বিটের)।

Burst length LDetection probability
L ≤ r১০০% (সব ধরা পড়ে)
L = r + 11 − (1/2)r−1
L > r + 11 − (1/2)r

এখানে L = 10 এবং r = 10, তাই L ≤ r। Generator-এর সর্বোচ্চ ও সর্বনিম্ন (x0) বিট দুটিই 1, তাই সব burst error ধরা পড়বে; detection probability = 1 (100%)।

তুলনার জন্য: L = 11 হলে probability = 1 − 1/29 ≈ 0.998; L ≥ 12 হলে 1 − 1/210 ≈ 0.999।

প্রশ্ন ৬ Combined 5 Bank AP 2023 Consider the two standard representations of a directed graph: adjacency list and adjacency matrix. Give one problem that can be solved more efficiently with the adjacency-list representation than with the adjacency-matrix representation, and another problem that can be solved more efficiently with the adjacency matrix than with the adjacency list.
বিষয়Adjacency ListAdjacency Matrix
SpaceO(V + E): sparse graph-এ ভালোO(V²)
u-এর সব neighbour বের করাO(out-degree(u))O(V), পুরো row স্ক্যান করতে হয়
(u, v) edge আছে কিনাO(out-degree(u))O(1)
BFS / DFSO(V + E)O(V²)
In-degree বের করাO(V + E)O(V), একটি column

List-এ দ্রুত: ১০ লক্ষ নোড ও ৫০ লক্ষ edge-এর একটি sparse graph-এ (যেমন ব্যাংক গ্রাহকের লেনদেন নেটওয়ার্ক) BFS/DFS দিয়ে সব reachable নোড বের করা, বা প্রতিটি নোডের out-degree গোনা। List-এ এতে O(V + E) সময় লাগে, matrix-এ O(V²)।
Matrix-এ দ্রুত: "u থেকে v-তে সরাসরি edge আছে কিনা" বারবার জিজ্ঞাসা করা (O(1) lookup), dense graph-এ Floyd–Warshall all-pairs shortest path, অথবা কোনো vertex universal sink কিনা (in-degree V−1, out-degree 0) তা O(V) সময়ে বের করা।

প্রশ্ন ৭(ক) Combined 5 Bank AP 2023 Suppose A and B are two frames in a browser, loaded from different origins. Why is it a reasonable security policy to allow A to navigate B to another origin based only on whether the display area of A contains that of B, i.e., A already controls that area?

এটি ব্রাউজারের frame navigation policy নিয়ে প্রশ্ন। বর্তমান ব্রাউজার Descendant Policy মেনে চলে: একটি frame কেবল তার নিজের ভেতরের (descendant) frame-কে অন্য URL-এ নিতে পারে।

  1. Pixel delegation-এর যুক্তি: B যদি A-এর display area-র ভেতরে থাকে, তাহলে স্ক্রিনের ওই অংশটি A-রই দেওয়া। A চাইলে এমনিতেই ওই জায়গায় নিজের কনটেন্ট দেখাতে, B-কে সরিয়ে দিতে বা ওপরে কিছু বসাতে পারে। তাই B-কে অন্য origin-এ পাঠানোর অনুমতি দিলে A-এর নতুন কোনো ক্ষমতা যোগ হয় না, আর নিরাপত্তাও কমে না।
  2. Same-Origin Policy অক্ষত থাকে: Navigation করলে A, B-এর DOM, cookie বা ডেটা পড়তে পারে না; শুধু B-এর জায়গায় কী লোড হবে তা ঠিক করে। তাই confidentiality ভাঙে না।
  3. উদার নীতির ঝুঁকি: যেকোনো frame যেকোনো frame-কে navigate করতে পারলে (permissive policy) একটি আক্রমণকারী frame অন্য সাইটের ভেতরের login বা payment frame-কে ভুয়া পেজে পাঠিয়ে দিতে পারত (frame hijacking / Guninski attack)। ব্যবহারকারী ঠিকানা দেখে আসল সাইট ভাবত, অথচ তথ্য যেত আক্রমণকারীর কাছে।
  4. তাই সীমারেখা: "যার স্ক্রিন, তার নিয়ন্ত্রণ।" A কেবল নিজের এলাকার ভেতরের frame বদলাতে পারে। পাশের বা ওপরের অন্য origin-এর frame বদলাতে পারে না।
প্রশ্ন ৭(খ) Combined 5 Bank AP 2023 Consider the page reference string 1 2 3 4 2 3 4 1 2 1 1 3 1 4 with three frames. Using LRU, find the number of page faults.

LRU (Least Recently Used) নিয়মে page fault হলে, সবচেয়ে বেশি সময় ধরে ব্যবহার হয়নি এমন page সরানো হয়। F = fault, H = hit।

Ref12342341211314
Frame 111144444444333
Frame 2–2222221111111
Frame 3––333333222224
F/HFFFFHHHFFHHFHF

সরানোর সিদ্ধান্ত:

  • Ref 4-এ সবচেয়ে পুরোনো 1, তাই 1 সরে।
  • Ref 1 (৮ম)-এ ক্রম 2, 3, 4 (২ সবচেয়ে পুরোনো), তাই 2 সরে।
  • Ref 2 (৯ম)-এ ক্রম 3, 4, 1, তাই 3 সরে।
  • Ref 3 (১২তম)-এ ক্রম 4, 2, 1, তাই 4 সরে।
  • Ref 4 (১৪তম)-এ ক্রম 2, 3, 1, তাই 2 সরে।

উত্তর: Page faults = 8, hits = 6; fault rate = 8/14 ≈ 57%।

১.২Bangladesh Bank — Assistant Programmer (০৩.০২.২০২৩)

তথ্যবিবরণ
তারিখ০৩.০২.২০২৩ (১ ঘণ্টা MCQ + ২ ঘণ্টা লিখিত)
প্রশ্নকর্তাBIBM
ধরন৮০ MCQ; লিখিত = ৯টি subjective (১৫০) + গণিত ৪টি (২০) + Focus (১০) + অনুবাদ B/E (২০)
টপিকHashing, graph representation, LCM program, SQL, UML, overriding/hiding, CIA ও E2E encryption, Diffie-Hellman MitM
প্রশ্ন ১ BB AP 2023 Consider a hash table of size 13 with integer keys. The hash function is h(k) = k mod 13. Insert the keys 10, 3, 5, 6, 16, 17, 19 in the given order using linear probing to resolve collisions. Show all the work.
h(k) = k mod 13   |   Linear probing: hi(k) = (h(k) + i) mod 13, i = 0, 1, 2, …
Keyh(k) = k mod 13Probe sequenceFinal slot
101010 খালি10
333 খালি3
555 খালি5
666 খালি6
1633 (3 দিয়ে ভরা) → 4 খালি4
1744 (16) → 5 (5) → 6 (6) → 7 খালি7
1966 (6) → 7 (17) → 8 খালি8
Index0123456789101112
Key–––316561719–10––

মোট collision: 16-এ ১টি, 17-এ ৩টি, 19-এ ২টি, মোট ৬টি। Index 3 থেকে 8 পর্যন্ত একটানা ভরা অংশটি primary clustering-এর উদাহরণ, যা linear probing-এর প্রধান দুর্বলতা। এর প্রতিকার হলো quadratic probing বা double hashing। Load factor α = 7/13 ≈ 0.54।

প্রশ্ন ২ BB AP 2023 Give an adjacency-list representation for a complete binary tree on 7 vertices. Give an equivalent adjacency-matrix representation. Assume that vertices are numbered from 1 to 7 as in a binary heap.

Binary heap-এর মতো নম্বর দিলে vertex i-এর children হয় 2i ও 2i+1, আর parent হয় ⌊i/2⌋। Tree-কে undirected graph ধরা হলো।

1234567
চিত্র ১.৩: ৭ শীর্ষের complete binary tree (heap numbering)

Adjacency List

1 → 2 → 3
2 → 1 → 4 → 5
3 → 1 → 6 → 7
4 → 2
5 → 2
6 → 3
7 → 3

Directed (parent → child) হিসেবে ধরলে: 1→2,3; 2→4,5; 3→6,7; এবং 4–7-এর list খালি।

Adjacency Matrix (symmetric)

1234567
10110000
21001100
31000011
40100000
50100000
60010000
70010000

Edge সংখ্যা = V − 1 = 6। List-এ মোট entry ২ × 6 = 12, matrix-এ cell 7 × 7 = 49, যার মাত্র 12টি 1। Tree sparse, তাই এখানে list বেশি সাশ্রয়ী।

প্রশ্ন ৩ BB AP 2023 Given two integers A and B as input, write a program to compute the LCM of A and B.
LCM(A, B) = |A × B| ÷ GCD(A, B)   |   GCD (Euclid): gcd(a, b) = gcd(b, a mod b), gcd(a, 0) = a

Overflow এড়াতে (a / gcd) * b ক্রমে হিসাব করুন। এতে আগে ভাগ হয়, তারপর গুণ।

/* C */
#include <stdio.h>
#include <stdlib.h>

long long gcd(long long a, long long b) {
    while (b != 0) {
        long long t = a % b;
        a = b;
        b = t;
    }
    return a;
}

int main(void) {
    long long a, b;
    printf("Enter A and B: ");
    scanf("%lld %lld", &a, &b);
    a = llabs(a); b = llabs(b);
    if (a == 0 || b == 0) {
        printf("LCM = 0\n");
        return 0;
    }
    long long lcm = (a / gcd(a, b)) * b;
    printf("LCM = %lld\n", lcm);
    return 0;
}
/* Input: 12 18  ->  LCM = 36 */
// Java
import java.util.Scanner;

public class LCM {
    static long gcd(long a, long b) {
        while (b != 0) {
            long t = a % b;
            a = b;
            b = t;
        }
        return a;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = Math.abs(sc.nextLong());
        long b = Math.abs(sc.nextLong());
        long lcm = (a == 0 || b == 0) ? 0
                 : (a / gcd(a, b)) * b;
        System.out.println("LCM = " + lcm);
    }
}
// Input: 12 18  ->  LCM = 36

Trace (12, 18): gcd(12, 18) → gcd(18, 12) → gcd(12, 6) → gcd(6, 0) = 6; LCM = 12/6 × 18 = 36। Time complexity O(log min(A, B))।

প্রশ্ন ৪ BB AP 2023 Write an SQL query that returns the number of movies that are romantic comedies. Tables: Movies(mid, title, year), People(pid, name), Genres(gid, genre), ActsIn(pid, mid), HasRole(pid, mid, role), HasGenre(gid, mid). In ActsIn and HasRole, pid is a foreign key into People and mid into Movies; in HasGenre, mid is a foreign key into Movies and gid into Genres.

যুক্তি: "Romantic comedy" মানে একই movie-র দুটি genre আছে: Romance এবং Comedy। প্রতিটি genre HasGenre-এ আলাদা সারিতে থাকে, তাই দুটি শর্ত একই সারিতে মেলানো যায় না।

-- পদ্ধতি ১: GROUP BY + HAVING (সবচেয়ে পরিষ্কার)
SELECT COUNT(*) AS romantic_comedy_count
FROM (
    SELECT hg.mid
    FROM   HasGenre hg
    JOIN   Genres g ON g.gid = hg.gid
    WHERE  g.genre IN ('Romance', 'Comedy')
    GROUP  BY hg.mid
    HAVING COUNT(DISTINCT g.genre) = 2
) AS rc;

-- পদ্ধতি ২: দুটি IN subquery
SELECT COUNT(*) AS romantic_comedy_count
FROM   Movies m
WHERE  m.mid IN (SELECT hg.mid FROM HasGenre hg JOIN Genres g ON g.gid = hg.gid
                 WHERE g.genre = 'Romance')
  AND  m.mid IN (SELECT hg.mid FROM HasGenre hg JOIN Genres g ON g.gid = hg.gid
                 WHERE g.genre = 'Comedy');
সাধারণ ভুল WHERE genre = 'Romance' AND genre = 'Comedy' লিখলে সবসময় 0 আসে, কারণ এক সারির genre একসাথে দুটি মান হতে পারে না। আবার OR লিখলে শুধু romance বা শুধু comedy movie-ও গোনা হয়। যদি ডেটাবেসে "Romantic Comedy" নামে একটিমাত্র genre থাকে, তাহলে সহজ WHERE g.genre = 'Romantic Comedy' দিয়েই হবে। উত্তরে এই অনুমানটি উল্লেখ করুন।
প্রশ্ন ৫ BB AP 2023 Draw a class diagram. A token-ring based local-area network (LAN) is a network consisting of nodes, in which network packets are sent around. Every node has a unique name within the network and refers to its next node. Different kinds of nodes exist: workstations are originators of messages; servers and printers are network nodes that can receive messages. Packets contain an originator, a destination and content, and are sent around on a network. A LAN is a circular configuration of nodes.
LAN«abstract»Node PacketWorkstationServerPrinter - topology = ring+ circulate(p: Packet) - name: String {unique}+ forward(p: Packet) - originator: Workstation- destination: Node- content: String + originate(): Packet+ receive(p: Packet)+ receive(p: Packet) 12..* consists of (ring) next1 destination 10..* originator 1originates ▸0..* △ = Generalization (is-a) · ◆ = Composition · → = Association
চিত্র ১.৪: Token-ring LAN-এর class diagram
বাক্যমডেলে কী
"LAN consists of nodes; circular configuration"LAN ◆— Node, composition, multiplicity 1 → 2..*; ring গঠন হয় self-association দিয়ে
"Every node has a unique name and refers to its next node"Node-এ name {unique}; self-association next, multiplicity 1
"Different kinds of nodes"Node একটি abstract superclass; Workstation, Server ও Printer তার subclass (generalization)
"Workstations are originators of messages"Workstation 1 —originates→ 0..* Packet
"Servers and printers can receive messages"Server ও Printer-এ receive(p: Packet) operation
"Packets contain originator, destination and content"Packet-এর attribute বা association: originator (Workstation), destination (Node), content
প্রশ্ন ৬ BB AP 2023 Determine the overloaded methods, the overridden methods and the hidden superclass methods in the following code:
public class A {
    public void m1() {}
    public void m2() {}
    public void m3(int i) {}
    public void m4(String i) {}
}
public class B extends A {
    public static void m1() {}
    public void m2() {}
    public void m3(int i) {}
    public static void m4(String i) {}
}
ধারণাশর্তকখন resolve হয়
Overloadingএকই নাম, ভিন্ন parameter list (একই বা subclass-এ)Compile time
OverridingSubclass-এ একই signature-এর instance method; parent-এর method-ও instanceRuntime (dynamic dispatch)
HidingParent ও child দুজনেরই static method, একই signatureCompile time (reference type দেখে)
MethodA-তেB-তেফল
m1()instancestaticCompile error: "m1() in B cannot override m1() in A; overriding method is static"। Static method দিয়ে instance method লুকানো যায় না।
m2()instanceinstance, একই signatureOverridden
m3(int)instanceinstance, একই signatureOverridden
m4(String)instancestaticCompile error (m1-এর একই কারণে)

উপসংহার: m2 ও m3 overridden। m1 ও m4 compile হবে না, তাই এখানে কোনো hiding ঘটে না। কোনো method-এর parameter list ভিন্ন নয়, তাই কোনো overloading-ও নেই। এছাড়া কোডে দুটি সমস্যা ঠিক করতে হবে: extends a হবে extends A, আর একটি .java ফাইলে দুটি public class থাকতে পারে না, তাই দুটি আলাদা ফাইলে রাখতে হবে।

Hiding ও overloading কখন হতো: A-এর m1 যদি public static void m1() হতো, তাহলে B-এর static m1() সেটিকে hide করত। B-তে যদি public void m3(double d) থাকত, তাহলে সেটি A-এর m3(int)-এর overload হতো।

class A {
    public static void s()   { System.out.println("A.s"); }
    public void m()          { System.out.println("A.m"); }
}
class B extends A {
    public static void s()   { System.out.println("B.s"); }   // hiding
    @Override public void m(){ System.out.println("B.m"); }   // overriding
    public void m(int x)     { System.out.println("B.m(int)"); } // overloading
}
public class Demo {
    public static void main(String[] args) {
        A ref = new B();
        ref.m();   // B.m  : runtime-এ object-এর type (B) দেখে
        ref.s();   // A.s  : compile time-এ reference-এর type (A) দেখে, অর্থাৎ hiding
    }
}
প্রশ্ন ৭ BB AP 2023 A question about the CIA triad: to protect its data, a company decided to add end-to-end encryption. Which layer of the OSI model is suitable for it, considering development time, software maintainability and development cost? Give reasons.

CIA Triad:

  • Confidentiality: অননুমোদিত কেউ তথ্য পড়তে পারবে না।
  • Integrity: তথ্য অননুমোদিতভাবে বদলানো যাবে না।
  • Availability: অনুমোদিত ব্যবহারকারী প্রয়োজনের সময় তথ্য পাবে।

End-to-end encryption (E2EE) মূলত confidentiality ও (MAC বা AEAD ব্যবহার করলে) integrity নিশ্চিত করে।

উত্তর: Application Layer (Layer 7)।

লেয়ারউদাহরণE2E কি?খরচ ও রক্ষণাবেক্ষণ
Network (L3)IPsecনা; host-to-host বা gateway-to-gateway সুরক্ষা দেয়, ব্যবহারকারী-থেকে-ব্যবহারকারী নয়OS ও router কনফিগার করতে হয়; বিশেষজ্ঞ লাগে
Transport (L4)TLSনা; প্রতিটি hop-এ (সার্ভার, proxy, load balancer) ডিক্রিপ্ট হয়, সার্ভার plaintext দেখেসহজ, কিন্তু উদ্দেশ্য পূরণ হয় না
Application (L7)Signal Protocol, PGP, libsodiumহ্যাঁ; কেবল প্রেরক ও প্রাপকের অ্যাপের কাছে key থাকেপ্রস্তুত লাইব্রেরি, নেটওয়ার্ক অবকাঠামো বদলাতে হয় না

কারণ:

  1. Development time: পরীক্ষিত লাইব্রেরি (OpenSSL, libsodium, Bouncy Castle) সরাসরি অ্যাপের কোডে ব্যবহার করা যায়। Kernel বা নেটওয়ার্ক ডিভাইসে হাত দিতে হয় না।
  2. Maintainability: এনক্রিপশন লজিক অ্যাপের ভেতরেই থাকে। নেটওয়ার্ক, ক্লাউড প্রোভাইডার বা ISP বদলালেও কিছু পরিবর্তন করতে হয় না, এবং আপডেট সাধারণ সফটওয়্যার রিলিজের মতো দেওয়া যায়।
  3. Development cost: বিশেষ হার্ডওয়্যার (VPN concentrator) বা প্রতিটি router কনফিগারেশনের খরচ লাগে না।
  4. প্রকৃত end-to-end: একমাত্র এই লেয়ারেই মাঝের সার্ভার, এমনকি কোম্পানির নিজের সার্ভারও, ডেটা পড়তে পারে না। ফলে ডেটা লিক হলেও confidentiality বজায় থাকে।

সীমাবদ্ধতা: প্রতিটি অ্যাপে আলাদাভাবে বাস্তবায়ন করতে হয় এবং key management (key exchange, backup) সাবধানে ডিজাইন করতে হয়। বাস্তবে Application-layer E2EE-র নিচে TLS-ও রাখা হয় (defense in depth)।

প্রশ্ন ৮ BB AP 2023 Describe a man-in-the-middle attack on the Diffie-Hellman key exchange protocol in which the adversary generates two public key pairs for the attack.

মূল দুর্বলতা: সাধারণ Diffie-Hellman-এ authentication নেই। কেউ যাচাই করে না যে প্রাপ্ত public key আসলে অপর পক্ষেরই। প্রকাশ্য মান: prime q ও primitive root α।

আক্রমণের ধাপ (আক্রমণকারী Darth, Stallings-এর বিবরণ অনুযায়ী):

  1. Darth দুটি private key XD1 ও XD2 বেছে নেয় এবং সংশ্লিষ্ট public key হিসাব করে: YD1 = αXD1 mod q, YD2 = αXD2 mod q।
  2. Alice, Bob-কে YA পাঠায়। Darth সেটি আটকে দিয়ে Bob-কে YD1 পাঠায়, এবং নিজে হিসাব করে K2 = YAXD2 mod q।
  3. Bob, YD1 পেয়ে হিসাব করে K1 = YD1XB mod q।
  4. Bob, Alice-কে YB পাঠায়। Darth সেটি আটকে দিয়ে Alice-কে YD2 পাঠায়, এবং হিসাব করে K1 = YBXD1 mod q।
  5. Alice, YD2 পেয়ে হিসাব করে K2 = YD2XA mod q।

ফল: Alice ও Darth একই key K2 পায়, আর Bob ও Darth একই key K1 পায়। Alice ও Bob ভাবে তারা নিজেদের মধ্যে একটি গোপন key ভাগ করেছে। Darth প্রতিটি বার্তা ডিক্রিপ্ট করে পড়তে বা বদলাতে পারে, তারপর আবার এনক্রিপ্ট করে সামনে পাঠায়।

সংখ্যাগত উদাহরণ: q = 23, α = 5 Alice: XA = 6 → YA = 56 mod 23 = 8  |  Bob: XB = 15 → YB = 515 mod 23 = 19
Darth: XD1 = 3 → YD1 = 125 mod 23 = 10  |  XD2 = 7 → YD2 = 57 mod 23 = 17
Alice: K2 = 176 mod 23 = 12  |  Darth: K2 = 87 mod 23 = 12 ✔
Bob: K1 = 1015 mod 23 = 5  |  Darth: K1 = 193 mod 23 = 5 ✔
আক্রমণ না থাকলে Alice ও Bob একই key পেত: 196 mod 23 = 815 mod 23 = 2।
AliceDarthBob X_D1 = 3, X_D2 = 7 → Y_D1 = 10, Y_D2 = 17 ① Y_A = 8 (আটকানো) ② Y_D1 = 10 (Alice সেজে) ③ Y_B = 19 (আটকানো) ④ Y_D2 = 17 (Bob সেজে) K2 = 17^6 mod 23 = 12K2 = 8^7 = 12 · K1 = 19^3 = 5 (mod 23)K1 = 10^15 mod 23 = 5 Alice ↔ Darth ভাগ করে K2, Darth ↔ Bob ভাগ করে K1; Darth দুই দিকের সব বার্তা পড়তে ও বদলাতে পারে
চিত্র ১.৫: দুটি key pair ব্যবহার করে Diffie-Hellman-এর ওপর MitM আক্রমণ

প্রতিরোধ:

  • Public key-কে authenticate করা: digital signature বা certificate-সহ DH (Station-to-Station protocol, TLS-এর signed ECDHE)।
  • বাইরের কোনো চ্যানেলে key fingerprint মিলিয়ে দেখা (যেমন Signal-এর safety number)।
  • Pre-shared key বা PKI ব্যবহার করা।

১.৩Combined 5 Bank (Job ID 10198) — Assistant Programmer (০৯.০২.২০২৪)

তথ্যবিবরণ
ব্যাংকSonali Bank, BKB, Karmasangsthan Bank, ICB প্রমুখ
তারিখ০৯.০২.২০২৪ (১ ঘণ্টা MCQ + ২ ঘণ্টা লিখিত)
প্রশ্নকর্তাBIBM
ধরন৮০ MCQ (IT ৫০ + গণিত ও GK ২০); লিখিত = ১০টি subjective (১৫০) + গণিত ৪টি (২০) + Focus (২০) + Letter (১০)
বৈশিষ্ট্যপ্রোগ্রামিং-প্রধান: ৩টি প্রোগ্রাম লেখা, ১টি output নির্ণয়, ৩টি SQL, এরপর তত্ত্ব ও নিজের প্রজেক্ট নিয়ে প্রশ্ন
প্রশ্ন ১ Combined 5 Bank AP 2024 Write a C/Java program that shows the prime numbers between 1 and n, where n is given by user input.

লজিক: x prime হবে যদি x ≥ 2 হয় এবং 2 থেকে √x পর্যন্ত কোনো সংখ্যা দিয়ে x বিভাজ্য না হয়। লুপের শর্ত d * d <= x লিখলে sqrt function লাগে না। প্রতিটি সংখ্যার জন্য O(√x), মোট O(n√n)। বড় n-এর জন্য Sieve of Eratosthenes দ্রুততর: O(n log log n)।

/* C */
#include <stdio.h>

int isPrime(int x) {
    if (x < 2) return 0;
    for (int d = 2; d * d <= x; d++)
        if (x % d == 0) return 0;
    return 1;
}

int main(void) {
    int n;
    printf("Enter n: ");
    scanf("%d", &n);
    printf("Primes between 1 and %d:\n", n);
    for (int i = 2; i <= n; i++)
        if (isPrime(i))
            printf("%d ", i);
    printf("\n");
    return 0;
}
// Java
import java.util.Scanner;

public class Primes {
    static boolean isPrime(int x) {
        if (x < 2) return false;
        for (int d = 2; d * d <= x; d++)
            if (x % d == 0) return false;
        return true;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter n: ");
        int n = sc.nextInt();
        for (int i = 2; i <= n; i++)
            if (isPrime(i))
                System.out.print(i + " ");
        System.out.println();
    }
}

Sample: Enter n: 30 → 2 3 5 7 11 13 17 19 23 29। 1 prime নয়, তাই লুপ 2 থেকে শুরু।

প্রশ্ন ২ Combined 5 Bank AP 2024 Write a C/Java program that calculates the sum of the series 1 + 2 + 4 + 7 + 11 + … up to the n-th term.

Pattern: পাশাপাশি পদের পার্থক্য 1, 2, 3, 4, …। তাই প্রতিটি পদ আগের পদের সঙ্গে k যোগ করে পাওয়া যায় (k = 1, 2, 3, …)।

k-তম পদ: tk = 1 + k(k − 1)/2   |   n পদের যোগফল: Sn = n + (n − 1)n(n + 1)/6

যাচাই: t5 = 1 + 5·4/2 = 11 ✔; S5 = 5 + 4·5·6/6 = 5 + 20 = 25 = 1 + 2 + 4 + 7 + 11 ✔

/* C */
#include <stdio.h>

int main(void) {
    int n;
    long long term = 1, sum = 0;
    printf("Enter n: ");
    scanf("%d", &n);
    for (int k = 1; k <= n; k++) {
        printf("%lld%s", term, k < n ? " + " : "");
        sum += term;
        term += k;      /* next term = term + k */
    }
    printf("\nSum = %lld\n", sum);
    return 0;
}
// Java
import java.util.Scanner;

public class SeriesSum {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter n: ");
        int n = sc.nextInt();
        long term = 1, sum = 0;
        for (int k = 1; k <= n; k++) {
            System.out.print(term + (k < n ? " + " : ""));
            sum += term;
            term += k;
        }
        System.out.println("\nSum = " + sum);
        // closed form check:
        long f = n + (long)(n - 1) * n * (n + 1) / 6;
        System.out.println("Formula = " + f);
    }
}

Sample: n = 5 → 1 + 2 + 4 + 7 + 11, Sum = 25। n = 7 হলে পদগুলো 16 ও 22 পর্যন্ত যায়, Sum = 63 (সূত্রে 7 + 6·7·8/6 = 63 ✔)।

প্রশ্ন ৩ Combined 5 Bank AP 2024 Write a program in C/Java to print the following Floyd's triangle (0–1 pattern). N is given by user input. For n = 5:
1
01
101
0101
10101

Pattern বিশ্লেষণ: i-তম সারিতে i টি অঙ্ক। বিজোড় সারি 1 দিয়ে আর জোড় সারি 0 দিয়ে শুরু হয়, তারপর 1 ও 0 পালাক্রমে আসে। দুটি নিয়মকে একসাথে লেখা যায়: (i + j) জোড় হলে 1, বিজোড় হলে 0 (i ও j 1 থেকে গোনা)।

/* C */
#include <stdio.h>

int main(void) {
    int n;
    printf("Enter n: ");
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= i; j++)
            printf("%d", (i + j) % 2 == 0 ? 1 : 0);
        printf("\n");
    }
    return 0;
}
// Java
import java.util.Scanner;

public class BinaryFloyd {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            StringBuilder row = new StringBuilder();
            for (int j = 1; j <= i; j++)
                row.append((i + j) % 2 == 0 ? 1 : 0);
            System.out.println(row);
        }
    }
}

যাচাই: i = 1: j = 1 → 2 জোড় → "1"। i = 2: 3 → 0, 4 → 1 → "01"। i = 4: 5, 6, 7, 8 → "0101"। প্রশ্নের নমুনার সঙ্গে হুবহু মেলে ✔। প্রচলিত সংখ্যাভিত্তিক Floyd's triangle (1 / 2 3 / 4 5 6 …) চাইলে একটি counter রেখে প্রতিবার printf("%d ", c++) লিখুন।

প্রশ্ন ৪ Combined 5 Bank AP 2024 Find the output of the following program:
#include <stdio.h>
int fun(int i) {
    if (i <= 0) return;
    printf("%d, ", i--);
    fun(--i);
    printf("%d, ", i);
}
int main() {
    fun(5);
}

মনে রাখুন: i-- (post-decrement) আগে মান ব্যবহার করে, তারপর কমায়। --i (pre-decrement) আগে কমায়, তারপর মান ব্যবহার করে। তাই প্রতিটি call-এ i মোট ২ কমে। দ্বিতীয় printf recursive call ফেরার পরে চলে, তাই ওই মানগুলো উল্টো ক্রমে ছাপা হয়।

Callপ্রথম printfi-এর পরিবর্তনRecursive callফেরার পর দ্বিতীয় printf
fun(5)"5, "i-- → 4, --i → 3fun(3)"3, " (সবশেষে)
fun(3)"3, "i-- → 2, --i → 1fun(1)"1, "
fun(1)"1, "i-- → 0, --i → −1fun(−1)"−1, "
fun(−1)—i ≤ 0, তাই কিছু না ছেপেই return

ক্রম: নামার পথে 5, 3, 1 → fun(−1) ফেরে → ওঠার পথে −1 (fun(1)), 1 (fun(3)), 3 (fun(5))।

Output: 5, 3, 1, -1, 1, 3,
সূক্ষ্ম বিষয় (উত্তরে এক লাইনে লিখুন) int fun() একটি non-void function, অথচ return;-এ কোনো মান নেই এবং শেষেও return নেই। C99/C11-এ এটি constraint violation বা warning, কিন্তু যেহেতু ফেরত মানটি কোথাও ব্যবহার হয়নি, বেশিরভাগ compiler (gcc) warning দিয়ে উপরের output-ই দেয়। প্রশ্নপত্রের "I", "Printf" ও "Ø" OCR বা টাইপের ভুল; সেগুলো i, printf ও 0 ধরা হয়েছে।
প্রশ্ন ৫–৬ Combined 5 Bank AP 2024 Given two tables Department and Employee:
CREATE TABLE Department (DeptCode INT, DeptName VARCHAR(20), Location VARCHAR(20));
CREATE TABLE Employee   (EmpCode INT, EmpFname VARCHAR(20), Salary INT,
                         Commission INT, DeptCode VARCHAR(20));
(a) Select every EmpFname with total salary (total salary = salary + commission). (b) Select EmpFname and Location of employees whose salary is greater than the average salary, ordered by EmpFname. (c) Select EmpFname and the count of employees, ordered by the employee count ascending.

Schema সংশোধন (উত্তরে উল্লেখ করুন): Employee-র DeptCode-এর type Department-এর DeptCode-এর মতোই INT হওয়া উচিত, যাতে join ও foreign key ঠিকমতো কাজ করে। মূল DDL-এ Commission INT-এর পরে কমা নেই এবং শেষে একটি বাড়তি কমা আছে; দুটোই syntax error।

CREATE TABLE Department (
    DeptCode  INT PRIMARY KEY,
    DeptName  VARCHAR(20),
    Location  VARCHAR(20)
);
CREATE TABLE Employee (
    EmpCode    INT PRIMARY KEY,
    EmpFname   VARCHAR(20),
    Salary     INT,
    Commission INT,
    DeptCode   INT REFERENCES Department(DeptCode)
);

-- (a) Total salary; Commission NULL হলে 0 ধরা হয়
SELECT EmpFname,
       Salary + COALESCE(Commission, 0) AS TotalSalary
FROM   Employee;

-- (b) গড় বেতনের চেয়ে বেশি পান যাঁরা, তাঁদের নাম ও Location
SELECT   e.EmpFname, d.Location
FROM     Employee e
JOIN     Department d ON e.DeptCode = d.DeptCode
WHERE    e.Salary > (SELECT AVG(Salary) FROM Employee)
ORDER BY e.EmpFname;

-- (c) প্রতিটি EmpFname-এ কতজন কর্মচারী, সংখ্যার ক্রমে
SELECT   EmpFname, COUNT(EmpCode) AS EmpCount
FROM     Employee
GROUP BY EmpFname
ORDER BY EmpCount ASC;
ব্যাখ্যা ও বিকল্প (a): NULL + সংখ্যা = NULL, তাই COALESCE (বা MySQL-এ IFNULL, SQL Server-এ ISNULL) না দিলে কমিশনহীন কর্মচারীর total salary NULL দেখাবে।
(b): WHERE-এ সরাসরি AVG() ব্যবহার করা যায় না, তাই subquery লাগে।
(c): প্রশ্নটি অস্পষ্ট। Aggregate-এর সঙ্গে non-aggregate কলাম (EmpFname) রাখতে হলে সেটি GROUP BY-তে থাকতে হবে। উপরে "একই নামে কতজন" ধরা হয়েছে। যদি উদ্দেশ্য হয় প্রতিটি বিভাগে কতজন কর্মচারী, তাহলে:
SELECT d.DeptName, COUNT(e.EmpCode) AS EmpCount
FROM Department d LEFT JOIN Employee e ON e.DeptCode = d.DeptCode
GROUP BY d.DeptName
ORDER BY EmpCount ASC;
আর প্রতিটি নামের পাশে মোট কর্মচারী সংখ্যা দেখাতে চাইলে window function: SELECT EmpFname, COUNT(*) OVER () AS TotalEmp FROM Employee ORDER BY EmpCode;। খাতায় নিজের ব্যাখ্যাটি এক লাইনে লিখে দিন।
প্রশ্ন ৭ Combined 5 Bank AP 2024 What is the difference between a stack and a queue? Also write two uses of each.
বিষয়StackQueue
নীতিLIFO (Last In First Out)FIFO (First In First Out)
প্রান্তএকটি প্রান্ত (top)। এখানেই insert ও delete হয়দুটি প্রান্ত: rear-এ insert, front-এ delete
অপারেশনpush, pop, peekenqueue, dequeue, front
Pointertopfront ও rear
Complexitypush/pop O(1)enqueue/dequeue O(1) (circular array বা linked list-এ)
রূপভেদ—Circular queue, priority queue, deque
বাস্তব উদাহরণপ্লেটের স্তূপব্যাংকের কাউন্টারের লাইন
Stack-এর ব্যবহার
  1. Function call ও recursion-এর call stack, যেখানে return address ও local variable থাকে।
  2. Expression evaluation ও infix → postfix রূপান্তর; balanced parentheses যাচাই।
  3. (অতিরিক্ত) Undo/Redo, ব্রাউজারের Back বাটন, DFS।
Queue-এর ব্যবহার
  1. CPU scheduling (Round Robin ready queue) ও printer spooling।
  2. BFS traversal; নেটওয়ার্ক router-এর packet buffer।
  3. (অতিরিক্ত) ব্যাংকের টোকেন সিস্টেম, message queue (RabbitMQ, Kafka)।
প্রশ্ন ৮ Combined 5 Bank AP 2024 What is polymorphism? Describe the different types of polymorphism.

সংজ্ঞা: Polymorphism (poly = অনেক, morph = রূপ) মানে একই interface বা নাম দিয়ে ভিন্ন ভিন্ন type-এর object-এর সঙ্গে ভিন্ন আচরণ করা। এটি OOP-এর চারটি স্তম্ভের একটি; বাকি তিনটি encapsulation, inheritance ও abstraction।

ধরনঅন্য নামকীভাবেBinding
Compile-timeStatic polymorphismMethod overloading (একই নাম, ভিন্ন parameter); C++-এ operator overloadingEarly/static binding
RuntimeDynamic polymorphismMethod overriding + upcasting (parent reference, child object); C++-এ virtual functionLate/dynamic binding
ParametricGenerics / TemplatesJava-র List<T>, C++ template। একই কোড বিভিন্ন type-এর সঙ্গে কাজ করেCompile time
// Compile-time: overloading
class Calculator {
    int    add(int a, int b)          { return a + b; }
    double add(double a, double b)    { return a + b; }
    int    add(int a, int b, int c)   { return a + b + c; }
}

// Runtime: overriding
abstract class Account {
    abstract double interest(double balance);
}
class Savings extends Account {
    @Override double interest(double b) { return b * 0.05; }
}
class FixedDeposit extends Account {
    @Override double interest(double b) { return b * 0.09; }
}

public class Bank {
    public static void main(String[] args) {
        Calculator c = new Calculator();
        System.out.println(c.add(2, 3));        // 5    (int version)
        System.out.println(c.add(2.5, 3.5));    // 6.0  (double version)

        Account[] list = { new Savings(), new FixedDeposit() };
        for (Account a : list)                    // একই call, ভিন্ন আচরণ
            System.out.println(a.interest(10000)); // 500.0, 900.0
    }
}

সুবিধা: নতুন account type যোগ করলে Bank-এর লুপ বদলাতে হয় না (Open–Closed principle)। কোড পুনর্ব্যবহারযোগ্য ও extensible হয়।

প্রশ্ন ৯ Combined 5 Bank AP 2024 Describe the different types of relationships in a DBMS.

ER model-এ relationship মানে দুই বা ততোধিক entity-র মধ্যে সম্পর্ক। একে তিনভাবে শ্রেণিবিভাগ করা হয়।

(ক) Cardinality (mapping) অনুযায়ী

ধরনঅর্থউদাহরণটেবিলে বাস্তবায়ন
One-to-One (1:1)A-এর একটি record, B-এর সর্বোচ্চ একটির সঙ্গেCustomer — NID; Employee — Deskযেকোনো এক পাশে UNIQUE foreign key
One-to-Many (1:N)A-এর একটি, B-এর অনেকের সঙ্গেBranch — Accounts; Department — Employees"Many" পাশের টেবিলে foreign key
Many-to-One (N:1)1:N-এর উল্টো দিক থেকে দেখাAccounts — Branchএকই
Many-to-Many (M:N)দুই পাশেই অনেকCustomer — Account (joint account); Student — CourseJunction (bridge) টেবিল, দুই FK মিলিয়ে composite PK, যেমন প্রশ্ন ২-এর R ও Q

(খ) Degree অনুযায়ী

  • Unary (recursive): একই entity নিজের সঙ্গে সম্পর্কিত, যেমন Employee manages Employee, বা Node next Node (token ring)।
  • Binary: দুটি entity, যেমন Customer holds Account। এটিই সবচেয়ে প্রচলিত।
  • Ternary: তিনটি entity একসাথে, যেমন Doctor–Patient–Medicine (prescribes), বা Supplier–Part–Project।

(গ) Participation অনুযায়ী

  • Total (mandatory): প্রতিটি record-কে সম্পর্কে থাকতেই হবে, যেমন প্রতিটি Loan-এর একজন Borrower থাকবেই। ER diagram-এ এটি দুই দাগ দিয়ে দেখানো হয়।
  • Partial (optional): সব record-এর থাকা জরুরি নয়, যেমন সব Customer-এর Loan নেই।

"Relation" শব্দটি দিয়ে যদি টেবিল বোঝানো হয়: base relation (সংরক্ষিত টেবিল), view (virtual relation) ও query result (derived relation)। প্রয়োজনে উত্তরের শেষে এক লাইনে যোগ করুন।

প্রশ্ন ১০ Combined 5 Bank AP 2024 Describe a real-life software project you have built. What problems or challenges did you face during that time, and how did you solve them?
কৌশল নিজের থিসিস, ইন্টার্নশিপ বা চাকরির প্রজেক্ট নিন এবং নিচের কাঠামোয় লিখুন। ব্যাংকিং সংশ্লিষ্ট হলে আরও ভালো। পরীক্ষক যাচাই করেন আপনি সমস্যা চিহ্নিত করে প্রযুক্তিগত সমাধান দিতে পারেন কিনা। শুধু "অনেক কষ্ট হয়েছিল" লিখলে নম্বর আসে না। প্রতিটি চ্যালেঞ্জের সঙ্গে নির্দিষ্ট টুল বা কৌশলের নাম লিখুন।

মডেল উত্তর (নিজের প্রজেক্ট অনুযায়ী বদলে নিন):

১. প্রজেক্ট পরিচিতি: "Micro-Loan Management System" — একটি ওয়েব অ্যাপ্লিকেশন, যা একটি NGO বা ক্ষুদ্রঋণ প্রতিষ্ঠানের ঋণ আবেদন, অনুমোদন, কিস্তি সংগ্রহ ও রিপোর্ট পরিচালনা করে। ব্যবহারকারী প্রায় ৫০ জন মাঠকর্মী ও ১০ জন শাখা ব্যবস্থাপক; গ্রাহকের রেকর্ড প্রায় ২০,০০০।

২. প্রযুক্তি ও আমার ভূমিকা: Java (Spring Boot) REST API, MySQL, React frontend, Git ও Docker। আমি backend ডেভেলপার হিসেবে database design, কিস্তি হিসাবের মডিউল ও রিপোর্টিং তৈরি করেছি। কাজ চলেছে Agile (২ সপ্তাহের sprint) পদ্ধতিতে।

চ্যালেঞ্জকারণসমাধান
একই কিস্তি দুবার পোস্ট হওয়া (double posting)দুর্বল নেটওয়ার্কে মাঠকর্মী বারবার Submit চাপতেন; concurrent requestTransaction (@Transactional) ও row-level lock ব্যবহার; প্রতিটি পেমেন্টে idempotency key; ক্লিকের পর বাটন নিষ্ক্রিয়
মাসিক রিপোর্ট খুব ধীর (প্রায় ৪০ সেকেন্ড)বড় টেবিলে full table scan; N+1 queryEXPLAIN দিয়ে বিশ্লেষণ; (branch_id, due_date)-এ composite index; JOIN FETCH; রাতের batch-এ summary টেবিল। ফলে সময় নেমে আসে ২ সেকেন্ডের নিচে
Requirement বারবার বদলানোসুদের হার ও জরিমানার নিয়ম শাখাভেদে ভিন্ননিয়মগুলো কোডে hard-code না করে configuration টেবিলে রাখা; প্রতিটি sprint শেষে demo দিয়ে feedback নেওয়া
নিরাপত্তাসংবেদনশীল আর্থিক ও ব্যক্তিগত তথ্যbcrypt দিয়ে password hashing; role-based access (RBAC); prepared statement দিয়ে SQL injection প্রতিরোধ; HTTPS; audit log
Deployment-এ "আমার পিসিতে চলে, সার্ভারে চলে না"পরিবেশের পার্থক্যDocker image, CI pipeline (GitHub Actions) এবং স্বয়ংক্রিয় unit ও integration test

৩. ফলাফল ও শিক্ষা: কাগজের খাতার বদলে রিয়েল-টাইম ড্যাশবোর্ড চালু হয় এবং হিসাবের ভুল প্রায় শূন্যে নেমে আসে। শিক্ষা: শুরুতেই ডেটার অখণ্ডতা (transaction, constraint) নিশ্চিত করা, performance মেপে তারপর অপ্টিমাইজ করা, আর ব্যবহারকারীর সঙ্গে নিয়মিত যোগাযোগ রাখা জরুরি। ব্যাংকের Assistant Programmer হিসেবে CBS-সংলগ্ন অ্যাপ বা ইন্টারনাল টুল তৈরিতে এই অভিজ্ঞতা সরাসরি কাজে লাগবে।

ITProstuti — free preparation notes for Bangladesh bank and government IT job exams.

Past questions belong to their setters (BSCS, BIBM and others); solutions and notes are written for learning. Spotted a mistake? Note the page and section and report it.