0% found this document useful (0 votes)
10 views5 pages

Key With Question Paper 2

Uploaded by

devi.g
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views5 pages

Key With Question Paper 2

Uploaded by

devi.g
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

PART-A

ANSWER ALL QUESTIONS AND EACH QUESTION CARRIES 1M: 10*1=10M

Q.NO-1 QUESTIONS

a AVL is the self - balancing binary search tree

b DFS works on the concept of __Queue___

c Trie is also known as ____Digital tree_____

d Splay tree is a ___Self balancing Binary search tree__

e Hash table is a ____pairs keys to values_____

f Which traversal of binary search tree is in ascending order? [C ]


[A]. Pre Order Traversal [B].Post Order Traversal
[C]. In Order Traversal [D].Level Oreder Traversal

g Which of the following rotations is called a double rotation in AVL Tree? [ D]


[A]. RL and RR [B].LR and LL
[c]. LL and RR [D].LR and RL

h Which of the following sorting algorithm is of divide and conquer type? [C ]


[ A]. Bubble sort [B].Insertion sort
[ C]. Merge sort [D]. Selection sort

i Partition and exchange sort is [ A ]


[A]. quick sort [B]. tree sort
[C]. heap sort [D]. bubble sort

J What is the best case for linear search?[D ]


[A]. O(nlogn) [ B]. O(logn)
[ C]. O(n) [D]. O(1)

PART-B

Answer any four questions out of six. Each question carries 5 marks: 4*5=20M

Q.NO QUESTIONS
2. construct a Binary tree using the given Preorder and Postoreder?
Preorder:[50,25,12,37,30,40,75,62,60,70,87]
Postorder :[12,30,40,37,25,60,70,62, 87,75, 50]
3. Explain Graph Traversals with an Example?
The graph is one non-linear data structure. That is consists of some nodes and their
connected edges. The edges may be director or undirected. This graph can be represented
as G(V, E). The following graph can be represented as G({A, B, C, D, E}, {(A, B), (B,
D), (D, E), (B, C), (C, A)})

The graph has two types of traversal algorithms. These are called the Breadth First
Search and Depth First Search.

Breadth First Search (BFS)

The Breadth First Search (BFS) traversal is an algorithm, which is used to visit all of
the nodes of a given graph. In this traversal algorithm one node is selected and then all of
the adjacent nodes are visited one by one. After completing all of the adjacent vertices, it
moves further to check another vertices and checks its adjacent vertices again.

Algorithm

bfs(vertices, start)
Input: The list of vertices, and the start vertex.
Output: Traverse all of the nodes, if the graph is connected.
Begin
define an empty queue que
at first mark all nodes status as unvisited
add the start vertex into the que
while que is not empty, do
delete item from que and set to u
display the vertex u
for all vertices 1 adjacent with u, do
if vertices[i] is unvisited, then
mark vertices[i] as temporarily visited
add v into the queue
mark
done
mark u as completely visited
done
End

Depth First Search (DFS)

The Depth First Search (DFS) is a graph traversal algorithm. In this algorithm one
starting vertex is given, and when an adjacent vertex is found, it moves to that adjacent
vertex first and try to traverse in the same manner.
Algorithm

dfs(vertices, start)
Input: The list of all vertices, and the start node.
Output: Traverse all nodes in the graph.
Begin
initially make the state to unvisited for all nodes
push start into the stack
while stack is not empty, do
pop element from stack and set to u
display the node u
if u is not visited, then
mark u as visited
for all nodes i connected to u, do
if ith vertex is unvisited, then
push ith vertex into the stack
mark ith vertex as visited
done
done
End

4.
Define AVL tree ? Insert the following list of elements
21,26,30,9,4,14,28,18,15,10,2,3,7.
An AVL tree defined as a self-balancing Binary Search Tree (BST) where the
difference between heights of left and right subtrees for any node cannot be more than
one.
The difference between the heights of the left subtree and the right subtree for any
node is known as the balance factor of the node.
The AVL tree is named after its inventors, Georgy Adelson-Velsky and Evgenii
Landis, who published it in their 1962 paper “An algorithm for the organization of
information”.
5.
Write an algorithm and function for Binary search tree
Deletion?
Deletion

Delete function is used to delete the specified node from a binary search tree. However,
we must delete a node from a binary search tree in such a way, that the property of
binary search tree doesn't violate. There are three situations of deleting a node from
binary search tree.
The node to be deleted is a leaf node

It is the simplest case, in this case, replace the leaf node with the NULL and simple free
the allocated space.

In the following image, we are deleting the node 85, since the node is a leaf node,
therefore the node will be replaced with NULL and allocated space will be freed.

the node to be deleted has only one child.

In this case, replace the node with its child and delete the child node, which now
contains the value which is to be deleted. Simply replace it with the NULL and free the
allocated space.

6.
Explain about a)Rehashing B) Extendible hashing?
Rehashing is the process of recalculating the hashcode of previously-stored entries (Key-
Value pairs) in order to shift them to a larger size hashmap when the threshold is
reached/crossed, When the number of elements in a hash map reaches the maximum.
Extendible Hashing is a dynamic hashing method wherein directories, and buckets are
used to hash data. It is an aggressively flexible method in which the hash function also
experiences dynamic changes.
Main features of Extendible Hashing : The main features in this hashing technique are:

 Directories: The directories store addresses of the buckets in pointers. An id is


assigned to each directory which may change each time when Directory Expansion
takes place.
 Buckets: The buckets are used to hash the actual data.
threshold value, it is rehashed.

7. Explain Quick sort and also perform quick sort for 10,9,8,7,6,5,4,3,2,1

You might also like