Important Instructions To Examiners:: Correct 2M

Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION

(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Data Structure Using ‘C’ Subject Code: 22317

Important Instructions to examiners:


1) The answers should be examined by key words and not as word-to-word as given in the
model answer scheme.
2) The model answer and the answer written by candidate may vary but the examiner may try
to assess the understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more
Importance (Not applicable for subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components indicated in the
figure. The figures drawn by candidate and model answer may vary. The examiner may give
credit for any equivalent figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed
constant values may vary and there may be some difference in the candidate’s answers and
model answer.
6) In case of some questions credit may be given by judgement on part of examiner of relevant
answer based on candidate’s understanding.
7) For programming language papers, credit may be given to any other program based on
equivalent concept.
8) As per the policy decision of Maharashtra State Government, teaching in English/Marathi
and Bilingual (English + Marathi) medium is introduced at first year of AICTE diploma
Programme from academic year 2021-2022. Hence if the students in first year (first and
second semesters) write answers in Marathi or bilingual language (English +Marathi), the
Examiner shall consider the same and assess the answer based on matching of concepts
with model answer.

Q. Sub Answer Marking


No Q.N. Scheme
1. Attempt any FIVE of the following: 10
a) Define Abstract Data Type (ADT) 2M
Ans.  ADT is defined as a mathematical model of the data objects that make Correct
definition
up a data type as well as functions that operate on these objects. 2M
 ADT is the specification of logical and mathematical properties of a
data type or structure.
b) Explain the term: Time Complexity 2M
Ans. Time Complexity: Time complexity of program or algorithm is Correct
definition
amount of computer time that it needs to run to completion. To measure 1M
time complexity of an algorithm we concentrate on developing only Example
1M
frequency count for key statements.

Page 1 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Data Structure Using ‘C’ Subject Code: 22317

Example:-
Algorithm A: - a=a+1
Algorithm B: - for x = 1 to n step 1 a=a+1 Loop

Frequency count for algorithm A is 1 as a=a+1 statement will execute


only once. Frequency count for algorithm B is n as a=a+1 is key
statement executes n time as the loop runs n times.
c) List the operations that can be performed on data structure. 2M
Ans. 1. Inserting Any two
correct
2. Deleting operations
3. Sorting 1M
4. Searching each
5. Traversing
6. Merging
7. Copying
8. Concatenation

d) Define Searching. State two methods of Searching. 2M


Ans. Searching: The process of finding the desired information from the set Correct
definition
of items stored in the form of elements in the computer memory is 1M
referred to as 'searching in data structure'
Two
Methods methods
1. Linear search 1M
2. Binary Search

e) Define Stack with suitable example. 2M


Ans. A stack is linear data structure or orderly collection of data in which Correct
definition
data may be inserted or deleted from one end called “top of stack‟ for 1M
this reason stack is referred as LIFO (Last in First Out).
Example:-
1. stack of plates Any one
2. deck of cards, Example
1M
3. piles of books

Page 2 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Data Structure Using ‘C’ Subject Code: 22317

f) Define linked list with example. 2M


Ans. Linked list: It is linear collection of data elements. Each element in
Correct
linked list is called as ‘node’. Each node contains two fields. First is definition
INFO which stores data & second is LINK/NEXT which is linked with 1M
address of next node in a list.

Example:-

Example
1M

g) Define the following terms with respect to tree: 2M


(i) In-degree
(ii) Out-degree Correct
Ans. definition
In -degree: Number of edges coming towards node is in-degree of and
node. example of
For e.g. : In degree of node B is 1 each
1M
Out -degree: Number of edges going out from node is out -degree of
node.
For e.g. Out Degree of is node D is 2

Page 3 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Data Structure Using ‘C’ Subject Code: 22317

2. Attempt any THREE of the following: 12


a) Describe working of Bubble sort with example 4M
Ans. BUBBLE SORT:-The algorithm in bubble sort involves two steps,
1. Compares two adjacent items
Working
2. If necessary , swap (exchange) them 2M
Sorting begins with 0th elements & it compares with 1st element in list.
If 1st element is less than 0th element then interchange takes place. Example
2M
 Like this all elements are compared with next element &
interchanged if required. At end of 1st pass largest element is placed
at last position. In 2nd pass again comparisons starts with 0th
element & 2nd largest element is placed at second last position. This
process continues till list is in sorted order.
 First Pass:
( 5 1 4 2 8 ) –> ( 1 5 4 2 8 ), Here, algo compares the first two
elements, & swaps since 5 > 1.
( 1 5 4 2 8 ) –> ( 1 4 5 2 8 ), Swap since 5 > 4
( 1 4 5 2 8 ) –> ( 1 4 2 5 8 ), Swap since 5 > 2
( 1 4 2 5 8 ) –> ( 1 4 2 5 8 ), Now, since these elements are
already in order (8 > 5), algorithm does not swap them.
 Second Pass:
( 1 4 2 5 8 ) –> ( 1 4 2 5 8 )
( 1 4 2 5 8 ) –> ( 1 2 4 5 8 ), Swap since 4 > 2
( 1 2 4 5 8 ) –> ( 1 2 4 5 8 )
( 1 2 4 5 8 ) –> ( 1 2 4 5 8 )
Now, the array is already sorted, but our algorithm does not know
if it is completed. The algorithm needs one whole pass
without any swap to know it is sorted.
 Third Pass:
( 1 2 4 5 8 ) –> ( 1 2 4 5 8 )
( 1 2 4 5 8 ) –> ( 1 2 4 5 8 )
( 1 2 4 5 8 ) –> ( 1 2 4 5 8 )
( 1 2 4 5 8 ) –> ( 1 2 4 5 8 )
 Fourth Pass:
( 1 2 4 5 8 ) –> ( 1 2 4 5 8 )
( 1 2 4 5 8 ) –> ( 1 2 4 5 8 )
( 1 2 4 5 8 ) –> ( 1 2 4 5 8 )
( 1 2 4 5 8 ) –> ( 1 2 4 5 8 )

Page 4 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Data Structure Using ‘C’ Subject Code: 22317

b) Explain PUSH and POP operation on stack with suitable example. 4M


Ans. 1) PUSH: The process of adding new element to the top of the stack is
called PUSH operation. Explanatio
n of PUSH
Algorithm: and POP
Step 1: [Check for stack full/ overflow] If stack top is equal to max-1 1M each
then write “Stack Overflow” return S
Step 2: [Increment top] top= top +1; Example
Step 3 : [Insert element] stack [top] = item; of PUSH
and POP
Step 4 : return 1M each

2) POP: The process of deleting an element from top of the stack is


called POP operation.
Algorithm:
Step 1: [Check for stack empty/ underflow] If stack top is equal to -1
then write “Stack Underflow” return
Step 2:
[Copy data] item=stack[top];
Step 3 : [decrement top] top = top-1;
Step 4 : return

c) Explain the concept of information, next, null pointer and empty 4M


list with respect to linked list.

Page 5 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Data Structure Using ‘C’ Subject Code: 22317

Ans.  Information: It is also known as data part. It is used to store data Explanatio
inside the node. n of each
term 1M
 Next Pointer for Linked list: Which Hold the Address of the next
node, which intern links the nodes together.

 NULL pointer: It is used to specify end of list. The last element of


list contains NULL pointer to specify end of list.

 Empty list: A linked list is said to be empty if head (start) node


contains NULL pointer.

d) Write an algorithm to insert a new node at the beginning in linear 4M


list.
Ans. Algorithm to insert a new node at the beginning in linear list: Correct
Algorithm
1. START 4M
2. Obtain free space for new node
3. Assign data to the data field of new node.
4. Set the next field of new node to the beginning of the list.
5. Change the reference pointer (head) of the linked list to point new
node.
6.STOP

Page 6 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Data Structure Using ‘C’ Subject Code: 22317

3. Attempt any THREE of the following: 12


a) Write a program to implement linear search for 10 elements in an 4M
array.
Ans. Note: Any other relevant logic shall be considered Correct
# include <stdio.h> logic 2M
# include <conio.h> Correct
void main () syntax 2M
{
int a[10] = {10, 20, 30, 40, 50, 65, 54, 25, 37, 15}, se, i, flag=0;
clrscr( );
printf (“Enter search element”);
scanf (“%d”,&se);
for (i = 0; i <10; i ++)
{
if (a[i] = = se)
{
flag=1;
printf(“Element found”);
break;
}
}
if (flag= =0)
printf (“Number not found”);
getch( );
}

Page 7 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Data Structure Using ‘C’ Subject Code: 22317

b) Write a program to print a string in reverse order. 4M


Ans. Note: Any other relevant logic shall be considered
#include <stdio.h>
#include <string.h> Initializati
void main() on of
string
{ 1M
char str1[50], temp; reversing
int i = 0, j =0; of string
printf (" Enter a string to be reversed: "); 2M display
scanf( "%s", str1); of reversed
string 1M
j = strlen (str1) - 1;
while ( i < j)
{
temp = str1[j];
str1[j] = str1[i];
str1[i] = temp;
i++;
j--;
}
printf (" The reversed of the string: %s", str1);
}

c) Explain the operations on a singly linked list 4M


Ans 1. Creating Linked List: Any four
Creating a linked list insert first element (node) in linked list. operations
1M each
Initially list contains start node which is a null pointer.
After inserting first element start pointer points to new node as
shown in following diagram.

2. Inserting a node at the beginning of list:


In this operation, new node is created and added at the beginning
of a list. To make new node first node, store existing node’s address
in new node’s address field and add new node’s address in header
node.

Page 8 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Data Structure Using ‘C’ Subject Code: 22317

3. Inserting a node at the end of the list:


In this operation, a new node can be added at the end of the list. Set
new nodes info with data and next field with NULL value. Then
search for the last node in a list and set last node’s next field to new
node.

4. Inserting a node at the specified position:


In this operation, a new node can be added at any specified position.
Set new node’s info field with data, then traverse through the list
up to the position -1 node (previous node) and set next field of
previous as well as new node.

5. Display/traverse through linked list:


It is used to visit each and every element at-least once from the
linked list.
6. Delete Starting from Linked List
7. Delete Ending Node from Linked List
Page 9 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Data Structure Using ‘C’ Subject Code: 22317

8. Delete specific node from Linked List


9. Search a node from Linked List
d) Draw a binary search tree for the given numbers: 4M
50, 33, 44, 22, 77, 35, 60, 40
Ans.
4M for tree
build
OR
½ M for
each
correct
node
placed in
correct
position in
tree.

Page 10 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Data Structure Using ‘C’ Subject Code: 22317

Page 11 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Data Structure Using ‘C’ Subject Code: 22317

4. Attempt any THREE of the following: 12


a) Explain linear data structure with any three types 4M
Ans. In this type of data structure, all the elements are placed in a sequence.
In the linear data structure, data is arranged in such a way that one 1M for
element is adjacent to its previous and the next element. It includes explanatio
n of linear
the data at a single level such that we can traverse all data into a single data
run. structure
For example and
Array, Stack, Queue 1M for
Array: It is a collection of elements stored in contiguous locations each type
inside memory.
Example:
Array of five elements:

Stack:
It is a collection of elements stored in a sequence. It has one end called
as stack top. All elements are inserted and deleted only from stack top
so stack is also called as LIFO-Last. In First Out data structure. Last
inserted element in stack is removed first from stack.
Example: Stack of five elements:

Queue:
It is a collection of elements stored in a sequence. It has two end: one
is rear end from which an element is inserted in a queue and other is
front from which an element is removed from queue so queue is also
called as FIFO-First. In First Out data structure. First inserted element
in a queue is removed from queue first.

Page 12 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Data Structure Using ‘C’ Subject Code: 22317

Example: Queue of five elements using array:

b) Write a ‘C’ program to implement selection sort. 4M


Ans. Note: Any other relevant logic shall be considered
# include <stdio.h> Initializati
# include <conio.h> on of an
array 1M,
void main () Sorting
{ 2M,
int a[5],i,j,temp; Display of
clrscr(); sorted
printf ("\nEnter five numbers for sorting:"); array 1M
for(i=0;i<5;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<4;i++)
{
for(j=i+1;j<5;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
printf ("sorted order:");
for(i=0;i<5;i++)
{
printf("\n%d",a[i]);
}
getch();
}
c) Convert the following infix expression to postfix expression using stack 4M
and show the details of stack in each step:
((A+B)*C)  (D - E)

Page 13 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Data Structure Using ‘C’ Subject Code: 22317

Ans.
Correct
conversion
4M

Page 14 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Data Structure Using ‘C’ Subject Code: 22317

d) Implement a C program to insert element into the queue and delete 4M


the element from the queue.
Ans. Note: Any other relevant logic shall be considered
#include <stdio.h>
#define qsize 5 Program to
insert
int front; element
int rear; 2M,
Program to
int queue[qsize];
delete
void insertq(int);// function declaration element
void deleteq(); 2M
void display();
int main()
{
//initially queue is empty
front = rear =-1;
int x,choice;
do
{
printf("Queue Operations\n");
printf("1.Insert\n2.Delete\n3.Display\n4.Exit");
printf("Enter your choice 1\2\3\4");
scanf("%d",&choice);
switch(choice)
{
case 1:
{
printf("Enter value to be added\n");
scanf("%d",&x);
insertq(x);
break;
}
case 2:
{
deleteq();
break;

Page 15 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Data Structure Using ‘C’ Subject Code: 22317

}
case 3:
{
display();
break;
}
case 4: {
printf("Exit\n");
break;
}
default: printf("Enter Valid choice from 1/2/3/4\n");
break;
}
}while(choice !=4);
return 0;
}
void insertq(int x)
{
//check queue is full?yes or no
if(rear == qsize-1)
printf("Queue is Overflow\n");
else
{
//queue with zero element
if(front ==-1 && rear==-1)
{
front=0;
rear =0;
}
else
{
// queue with one or more element
rear = rear +1;
}

Page 16 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Data Structure Using ‘C’ Subject Code: 22317

// add new element at rear end of queue


queue[rear]=x;
}
}
void deleteq()
{
int x;
//check queue underflow? yes or no
if (front==-1 && rear==-1)
{
printf("queue is underflow\n");
}
else
{
// identify element to be processed
x= queue[front];
//is it the last element
if(front==rear)
{
front=rear=-1;// queue is empty
}
else
{
front = front+1;
}
printf("element %d is deleted\n",x);
}
}
void display()
{
int i;
if(front==-1 && rear ==-1)
{
printf("Queue is Empty\n");

Page 17 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Data Structure Using ‘C’ Subject Code: 22317

}
else
{
printf("Queue elements are\n");
for(i=front; i<=rear; i++)
{
printf("%d\t",queue[i]);
}
}
}
e) Compare linear list with Circular list (Any four points) 4M
Ans. Any four
Sr No Linear List Circular List correct
points 1M
each
1. Next field of the last Next field of the last node is
node is set to NULL. connected back to head node.
2. Points to first node. Points to last node.
3. Insertion at end has O(n) Insertion at end has O(1)
complexity. complexity.
4. Ends on Finding the Searching terminates on
NULL pointer. coming to first node.
5. Not suited for Can be used for Queue data
implementing data structure.
structure.

5. Attempt any TWO of the following: 12


a) Evaluate the given infix expression to the postfix expression using 6M
stack:
((a / (b – c + d)) *( e – a) *c)

Page 18 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Data Structure Using ‘C’ Subject Code: 22317

Ans.
Infix Expression Read Stack Postfix
Correct
Charac Contents Expressions
evaluation
ter
6M
((a / (b – c + d)) *( e – a) *c) ( (
(a / (b – c + d)) *( e – a) *c) ( ((
a / (b – c + d)) *( e – a) *c) a (( a
/ (b – c + d)) *( e – a) *c) / ((/ a
(b – c + d)) *( e – a) *c) ( ((/( a
b – c + d)) *( e – a) *c) b ((/( ab
– c + d)) *( e – a) *c) - ((/(- ab
c + d)) *( e – a) *c) c ((/(- abc
+ d)) *( e – a) *c) + ((/(+ abc-
d)) *( e – a) *c) d ((/(+ abc-d
)) *( e – a) *c) ) ((/ abc-d+
) *( e – a) *c) ) ( abc-d+/
*( e – a) *c) * (* abc-d+/
( e – a) *c) ( (*( abc-d+/
e – a) *c) e (*( abc-d+/e
– a) *c) - (*(- abc-d+/ea-
a) *c) a (*(- abc-d+/ea-
) *c) ) (* abc-d+/ea-
*c) * (* abc-d+/ea-*
c) c (* abc-d+/ea-*c
) ) Empty abc-d+/ea-*c*
stack

Postfix conversion: abc-d+/ea-*c*


b) Create a singly linked list using data fields 15, 20, 22, 58, 60. Search 6M
a node 22 from the singly linked list and show procedure step-by-
step with the help of diagram from start to end.
Note: Any relevant algorithm / procedure with diagram for search
Ans.
process shall be considered.

Page 19 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Data Structure Using ‘C’ Subject Code: 22317

Creating
singly link
list 2M

Search Procedure: Search


procedure
Step1 – Visit first node pointed by head node start
4M
Step 2 – Compare info field of node-1 with search element 22

Node-1 -> info != 22


Move to next node –> node-2
Step 3 – Compare info field of node-2 with search element 22

Node-2 -> info != 22


Move to next node –> node
Step 4 – Compare info field of node-3 with search element 22

Node-2 -> info = 22


Display element found

Page 20 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Data Structure Using ‘C’ Subject Code: 22317

c) From the given tree, complete six answers 6M

i) Degree of tree
ii) Degree of node 3
iii) Level of node 5
iv) In-degree of node 3
v) Out-degree of node 3
Each
vi) Height of tree correct
answer 1M
Ans. i) 2
ii) 2
iii) Level 2
iv) 1
v) 2
vi) 3
6. Attempt any TWO of the following: 12
a) With a neat sketch explain working of priority queue. 6M
Ans. Priority queue: Correct
 A priority queue is a data structure in which each element is explanatio
n 6M
assigned a priority.
 The priority of the element will be used to determine the order in
which the elements will be processed.
 The general rules of processing the elements of a priority queue are:
 An element with higher priority is processed before an element
with a lower priority.
 Two elements with the same priority are processed on a first-come-
first-served (FCFS) basis.
 A priority queue can be thought of as a modified queue in which
when an element has to be removed from the queue, the one with
the highest-priority is retrieved first.

Page 21 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Data Structure Using ‘C’ Subject Code: 22317

Operation on priority queue


1) Insertion in priority queue
 When a new element has to be inserted in a priority queue, we have
to traverse the entire list until we find a node that has a priority lower
than that of the new element.
 The new node is inserted before the node with the lower priority.
However, if there exists an element that has the same priority as the
new element, the new element is inserted after that element.

2) Deletion in priority queue


 It is a very simple process in this case.
 The first node of the list will be deleted, and the data of that node will
be processed first.

b) Draw the tree for given expression: 6M


( a – 2b + 5c)2 * (4d – 6e)5
Ans.

Correct
tree
diagram
6M

Page 22 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Data Structure Using ‘C’ Subject Code: 22317

c) Consider the graph G given below: 6M

i) Write adjacency matrix representation


ii) Write adjacency list
Ans. i)Adjacency matrix representation
Matrix
representat
ion 3M

Adjacency
List 3M

ii) Adjacency List

Nodes Adjacent Nodes


X Y, W, Z
Y W
W Z
Z Y, W

Page 23 / 23

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy