Second CIA (9 November 2021)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

SASTRA Deemed University

School of Computing
Second CIA
(9 November 2021)
Course Code: CSE103 Duration: 60 minutes
Course Name: Data Structures Max Marks: 20
Class: II B.Tech CSE
Answer all the questions 2 X 10 = 20 Marks

1.a) Trace the steps in converting the given infix expression into postfix expression using
stack. ( 4 Marks)

Expression: ((5+4)*(2-7) +6)/ (3+4)

1.b) Show the implementation of the Polynomial 5x3 + 7x2 – 4x – 6 using Singly Linked List.
The node structure must include fields for the coefficient and the power of x in addition to the
link field. (2 Marks)

1.c) Show the output of the following algorithm if Q consists of elements 10, 20, 30, 40 and
50 and S consists of elements from Top to Bottom: 5, 15, 25, 35, 45, 55, 65 (4 Marks)

Algorithm sample(Q, S)

Q is a queue consisting of n elements.


S is a stack consisting of m elements.

1. Create a DLL named list ( an ordered list)


2. loop until Q is not empty
2.1.1. x = Q.Dequeue()
2.1.2. list.insert(x)
2.1.3. y = S.Pop()
2.1.4. list.insert(y)
3. end loop
4. loop until S is not empty
4.1.1. y = S.pop()
4.1.2. list.insert(y)
5. end loop
6. loop until list is not empty
6.1.1. print list head data
6.1.2. delete list head
7. end loop
2.a) Create a Binary Search Tree from the data in the following order: ( 3 Marks)

903, 425, 1008, 317, 999, 379, 1000, 406, 1003, 398, 1001.

2.b) Show the BST after deleting 1000 and 903 from the result of question 2a.[Hint: Use In-
order Successor for replacement.] ( 2 Marks)

2.c) Convert the following General tree into a Binary tree. ( 2 Marks)

E
D
B C

N O
K L M
F G H I J

2.d) Draw the Binary tree provided the following facts are known about the tree: (3 Marks)

• The tree has 9 nodes.


• Preorder traversal gives “ ibacdfegh”
• Inorder traversal gives “abdciefgh”.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy