Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
9 views29 pages

DSA Pyqs

The document consists of questions and answers related to data structures and algorithms, covering topics such as binary trees, graphs, hashing, and tree traversal methods. It includes definitions, properties, and examples of various data structures like binary search trees, AVL trees, and red-black trees. Additionally, it discusses algorithms such as depth-first search (DFS), breadth-first search (BFS), and hashing techniques, along with practical applications and theoretical concepts.

Uploaded by

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

DSA Pyqs

The document consists of questions and answers related to data structures and algorithms, covering topics such as binary trees, graphs, hashing, and tree traversal methods. It includes definitions, properties, and examples of various data structures like binary search trees, AVL trees, and red-black trees. Additionally, it discusses algorithms such as depth-first search (DFS), breadth-first search (BFS), and hashing techniques, along with practical applications and theoretical concepts.

Uploaded by

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

CS 241: DATA STRUCTURES AND ALGORITHMS – II

P6383

Q1) Attempt any eight of the following: [8×1=8]

a) “Binary tree contains every node with minimum two child nodes”. State
true/false.
ANS. False
Binary tree has maximum 2 child nodes.

b) Define: left skewed binary tree.


ANS. The left skewed binary tree is a tree in which every node has only left
subtree.

c) What is degree of a graph?


ANS. The degree of graph node is the number of edges connected to it.

d) Name data structure used to implement depth first search (DFS) of a


graph.
ANS. Stack is the data structure used to implement depth first search (DFS)
Of a graph.

e) What is complete binary tree?


ANS. A complete binary tree is a binary tree in which every level, except
Possibly the last level, is completely filled, and all nodes are as far
left as possible.

f) Define: balance factor.


ANS. Balancing factor us used to determine whether the given binary tree
is balanced or not.
Balance factor = height of left subtree – height of right subtree

g) Write properties of a good hash function.


ANS. 1. The hash function is easy to understand and simple to compute.
2. A number of collisions should be less while placing the data in the hash
table.
h) Write any two applications of graph.
ANS. 1. Topological Sort
2. Dijkstra’s Algorithm
3. Prim’s and Kruskal’s Algorithm
4. Social Networks
5. Network Routing

i) “Complete graph contains n(n–1)/2 number of edges”. State true/false.


ANS. True

j) What is synonym of Hashing?


ANS. Colliding Keys

Q2) Attempt any four of the following. [4×2=8]

a) What is splay tree?


ANS. 1. Splay tree is a self-adjusting/ self- balancing tree binary search tree in
which every operation on element rearranges the tree so that the element
is placed at the root position of the tree.
2. All normal operations of BST are combined with one basic operation
Called splaying.

b) Explain Mid = Square function in hashing with suitable example.


ANS. 1. In this method, we square the value of a key and take the number of digits
required to form an address, from the middle position of squared value.
2. Steps: First, we square the key i.e., k = k^2, then we remove some of the
digits from both left and right ends of the k^2.
3. Ex. suppose key value is 16, then its square will be 256. Now we want
address of two digits then we select the address as 56.

c) What is inverse adjacency list?


ANS. 1.Inverse adjacency lists are a set of lists that contain one list for a vertex.
2. Each list contains a node per vertex adjacent to the vertex it represents.

d) Show the steps of creating a binary search tree for the following data
15, 30, 20, 5, 10, 2, 7
ANS.
Step 1 -> Insert 15. So now 15 becomes the root.
Step 2 -> 30 > 15. Insert 30 as a right child of parent root 15.
Step 3 -> 20 >15. Go right.
but 20 < 30. Insert 20 as a left child of 30
Step 4 -> 5 < 15. Insert 5 as a left child of 15
Step 5 -> 10 < 15. Go left.
10 > 5. Insert 10 as a right child of 5
Step 6 -> 2 < 5. Insert as a left child of 5
Step 7 -> 7 < 15. Go left. but 7 > 5. Go right. 7< 10 So insert at left position.
15
/ \
5 30
/\ /
2 10 20
/
7
e) Consider the following adjacency matrix Draw the graph from it.

Q3) Attempt any two of the following. [2×4=8]

a) Construct red black tree for the following.


50, 40, 30, 20, 10, 35, 5
ANS. We follow Red-Black Tree insertion rules, which maintain:

• Every node is either red or black


• Root is always black
• Red node cannot have red child
• Every path from root to leaf has the same number of black nodes

Insertion Steps (with fixups):

Step 1: Insert 50
Root node → Black
Step 2: Insert 40
Insert left of 50 → color Red
Step 3: Insert 30

• Insert left of 40 → Red


• Red-Red violation! → Rotate Right at 50
• Recolor: 40 becomes root Black, 50 and 30 become Red
40(B)

/ \
30(R) 50(R)
Step 4: Insert 20

• Insert left of 30 → Red → No violation

Step 5: Insert 10

• Left of 20 → Red
• Red-Red violation between 10 and 20 → Recolor 20 and 50 to Black, 40
becomes Red
• Root 40 turns Black again (as root is always Black)

40(B)
/ \
30(R) 50(B)
/
20(B)
/
10(R)
Step 6: Insert 35

• Right of 30 → Red → No violation

Step 7: Insert 5

• Left of 10 → Red
• Red-Red → Violation at 10 and 5 → Recolor and adjust

b) Write a recursive function in ‘c’ to display and count leaf nodes of a


binary search tree.
ANS.
c) Consider the following graph:

i) Draw Adjacency List


ANS.
1 → 2, 4, 6
2 → 3, 5, 7
3→
4→2
5→3
6→2
7→3

ii) Write BFS and DFS traversal


ANS.

BFS Steps:

Start at 1 → Queue: [1]


Visited: {1}

1 → 2, 4, 6 → Queue: [2, 4, 6]
Visited: {1, 2, 4, 6}

2 → 3, 5, 7 → Queue: [4, 6, 3, 5, 7]
Visited: {1, 2, 4, 6, 3, 5, 7}
4 → 2 (already visited)
6 → 2 (already visited)
5 → 3 (already visited)
7 → 3 (already visited)

✅ BFS Output:

1→2→4→6→3→5→7

🔷 iii) DFS Traversal (starting from Node 1):

Algorithm: Use Stack or Recursion

DFS Steps:

Start at 1
1→2
2→3
3 → (no more nodes)
Backtrack → 2 → 5
5 → 3 (visited)
Backtrack → 2 → 7
7 → 3 (visited)
Backtrack to 1 → 4
4 → 2 (visited)
Backtrack → 1 → 6
6 → 2 (visited)

✅ DFS Output:

1→2→3→5→7→4→6

Q4) Attempt any two of the following. [2×4=8]

a) Write a ‘c’ function to insert a node in binary search tree.


ANS.

b) Construct AVL tree for the following data:


XYZ, PQR, LMN, QBC, ABC, STR, UVW, BMC.
ANS. Steps: -
1. Insert XYZ -> root = XYZ
2. Insert PQR -> PQR < XYZ -> Insert left
XYZ
/
PQR
3. Insert LMN -> LMN < XYZ < PQR -> insert left of PQR
Now unbalanced at XYZ -> Left-Left case -> Right rotate at XYZ
PQR
/ \
LMN XYZ
4. Insert QBC -> QBC > PQR -> Insert right of PQR
QBC -> QBC < XYZ -> Insert left of XYZ
PQR
/ \
LMN XYZ
/
QBC
-> tree is balanced
5. Insert ABC -> ABC < LMN < PQR -> insert left of LMN
6. Insert STR -> STR > PQR, STR < XYZ =-> STR > QBC -> insert right of
QBC
-> PQR
/ \
LMN XYZ
/ /
ABC QBC
\
STR
7. Insert UVW -> UVW > PQR, < XYZ, > QBC, > STR → Insert right of
STR
Now STR has 1 right child and no left → backtrack to QBC → BF = -2 →
Right-Right (RR) at QBC
→ Left Rotate at QBC
PQR
/ \
LMN XYZ
/ /
ABC STR
/ \
QBC UVW
8. Insert BMC -> BMC > ABC, <LMN ->Insert right of ABC
PQR
/ \
LMN XYZ
/ /
ABC STR
\ / \
BMC QBC UVW

c) Store following values in Hash table:


13, 45, 24, 113, 161, 207, 211.
Use division method of hashing with table size 11. Number of slots is 1
in each bucket. Apply linear probing to resolve over flow. Show hash
table contents.
ANS. Hash Function -> h(k) = k % 11
Value h(k) = k % 11 Collision? Position
13 2 No 2
45 1 No 1
24 2 Yes 3 (next)
113 3 Yes 4
161 7 No 7
207 9 No 9
211 2 Yes 5

Final Hash Table ->


Index Value
0
1 45
2 13
3 24
4 113
5 211
6
7 161
8
9 207
10
Q5) Attempt any one of the following. [1×3=3]

a) Differentiate between B and B+ tree.


ANS.
B Tree B+ Tree
Balanced M-way search tree where all Balanced m-way tree where only leaf
nodes store keys and data nodes store actual data; internal nodes
store only keys.
Data is stored in both internal and leaf Data is stored only in leaf nodes.
nodes
No duplication of trees Keys are duplicated in internal nodes.
Leaf nodes may or may not have Leaf nodes have a pointer to the next
pointers leaf (Linked list format)
Contains keys and pointers to children Contains only keys

b) What will be the topological order of activities for the AOV network
given below?
ANS.
Edges (based on arrows):

• V1 → V2
• V1 → V3
• V2 → V4
• V3 → V4
• V4 → V5

Step 1: Find In-Degree of Each Vertex

• V1 → 0
• V2 → 1 (from V1)
• V3 → 1 (from V1)
• V4 → 2 (from V2 and V3)
• V5 → 1 (from V4)

Step 2: Start with node having in-degree 0 → V1

Process:
1. V1 → Add to result → remove edges → update in-degrees:
o V2: 0
o V3: 0
→ Next: V2, V3
2. V2 → Add → V4: in-degree becomes 1
3. V3 → Add → V4: in-degree becomes 0
4. V4 → Add → V5: in-degree becomes 0
5. V5 → Add

✅ Topological Order (One Possible):


V1, V2, V3, V4, V5
CS 241: Data Structure and Algorithms – II
P5143

Q1) Attempt any EIGHT of the following. [8 × 1 = 8]

a) Define Heap.
ANS. Heap is a special tree-based data structure in which the tree is a complete
binary tree.

b) List tree traversal methods.


ANS. A] In-order Traversal
B] Preorder Traversal
C] Post-order Traversal

c) Define node of tree.


ANS. In a tree, every individual element is called as node.

d) What is height balance tree?


ANS. A binary tree structure that is balanced with respect to the height of the
subtree is called as height balanced tree.

e) Define balance factor.


ANS. Balance factor is the difference between the height of left child and right
child. or balancing factor is used to determine whether the given binary
search tree is balanced or not.

f) Define Spanning tree.


ANS. A spanning tree is a subset of Graph G, which has all the vertices covered
with minimum possible number of edges.

g) Define in-degree & out-degree of vertex.


ANS. In directed graph, indegree of a vertex ‘v’ is the number of edges for which
‘v’ is the head.
In directed graph, outdegree of a vertex ‘v’ is the total number of edges for
which ‘v’ is the tail?

h) What is weighted graph.


ANS. A weighted graph is a graph in which every edge is assigned a weight.
i) Define Bucket
ANS. Bucket is a unit of storage used to store data of hash file in a bucket format.

j) What do you mean by rehashing.


ANS. Rehashing is a technique in which the table is resized, i.e., the size of table is
doubled by creating a new table.

Q2) Attempt any Four of the following. [4 × 2 = 8]

a) Write any two properties of hash function.


ANS. 1. The hash function is easy to understand and simple to compute.
2. A number of collisions should be less while placing the data in the hash
table.
3. the hash function should generate different hash values for the similar
string.
4. it uniformly distributes the data across the entire set of possible hash value

b) Define
i) Degree of vertex
ii) Subgraph
ANS. i) Degree of vertex is the number of edges incident to a vertex. it is written
as degree(V).
ii) A subgraph of G is a graph G’ such that V(G’)⊆V(G) and E(G’) ⊆ E(G).

c) List any two applications of tree data structure.


ANS. 1. Heap Sort
2. Huffman Encoding

d) What is skewed binary tree.


ANS. A tree in which every node has either only left subtree or right subtree is
called as skewed binary tree.

e) Convert the following undirected graph into adjacency matrix.


ANS.
1 2 3 4 5
1 0 1 1 0 1
2 1 0 1 4 0
3 1 2 0 1 1
4 0 1 1 0 1
5 1 0 1 1 0

Q3) Attempt any Two of the following. [2 × 4 = 8]

a) Write a program to sort 'n' randomly generated elements using heapsort


method.
ANS.

b) Write a program that accepts the vertices and edges of graph and store it
as an adjacency matrix. Display adjacency matrix.
ANS.

c) Write a function to search an element in binary search tree.


ANS.

Q4) Attempt any Two of the following. [2 × 4 = 8]

a) Construct an AVL tree for the following data.


70, 50, 30, 90, 80, 130, 120
ANS.

b) Consider the following adjacency matrix.


1234
1| 0 1 1 0 |
2| 1 0 1 0 |
3| 0 0 0 1 |
4| 1 0 0 0 |
i) Draw the graph
ii) Draw Adjacency list.
ANS.

c) Write a C function to traverse a graph using BFS.


ANS.

Q5) Attempt any ONE of the following. [1 × 3 = 3]

a) Define the following terms.


i) Height of tree
ii) Forest
iii) Siblings of tree
ANS. i) In tree data structure, the total number of edges from leaf node to a
particular node in the longest path is called as height of tree.
ii) A forest is a set of disjoint trees.
iii) Nodes which belongs to the same parent are called as siblings.

b) Traverse the following tree using preorder, in-order and post-order traversal
techniques.

ANS.

1. INORDER TRAVERSAL
B, A, D, E, I, H, L
2. PREORDER TRAVERSAL
A, B, E, D, H, I, L

3. POSTORDER TRAVERSAL

B, D, I, L, H, E, A
CS 241: DATA STRUCTURES AND ALGORITHMS – II
PA-1017

Q1) Attempt any Eight of the following: [8 × 1 = 8]

a) Define degree of a tree.


b) Define the term left skewed binary tree.
c) What is height balance tree?

d) List 2 applications of graph.


ANS. Topological Sorting, Prim’s, Kruskal, Dijkstra’s Algorithm

e) What is topological sorting?


ANS. The topological Sorting of a directed acyclic graph is a linear ordering of the
vertices, such that if there exists a path from vertex x to y, then x appears
before y in the topological sort.

f) Define Bucket.

g) What is collision?
ANS. The situation where a newly inserted key maps to an already occupied slot in
the hash table is called collision.

h) Define complete Binary tree.


ANS. A complete binary tree is a binary tree in which every level, except possibly
last, is completely filled, and all nodes are as far left as possible.

i) What is weighted graph?

j) Explain open addressing concept in hash table.


ANS. Open addressing ensures that all the elements are stored directly in the hash
table.

Q2) Attempt any four of the following: [4 × 2 = 8]

a) Traverse the following binary tree using given traversal technique


i) In-order ii) post-order.
In order -> G, D, B, A, E, C, H, F, I
Post order -> G, D, B, E, H, I, F, C, A

b) Compare B tree & B+ tree.


ANS.
Feature B Tree B+ Tree
Data stored in both internal and leaf
Data Location Data stored only in leaf nodes
nodes
Traversal Slower, must traverse internal nodes Faster for range and ordered queries
Leaf Node All leaf nodes are linked (doubly
Not necessarily linked
Linking linked list)
Search O (log n), but better for sequential
O (log n)
Complexity access
Insertion & More complex due to data in Easier as internal nodes only guide
Deletion internal nodes the search
Databases and file systems with range
Preferred For General balanced tree operations
queries

c) Define indegree & outdegree of vertex with example.

d) Explain the concept of hashing & rehashing in Hash table.


ANS. 1. Hashing is the process of indexing and retrieving element (data) in a data
structure to provide a faster way of finding the element using a hash key.
2. Rehashing is a technique in which the table is resized, i.e., the size of
table is doubled by creating a new table.

e) Explain concept of Red - Black Tree.


ANS. 1. A red black tree is a variant of binary search tree (BST) in which an
additional attribute, ‘color’ is used for balancing.
2. The value of this attributes can be either red or black.
3. Red-black trees are self-balancing BST. In this type of tree, the leaf
nodes are NULL/NIL child nodes storing no data.
4. Each and every node is either red or black, roof node and leaf nodes are
always black in color, If any node is red, then both its child nodes are
black.

Q3) Attempt any two: [2 × 4 = 8]

a) Write C program to represent graph as adjacency matrix.


b) Write C Program to compare two BST.
c) Write a program to find minimum value node from the BST.

Q4) Attempt any two: [2 × 4 = 8]

a) Write a program to insert an element into binary tree.

b) Construct AVL tree for the following:


{Mon, Sun, Thur, Fri, Sat, Wed, Tue}

c) Consider the following graph.

Give i) DFS Traversal


ii) BFS Traversal.

Q5) Attempt any one of the following: [1 × 3 = 3]


a) Write note on quadratic probing
ANS. 1. Quadratic probing is a collision resolving technique in open addressing
hash table. It operates by taking the original hash index and adding
successive values of an arbitrary quadratic polynomial until an open slot
is found.
2. One way of reducing "primary clustering" is to use quadratic probing to
resolve collision.
3. In quadratic probing, we try to resolve the collision of
the index of a hash table by quadratically increasing the search index free
location.
4. Let us suppose, if k is the index retrieved from the hash function. If the
kth index is already filled then we will look for (k+12) %M, then (k+22)
%M and so on. When we get a free slot, we will insert the object into that
free slot.

b) Compare the data structures. Tree & Graph.


ANS.
CS 241: DATA STRUCTURES AND ALGORITHMS – II
P-1294

Q1) Attempt any eight of the following: [8 × 1 = 8]

a) Define min heap.


ANS. min-heap the key present at the root node must be minimum among the keys
present at all of its children.

b) What is level order traversal?


ANS. level-order traversal of a binary tree traverses the nodes in a level-by-level
manner from top to bottom and among the nodes of the same level they are
traversed from left to right.

c) What is descendant in tree?


ANS. descendants of a node are those nodes which are reachable from node.

d) In B+ tree data can only be stored in leaf node. State true or false.
ANS.

e) List AVL tree Rotations.


ANS. 1. Left Rotation (LL Rotation)
2. Right Rotation (RR Rotation)
3. Left-Right Rotation (LR Rotation)
4. Right-Left Rotation (RL Rotation)

f) List any two minimum spanning tree algorithms.


ANS. 1. Prim’s
2. Kruskal’s

g) "DFS uses queue implementation". State true or false.


ANS. False. It uses stack implementation.

h) What is weighted graph?


ANS. A weighted graph is a graph in which every edge is assigned a weight.
i) What is load factor?
ANS.

j) What is hashing?

Q2) Attempt any four of the following: [4 × 2 = 8]

a) Write a note on minimum spanning tree.


ANS. 1. For a connected graph G, it is required to construct a spanning tree T such
that the sum of weights of the edges in T must be minimum. Such a tree is
called as minimum spanning tree.
2. A Minimum Spanning Tree (MST) or minimum weight spanning tree is a
subset of the edges of a connected, edge-weighted undirected graph that
connects all the vertices together, without any cycles and with the
minimum possible total edge weight.
3. Greedy Strategy to find the minimum spanning tree are Prim’s and
Kruskal’s algorithm.

b) Write a note on splay tree.


ANS. 1. Splay Tree is a self-adjusted/self-balancing Binary Search Tree in which
every operation on element rearranges the tree so that the element is
placed at the root position of the tree.
2. All normal operations on a binary search tree are combined with one basic
operation, called splaying.
3. Splaying the tree for a certain element rearranges the tree so that the
element is placed at the root of the tree.
4. Rotation in splay tree are: -
Zig rotation, Zag rotation, Zig-Zig, Zag-Zag, Zig-Zag rotation and
zag-zig rotation.

c) Give any two differences between DFs & BFs.


ANS.
d) Explain any two properties of good hash function.

e) Write a note on B tree.


ANS. 1. The B-tree is a self-balancing search tree like AVL and red-black trees.
2. The main objective of B-trees is to minimize/reduce the number of disk
accesses for accessing a record.
3. B tree of order m can have a maximum of m–1 keys and m pointers to its
sub-trees.
4. B-tree is a type of tree in which each node can store multiple values and
point to multiple trees.
5. The two most common operations insert and delete are performed on
B- trees.

Q3) Attempt any two of the following: [2 × 4 = 8]

a) Write a 'C' function to calculate


i) leaf nodes
ii) non leaf nodes
ANS.

b) Write a program that accepts adjacency matrix and print indegree and
outdegree of each vertex.
ANS.

c) Write a program to insert new element in hash table.


ANS.

Q4) Attempt any two of the following: [2 × 4 = 8]

a) Construct Red Black Tree for 2, 10, 7, 20, 30, 25, 50.
ANS.

b) Consider following adjacency matrix


1110
0110
1011
0001
i) Draw the graph
ii) Give adjacency list
ANS.

c) Construct minimum spanning tree using Kruskal's algorithm.

ANS.

Q5) Attempt any one of the following: [1 × 3 = 3]

a) Define the following terms:


i) Terminal node
ii) depth of node
iii) root node
ANS. 1. The nodes with no subtrees are called terminal node or leaves.
2. Total number of edges from root node to a particular node is called
as depth of that node.
3. In tree data structure, the first node from where the tree originates is
called as a root node.

b) Give in-order, preorder and post-order traversal for:

ANS.
In-order ->
Preorder ->
Post-order ->
MORE PYQS

1st lesson

1. Write the steps for creating a binary search tree for the following data: 13, 4, 25,
3, 21, 20, 7
2. Traverse the following binary tree using three traversals techniques (preorder,
post-order, in-order).

3. List any two applications of tree data structure


4. Write a recursive ‘C’ function to insert an element in a binary search tree
5. Write a ‘C’ function to compare two BST. [5 M]
6. Define skewed binary tree.
7. What is siblings?
8. Show steps in creating a binary search tree for the data: 40, 70, 60, 50, 65, 20, 25
9. Define degree of the tree
10. Write the steps for creating a binary search tree for the following data: 15, 11,
13, 8, 9, 18, 16
11. What is complete binary tree?
12. The indegree of the root node of a tree is always zero. Justify (T/F).
13. Write a Recursive ‘C’ function to count total nodes in a BST.
14. Write the steps for creating a BST for the following data: 22, 13, 4, 6, 25, 23,
20, 18, 7, 27.
15. Define the term heap tree

2nd lesson
1. Construct AVL tree for the following data: Mon., Wed., Tue., Sat., Sun., Thur.
2. Construct AVL tree for the following data: Pen, Eraser, Book, Scale, Sketch
pen, Crayon, Color pencil
3. Define balance factor.
4. Construct AVL tree for the following data: NFD, ZIM, IND, AUS, NEL, ENG,
SRL, PAK.
5. Construct AVL tree for the following data: [SUN, FRI, MON, WED, TUE,
THUR, SAT.
6. Construct AVL tree for the following data: [55, 40, 25, 100, 80, 200, 150.
7. Construct the AVL tree for the following data: Chaitra, Magh, Vaishakh, Kartik,
Falgun, Aashadh.

3rd lesson

1. Consider the following graph:

(i) Write adjacency matrix


(ii) Draw adjacency list
(iii) DFS and BFS traversals (start vertex v1).
2. Define the following terms: [2 M]
(i) Degree of vertex
(ii) Topological sort.
3. Which data structure is used for BFS.
4. Define the term complete graph.
5. Consider the following adjacency matrix:
1234
10100
20010
30001
41000
(i) Draw the graph
(ii) Draw adjacency list
(iii) Draw inverse adjacency list
6. Write an algorithm for BFS traversal of a graph.
7. List any methods of representing graphs
8. List two applications of graph
9. Consider the following graph:
Starting vertex v1
(i) Draw adjacency list
(ii) Give DFS and BFS traversals
10. State any two applications of graph.
11. Consider the following specification of a graph G:
V(G) = {1, 2, 3, 4}
E(G) = {(1, 2),(1, 3),(3, 3),(3, 4),(4, 1)}
(i) Draw a picture of the undirected graph.
(ii) Draw adjacency matrix of lists.
12. Define the following terms: [2 M]
(i) Acrylic graph
(ii) Multigraph.
13. Define the term topological sort.

14.
(i) Write adjacency matrix
(ii) Draw adjacency list
(iii) DFS and BFS traversals (start vertex v1).

15.

(i) Write adjacency matrix


(ii) Give DFS and BFS (Source vertex v1).

You might also like