Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 24

UNIT – III

PART – A

1. What is meant by Sorting and searching?


Sorting and searching are fundamentals operations in computer
science. Sorting refers to the operation of arranging data in some given
order
Searching refers to the operation of searching the particular record
from the existing information

2. What are the types of sorting available ?


Insertion sort
Merge Sort
Quick Sort
Radix Sort
Heap Sort
Selection sort
Bubble sort
3. Define Bubble sort.
Bubble sort is the one of the easiest sorting method. In this method each
data item is compared with its neighbor and if it is an descending sorting ,
then the bigger number is moved to the top of all .The smaller numbers are
slowly moved to the bottom position, hence it is also called as the exchange
sort.
4. Mention the various types of searching techniques in C
Linear search
Binary search
5. What is linear search?
In Linear Search the list is searched sequentially and the position is returned
if the key element to be searched is available in the list, otherwise -1 is
returned. The search in Linear Search starts at the beginning of an array
and move to the end, testing for a match at each item.
6. What is binary search?
Binary search is simpler and faster than linear search. Binary search
the array to be searched is divided into two parts, one of which is ignored as
it will not contain the required element
One essential condition for the binary search is that the array which is
to be searched, should be arranged in order.

7. Define merge sort?


Merge sort is based on divide and conquer method. It takes the list to
be stored and divide it in half to create two unsorted lists.
The two unsorted lists are then sorted and merge to get a sorted list.

8. Define insertion sort?


Successive element in the array to be sorted and inserted into its
proper place with respect to the other already sorted element. We start with
second element and put it in its correct place, so that the first and second
elements of the array are in order.

9. Define selection sort?


It basically determines the minimum or maximum of the lists and
swaps it with the element at the index where its supposed to be.
The process is repeated such that the nth minimum or maximum
element is swapped with the element at the n-1th index of the list.

10.
What is the purpose of quick sort and advantage?
The purpose of the quick sort is to move a data item in the correct direction,
just enough for to reach its final place in the array.
Quick sort reduces unnecessary swaps and moves an item to a greater
distance, in one move.
11. Define quick sort?
The quicksort algorithm is fastest when the median of the array is
chosen as the pivot value. That is because the resulting partitions are of
very similar size.
Each partition splits itself in two and thus the base case is reached
very quickly and it follow the divide and conquer strategy.
12. Advantage of quick sort?
Quick sort reduces unnecessary swaps and moves an item to a greater
distance, in one move.
13. Define hashing.
It is the implementation of hash tables. Hashing is a technique used for
performing insertions, deletions and finds in constant average time. Hashing
is used to index and retrieve items in a database because it is faster to find
the item using the short hashed key than to find it using the original value.
14. Define hash table.
Hash table data structure is merely an array of some fixed size, containing
keys. Each key is mapped into some number in the range 0 to Tablesize-1
15. What is hash function? Give an example
Each key is mapped into some number in the range 0 to Tablesize-1. The
mapping is called a hash function. If the input keys are integers, then the
hash function is KEY MOD TABLESIZE
Example: Tablesize: 10 Keys: 15,12,4
Hash function (15) =15 mod 10=5
Hash function (12) =12 mod 10=2
Hash function (4) =4 mod 10=4

16. Write a simple hash function.


Hash(char* key,int tablesize)
{
Int hashval=0;
While(*key!=’\0’)
Hashval +=*key++;
Return hashval % tablesize; }
17. What do you mean by hash function?
A hash function is a key to address transformation which acts upon a given
key to compute the relative position of the key in an array. The choice of
hash function should be simple and it must distribute the data evenly. A
simple hash function is hash_key=key mod tablesize.
18. Write the importance of hashing.
Maps key with the corresponding value using hash function.Hash tables
support the efficient addition of new entries and the time spent on searching
for the required data is independent of the number of items stored.
19. List out the different types of hashing functions?
The different types of hashing functions are,
 The division method
 The mind square method
 The folding method
 Multiplicative hashing
 Digit analysis

20. What do you mean by collision in hashing?


When an element is inserted, if two values hashes to the same index as an
already inserted element, then it produces collision.
44 %10= 4
74 %10=4
Both 44 and 84 hashes to the same index 4, its called as collision.
21. What are the collision resolution methods?
 Separate chaining or External hashing
 Open addressing or Closed hashing
22. What do you mean by separate chaining?
Separate chaining is a collision resolution technique to keep the list of all
elements that hash to the same value. This is called separate chaining
because each hash table element is a separate chain (linked list). Each
linked list contains all the elements whose keys hash to the same index
23. Write the advantage of separate chaining.
More number of elements can be inserted as it uses linked lists
24. Write the disadvantages of separate chaining.
 The elements are evenly distributed. Some elements may
have more elements and some may not have anything.
 It requires pointers. This leads to slow the algorithm down a bit
because of the time required to allocate new cells, and also
essentially requires the implementation of a second data
structure.
25. What do you mean by open addressing?
Open addressing is a collision resolving strategy in which, if collision occurs
alternative cells are tried until an empty cell is found. The cells h 0(x), h1(x),
h2(x),…. are tried in succession, where hi(x)=(Hash(x)+F(i))mod Tablesize
with F(0)=0. The function F is the collision resolution strategy.

26. What are the types of collision resolution strategies in open


addressing?
 Linear probing
 Quadratic probing
 Double hashing
27. What is meant by primary clustering in linear probing technique?
It is the forming of blocks of occupied cells. It means that any key that
hashes into the cluster will require several attempts to resolve the collision
and then it will add to the cluster.
28. Define double hashing.
It is a collision resolution method .For double hashing F(i)=i.hash2(X).
(i.e) a second hash function is applied to X and probing is done at a distance
hash2(X), 2hash2(x)………. and so on.
29. Define rehashing.
Rehashing is the building of another table with an associated new hash
function that is about twice as big as the original table and scanning down
the entire original hash table computing the new hash value for each non
deleted element and inserting it in the new table.
30. List out the advantages and disadvantages of rehashing.
Advantage:
• Table size is not a problem.
• Hash tables cannot be made arbitrarily large.
• Rehashing can be used in other data structures.
Disadvantage:
• It is a very expensive operation.
• The running time is 0(N).
• Slowing down of rehashing method.
31. What are the ways in which rehashing can be implemented.
1. Rehash as soon as the table is half full.
2. Rehash only when an insertion fails.
3. Middle of the road strategy is to rehash when the table reaches a certain
load factor.
32. Define Extendible hashing.
Extendible hashing allows a find to be performed in two disk access and
insertions also require few disk accesses.
33. List out the applications of hashing.
 DBMS.
 Computer networks
 Storage of secret data
 Cryptography.
 Securing the database
 Database applications
 7. Storing data in a database

PART - B

1. Sort the sequence 3,1,4,1,5,9,2,6,5 using insertion sort.


2. Give short notes of : (i) Merge sort with suitable example.
3. Write an algorithm to sort ‘n’ numbers using quicksort. Show how the following
numbers are sorted using quicksort : 42, 28, 90,2, 56. 39, 12, 87
4. Sort the sequence 13,11, 74,37,85,39,22,56,25 using Insertion sort.
5. Explain the operation and implementation of merge sort.
6. Write quick sort algorithm and explain.
7. Write down the merge sort algorithm and give its worst case, best case and
average case analysis.
8. Explain linear search algorithm with an example
9. Explain linear search & binary search algorithm in detail
10. Briefly differentiate linear search algorithm with binary search algorithm.
11. What are the various hashing techniques? Give suitable examples.
12. What is meant by collision resolution in hashing? Explain in detail any two
strategies for dealing with collision.
13. Write routines to find and insert an element in a separate chaining hash table.
14. How will you resolve the collisions, while inserting elements into the hash table
using separate chaining and linear probing? Write the routines for inserting,
searching and removing elements from the hash table using the above
mentioned techniques.
15. Explain the concept of extendible hashing with neat example.
16. Given input {4371,1323,6173,4199,4344,9679,1989} and a hash function
h(X)=X(mod10), show the resulting:
(a) Separate chaining table (4)
(b) Open addressing hash table using linear probing (4)
(c) Open addressing hash table using quadratic probing (4)
(d) Open addressing hash table with second hash function h2(X) =7-(X mod 7).
17. Write an algorithm for initializing the hash table and insertion in a separate
chaining.
UNIT – IV
PART – A

1. Define non-linear data structure.

Data structure which is capable of expressing more complex relationship than


that of physical adjacency is called non-linear data structure. The non-liner data
structures are tree and graph.
2. Define tree?

A tree is a collection of nodes .The collection can be empty .Otherwise a tree


consists of a distinguished node r called the root and 0 or more non empty sub-
trees T1,T2,T3…………….Tk each of whose roots are connected by a directed

edge from r.

3. Define leaf?

In a directed tree any node which has out degree o is called a terminal node or a
leaf.
4. What is meant by directed tree?

Directed tree is an acyclic diagraph which has one node called its root with in
degree o while all other nodes have in degree I.
5. What is an ordered tree?

In a directed tree if the ordering of the nodes at each level is prescribed then
such a tree is called ordered tree.
6. What are the applications of binary tree?

Binary tree is used in data processing.


a. File index schemes.
b. Hierarchical database management system.
7. What is meant by traversing?

Traversing a tree is the process of visiting each node is


only once. There different types traversing namely pre-order, post-order, in-
order.

8. What are the different types of traversing?

The different types of traversing are:


 Pre-order traversal-yields prefix form of expression.
 In-order traversal-yields infix form of expression.
 Post-order traversal-yields postfix form of expression.
9. What are the two methods of binary tree implementation?

Two methods to implement a binary tree are,


a. Linear representation.
b. Linked representation
10. Define pre-order traversal?

Pre-order traversal entails the following steps:


a. Process the root node
b. Process the left subtree
c. Process the right subtree
11. Define post-order traversal?

Post order traversal entails the following steps;


a. Process the left subtree
b. Process the right subtree
c. Process the root node
12. Define in -order traversal?

In-order traversal entails the following steps;


a. Process the left subtree
b. Process the root node
c. Process the right subtree
13. Define depth and height of a tree

The depth of the tree is the depth of the deepest leaf. The height of the
tree is equal to the height of the root. Always depth of the tree is equal to height
of the tree
14. Define terminal nodes in a tree

A node that has no children is called a terminal node. It is also referred to as leaf
node.
15. Define non-terminal nodes in a tree

All intermediate nodes that traverse the given tree from its root node to the
terminal nodes are referred as non-terminal nodes.
16. Define a full binary tree

A full binary tree is a tree in which all the leaves are on the same level and every
non-leaf node has exactly two children.
17. Define a complete binary tree

A complete binary tree is a tree in which every non-leaf node has exactly two
children not necessarily to be on the same level.
18. Write the routine for node declaration in trees.

typedef struct TreeNode *PtrToNode;


struct TreeNode
{
ElementType Element;
PtrToNode FirstChild;
PtrToNode NextSibling;
};
19. List the applications of trees.

 Binary search trees


 Expression trees
 Threaded binary trees
20. List the tree traversal applications.

 Listing a directory in an hierarchal file system (preorder)


 Calculating the size of a directory (post order)
21. Define binary tree ADT with an example.

A binary tree is a tree in which no node can have more than two children.

22. Perform pre, in and post order traversal for the given tree.

ABDHECFG
DHBEAFCG
HDEBFGCA
23. Define the following.

i) Leaf
Nodes at the bottommost level of the tree are called leaf nodes
ii) Sibling
The nodes with common parent are called Sibling
24. Show that maximum and minimum number of nodes in a binary tree of
height H is 2H-1.

Maximum number of nodes = 1 + 2 + 4 + 8 + ... + 2 H -1


= 2 H -1.
Minimum number of nodes=H
25. Define Threaded binary tree.

A binary tree is threaded by making all right child pointers that would normally be
null point to the inorder successor of the node, and all left child pointers that
would normally be null point to the inorder predecessor of the node.
26. Define binary search tree ADT with an example.

A binary search tree is a tree in which for every node X, the values of all the keys
in its left sub tree are smaller than the key value in X and the values of all the
keys in its right sub tree are larger than the key value in X.
27. List the uses of binary tree.

 Searching.
 Compiler design.
28. List the Operations of binary search tree?

 Make Empty
 Find
 Insert
 Delete
 Search
 Display
29. How deletion is performed in a binary search tree.

Once the node to be deleted is found there are three possibilities


 If the node is a leaf, it can be deleted immediately.
 if the node has one child the node can be deleted after its parent adjusts a
Pointer to bypass the node.
 If the node has two children the general strategy is to replace the data of
this node with the smallest data of the right sub tree and recursively
delete the node which is empty.
30. List out the disadvantages of Binary search tree.

 Deletions in a binary search tree leads to trees which are not equally
likely.
 Absence of balanced search tree.
 The average depth is not O (log N) in trees which are not equally likely.
31. Define AVL Tree.
An AVL Tree is a binary search tree with a balance condition, for any node in the
tree, the height of the left and right subtrees can differ by at most 1.
32. Define Balance factor.
The balance factor of a node in binary tree is defined to be h R- hL where hL and
hR are heights of left and right subtrees of T. For any node in AVL tree the
balance factor should be 1, 0 or -1.
33. How will you compute the balance factor? Give an example
To determine whether the tree is balanced, the balance factor should be
calculated. BF=HL-HR
HL->height of the left subtree ,HR-> height of the right subtree
34. What do you mean by balanced trees?
Balanced trees have the structure of binary trees and obey binary search tree
properties. Apart from these properties, they have some special constraints,
which differ from one data structure to another. However, these constraints are
aimed only at reducing the height of the tree, because this factor determines the
time complexity.
Eg: AVL trees, Splay trees.
35. When AVL tree property is violated and how to solve it?
After insertion of any node in an AVL tree if the balance factor of any node
becomes other than -1,0, or 1 then it is said that AVL property is violated. So the
node on the path from the inserted node to the root needs to be readjusted.
Check the balance factor for each node in the path from inserted node to the root
node and adjust the affected subtree such that the entire subtree should satisfy
the AVL property.
36. Mention the four cases to rebalance the AVL tree.

 An insertion of new node into Left subtree of Left child(LL).


 An insertion of new node into Right subtree of Left child(LR).
 An insertion of new node into Left subtree of Right child(RL).
 An insertion of new node into Right subtree of Right child(RR).
37. What is the minimum number of nodes in an AVL tree of height h?
The minimum number of nodes S(h), in an AVL tree of height h is given
by S(h)=S(h-1)+S(h-2)+1. For h=0, S(h)=1.
38. Define Splay Tree.

A splay tree is a self-balancing binary search tree with the additional property
that recently accessed elements are quick to access again. So , the recently
accessed elements are splayed to the root.
39. List the Operations of Splay tree.

• Splaying
• Insertion
• Deleting
40. List the Operations on B-Trees.

• Search
• Create
• Insert
41. Define B-Tree.

A search tree that is not a binary tree is called B-Tree. That satisfies the
follpwing structural properties
• Root is either a leaf or has between 2 and M children
• All non leaf nodes except the root have between [M/2] and M children.
• All leafs are at the same depth.
42. What do you mean by 2-3 tree?
A B-tree of order 3 is called 2-3 tree. A B-tree of order 3 is a tree that is not
binary with the following structural properties:

 The root is either a leaf or has between 2 and 3 children.


 All non-leaf nodes (except the root) have between 2 and 3 children.
 All leaves are at the same depth.
43. What do you mean by 2-3-4 tree?
A B-tree of order 4 is called 2-3-4 tree. A B-tree of order 4 is a tree that is not
binary with the following structural properties:
 The root is either a leaf or has between 2 and 4 children.
 All non-leaf nodes (except the root) have between 2 and 4 children.
 All leaves are at the same depth.
44. Define binary heaps.

A binary heap is a heap data structure created using a binary tree. It can be
seen as a binary tree with two additional constraints:
• The Structural property: the tree is an almost complete binary tree; that is, all
levels of the tree, except possibly the last one (deepest) are fully filled, and, if the
last level of the tree is not complete, the nodes of that level are filled from left to
right.
• The heap property: each parent node is less than or equal to each of its
children if the heap is Max heap, each parent node is greater than or equal to
each of its children if the heap is Max heap.
45. Define binary heap and list its properties
The efficient way of implementing priority queue is binary heap and it should be
a complete binary tree.
Properties: 1. Structural Property 2. Heap order property
46. Write about the types of binary heap
Min Heap: The root/parents value should be minimum when compared to all of
its children.
Max Heap: The root/parents value should be maximum when compared to all of
its children
47. What is the need for Priority queue?

In a multiuser environment, the operating system scheduler must decide which


of the several processes to run only for a fixed period of time. One algorithm
uses queue. Jobs are initially placed at the end of the queue. The scheduler will
repeatedly take the first job on the queue, run it until either it finishes or its time
limit is up and place it at the end of the queue if it does not finish. This strategy is
not appropriate, because very short jobs will soon to take a long time because of
the wait involved in the run.
Generally, it is important that short jobs finish as fast as possible, so these jobs
should have precedence over jobs that have already been running. Further
more, some jobs that are not short are still very important and should have
precedence. This particular application seems to require a special kind of queue,
known as priority queue. Priority queue is also called as Heap or Binary Heap
48. What do you mean by structure property in a heap?
A heap is a binary tree that is completely filled with the possible exception at the
bottom level, which is filled from left to right. Such a tree is known as a complete
binary tree. It’s the structural property of the heap.
49. What do you mean by heap order property?
In a heap, for every node X, the key in the parent of X is smaller than (or equal
to) the key in X, with the exception of the root (which has no parent).
50. What do you mean by the term “Percolate up”?
To insert an element, we have to create a hole in the next available heap
location. Inserting an element in the hole would sometimes violate the heap
order property, so we have to slide down the parent into the hole. This strategy is
continued until the correct location for the new element is found. This general
strategy is known as a percolate up; the new element is percolated up the heap
until the correct location is found.
51. What do you mean by the term “Percolate down”?
When the minimum element is removed, a hole is created at the root. Since the
heap now becomes one smaller, it follows that the last element X in the heap
must move somewhere in the heap. If X can be placed in the hole, then we are
done.. This is unlikely, so we slide the smaller of the hole’s children into the hole,
thus pushing the hole down one level. We repeat this step until X can be placed
in the hole. Thus, our action is to place X in its correct spot along a path from the
root containing minimum children. This general strategy is known as percolate
down.
52. What are the different ways to implement the priority queue?
 Binary heap
 Linked list
53. List the properties of B-Tree.
A B-tree of order M is a tree with the following structural properties
 The root is either a leaf or has between 2 and M children
 All nonleaf nodes have between M/2 and M children
 All leaves are at the same depth
54. What do you mean by 2-3-4 tree?
A B-tree of order 4 is called 2-3-4 tree. A B-tree of order 4 is a tree that is not
binary with the following structural properties:
 The root is either a leaf or has between 2 and 4 children.
 All non-leaf nodes (except the root) have between 2 and 4 children
 All leaves are at the same depth.
55. What are the applications of B-tree?
 Database implementation
 Indexing on non primary key fields
56. List the Applications of Binary heap
 Heap sort
 Selection Algorithm
 Graph Algorithm
57. What are the applications of priority queues?
 The selection problem
 Event simulation

PART - B

1. Explain binary tree traversals?


2. What is a threaded binary tree? Explain its operation with example?
3. Explain the expression trees with example?
4. Write the procedure to convert general tree to binary tree.
5. Construct an expression tree for the expression a+(b-c)*d+(e*f)
6. Write an algorithm to create an empty binary tree and to search for an element
‘X’ in it.
7. Explain the types of tree traversals with the ADT.
8. Construct a binary tree to satisfy the following orders:
Inorder: D B F E A G C L J H K
Postorder: D F E B G L J K H C A

9. Explain the non-recursive algorithm for tree traversals with examples.


10. Consider the following binary tree:
G
/ \
D T
/ / \
B M X
/ \ / \ \
A C I K Y
\
P
(a) What is the result of a postorder traversal of the above tree?
(b) What is the result of an inorder traversal of the above tree?
(c) Is the above tree a binary search tree? Why or why not?

11. Write a C program to implement the Expression tree.


12. State the properties of binary tree. Explain how the General tree is converted to
first child next sibling representation with example.
13. What is a binary search tree? Explain with example?
14. Write the data structure of BST and explain the operations insertion, deletion
with an example.
15. How the binary tree is converted into BST? Explain with corresponding routines
in it.
16. Consider the following binary search tree and do following deletion operations
cited below:
60
25 75

15 50

33

44
1) Node 33 is deleted. 2) Node 75 is deleted. 3) Node 25 is deleted.

17. Write a program in C to create an empty binary search tree & search for an
element X in it.
18. How to insert an element into a binary search tree and write down the code for
the insertion routine with examples. Construct the binary search tree for the
following data 1,8,11,32,23,4,3,5,9,11,12,41,63,44,17
19. What is BST? Explain with suitable algorithms for insertion and deletion of nodes
at different instances. Illustrate it with example.
20. (i) Explain the process of finding minimum and maximum element in the
BST.
(ii) Explain the operation of threaded binary tree.
21. Construct an expression tree for the expression (a + b * c) + ((d * e + 1) *
g). Give the outputs when you apply preorder, inorder and postorder traversals.
22. Draw a binary search tree for the following input list {60, 25, 75, 15, 50, 66, 33,
and 44}. Trace the algorithm to delete the nodes {25, 75, 44} from the tree.
23. Write down the algorithm binary search for searching x from an array a[1,n] and
give the stepwise execution for an array (10,12,20,23,27,30,31,39,42,
44,45,49,57,63,70) to search x=44.
24. Construct a binary search tree for the following set of numbers and find the
preorder,inorder and postorder traversal of the tree {1,8,11,32,23,4,3,5,9,11,12,
41,63,44,17}
25. Define AVL tree. Explain the AVL tree rotations.
26. Show the result of inserting 2, 1,4,5,9,3,6,7 into an initially empty AVL tree.
27. Write a routine to perform insertion and deletion in a B-tree.
28. Insert the following keys to a 5-way B-tree: 3, 7, 9, 23, 45, 1, 5, 14, 25, 24, 13,
11, 8, 19, 4, 31, 35, 56.
29. Given 5-way B-tree created by these data
• 3, 7, 9, 23, 45, 1, 5, 14, 25, 24, 13, 11, 8, 19, 4, 31, 35, 56
• Add these further keys: 2, 6,12
• Delete these keys: 4, 5, 7, 3, 14
30. Explain the Basic operations performed in a Binary heap with examples.
31. Construct a Min and MAX heap for the following values. 23,67,1,45,7,89,56,35
32. Explain the routine to perform insert and delete min operation in Binary Heap.
33. Describe the operation increase key, decrease key, delete and build heap.
34. Show the result of inserting 10, 12, 1, 14, 6, 5, 8, 15, 3, 9, 7, 4, 11, 13 and Show
the result of performing three DeleteMin operations in the heap.
35. Add the following list of numbers to an initially empty binary heap: 12, 5, 15,
9,13, 7, 15, 10, 3, 20, 4.
UNIT-V

PART-A

1. Define graph.
A graph G= (V, E) consists of a set of vertices, V, and a set of edges, E. Each
edges is a pair (v, w), where v, w  V.

2. Name the different ways of representing a graph?


 Adjacency matrix
 Adjacency list
3. Write the adjacency matrix and adjacency list representation for the
following graph
1

2 3

4
Adjacency Matrix and Adjacency List Representation

4. Define topological sort


A topological sort is an ordering of vertices in an directed acyclic graph, such
that if there is a path from Vi to Vj , then Vj appears after Vi in the ordering
5. Define adjacent nodes.
Any two nodes which are connected by an edge in a graph are called
adjacent nodes. For example, if an edge x ε E is associated with a pair of nodes
(u,v) where u, v ε V, then we say that the edge x connects the nodes u and v.
6. What is a directed graph? What is a loop?
A graph in which every edge is directed is called a directed graph.
An edge of a graph which connects to itself is called a loop or sling.
7. What is a undirected graph?
A graph in which every edge is undirected is called a directed graph.
8. What is a simple graph?
A simple graph is a graph, which has not more than one edge between a
pair of nodes than such a graph is called a simple graph.
9. Define outdegree of a graph?
In a directed graph, for any node v, the number of edges which have v as their
initial node is called the out degree of the node v.
10. Define indegree of a graph?
In a directed graph, for any node v, the number of edges which have v as their
terminal node is called the indegree of the node v.
11. What is an acyclic graph?
A simple diagram which does not have any cycles is called an acyclic graph.
12. What is meant by strongly connected in a graph?
An undirected graph is connected, if there is a path from every vertex to every
other vertex. A directed graph with this property is called strongly connected.
13. When is a graph said to be weakly connected?
When a directed graph is not strongly connected but the underlying graph is
connected, then the graph is said to be weakly connected.
14. Name the different ways of representing a graph?
Adjacency matrix and Adjacency list
15. What is an undirected acyclic graph?
When every edge in an acyclic graph is undirected, it is called an undirected
acyclic graph. It is also called as undirected forest.

16. What are the two traversal strategies used in traversing a graph?
Breadth first search and Depth first search
17. What is a minimum spanning tree?
A minimum spanning tree of an undirected graph G is a tree formed from graph
edges that connects all the vertices of G at the lowest total cost.
18. Name two algorithms two find minimum spanning tree
Kruskal’s algorithm and Prim’s algorithm
19. What do you mean by breadth first search (BFS)?
BFS performs simultaneous explorations starting from a common point and
spreading out independently.
20. Differentiate BFS and DFS.

No. DFS BFS


1 Backtracking is possible from a Backtracking is not possible
dead end
2 Vertices from which exploration The vertices to be explored are
is incomplete are processed in a organized as a FIFO queue
LIFO order
3 Search is done in one particular The vertices in the same level are
direction maintained parallely
21. What do you mean by tree edge?
If w is undiscovered at the time vw is explored, then vw is called a tree edge and
v becomes the parent of w.
22. Define biconnectivity.
A connected graph G is said to be biconnected, if it remains connected after
removal of any one vertex and the edges that are incident upon that vertex. A
connected graph is biconnected, if it has no articulation points.
23. What do you mean by articulation point?
If a graph is not biconnected, the vertices whose removal would disconnect the
graph are known as articulation points.
24. What do you mean by shortest path?
A path having minimum weight between two vertices is known as shortest path,
in which weight is always a positive number.
25. What is minimum spanning tree?
A minimum spanning tree of a weighted connected graph G is its spanning tree
of the smallest weight, where the weight of a tree is defined as the sum of the
weights of all its edges. The tree is a connected graph with no cycles. A
spanning tree is a sub graph of G and is a tree.
26. Write down the applications of graph.
 Network analysis
 Graph theory.
27. Define simple cycle.
Simple cycle means the vertex should not be repeated and the first and last
vertex should be the same.
28. Explain the principle of topological sort.
 Find the vertex with no incoming edge.
 Print the vertex and remove it along with its edges from the graph.
 Apply the same strategy to the rest of the graph.
 Finally all recorded vertices give topological sorted list.
29. What is the disadvantage of topological sort?
Ordering of vertices is not possible if the graph is a cyclic graph. Because if there
are two vertices v and w on the cycle, v proceeds w and w proceeds v, so
ordering not unique.
30. What is the running time for topological sort?
The running time of the algorithm for topological sort is O ( V 2).For the algorithm
using Queue, the running time is O ( E + V ) if adjacency list are used.
31. State the shortest path problem OR Single source shortest path problem.
Given as input a weighted graph or an unweighted graph G= (V, E) and a
distinguished vertex s , the shortest path problem is to find the shortest weighted
or unweighted path from s to every other vertex.
32. What do you mean by Negative edge?
Negative edge means a graph having atleast one edge with a negative weight.
33. What do you mean by negative cost cycle?
A graph having the shortest path with negative weight is known Negative cost
cycle.
34. Give examples for problems solved by shortest path algorithm.
• Cheapest way of sending electronic news from one computer to another.
• To compute the best route
35. What is the advantage of unweighted shortest path algorithm?
There is no calculation with weights. Only the number of edges on the shortest
path is found.

PART-B

1. What is Topological sort? Write down the pseudo code to perform topological
sort and apply the same to the following graph.

2. Explain Dijistra’s algorithm and find the shortest path from a to all other
vertices in a graph.
3. Explain Prim’s and Kruskal’s algorithm. Find the minimum spanning tree for
the following graph.

4. Explain shortest path algorithm with example.


5. Explain depth first and breadth first traversal?
6. Explain spanning and minimum spanning tree?
7. Explain kruskal’s and prim’s algorithm?
8. Explain the BFS algorithm with an example.
9. Explain Graph representation in detail.
10. Explain Topological sort in detail with a example.
11. Explain the method to find the shortest path in an unweighted graph with a
pseudocde and an example.
12. Write kruskals algorithm with an example.
13. Explain Dijkstra’s algorithm to find the shortest path in a weighted graph with
example.
14. Explain Prim’s algorithm to find MST of a graph with example.
15. What are the applications of DFS? Explain in detail.
16. Find a minimum spanning tree for the graph using prim’s algorithms.

You might also like