CS 745
CS 745
solving the assignment based paper of Mid Term Examination 2020. I take full responsibility
cheating/copying/plagiarizing then Institute reserves the right to take any disciplinary action
against me.
Student Signature
Finl Exam / Spring 2020 (Paper Duration 24 hours)
Department of Computer Science
To be filled by Student
Q.No.1.
Answer the following short questions. (09)
a. Suppose we have the following representation for a complete Binary Search Tree,
tell the Left and Right child nodes of the node D.
b. What is the difference between strict and complete binary tree?
c. List some basic functions of stack.
d. Define the following terminologies used in graphs. (Vertex, Degree of vertex, path,
cycle)
e. How many leaf and non-leaf nodes are present in a perfect binary tree if its depth is
3?
f. Represent the following Binary tree using array representation?
Answer:
a.
2(i)+1=right node=2*4+1=9=I
2(i)=left node=2*4=8=H
i/2=parent node=4/2=2=B
Vertices:
e. How many leaf and non-leaf nodes are present in a perfect binary tree if its
depth is 3?
Answer:
leaf nodes= 2^d = 8
non-leaf nodes= 2^d-1 = 4
a. Represent the following Binary tree using array representation?
Q.No.2 a. Write pseudo code for Dikstra’s Algorithm and also solve with example . (04)
We also want to be able to get the shortest path, not only know the length of the
shortest path. For this, we map each vertex to the vertex that last updated its path
length.
Once the algorithm is over, we can backtrack from the destination vertex to the
source vertex to find the path.
A minimum priority queue can be used to efficiently receive the vertex with least
path distance.
function dijkstra(G, S)
for each vertex V in G
distance[V] <- infinite
previous[V] <- NULL
If V != S, add V to Priority Queue Q
distance[S] <- 0
___________________________________________________________________________
___________________________________________________________________________
_______________________________________________________________
b. Starting from the root node perform In-order, pre order and post order traversals on the
following : binary tree and show the resultant series for each traversal. (04)
___________________________________________________________________________
___________________________________________________________________________
__________________________________________________________________________
Q.No.3.
a. Considers the following unsorted array, sort it by using Merge sort technique and draw
each step graphically. (04)
56 45 48 55 60 74 46 24 20
Answer:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
_______________________________________________________________
b.Write a program in C++ to create a Doubly linked list of n nodes and count the number
of nodes. (03)
Answer:
______
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
__
Q.No.4. (06)
The following array of current size 11 starting from index 1, represents a heap
structure.
a. Draw a tree diagram of the heap which is shown above.
b. Insert a new value 86 into the heap. Draw the new heap tree when insertion is
done.
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________