National Institute of Technology Rourkela: 1. Starting With The Empty Stack, Suppose We PUSH The
National Institute of Technology Rourkela: 1. Starting With The Empty Stack, Suppose We PUSH The
National Institute of Technology Rourkela: 1. Starting With The Empty Stack, Suppose We PUSH The
1. Let S be a stack of size n ≥ 1. Starting with the empty stack, suppose we PUSH the
first n natural numbers in sequence, and then perform n POP operations. Assume
that PUSH and POP operations take x seconds each, and y seconds elapse between
the end of one such stack operation and the start of the next operation. For m ≥ 1,
derive the stack-life of m as the time elapsed from the end of PUSH(m) to the start
of the POP operation that removes m from S. Derive an expression for average
stack-life of an element of this stack. [4]
2. Suppose a positive integer number is stored using a 2-way linked list, in every node
of which a digit of the number is stored. Write an algorithm to check if the stored
number is a palindrome. [4]
4. Write the formula for finding storage location of any non-zero integer in a 2D lower
triangular matrix of size 10 × 10 for both row and column major order. None of
the elements with value zero, in the above matrix, occupy any space. Assume that
indexing starts from 0 for both rows and columns and base address of the memory
starts at 300. What is the storage address of A[3][2] and A[4][1] for both row and
column major order representation of matrix assuming every integer occupies 2
bytes in memory. [3]
2
(a) Remove the nodes from nth position to 1st position and insert them in a new
linked list L2 in the order they are removed.
8. Convert the following expression to Reverse Polish notation using proper data
structure:
(A ∧ (B ∨ C ∧ ¬D ∨ E) ∨ F ) → G
The following table shows the precedence levels (1: Highest, 4: Lowest)
Operator(s) Precedence level
¬ 1
∧ 2
∨ 3
→ 4
Mention the content of the associated data structure in each step. [3]