ESP-VI Part C
ESP-VI Part C
answer in details
Let's go through each of the five questions in the image step by step:
Step-by-step Insertion:
1. Insert 1
Heap becomes: `10, 8, 5, 3, 2, 1`
Since 1 < 5 (its parent), no swapping needed.
2. Insert 7
Heap becomes: `10, 8, 5, 3, 2, 1, 7`
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 1/4
7 > 5 (its parent), swap with 5 → `10, 8, 7, 3, 2, 1, 5`
`10, 8, 7, 3, 2, 1, 5`
Task: Move the last element of a singly linked list to the front.
C Code:
`struct Node {
int data;
struct Node* next;
};
secondLast->next = NULL;
last->next = head;
head = last;
return head;
}
`
Given operators:
Expression: `7 ↧ 1 ∨ 3 ↧ 4 ∨ 3 ∧ 2`
Assuming the exact parse tree needs evaluation based on those rules, but for clarity without the
operator semantics, only the operator precedence and associativity is considered.
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 2/4
Example parse tree:
markdown
` ∨
/ \
↧ ∧
/ \ / \
7 1 3 2
/
4
`
This structure depends on exact operator definitions, but parsing happens in this precedence-based
order.
Let’s compute:
`foo(345, 10)`
Base `r = 10`, so this gives the sum of digits in base 10 of 345 → `3 + 4 + 5 = 12`
`foo(513, 2)`
This gives the sum of digits in base 2 of 513
`513 in binary = 1000000001` → sum of digits = `1 + 0 + ... + 1 = 2`
Final Answers:
`foo(513, 2) = 2`
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 3/4
Minimum comparisons: `n log₂n - n + 1`
(These are standard bounds for the number of comparisons in merge sort.)
✅ Summary:
Q.No Topic Final Answer
Let me know if you want diagrams or dry run examples for any of these!
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 4/4
DFS and AVL Explanation
Uploaded image
Uploaded image
Uploaded image
answer in details
Question: Evaluate how many nodes (apart from `s`) does the Depth First Search (DFS) algorithm
discover before discovering `t` when starting from `s`.
Approach:
From the image, the graph is layered. The nodes are named `u[i,j]` and the edges are directional.
Starting from `s`, DFS will go deep into one path until it reaches a dead end or the target.
Steps:
Answer: 4 nodes
Lexicographic order input: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec
Steps:
markdown
`1. Apr
2. Aug
3. Dec
4. Feb
5. Jan
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 1/19
6. Jul
7. Jun
8. Mar
9. May
10. Nov
11. Oct
12. Sep
`
(You can visualize the AVL tree with rotations at every imbalance and compute balance factors at each
stage.)
Would you like a fully drawn tree with balance factors for each step?
Given elements: a0 = 1, a1 = 5, a2 = 7, a3 = 8, a4 = 9, a5 = 2
Operations Summary:
Stack: LIFO
Queue: FIFO
Dequeue `8`, push into `S` → `S: [..., 8]`, `Q: [9, 2]`
Dequeue `9`, push into `S` → `S: [..., 9]`, `Q: [2]`
Dequeue `2`, push into `S` → `S: [..., 2]`, `Q: []`
Given:
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 2/19
Cache = 100 ns
Write-through protocol
yes
256 blocks
8 words per block
Main memory is addressable
16-bit address
4K blocks in memory
Goal: Calculate bits for TAG, BLOCK/SET, and WORD fields for various mapping techniques.
Memory Breakdown:
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 3/19
Total addressable memory = 4K blocks × 8 words/block = 32K words
Memory size = 215 (since 32K = 2¹⁵), hence address size = 15 bits
TAG field:
Total = 15 bits
TAG = 5 bits
SET/Block Index = 7 bits
WORD (Offset) = 3 bits
Would you like direct comparison with direct-mapped and fully associative too?
RAM Size:
ROM Size:
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 4/19
Memory Map in Hexadecimal:
RAM range:
Size = 2K = 0x0800 ⇒
RAM: `0x0000` – `0x07FF`
ROM range:
Starts from `0x0800`, Size = 4K = 0x1000 ⇒
ROM: `0x0800` – `0x17FF`
Given:
4-word blocks
1024 words total in cache
Address size:
Break address:
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 5/19
Question 13: Turing Machine for Palindrome
Logic:
1. Read first symbol, move to end, check match with last symbol.
2. If match: mark both symbols (e.g., replace with X), return to start, repeat.
Logic:
Input:
Output:
Fibonacci(n) in unary
Basic Idea:
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 6/19
Use multiple tracks or symbols to remember partial sums
Note: This TM will be very complex; often converted into 3-tape TM for efficiency.
Would you like me to write transition functions or draw Turing diagrams for Questions 13–15?
Let me know which parts you'd like expanded!
yes
Perfect! Let's go through Questions 13, 14, and 15 with transition functions and logic for the Turing
Machines (TMs) in detail.
High-level Idea:
States:
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 7/19
Current State Read Symbol Write Move Next State
`q3` ␣ ␣ R `q0`
(Similarly for `q1b`, `q2b`…)
This TM checks palindromes by marking and verifying matching symbols from both ends.
Logic:
1. Find an `a`, mark it (`X`), and search for a `b` to match → mark it (`Y`).
2. Repeat until no unmarked `a` or `b` remains.
Transition Overview:
`q0` ␣ ␣ - `q_accept`
`q1` ␣ ␣ - `q_reject`
`q2` `b`/`Y`/`X` Same R `q2`
`q2` ␣ ␣ - `q_reject`
`q3` `X`/`Y`/`a`/`b` Same L `q3`
`q3` ␣ ␣ R `q0`
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 8/19
✅ Question 15: TM to Compute Fibonacci(n)
Input: `n` in unary (e.g., 3 = `|||`)
Logic Overview:
We simulate:
python
`fib(0) = 0
fib(1) = 1
fib(n) = fib(n-1) + fib(n-2)
`
css
Steps:
Result
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 9/19
Iterations via state machine loops
Uploaded image
Uploaded image
answer in details
Great! Let’s break down and answer questions 16 to 25 in detail, one by one:
Transitions:
Logic:
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 10/19
2. Final result is unary of length `n + m`.
Transition Highlights:
Example:
Input: `111B11`
Output: `11111`
For read-through:
Hit: 100 ns
Since write always goes to main memory → only read hits count.
Eff ective Hit Ratio = 0.7 × 0.9 = 0.63
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 11/19
✅ Q19: CPU Access Time (200 Accesses)
Hits = 160, Misses = 40
Total Time = (160 × 10) + (40 × (10 + 100)) = 1600 + 4400 = 6000ns
Average = 6000/200 = 30ns
Available time:
= 2ms–0.8192ms = 1.1808ms
1.1808
2
× 100 ≈ 59
1. Interrupt occurs
2. CPU finishes current instruction
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 12/19
8. Restore saved state
9. Resume execution
Roles of ISR:
q0 → start
q1 → seen `1`
q2 → seen `10`
q3 → accept on `101`
sql
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 13/19
sql
`SELECT e.emp_name
FROM Employees e
JOIN (
SELECT department_id, AVG(salary) AS avg_salary
FROM Employees
GROUP BY department_id
) dept_avg ON e.department_id = dept_avg.department_id
WHERE e.salary > dept_avg.avg_salary;
`
Efficiency Tips:
ALU
Registers (A, B, C, D, E, H, L)
Control Unit
Address/Data bus
Let me know which questions you'd like visual diagrams, FSMs, or Turing machines drawn for!
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 14/19
then pumping occurs.
On which characteristic of the machine does this value depend? Does pumping occur even
otherwise? Demonstrate.
29)Why BCNF is stricter than 3NF in RDBMS? Justify your answer.
30)Show with an example that Canonical cover of a set of Functional Dependencies may not be
unique.
31)Relation R has eight attributes (ABCDEFGH) fields of R contains only atomic values. F = {CH -> G, A
-> BC, B -> CFH, E -> A, F -> EG} is a set of functional dependencies (FDs). How many candidate keys
does the relation R have (Need to show every steps) ?
32)Consider a relation scheme R = (A, B, C, D, E, H) on which the following functional dependencies
hold: {A–>B, BC–> D, E–>C, D–>A}. What are the candidate keys of R (Need to show every steps)?
Working:
Advantages:
Efficient pipelining.
Simpler control unit (hardwired).
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 15/19
Each block of main memory maps to exactly one cache line.
Fast, but causes more collisions.
3. Set-Associative Mapping:
If a language is regular, then any string `s` in the language of length ≥ p (pumping length) can be split
into `xyz` such that:
`|y| > 0`
`|xy| ≤ p`
`∀ i ≥ 0`, `xy^i z ∈ L`
Depends On:
Diagram:
For string length > number of states, pigeonhole principle → a state must repeat → loop → pumping.
Example:
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 16/19
✅ Q29: Why BCNF is Stricter than 3NF
3NF Condition:
X is a superkey, or
A is a prime attribute.
BCNF Condition:
Why stricter?
Example:
Example:
Let F = { A → B, A → C }
{ A → BC }
{ A → B, A → C }
Both are minimal and imply the same closure, but structurally different.
Thus, canonical cover may not be unique.
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 17/19
Try E+:
E→A
A → BC
B → CFH
CH → G
⇒ E+ = {E, A, B, C, F, H, G}
Try E and B:
E→C
BC → D
D→A
A→B
So E, B → C → D → A → B
EB+ = {E, B, C, D, A}
Still missing H
Try E, B, H:
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 18/19
✅ EH is also a candidate key
Check for more:
Try E and C: E → C
No path to B
Final check: ✅ Candidate Keys: EH and EBH
Let me know if you'd like diagrams, closures, or SQL examples for any specific question!
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 19/19
Normalization and Functional Dependencies
answer in details
Given:
Functional Dependencies:
F1 → F3
F2 → F4
(F1, F2) → F5
To determine the candidate key, check which attributes determine all others.
F1 and F2 together determine F3, F4, F5.
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 1/15
1NF: No multivalued or repeating groups — assumed true.
2NF: No partial dependency on a part of the primary key.
Answer:
The highest normal form is 1NF because there are partial dependencies on the primary key (F1, F2),
which violates the condition of 2NF.
Given:
Functional Dependencies:
rollNo → name
Candidate Key:
1NF: Satisfied.
2NF: No partial dependencies — each non-prime attribute (grade) is fully functionally dependent
on the full key.
No transitive dependencies.
Hence, relation is in 3NF.
Answer:
The relation is in 3NF. All non-prime attributes are fully functionally dependent on the candidate key,
and no transitive dependencies exist.
Candidate Minimal set of attributes that can `rollNo` and `studentID` can both be candidate
Key uniquely identify a tuple. keys
plaintext
1. α+ := α
2. repeat
3. for each functional dependency X → Y in F do
4. if X ⊆ α+ then
5. α+ := α+ ∪ Y
6. end if
7. until no change in α+
8. return α+
`
Example:
F = { A → B, B → C }
Find closure of A:
A+ = {A}
A → B → add B
B → C → add C
A+ = {A, B, C}
Canonical Cover:
A minimal set of functional dependencies that preserves the original dependencies without redundancy.
Applications:
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 3/15
38. Dense vs Sparse Index
Dense Index:
Has an index record for every search-key value in the data file.
Faster for searching but takes more space.
Sparse Index:
Answer:
Dense index is preferable when fast retrieval is required and storage overhead is not a major concern.
Comparison:
DMA: Best for high-speed data transfer with minimal CPU usage.
Let me know if you want these as a formatted document or need explanations in simpler terms!
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 4/15
Here are detailed answers for questions 40 to 50 from your uploaded image:
Instruction Formats define how instructions are represented in binary. Types include:
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 5/15
Performance Improvement Methods:
Instruction Pre-fetching
Branch Prediction
Out-of-Order Execution
Hazard Detection and Resolution
Super-scalar Architecture
Using buffers/register forwarding
Paging:
Segmentation:
Advantages:
Disadvantages:
Common Levels:
Case Study:
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 6/15
A data center using RAID 5 for 5 disks. If one fails, data is rebuilt using parity.
Working:
Advantages:
Increased performance
Resource sharing
Better throughput for multitasking systems
Analysis:
Given:
Memory Organization:
Use address lines A0 to A12 for addressing within a chip (13 bits = 8KB)
Use additional 3 bits (A13 to A15) for chip selection.
Given:
Set-Associative: 4-way
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 7/15
(b) For 32-bit address:
Tag = 32 - 6 - 6 = 20 bits
Given:
Clock = 2 ns
Secondary Storage:
Floating-point pipeline:
4 processors
Each takes 40 ns
Latency = 4 × 50 = 200 ns
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 8/15
Time = 200 + (200 - 1) × 50 = 10,150 ns = 10.15 µs
Non-volatile memory
Use in processors:
Let me know if you want all this compiled into a PDF/Word document or need a simplified version!
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 9/15
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 10/15
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 11/15
answer in details
50. What is EPROM? How long for 200 operations on 4 processors with 10ns cycle
time?
Non-volatile memory.
Data can be erased using UV light and reprogrammed.
Used for storing firmware.
4-stage pipeline
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 12/15
markdown
` 30
/ \
20 39
/ \ / \
10 25 35 42
\ /
15 23
`
Post-order traversal:
10, 15, 23, 25, 20, 35, 42, 39, 30
Proof:
Example:
mathematica
`Graph:
A—B—C
Edges = 2
Deg(A)=1, Deg(B)=2, Deg(C)=1
Sum = 1+2+1 = 4 = 2×2
`
Resulting Pre-order (after building BST): 14, 15, 9, 4, 3, 5, 7, 18, 16, 17, 20
S0 —1→ S1
S1 —0→ S2
S2 —1→ S3
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 13/15
Design for 00101: Add more states accordingly.
(b) Algorithm to build FA from substring:
NFA Design:
DFA Conversion:
Build full table of transitions from every possible state on input {0,1}
(b) Accept strings matching aⁿbⁿ (n ≥ 0): This is a Context-Free Language, not regular, so FA cannot
recognize it.
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 14/15
Use modulo-3 tracking states:
q0: remainder 0 (accepting)
q1: remainder 1
q2: remainder 2
Transitions based on binary input (0/1)
Let me know if you want diagrams or automata drawn for any question, or a Word/PDF version
compiled!
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 15/15