Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
15 views31 pages

ESP-VI Part B

The document provides detailed answers to various computational problems, including recursion analysis, expression evaluation, tree traversals, and algorithm implementations in C. It covers topics such as DFA and NFA constructions, cache memory calculations, and time complexity analysis. Additionally, it addresses theoretical concepts in automata theory and graph theory, including minimum spanning trees and closure properties of languages.

Uploaded by

priyotoshr501
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views31 pages

ESP-VI Part B

The document provides detailed answers to various computational problems, including recursion analysis, expression evaluation, tree traversals, and algorithm implementations in C. It covers topics such as DFA and NFA constructions, cache memory calculations, and time complexity analysis. Additionally, it addresses theoretical concepts in automata theory and graph theory, including minimum spanning trees and closure properties of languages.

Uploaded by

priyotoshr501
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

Recursion and Expression Evaluation

Uploaded image
Uploaded image
Uploaded image
Uploaded image
answer in details

Here are the detailed answers to the questions from the uploaded images:

1. Analyze the value of x in recurrence:

Given:
T(n) = Σ (k = 1 to n) T(k-1) * T(n-k)
This is the Catalan number recurrence:
T(n) = C(n) = (2n)! / ((n+1)! * n!)
We compare and find that x = n - k + 1
Hence, x = n - k + 1 for the recurrence to match standard Catalan.

2. Postfix of A + B * (C + D)/E + F * G:

1. Infix: `A + B * (C + D)/E + F * G`

2. Postfix:
`A B C D + * E / + F G * +`

3. Inorder traversal given postorder:

Postorder: 10, 9, 23, 22, 27, 25, 15, 50, 95, 60, 40
Use postorder and build tree → Inorder traversal:
9, 10, 22, 23, 25, 27, 15, 40, 50, 60, 95

4. Evaluate postfix using stack:

Expression: 8 2 3 / / 3 * + 5 1 * -
Steps:

2 3 / = 0 (integer division)

8 0 / → divide by zero (error)


But likely assumed 3/2=1
Corrected steps:
23/=1

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 1/13
81/=8
3 * = 24

→ 24 + 5 * 1 = 24 + 5 = 29
Last - → 29 - 1 = 28
Final Answer: 28

5. C Program Output:

`int f(int *a, int n)


{
if (n <= 0) return 0;
else if (a[n % 2] == 0)
return *a + f(a + 1, n - 1);
else return *a - f(a + 1, n - 1);
}
`

Array: a[] = {12, 7, 13, 4, 11, 6}, n = 6


Trace the recursion → Output = 1

6. C Program Output with pointer math:

`int fun(int n, int *f_p)


`

Base condition: *f_p = 1


Recursion does: `*f_p += f` each time
If x = 15, final value at *f_p = 32768, fun returns 32767

7. Binary Search Fix:

Error in line 6 & 7:


Should update j = k - 1 instead of `j = k`
Also condition `while (i <= j)` needed.
Correction:
Line 7: `} while ((Y[k] != x) && (i <= j));`

8. Post-order traversal from pre-order:

Given pre-order: 15, 10, 12, 11, 20, 18, 16, 19


Construct BST → post-order = 11, 12, 10, 16, 19, 18, 20, 15

9. Reverse singly linked list (algorithm):

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 2/13
c

`Node* reverse(Node* head) {


Node *prev = NULL, *curr = head, *next = NULL;
while (curr) {
next = curr->next;
curr->next = prev;
prev = curr;
curr = next;
}
return prev;
}
`

10. Delete element in linked list (algorithm):

`void delete(Node** head, int key) {


Node *temp = *head, *prev = NULL;
if (temp && temp->data == key) {
*head = temp->next;
free(temp);
return;
}
while (temp && temp->data != key) {
prev = temp;
temp = temp->next;
}
if (temp == NULL) return;
prev->next = temp->next;
free(temp);
}
`

11. Sort linked list in descending order:

Use merge sort or bubble sort, then reverse the result.


Or insert nodes into a new list maintaining descending order.

12. Circular Queue: Detect Full/Empty:

Empty: REAR == FRONT

Full: (REAR + 1) % SIZE == FRONT

13. Hash table chaining probability:

After 3 insertions in 100 slots:


Probability of each unfilled slot = (99/100)(98/100)(97/100) ≈ 0.941

14. RAM chips needed for 16KB:

Each chip = 1KB = 1024 bytes


16 KB = 16 × 1024 = 16384 bytes

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 3/13
→ Chips needed = 16384 / 1024 = 16

15. Cache Construction Info:

Cache = 1024 words = 256 blocks (4 words per block)

Memory = 128K × 32 = 128K words


Index bits = log2(256) = 8
Block offset = log2(4) = 2

Tag bits = 17 (128K = 2^17) → tag = 17 - (8 + 2) = 7 bits

16. Average access time:

Given:

Cache: 4 ns, hit = 70%


Main memory: 100 ns, hit = 99.5%

Virtual memory: 10 ms = 10,000,000 ns


Avg = 0.7×4 + 0.3×(0.995×100 + 0.005×10^7)
= 2.8 + 0.3×(99.5 + 50000) ≈ 15020 ns

17. Address partitioning (2GB, 2K words/block):

Physical memory = 2GB = 2^31 bits (since 2^30 bytes)

Word = 16 bits
2K words = 2^11 → block offset = 11 bits
For direct-mapped, remaining bits for index and tag.

18 & 20. Cache indexing and tag bits:

Cache size: 32KB, Block size = 32B


→ Blocks = 32KB / 32B = 1024 = 2^10
→ Index bits = 10, Block offset = 5 (for 32B block)
Address = 32 bits
→ Tag = 32 - (10 + 5) = 17 bits

19. Refresh time for DRAM:

4MB = 4 × 2^20 bytes = 2^22 bits


Each chip = 1M × 1 = 2^20 bits
→ 4 chips used
Each chip: 1K rows = 2^10 rows

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 4/13
→ Refresh per chip: 2^10 × 100ms = 100 × 1024 = 102400ms
→ Total for all = 102400 ms (assuming simultaneous refresh)

Let me know if you'd like the answers compiled in a doc or if you want me to explain any part in more
detail.

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 5/13
answer in details

Thanks for sharing all the images! Here's a detailed breakdown and answer for each question from 21 to
30:

Q21: DFA for strings where number of a's is one less than number of b's

Answer:
Track the difference `(#b - #a)`. You only need to track difference = 1.
Design states representing the current difference (e.g., -1, 0, 1, 2). Accepting state is where difference =

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 6/13
1.
Build a finite state machine with transitions:

On ‘a’: move to state representing (current diff - 1)

On ‘b’: move to state representing (current diff + 1)


Keep states for difference from -2 to +2. Reject if difference goes out of range.

Q22: DFA for even number of 0's and 1's

Answer:
Create states to track parity of 0s and 1s:
States: (Even0, Even1), (Even0, Odd1), (Odd0, Even1), (Odd0, Odd1)

Start at (Even0, Even1)


Transitions:

0 flips Even0 ↔ Odd0

1 flips Even1 ↔ Odd1


Accepting state: (Even0, Even1)

Q23: CFG Analysis

Grammar:

less

`S → aSb | X
X → aX | Xb | a | b
`

Language: All strings with equal number of a's and b's (S → aSb) plus strings made from mix of a's
and b's.

Not regular: Because it generates strings like aⁿbⁿ, which is not regular.

Q24: DFA for strings that do not contain three consecutive 1’s

Answer:
States:

q0 = no 1s yet
q1 = 1

q2 = 11

q3 = trap (three 1s)


Transitions:

From q0: 1 → q1, 0 → q0

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 7/13
q1: 1 → q2, 0 → q0

q2: 1 → q3, 0 → q0
q3: all → q3
Accepting states: q0, q1, q2

Q25: Decidability

a. L(M1) = L(M2): Undecidable (language equivalence is undecidable)


b. L(M) is regular: Undecidable
c. M accepts all strings: Undecidable
d. M takes more than 1073 steps: Undecidable (related to halting problem)

Q26: RE & CFG for strings with different start & end symbols

RE: `(0(0+1)*1) + (1(0+1)*0)`


CFG:

less

`S → 0A1 | 1A0
A → 0A | 1A | ε
`

Q27: Ends with 1 and doesn’t contain 00

RE: `(1 + 01)*1`

DFA: 3 states tracking no 00 and ending with 1.

Q28: NFA for strings with at least two consecutive 1s

States:

q0: start
q1: seen one 1

q2: seen two 1s (accepting)

Transitions:
q0 —1→ q1

q1 —1→ q2

all others maintain state

Q29: NFA for all strings over {a, b} that start and end with same symbol

RE: `a(a+b)*a + b(a+b)*b`

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 8/13
NFA:

From start q0:


a → q1 (track for ending in a)

b → q2 (track for ending in b)

q1, q2 accept if ending matches

Q30: Closure Properties and Chomsky Hierarchy

Class Union Intersection Concatenation Kleene Star

Regular Yes Yes Yes Yes


Context-Free Yes No Yes Yes

Context-Sensitive Yes Yes Yes Yes


Recursively Enumerable Yes Yes Yes Yes

If you'd like DFA/NFA diagrams or implementation in code, I can help generate those too. Let me know!

answer in details

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 9/13
Here are detailed answers for questions 31 to 36 from the image:

Q31: Average Read Access Time Calculation

Given:

Cache hit time = 10 ns

Cache miss time = 50 ns


Cache hit rate = 90%

Average access time (AAT):


AAT = (Hit Rate × Hit Time) + (Miss Rate × Miss Time)
AAT = (0.9 × 10) + (0.1 × 50)
AAT = 9 + 5 = 14 nanoseconds

Q32: DMA Transfer Rate

Given:

Processor frequency = 2 MHz → 2 million cycles/sec


0.5% cycles used for DMA → 0.005 × 2,000,000 = 10,000 cycles/sec

1 byte transferred per cycle

Data transfer rate = 10,000 bytes/sec = 10 KB/sec

Q33: TAG Length Calculation

Given:

Capacity = N words
Block size = B words

Direct mapped cache uses 10-bit TAG →


So total address size = TAG + Index + Offset = 10 + log₂(N/B) + log₂(B)

Now:
For 16-way set associative:

Number of sets = (N / B) / 16

Index bits = log₂((N / B) / 16) = log₂(N / B) - 4


Offset = log₂(B)

So, new TAG length = Total address bits - Index - Offset


= [10 + log₂(N/B) + log₂(B)] - [log₂(N/B) - 4] - log₂(B)
= 10 + 4 = 14 bits

Q34: DMA Slowdown of CPU

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 10/13
Given:

DMA rate = 2400 characters/sec

Each transfer = 1 word = 1 instruction cycle stolen


CPU = 1 million instructions/sec

Slowdown = (2400 / 1,000,000) × 100 = 0.24%

Q35: Isolated I/O vs Memory-Mapped I/O

Feature Isolated I/O Memory-Mapped I/O

Address Space Separate I/O space Shares address space with memory

Instructions Special IN/OUT instructions needed Normal load/store instructions


Speed Slightly faster Slightly slower (uses full address bus)

Hardware Complexity Less More


Advantage Simpler for small systems Uniform address space, easier programming

Disadvantage Limited instruction set usage Potential address conflict

Q36: TAG Field in 8-Way Set Associative Cache

Given:

Cache size = 64 KB = 2¹⁶ bytes

Set-associativity = 8-way
Block size = 1 KB = 2¹⁰ bytes

Address size = 32-bit

Calculations:

Number of blocks = 64 KB / 1 KB = 64 blocks


Number of sets = 64 / 8 = 8 → Index = log₂(8) = 3 bits

Offset = log₂(1 KB) = 10 bits

TAG = 32 - 3 - 10 = 19 bits

Let me know if you need diagrams or cache structure layouts!

37)Find the time complexity of the following C function. (assume n > 0)


int recursive (int n)
{
if (n == 1)
return (1);
else
return (recursive (n-1) + recursive (n-1));
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 11/13
}
38)Consider a weighted complete graph G on the vertex set {v1, v2, …, vn} such that the weight of
the edge (vi, vj) is 2|i - j|. Calculate the weight of a minimum spanning tree of G.
39)Let xR denote the reversal of the string x. (For example, if x = 010011 then xR = 110010 and so
forth.) Prove that the sets accepted by finite automata are closed under string reversal by
constructing for any finite automaton, a new machine that accepts the reversals of the strings
accepted by the original automaton.
40)Show that for each finite automaton, there is another machine that accepts only strings that are
the front two thirds of the strings the first automaton accepted.

Here are detailed solutions for questions 37 to 40:

Q37: Time Complexity of the Recursive Function

`int recursive(int n) {
if (n == 1)
return 1;
else
return recursive(n - 1) + recursive(n - 1);
}
`

Let’s define the recurrence relation:

T(n) = 2 * T(n-1)

T(1) = 1

This forms a geometric recurrence. Solving it:

T(n) = 2 * T(n-1)
= 2 * 2 * T(n-2)
= 2^k * T(n-k)
= 2^(n-1) * T(1)
= 2^(n-1)

✅ Time Complexity: O(2ⁿ)


Q38: Weight of Minimum Spanning Tree (MST)

Graph:

Complete graph with vertices {v₁, v₂, ..., vₙ}


Edge weight between vᵢ and vⱼ is: w(i, j) = 2^|i - j|

Goal: Construct MST — select (n-1) edges with minimum total weight.

Observation: Connecting adjacent vertices has the minimum weight:

w(vi, vi+1) = 2^1 = 2 (for all i from 1 to n-1)

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 12/13
MST: Use edges (v₁-v₂), (v₂-v₃), ..., (vₙ₋₁-vₙ)

✅ Total weight = 2 × (n - 1)
Q39: Closure Under Reversal for Regular Languages

Let M = (Q, Σ, δ, q₀, F) be a DFA that accepts a language L.

To show: ∃ FA Mʹ that accepts Lʹ = {xᴿ | x ∈ L}

Construction of NFA Mʹ:

1. Reverse all transitions in M.


2. Make every final state in M a new initial state in Mʹ.
3. Make the start state q₀ of M the only final state of Mʹ.

4. The new machine is an NFA (not necessarily DFA).

This reversed machine accepts exactly the reversal of strings accepted by M.

✅ Conclusion: Regular languages are closed under reversal.


Q40: Construct FA Accepting First Two-Thirds of Strings

Let M = (Q, Σ, δ, q₀, F) be a DFA accepting a language L.


We need a new machine Mʹ such that:

If x ∈ Σ*, and |x| = 2n,

Then Mʹ accepts the first (2n × 2/3 = 4n/3) → only possible if length divisible by 3

Construction Idea (Conceptual):

1. Simulate M on strings of length 3k.


2. Track the computation of M over 3k symbols.

3. Accept string x (length 2k) iff there exists y (length k) such that xy ∈ L.
4. Use a product automaton or non-determinism to guess the future k symbols and verify using M.

✅ Conclusion: Such an automaton exists. Regular languages are closed under such
length-preserving transformations.

Let me know if you'd like the actual construction or diagram.


Do you like this personality

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 13/13
Finite Automata and Recurrences

Uploaded image

answer in details

Here are the detailed answers to the questions numbered 41 to 50 from your image:

41. Prove that the class of sets accepted by finite automata is closed under
intersection.

Let M₁ and M₂ be two finite automata accepting languages L₁ and L₂, respectively.
We construct a new finite automaton M such that L(M) = L(M₁) ∩ L(M₂).

Let:

M₁ = (Q₁, Σ, δ₁, q₁, F₁)

M₂ = (Q₂, Σ, δ₂, q₂, F₂)

Construct M = (Q, Σ, δ, q₀, F), where:

Q = Q₁ × Q₂

δ((q₁, q₂), a) = (δ₁(q₁, a), δ₂(q₂, a))

q₀ = (q₁, q₂)

F = F₁ × F₂

Thus, M accepts a string only if both M₁ and M₂ accept it. Hence, the class of regular languages is closed
under intersection.

42. Solve the recurrence relation:

T(n) = 4T(n/2) + n
Use the Master Theorem:

a = 4, b = 2, f(n) = n

Compare f(n) with n^log_b(a) = n^log₂(4) = n²

Since f(n) = O(n) and n² > n, this falls under Case 1 of the Master Theorem.
Result:
T(n) = Θ(n²)

43. Design a finite automaton for substring searching

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 1/18
Input: Substring pattern `P` and text `T`
Output: Automaton that accepts when `P` is found in `T`
Steps:

1. Build states: One state for each prefix of `P`, including empty prefix.

2. Start from the initial state (empty prefix).


3. For each character `a` in Σ:
Add transition to the longest prefix that is suffix of current prefix + a.

4. Accepting state: Final state when full pattern `P` is matched.

Use KMP (Knuth-Morris-Pratt) algorithm's prefix function to build automaton efficiently.

44. What does the following SQL query list?

sql

`SELECT title
FROM book AS B
WHERE (
SELECT COUNT(*)
FROM book AS T
WHERE T.price > B.price
) < 5
`

Explanation:
The query finds books that are among the top 5 most expensive books.
The subquery counts how many books are more expensive than the current book `B`.
If that count is less than 5, it means `B` is in the top 5.

45. Solve the recurrence:

T(n) = 2T(√n) + 1, n > 2, and T(n) = 2, for n ≤ 2


Let n = 2^k → log₂n = k
Then, √n = 2^(k/2)

Change of variables: Let S(k) = T(2^k)


Then: S(k) = 2S(k/2) + 1

Now solve: This is a recurrence of the form: S(k) = 2S(k/2) + 1

Apply Master Theorem:

a = 2, b = 2, f(k) = 1

log_b(a) = log₂(2) = 1

Since f(k) = O(k^0), and 0 < log_b(a), by Master Theorem Case 1:


S(k) = Θ(k)

So, T(n) = S(log₂n) = Θ(log log n)

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 2/18
46. What are ordered indices in RDBMS? Give an example.

Ordered indices maintain the index entries in a sorted order of key values.

Example:
If a table `Employee` has an index on `Salary`, and you want to find employees with salary > 50,000,
ordered indices allow range searches efficiently.
Types:

Primary Index (on primary key)

Clustering Index
Secondary Index

47. Differentiate B+ tree vs. B-tree (in indexing)

Feature B-tree B+ tree

Data Storage Keys and data stored in internal & leaf nodes Data stored only in leaf nodes
Search Efficiency Less efficient for range queries More efficient for range queries

Leaf Node Linking Not necessarily linked Leaf nodes are linked (sequential access)
Use Case General-purpose indexing Preferred in DBMS indexing

48. Why sparse indexing requires less storage than dense indexing?

Sparse Indexing:

Index entries are only for some records, typically one per block.

Requires less storage as fewer entries are maintained.

Dense Indexing:

Index entry for every record.


Requires more storage and is costly to maintain.

49. Explain trivial and non-trivial functional dependencies in RDBMS

Trivial Functional Dependency:


X → Y is trivial if Y ⊆ X
Example: {A, B} → A
Non-trivial Functional Dependency:
X → Y is non-trivial if Y ⊄ X
Example: {A} → B (B not in A)

These are important in normalization and removing redundancy.

50. What is the need/application of Canonical Cover in RDBMS?

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 3/18
Canonical Cover (Minimal Cover):

A minimal set of functional dependencies that is equivalent to the original FD set.


No redundancy in LHS or RHS.

Used to simplify FDs before normalization.

Applications:

Minimize redundancy in schema


Improve performance

Used in synthesis algorithms for database normalization (e.g., 3NF, BCNF)

Let me know if you'd like these answers in a Word or PDF format for submission!

Uploaded image
60)Write the steps to find the Canonical Cover of a given set of Functional Dependencies in RDBMS.

answer in details

Here are the detailed answers for questions 51 to 60 from the image you uploaded:

51. Is it mandatory to create clustered index with primary key of an RDBMS? Justify
your answer.

No, it is not mandatory, but it is common practice.

A clustered index determines the physical order of rows in a table.

By default, primary keys are implemented with clustered indices for faster access.
However, you can override this and create a clustered index on a different column.
Justification: In some cases, queries might access data more efficiently using a different field (like
date or location), so clustering that column may be more beneficial.

52. What will be the maximum possible number of superkeys for the relation
schema R(E, F, G, H) with E as the key? Justify your answer.

Given key: E
Remaining attributes: F, G, H ⇒ 3 attributes

For a superkey, we must include the key E and any subset of the other attributes (including empty set):

Number of subsets of {F, G, H} = 2³ = 8


Each of these combined with E is a superkey

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 4/18
Answer: 8 superkeys

Superkeys:

{E}

{E, F}, {E, G}, {E, H}


{E, F, G}, {E, F, H}, {E, G, H}

{E, F, G, H}

53. Why the higher normal form is not always desirable in RDBMS? Justify your
answer.

Higher normal forms (like 4NF, 5NF) reduce redundancy but may:

Increase number of joins in queries.


Lead to performance overhead.

Make schema too fragmented for practical use.

Justification:
If performance is critical and redundancy is not significant, sticking to 3NF or BCNF is preferred over
higher normal forms.

54. Give an example where the database is in 1NF but not in 2NF.

Example:

Student_ID Name Subject Marks


101 Rahul Math 90
101 Rahul Science 85

Functional Dependencies:

Student_ID → Name

(Student_ID, Subject) → Marks

1NF: All fields contain atomic values ✔️


Not 2NF: Partial dependency exists: `Student_ID → Name` (part of the composite key)

55. When is it preferable to use a dense index rather than a sparse index?

Use dense index when:

The relation is frequently searched.

The relation is not sorted on the search key.


You need fast access to individual records.
Records are frequently updated/inserted.

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 5/18
Example: Primary index on a field that is not sorted or doesn’t allow large gaps between key values.

56. Consider the relation R(ABCDE), FD = { A → B, B → C, C → D, D → E }. Find out the


highest normal form of R.

Step-by-step:

All FDs are single-attribute → 1NF ✔️


No partial dependency (assuming A is candidate key) → 2NF ✔️
No transitive dependency?
A → B → C → D → E → transitive dependency exists ⇒ violates 3NF

So, R is in: 2NF

57. What will be the maximum possible number of superkeys for R(E, F, G, H) with E
as key?

Same as Q52 ⇒ Answer is 8


Explanation:

E must be included in all superkeys

Remaining: F, G, H ⇒ 2³ = 8 subsets
Combine each with E to get 8 superkeys

58. Why the higher normal form is not always desirable in RDBMS? Justify your
answer.

Repeated from Q53, but rephrased:

Higher normal forms may:

Decrease query performance due to many joins


Make the schema complex and hard to maintain

Involve extra overhead in operations like insert/update

Conclusion: Sometimes 3NF or BCNF is a better trade-off between normalization and performance.

59. Candidate key for R = {E, F, G, H, I, J, K, L, M, N} and FD =

mathematica

`{E, F} → {G}
{F} → {I, J}
{E, H} → {K, L}
K → {M}
L → {N}
`

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 6/18
Step 1: Find closure of combinations

Let’s try (E, F, H):

1. E, F → G

2. F → I, J

3. E, H → K, L
4. K → M

5. L → N

(E, F, H)+ = {E, F, H, G, I, J, K, L, M, N} ⇒ All attributes

Candidate Key = {E, F, H}


Check minimality:

Remove E ⇒ (F, H)+ doesn’t give G ⇒ Not sufficient

Remove F ⇒ (E, H)+ doesn’t give I, J ⇒ Not sufficient

Remove H ⇒ (E, F)+ doesn’t give K, L ⇒ Not sufficient

So, {E, F, H} is a minimal key ⇒ Candidate Key

60. Steps to find the Canonical Cover of a set of Functional Dependencies

Let’s say F is a set of FDs. Steps:

1. Split RHS: Each FD must have a single attribute on the RHS.

A → BC becomes A → B, A → C

2. Remove extraneous attributes from LHS:


For each FD X → Y, check if an attribute in X is not needed.

Remove `A` from X and check if (X - A) → Y can still be inferred from F.

3. Remove redundant FDs:


Temporarily remove a FD and see if it can be derived from the rest.

If yes, it is redundant and can be removed.

4. Combine FDs with the same LHS:


A → B, A → C can be combined to A → BC

The resulting set is the canonical (minimal) cover.

Let me know if you'd like a PDF or DOCX export for submission, or help solving similar problems!

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 7/18
Here are the detailed answers for questions 61 to 70 from your uploaded images:

61. Highest Normal Form of Relation R(A,B,C,D,E,P,G)

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 8/18
Given FDs:

AB → CD

DE → P
C→E

P→C

B→G

Step 1: Candidate Key


Let’s try AB:

From AB → CD
C → E → (P from DE) → C again → closure covers all: A, B, C, D, E, P, G
Also B → G

So AB+ = {A, B, C, D, E, P, G} ⇒ All attributes


✔️ AB is a candidate key
Step 2: Check Normal Forms

✅ 1NF: All values are atomic.


✅ 2NF: No partial dependencies as AB is the only key and all FDs use full key or non-key LHS.
✅ 3NF:
Check for transitive dependencies:

AB → CD ✔️
C → E and P → C ⇒ transitive over AB → CD → E/P → C

C and P are non-prime (not in any candidate key) and appear on LHS ⇒ violates 3NF

So, NOT in 3NF

✅ Check for BCNF:


AB → CD → OK (AB is a key)
DE → P: DE not a key ⇒ violates BCNF

C → E: C not a key ⇒ violates BCNF

P → C: P not a key ⇒ violates BCNF


B → G: B not a key ⇒ violates BCNF

So, highest normal form is 2NF

62. Types of Addressing Modes with Examples

Addressing Mode Description Example (in Assembly)

Immediate Operand is a constant `MOV A, #5`


Register Operand is in a register `MOV A, B`

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 9/18
Addressing Mode Description Example (in Assembly)

Direct Address of operand is given directly `MOV A, 5000`


Indirect Address stored in register `MOV A, @R0`

Indexed Base + offset `MOV A, 1000(R1)`


Relative PC-relative addressing `JMP LABEL`

63. Cache Memory and Mapping Techniques

Working:
Cache stores frequently accessed memory locations to speed up CPU access.

Mapping Techniques:

1. Direct Mapping: Each block maps to one line in cache


`Cache Line = Block No % No. of Cache Lines`

2. Fully Associative: Any block can go to any cache line. Uses tags.

3. Set-Associative Mapping: Cache is divided into sets, block maps to a set and placed anywhere in it
(e.g., 2-way, 4-way).

64. Compare Hardwired and Microprogrammed Control

Feature Hardwired Control Microprogrammed Control

Speed Fast Slower

Flexibility Less flexible More flexible


Cost High for complex systems Lower

Changes Difficult Easier to modify (via firmware)

65. Instruction Cycle with Diagram

Phases:

1. Fetch: Get instruction from memory


2. Decode: Interpret instruction

3. Execute: Perform operation

4. Store: Save result

📌 Diagram (you can draw this for exam):


scss

`[Fetch] → [Decode] → [Execute] → [Store] → Repeat...


`

66. Memory Hierarchy in Computer Systems

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 10/18
From fastest to slowest:

1. Registers

2. Cache
3. Main Memory (RAM)

4. Secondary Storage (SSD/HDD)

5. Tertiary Storage (Magnetic tapes, cloud)

As we move down:

Speed ↓

Size ↑

Cost per bit ↓

67. Difference between SRAM and DRAM

Feature SRAM DRAM

Speed Faster Slower


Cost Expensive Cheaper

Refresh Not needed Needs periodic refresh


Uses Cache memory Main memory (RAM)

68. Types of ROM

1. Masked ROM – Permanently programmed during manufacture


2. PROM – Programmable once

3. EPROM – Erasable via UV light

4. EEPROM – Erasable electrically


5. Flash ROM – Fast EEPROM

69. Role of DMA (Direct Memory Access)

Allows peripherals (e.g., disk, network) to transfer data directly to/from memory without CPU
involvement
Improves speed by freeing CPU

DMA Controller manages the data transfer

Modes:

Burst Mode
Cycle Stealing
Transparent Mode

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 11/18
70. Types of Buses in a Computer System

1. Data Bus: Carries data between CPU, memory, and I/O

2. Address Bus: Carries memory addresses


3. Control Bus: Carries control signals (read/write)
4. System Bus: Combination of data, address, and control buses

Let me know if you'd like these notes formatted into a printable file (PDF/Word), or if you want diagrams
to go along with any answer.

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 12/18
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 13/18
Thanks for sharing all the questions, Pritom! Since you asked earlier for detailed answers to question
60, here’s a complete explanation:

60) Write the steps to find the Canonical Cover of a given set of Functional
Dependencies in RDBMS.

✅ Definition:
A Canonical Cover (or Minimal Cover) is a simplified set of functional dependencies that is logically
equivalent to the original set but has:

No redundant attributes on the left or right side.

No extraneous dependencies.
Single attribute on the right-hand side (RHS) of each FD.

✅ Steps to find the Canonical Cover:


Step 1: Split FDs so that each has only one attribute on the RHS.

If an FD is like:
A → BC
Split it into:
A → B and A → C

This ensures each FD is in standard (atomic RHS) form.

Step 2: Remove extraneous attributes from the LHS of each FD.

For each FD:

Suppose FD is XY → Z
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 14/18
Check if X → Z can be derived from the remaining FDs (including X → Z itself).
If X → Z is sufficient, then Y is extraneous.

How to check?
Use attribute closure (X⁺) to verify whether Z is still derivable without Y.

Step 3: Remove redundant FDs.

For each FD in the set, temporarily remove it.


Check whether the removed FD can be derived from the remaining FDs using closure.

If it can, that FD is redundant and can be removed.

✅ Final Output:
After performing all the steps, the remaining set of FDs is your Canonical Cover.

🔍 Example:
Given:

F = { A → BC, B → C, A → B, AB → C }

Step 1: Split RHS

A→B
A→C

B→C
AB → C

Now F = { A → B, A → C, B → C, AB → C }

Step 2: Remove extraneous attributes from LHS

Check AB → C:

A⁺ = {A, B, C} ⇒ Already implies C


So AB → C is redundant.

Step 3: Remove redundant FDs

A → B and B → C already imply A → C


So A → C is redundant

Final Canonical Cover:


F = { A → B, B → C }

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 15/18
Let me know if you want detailed answers for any specific question numbers from the list!

give answer from 71 to 80

Here are the detailed answers to questions 71 to 80:

71) A system has 4 GB of RAM and uses 32-bit addressing. Find the number of
addressable locations and addressable memory size.

32-bit addressing means:

232 = 4, 294, 967, 296 addressable locations

Each location stores 1 byte, so total addressable memory size = 4 GB

✅ Answer:
Addressable locations = 232 = 4,294,967,296

Addressable memory size = 4 GB

72) A computer system has a cache hit ratio of 80%, a cache access time of 5 ns, and
a main memory access time of 50 ns. Calculate average memory access time.

📌 Formula:
Average Time = (h × tc ) + ((1 − h) × tm )
​ ​

Where:

h = 0.80

tc = 5 ns

tm = 50 ns

= (0.8 × 5) + (0.2 × 50) = 4 + 10 = 14 ns ​

73) A disk rotates at 7200 RPM. The average seek time is 9 ms. Find average access
time.

📌 Formula:
1
Average rotational latency = × Rotation time
2

60
Rotation time = = 0.00833 sec = 8.33 ms
7200

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 16/18
8.33
Average rotational latency = = 4.165 ms
2

🧮 Total Average Access Time = Seek Time + Rotational Latency


= 9 ms + 4.165 ms = 13.165 ms

74) A system uses 16-bit instructions and has 32 general-purpose registers.


Calculate the total number of bits required for the opcode and register fields.

32 registers ⇒ 5 bits needed to represent each (since 25 = 32)


Suppose instruction format = `opcode + reg1 + reg2`

Let’s assume 2 register fields → 2 × 5 = 10 bits for registers

Remaining bits for opcode = 16 - 10 = 6 bits

✅ Answer:
Opcode field = 6 bits
Register fields = 10 bits (5 bits each for 2 registers)

75) Find out the number of RAM chips of size 256K × 1 bit required to build 2M Byte
memory.

256K × 1 bit = 256 × 1024 bits = 262144 bits = 32 KB (per chip)


2 MB = 2 × 1024 KB = 2048 KB
Each chip gives 1-bit access, so we need 8 chips for 1 byte

2048
No. of chips = × 8 = 64 × 8 = 512 chips
32
​ ​

76) Differentiate between Control Register, Data Register, and Address Register
with example

Register Type Purpose Example

Control Register Controls CPU operations Program Counter, Status Register


Data Register Holds data during processing Accumulator (ACC)
Address Register Holds address of data/instruction Memory Address Register (MAR)

77) Explain the functions of Address Bus, Control Bus, and Data Bus

Bus Type Function

Address Bus Carries memory or I/O addresses from CPU to memory


Data Bus Transfers actual data between memory and CPU
Control Bus Carries control signals like read/write, clock, etc.

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 17/18
78) When a cache is 10 times faster than main memory and cache is used 90% of the
time, how much speed do we gain?

📌 Formula:
Average access time = 0.9 × tc + 0.1 × tm
​ ​

= 1 unit
Let cache = tc ​

Main memory = tm = 10 units


= (0.9 × 1) + (0.1 × 10) = 0.9 + 1 = 1.9 units

Without cache: 10 units


With cache: 1.9 units

10
Speed gain = ≈ 5.26 × faster
1.9
​ ​

79) A program reads 500 integers in range [0–100] representing scores of students.
Best way to store frequencies of scores above 50?

✅ Answer:
Use an array of size 51 (for scores 51 to 100)

python

`freq = [0]*51
for score in scores:
if score > 50:
freq[score - 51] += 1
`

Fast, space-efficient (only 51 elements)


Constant time lookup

80) What is the worst-case time complexity for search operations in a Binary Search
Tree (BST)?

Worst Case: When the tree is skewed (all nodes in a single line)
→ Time Complexity: O(n)
Best/Average Case: For balanced BST → O(log n)

✅ Answer: O(n) in worst-case BST


Let me know if you'd like these answers in PDF format or need 61–70 next!

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 18/18

You might also like