Exam Data Structure
Exam Data Structure
Instructions to Candidates:
Answer ALL questions.
Missing data, if any, may be suitable assumed.
1A. Explain different methods of Graph representation with an example for each. Also,
(05)
write the function for Depth First Search traversal of a graph.
1B. What is an expression tree? Construct an expression tree for the expression: A + B -
C * D / E + F + G * H with each step of construction shown clearly. Also write the
(03)
preorder and level order traversal sequence for the constructed expression tree.
1C. What is a spanning tree? Draw any two spanning trees for the graph given in Figure
(02)
Q.1C.
2A. Write a complete C++ program to implement basic operations (insert, delete, display)
on Priority Queue using circular singly linked list. Each node of the list contains an
integer element and its associated priority. Priority varies from 1 (highest priority) to
5 (lowest priority). Multiple elements may have same priority. Display should be
(05)
according to priority of the elements.
2B. Write a user defined function to sort the array elements using quick sort technique. (03)
2C. Define sparse matrix. Why does fast transpose take less time compared to normal
(02)
transpose?
3A. List the different rules to convert an infix expression to prefix form. Also write a user
(05)
defined function to convert an infix expression into prefix form.
3B. Write a C++ function to perform following operations on Doubly Linked List (DLL).
i. Delete a middle node of a DLL by traversing the list only once
(03)
ii. Insert a node at the beginning of the list
3C. What is the output of the following error-free C++ code:
void main()
{
int arr[] = {10, 20, 30, 40, 50, 60};
int *ptr1 = arr;
int *ptr2 = arr+5;
cout<<*ptr2<<endl;
cout<<(ptr1==arr); }
(02)
5A. Write the complete class definition for a Binary tree with member functions to
perform following operations.
i. Iterative postorder traversal
ii. Testing whether two given binary trees are equal
(05)
iii. Convert a given tree into its mirror image
5B. Write the uses of new and delete operators? Explain the syntax with an example for
(03)
each.
5C. Explain the following with examples:
i. Memory representations of a binary tree
ii. Depth of a binary tree
(02)
iii. Degree of a tree
Figure Q.1C