data structures cie paper solution
data structures cie paper solution
SCHEME OF VALUATION - 2
Course Dr. Naveen Kumar K R & Vishwanath V K & Dr. Abdul Razak M.S 3rd Sem/CSE
Semester/Branches
Coordinator Sections: A, B & C
Course Outcomes: After studying this course, students will be able to:
1. Explain different data structures and their applications.
2. Apply Arrays, Stacks and Queue data structures to solve the given problems.
3. Use the concept of linked list in problem solving.
4. Develop solutions using trees and graphs to model the real-world problem.
5. Explain the advanced Data Structures concepts such as Hashing techniques and Optimal Binary Search Trees.
MODULE 3
Write the C functions for Inorder, Preorder, Postorder traversals of Binary tree and
apply the same for the tree given in Figure 1a.
1 a 5 L3 3
Figure 1a:
OR
Provide two rules for constructing threaded binary trees, followed by the C declaration
for a threaded binary tree. Illustrate these concepts with an example using nodes A,
2 a 5 L3 3
B, C, D, E, F, G, H, and I. Additionally, define a C function for inorder traversal of a
threaded binary tree.
MODULE 4
Define Binary Search Tree with an example. Write a C function to insert a node into a
a 5 L2 4
Binary Search Tree.
3
Give the adjacency matrix and adjacency list representation for the graph shown in
b 5 L2 4
following figure 3b.
Figure 3b:
OR
A binary tree has 9 nodes. The inorder and preorder traversals yield the following
sequences of nodes:
a Inorder: E A C K F H D B G 5 L3 4
4 Preorder: F A E K C D H G B
Draw the binary tree.
b What are the methods used for traversing a graph? Explain any one with an example. 5 L2 4
MODULE 5
OR
inorder(root->left);
printf("%d ", root->data);
inorder(root->right);
}
postorder(root->left);
postorder(root->right);
printf("%d ", root->data);
}
For correctly implementing the inorder traversal function. 1+
1. Each node has a left child pointer and a right child pointer.
2. If a node has no left child, then its left child pointer points to its inorder
predecessor.
3. If a node has no right child, then its right child pointer points to its
inorder successor.
struct threaded_node {
int data;
struct threaded_node *left;
struct threaded_node *right;
int left_thread;
int right_thread;
};
For correctly stating the two rules for constructing threaded binary trees. 1+
A binary search tree (BST) is a binary tree in which each node has at most
two child nodes, one to the left and one to the right. Specifically, the data in
each node is greater than the data in all of its left child nodes and less than
the data in all of its right child nodes.
Example of a BST:
C function to insert a node into a BST:
return root;
}
3b Adjacency Matrix:
0 1 2 3 4 5 6 7
0 0 1 1 0 0 0 0 0
1 1 0 0 1 1 0 0 0
2 1 0 0 0 0 1 1 0
3 0 1 0 0 0 0 0 1
4 0 1 0 0 0 0 0 1
5 0 0 1 0 0 0 0 1
6 0 0 1 0 0 0 0 1
7 0 0 0 1 1 1 1 0
Adjacency List:
4a
Example:
For correctly stating the two methods used for traversing a graph. 1+
For correctly explaining depth-first search (DFS). 1+
For providing an example of DFS.
1+
For correctly describing the steps involved in DFS.
2
5a Hashing
Clearly defining and explaining the concept of hashing, including its key 2+
characteristics and advantages.
5b Clearly defining and explaining the concept of static hashing, including its 2.5 +
key characteristics, advantages, and limitations.
6a Priority Queues
6b 5