Loading...
Dhaka Power Distribution Company Limited

Post: Technical (Computer technology)
Subject code: 155; Mark: 80
1.(a) Find the output of this program.
#include
int main() {
int n = 4;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n - i; j++) {
printf(" ");
}
for (int j = 1; j <= i; j++) {
printf("*");
}
printf("\n");
}
return 0;
}

The hash function is given as h(k)=k mod 13.
The table size is 13, meaning we have indices from 0 to 12.

Step-by-Step Insertion Process
Key: 10
Hash value: h(10) = 10 mod 13 = 10. Insert 10 at index 10.
Key: 3
Hash value: h(3) = 3 mod 13 = 3. Insert 3 at index 3.
Key: 6
Hash value: h(6) = 6 mod 13 = 6. Insert 6 at index 6.
Key: 16
Hash value: h(16) = 16 mod 13 = 3. Index 3 is occupied. Use linear probing and insert 16 at index 4.
Key: 17
Hash value: h(17) = 17 mod 13 = 4. Index 4 is occupied. Use linear probing and insert 17 at index 5.
Key: 19
Hash value: h(19) = 19 mod 13 = 6. Index 6 is occupied. Use linear probing and insert 19 at index 7.
Final Hash Table

IndexValue
0
1
2
33
416
517
66
719
8
9
1010
11
12

Summary
The final hash table after inserting all keys using linear probing is as follows:

[ – , – , – , 3 , 16 , 17 , 6 , 19 , – , – , 10 , – , – ]
1.(b) Class C has some features. Class D uses all features of Class C and has some extra features of its own. Identify the concept used here in Object-Oriented Programming (OOP) and explain with an example.

The hash function is given as h(k)=k mod 13.
The table size is 13, meaning we have indices from 0 to 12.

Step-by-Step Insertion Process
Key: 10
Hash value: h(10) = 10 mod 13 = 10. Insert 10 at index 10.
Key: 3
Hash value: h(3) = 3 mod 13 = 3. Insert 3 at index 3.
Key: 6
Hash value: h(6) = 6 mod 13 = 6. Insert 6 at index 6.
Key: 16
Hash value: h(16) = 16 mod 13 = 3. Index 3 is occupied. Use linear probing and insert 16 at index 4.
Key: 17
Hash value: h(17) = 17 mod 13 = 4. Index 4 is occupied. Use linear probing and insert 17 at index 5.
Key: 19
Hash value: h(19) = 19 mod 13 = 6. Index 6 is occupied. Use linear probing and insert 19 at index 7.
Final Hash Table

IndexValue
0
1
2
33
416
517
66
719
8
9
1010
11
12

Summary
The final hash table after inserting all keys using linear probing is as follows:

[ – , – , – , 3 , 16 , 17 , 6 , 19 , – , – , 10 , – , – ]
2.(a) Let A = {1,2,3,4,5,6,7,8}. If five integers are selected from A, prove that at least one pair of selected integers has a sum of 9. Use the Pigeonhole Principle.

The hash function is given as h(k)=k mod 13.
The table size is 13, meaning we have indices from 0 to 12.

Step-by-Step Insertion Process
Key: 10
Hash value: h(10) = 10 mod 13 = 10. Insert 10 at index 10.
Key: 3
Hash value: h(3) = 3 mod 13 = 3. Insert 3 at index 3.
Key: 6
Hash value: h(6) = 6 mod 13 = 6. Insert 6 at index 6.
Key: 16
Hash value: h(16) = 16 mod 13 = 3. Index 3 is occupied. Use linear probing and insert 16 at index 4.
Key: 17
Hash value: h(17) = 17 mod 13 = 4. Index 4 is occupied. Use linear probing and insert 17 at index 5.
Key: 19
Hash value: h(19) = 19 mod 13 = 6. Index 6 is occupied. Use linear probing and insert 19 at index 7.
Final Hash Table

IndexValue
0
1
2
33
416
517
66
719
8
9
1010
11
12

Summary
The final hash table after inserting all keys using linear probing is as follows:

[ – , – , – , 3 , 16 , 17 , 6 , 19 , – , – , 10 , – , – ]
2.(b) Simplify using K-map: F(A,B,C) = A'BC' + A'BC + AB'C' + AB'C + ABC' + ABC

The hash function is given as h(k)=k mod 13.
The table size is 13, meaning we have indices from 0 to 12.

Step-by-Step Insertion Process
Key: 10
Hash value: h(10) = 10 mod 13 = 10. Insert 10 at index 10.
Key: 3
Hash value: h(3) = 3 mod 13 = 3. Insert 3 at index 3.
Key: 6
Hash value: h(6) = 6 mod 13 = 6. Insert 6 at index 6.
Key: 16
Hash value: h(16) = 16 mod 13 = 3. Index 3 is occupied. Use linear probing and insert 16 at index 4.
Key: 17
Hash value: h(17) = 17 mod 13 = 4. Index 4 is occupied. Use linear probing and insert 17 at index 5.
Key: 19
Hash value: h(19) = 19 mod 13 = 6. Index 6 is occupied. Use linear probing and insert 19 at index 7.
Final Hash Table

IndexValue
0
1
2
33
416
517
66
719
8
9
1010
11
12

Summary
The final hash table after inserting all keys using linear probing is as follows:

[ – , – , – , 3 , 16 , 17 , 6 , 19 , – , – , 10 , – , – ]
3.(a) Create an example of a trigger.

The hash function is given as h(k)=k mod 13.
The table size is 13, meaning we have indices from 0 to 12.

Step-by-Step Insertion Process
Key: 10
Hash value: h(10) = 10 mod 13 = 10. Insert 10 at index 10.
Key: 3
Hash value: h(3) = 3 mod 13 = 3. Insert 3 at index 3.
Key: 6
Hash value: h(6) = 6 mod 13 = 6. Insert 6 at index 6.
Key: 16
Hash value: h(16) = 16 mod 13 = 3. Index 3 is occupied. Use linear probing and insert 16 at index 4.
Key: 17
Hash value: h(17) = 17 mod 13 = 4. Index 4 is occupied. Use linear probing and insert 17 at index 5.
Key: 19
Hash value: h(19) = 19 mod 13 = 6. Index 6 is occupied. Use linear probing and insert 19 at index 7.
Final Hash Table

IndexValue
0
1
2
33
416
517
66
719
8
9
1010
11
12

Summary
The final hash table after inserting all keys using linear probing is as follows:

[ – , – , – , 3 , 16 , 17 , 6 , 19 , – , – , 10 , – , – ]
3.(b) Consider the following tables: Customer(customerID, name), Accounts(accountID, customerID), Orders(orderID, accountID, orderAmount). Write an SQL query to display customerID, name, and total order amount of all customers whose total order amount is greater than 5000.

The hash function is given as h(k)=k mod 13.
The table size is 13, meaning we have indices from 0 to 12.

Step-by-Step Insertion Process
Key: 10
Hash value: h(10) = 10 mod 13 = 10. Insert 10 at index 10.
Key: 3
Hash value: h(3) = 3 mod 13 = 3. Insert 3 at index 3.
Key: 6
Hash value: h(6) = 6 mod 13 = 6. Insert 6 at index 6.
Key: 16
Hash value: h(16) = 16 mod 13 = 3. Index 3 is occupied. Use linear probing and insert 16 at index 4.
Key: 17
Hash value: h(17) = 17 mod 13 = 4. Index 4 is occupied. Use linear probing and insert 17 at index 5.
Key: 19
Hash value: h(19) = 19 mod 13 = 6. Index 6 is occupied. Use linear probing and insert 19 at index 7.
Final Hash Table

IndexValue
0
1
2
33
416
517
66
719
8
9
1010
11
12

Summary
The final hash table after inserting all keys using linear probing is as follows:

[ – , – , – , 3 , 16 , 17 , 6 , 19 , – , – , 10 , – , – ]

You must subscribe & Login to view more.

Don’t have an account? Register

Or your subscription is under review by admin. Please message on WhatsApp / Telegram.

Leave a Comment

Latest Post
Field Based Job Question & Solution
Bank IT Job Solution

MCQ + Written from Bangladesh Bank, Sonali, Combined Bank IT recruitment.

BPSC IT Job Solution

BPSC Computer/IT cadre & non-cadre post Question papers with full solutions.

Gas Field IT Job Solution

Gas field like TGTDCL, BGDCL, JGTDSL, KGDCL, SGCL, RPGCL, GTCL etc. question solution

Power Sector IT Job Solution

Power sector such as NESCO, DESCO, DPDC, WZPDCL, BPDB, PGCB, BREB etc

Other IT Job Solution

Other Govt. Semi govt. organization like BCC, BTCL, CAAB, NSI etc.

NTRCA IT Job Solution (upcoming)

NTRCA ICT-related posts such as Assistant Teacher, Demonstrator, Lecturer.

IT MCQ Job Solution

Collected MCQ Job solution of BANK, BPSC, POWER SECTOR, GAS Field and Others.

Topic Based Q&S
WhatsApp Telegram Messenger