ESP-Assignments
ESP-Assignments
The
level-order traversal of the heap is given below: 10, 8, 5, 3, 2. Two new elements 1
and 7 are inserted in the heap in that order. Evaluate the level-order traversal of the
heap after the insertion of the elements.
2. The C function takes a singly linked list as an input argument. It modifies the list by
moving the last element to the front of the list and returns the modified list.
Implement the above function.
3. Consider two binary operators ↑ and ↓ with the precedence of operator ↓ being lower
than that of the operator ↑. Operator ↑ is right associative while operator ↓ is left
associative. Evaluate the parse tree for the expression (7 ↓ 343 ↓ 2).
4. Consider the following recursive C function that takes two arguments:
5. unsigned int foo (unsigned int n, unsigned int r) {
6. if (n > 0) return ((n % r) + foo(n / r, r));
7. else return 0;
8. }
Evaluate the return values of the function foo when it is called foo(345, 10) and
foo(513, 2).
Write a query to find the top 5 customers who have spent the most on purchases in the last 6
months.
20. Analyze different types of memory mapping techniques used in modern computer
systems.
21. 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.
22. Solve the recurrence relation: T(n) = 4T(n/2) + n.
23. Develop an algorithm to design finite automata for substring searching.
24. Explain canonical cover in relational databases and its application.
25. Prove that regular languages are closed under concatenation.
26. Design a DFA that accepts strings over {a, b} where the number of 'a's is one less
than the number of 'b's.
27. Compare and contrast BCNF and 3NF in RDBMS.
28. Given a relation schema R(E,F,G,H) with E as the key, find the maximum possible
number of superkeys.
29. Prove that a language of the form L = {aⁿ² | n ≥ 0} is not regular.
30. Evaluate the weight of a minimum spanning tree for a given weighted complete
graph.
31. Compare hardwired control and microprogrammed control in CPU architecture.
32. Explain the steps involved in the fetch-decode-execute cycle of a CPU.
33. Illustrate different types of ROM and their applications.
34. Differentiate between SRAM and DRAM in terms of speed, cost, and power
consumption.
35. Analyze the role of DMA (Direct Memory Access) in I/O operations.
36. Find the time complexity of a given recursive function.
37. Show that the class of sets accepted by finite automata is closed under intersection.
38. Implement a Turing machine that recognizes all even-length palindromes.
39. Compute the effective access time if the cache hit ratio is 90%, cache access time is
10 ns, and main memory access time is 100 ns.
40. Design a finite automaton to recognize strings over {0,1} that contain at least two
consecutive '1's.
41. Explain serial access memory and its real-world applications.
42. Describe memory hierarchy with an example.
43. Explain Chomsky hierarchy and its different language classes.
44. Illustrate how cache memory mapping works with an example.
45. Write an SQL query to determine the employees earning more than the department
average.
46. Given a direct mapped cache of size 16 KB, calculate the number of tag bits and the
tag directory size.
47. Define recursive languages and provide examples.
48. Compare Turing decidable and Turing recognizable languages.
49. Explain page replacement algorithms and analyze their performance.
50. Discuss indexed file allocation and its advantages.
51. Implement a suffix tree for a given string and analyze its efficiency.
52. Given a set of functional dependencies, find the candidate key and highest normal
form.
53. Design an NFA for strings ending with "101".
54. Compare deterministic and non-deterministic pushdown automata.
55. Design an NFA that recognizes the language of all strings over {a, b} that start and
end with the same symbol.
56. Explain Greibach Normal Form (GNF) and how a CFG can be converted into GNF.
57. Explain unit productions in CFG and how they can be eliminated.
58. Given a state transition table, derive the equivalent DFA.
59. Write an SQL query to find employees with no assigned projects.
60. Analyze different types of bus structures in computer architecture.
1. Let T(n) be the number of different binary search trees on n distinct elements.
Analyze its complexity.
2. Find the postfix expression for the infix expression A + B * (C + D)/E + F * G.
3. Postorder traversal of a given binary search tree T produces the sequence: 10, 9, 23,
22, 27, 25, 15, 50, 95, 60, 40, 2. Find the inorder traversal.
4. The following postfix expression is evaluated using a stack: 8 2 3 ∧ / 2 3 * + 5 1 * −.
Find the top two elements after evaluating the first *.
5. Analyze the output of the following C function:
6. int f(int * a, int n) {
7. if (n <= 0) return 0;
8. else if(*a % 2 == 0)
9. return *a + f(a + 1, n - 1);
10. else
11. return *a - f(a + 1, n - 1);
12. }
13. Analyze the output of the following C function:
14. int fun(int n, int * f_p) {
15. if (n <= 1) {
16. *f_p = 1;
17. return 1;
18. }
19. int t = fun(n - 1, f_p);
20. int f = t + *f_p;
21. *f_p = t;
22. return f;
23. }
24. Identify and fix the error in a given C program that attempts to locate an element in an
array using binary search.
25. The preorder traversal of a binary search tree is 15, 10, 12, 11, 20, 18, 16, 19.
Evaluate the postorder traversal.
26. Write an algorithm to reverse a singly linked list.
27. Write an algorithm to delete an element from a singly linked list if available.
28. Write an algorithm to sort a singly linked list in descending order.
29. Suppose a circular queue of capacity (n – 1) elements is implemented with an array of
n elements. Write an algorithm to detect whether the queue is full or empty.
30. Consider a hash table with 100 slots using chaining. Assuming simple uniform
hashing, calculate the probability that the first 3 slots are unfilled after 3 insertions.
31. A computer uses RAM chips of 1024 x 1 capacity. How many chips are needed for
16K bytes?
32. A 4-way set-associative cache memory uses blocks of four words. Compute all
necessary parameters to construct the cache memory.
33. Consider a memory hierarchy with cache, main memory, and virtual memory. Given
cache and main memory access times, calculate the average access time.
34. Given physical memory of 2GB, with cache containing 2K words, specify how
address partitioning changes in direct-mapped and 2-way set-associative caches.
35. Consider a direct-mapped cache of size 32KB with block size 32 bytes. CPU
generates 32-bit addresses. Find the number of bits needed for addressing block in
cache and the number of tag bits.
36. A main memory unit with capacity 4MB uses 1M × 1-bit DRAM chips. Compute
the time required for one refresh operation on all cells.
37. Create a DFA that recognizes strings over {a, b} where the number of 'a's is one less
than the number of 'b's.
38. Design a DFA that accepts strings over {0,1} containing an even number of both '0's
and '1's.
39. Consider the context-free grammar:
40. S --> aSb | X
41. X --> aX | Xb | a | b
42. Draw the DFA for the language L = {w | w does not contain three consecutive 1s}.
43. Analyze the decidability of problems related to Turing machines.
44. Provide a regular expression and CFG for *L = {x ∈ {0,1} | x starts and ends with
different symbols}**.
45. Give a Regular Expression and DFA for *L = {x ∈ {0,1} | x ends with 1 and does not
contain the substring 00}**.
46. Design an NFA recognizing all strings over {0,1} containing at least two consecutive
'1's.
47. Develop an NFA recognizing all strings over {a, b} that start and end with the same
symbol.
48. Investigate closure properties of languages under various operations in Chomsky
hierarchy.
49. Assume a 2MHz processor with 0.5% cycles used for DMA. Calculate the data
transfer rate.
50. A cache memory has capacity N words and block size B. Compare direct-mapped
and set-associative organizations.
51. A DMA controller transfers 16-bit words from a 2400 baud device. Compute CPU
slowdown.
52. Compare isolated I/O and memory-mapped I/O.
53. An 8-way set-associative cache of size 64KB with 32-bit addressing is given.
Compute TAG field size.
54. Find the time complexity of:
55. int recursive (int n) {
56. if (n == 1) return 1;
57. else return (recursive(n-1) + recursive(n-1));
58. }
59. Compute the weight of a minimum spanning tree given a weighted complete graph.
60. Prove that finite automata accept sets closed under intersection.
61. Solve the recurrence relation: T(n) = 2T(√n) + 1.
62. Implement a finite automaton for substring searching.
63. Evaluate a given SQL query that compares prices within a book database.
64. Explain the architecture of the 8085 microprocessor.
65. Discuss the design and working of a RISC processor.
66. Analyze different memory mapping techniques.
67. Demonstrate how pumping lemma applies to a given language.
68. Explain why BCNF is stricter than 3NF.
69. Determine the highest normal form for a given relational schema.
70. Describe the fetch-decode-execute cycle in a CPU.
71. Illustrate pipelining and types of hazards.
72. Explain memory hierarchy with an example.
73. Differentiate between SRAM and DRAM.
74. Explain different types of ROM.
75. Discuss Direct Memory Access (DMA).
76. Explain different types of buses in computer systems.
77. Compute the number of addressable locations in 4GB RAM with 32-bit
addressing.
78. Compute average memory access time for given cache statistics.
79. Compute disk access time given rotational speed and seek time.
80. Compute addressing requirements for a 16-bit instruction set.
81. Find the number of RAM chips required to build 2MB memory.
82. Differentiate Control Register, Data Register, and Address Register.
83. Explain the function of Address Bus, Control Bus, and Data Bus.
84. Compute speedup due to cache given hit rate and access times.
85. Choose the best data structure to store student test scores efficiently.
86. Compute worst-case search complexity in a Binary Search Tree.
87. Show regular languages are closed under string reversal.
88. Prove pumping lemma for a given language.
89. Design a Pushdown Automaton (PDA) for a given context-free language.
90. Convert a CFG to Chomsky Normal Form (CNF).
91. Explain unit productions and how to eliminate them.
92. Given a state transition table, construct an equivalent DFA.
93. Prove that DFA minimization preserves language recognition.
94. Explain page replacement algorithms.
95. Compute cache hit/miss penalties in a memory hierarchy.
96. Compare indexed and direct file allocation.
97. Construct a suffix tree for a given string.
98. Find the highest normal form for a given schema.
99. Design a NFA for L = {w | w contains "101"}.
100. Compare Deterministic and Non-Deterministic PDAs.
101. Design an NFA for strings starting and ending with the same symbol.
102. Explain Greibach Normal Form (GNF).
103. Explain unit productions in CFGs and their removal.