Final-Term DSA V1
Final-Term DSA V1
Final-Term DSA V1
Faculty of Computing
Subject: Data Structures & Algorithms Max Marks: 70
Instructor: Asadullah Tariq QCH Signature: Dr Irfan ud Din
Name: ___________________
Instructions:
Roll No: _________________
1. The person sitting next to you is also in worries, so trust on your own logic.
Date: ___________________
2. Read the statement very carefully and write the only part you’re asked to answer.
Time Allowed: 120 Min. 3. Keep an eye on your watch, no extra time will be given.
Instructor: Muhammad Hassan Total Marks: 50
(A) Write an algorithm to find minimum value in a Binary Search Tree (BST.
(C) Write an algorithm to search the given value in AVL tree, function
bool SearchinAVL(Node * root, int Key) will return true if key value
is present in tree otherwise it will return false.
(A) Insert the following values (from left to right) in an initially empty
Min-Heap. You are required to draw every step by hand in your answer.
(B) Insert the following values (left to right) in an initially empty AVL
Tree, Do balancing where required, show your work step by step.
o In-Order Traversing
o Pre-Order Traversing
o Post-Order traversing
B. Apply RemoveMin()on the following MinHeap, and draw each step by hand
to fulfill the Min-Heap property.
Note: RomoveMin() Function will remove the minimum value at once
only.
C. insert a new node 4 in the following heap and draw each step by hand
to fulfill the Min-Heap property.
Question 4: (3+3+8=14-Marks)
A. Consider the following graphs given in figure (a) and (b) respectively.
Your task is to represent these graphs using Adjacency matrix.
(A) (B)
Consider a list of elements given below, you are required to insert the
elements in the given order (Left to right) in a hash table of size 10 using
below mentioned methods, using the hash function h(x)=x mod N.
Methods to Perform:
a) Separate Chaining
b) Linear Probing