Daffodil International University
Department of Computer Science and Engineering
Faculty of Science & Information Technology
Midterm Examination, Spring 2021 @ DIU Blended Learning Center
Course Code: CSE134 (Day), Course Title: Data Structure
Level: 1 Term: 3 Section: All
Instructor: All Modality: Open Book Exam
Date: Sunday, 7 March, 2021 Time: 09:00am -11:30am
Two and half hours (2:30) to support online open/case study based assessment Marks: 25
Part A: Code Visualization and draw 3+3
a) Draw the node and pointer represented by the following code:
struct Node {
int p;
float q;
char r;
struct node *n;
};
typedef struct Node node;
node *head , *tail ;
head = (node *) malloc( sizeof(node));
tail =(node *) malloc( sizeof(node));
head -> p = 17; head->q =4.5; head->r=’H’;
tail -> p = 20; tail->q= head -> p; tail->r = ‘T’;
head->n = NULL; tail->n = head;
b) Consider an empty stack. Now do the following operations and draw your visualization: push(5), push(6),
push(7), push(8), pop(8), push(15), push(45), pop(45), pop(15), pop(7), pop(6), pop(5), push(2) and last of all, draw
the final stack.
Part B: Code Writing from Visual Map
(a) Consider the following link list:
head
8 • 3 • 6 • 9 • Ø
The “Node” contains integer data member “info” and a pointer member “link”. Write function for the following
operations:
(1) Find a data item in the list, and then insert a new node next to it.
(2) Delete a node from nth position of the list.
4+4+3+3
(b) Write code for the following: (only required code for the Node)
n m q n m q
N 2.5 • M 3.5 • Ø
(c) Write code for the following: (write code to create node and assign as per the following)
d e f d e f
D • • E • • Ø
PART C: Stack Application 2.5+2.5
Convert the following:
(a) Convert Expression U+ (Y/Z- (Q*R^S)/T)*X to prefix.
(b) Convert Expression -+*^XYZS/*TU+VW to postfix.