0% found this document useful (0 votes)
52 views

DS2021 Lab Component

The document describes several programming assignments related to data structures and algorithms in C language. It includes 6 sections that require students to design and develop menu driven programs to perform various operations on arrays, stacks, queues, linked lists and doubly linked lists. The operations include creating, inserting, deleting, displaying and evaluating expressions using these data structures. Functions are to be used to implement the required operations for each assignment.

Uploaded by

Charita N
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)
52 views

DS2021 Lab Component

The document describes several programming assignments related to data structures and algorithms in C language. It includes 6 sections that require students to design and develop menu driven programs to perform various operations on arrays, stacks, queues, linked lists and doubly linked lists. The operations include creating, inserting, deleting, displaying and evaluating expressions using these data structures. Functions are to be used to implement the required operations for each assignment.

Uploaded by

Charita N
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/ 37

DATASTRUCTURES AND APPLICATIONS (21CS32)

LAB COMPONENT

1.Design, Develop and Implement a menu driven Program in C for the following Array
Operations a. Creating an Array of N Integer Elements
b. Display of Array Elements with Suitable Headings
c. Exit.
Support the program with functions for each of the above operations.

#include<stdio.h>
int a[10],N;
void create()
{
int I;
printf(“Enter the elements of the array”);
for (I=0;I<N;I++)
scanf(“%d”,&a[I]);
}

void display()
{
int I;
printf(“The elements of the array are:\n”);
for (I=0;I<N;I++)
printf(“%d\t”,a[I]);
}

void main()
{
int ch;
printf(“Enter the number of Elements in the array”);
scanf(“%d”,&N);
while (1)
{
printf(“1:Create\n 2:Display\n 3:Exit\n Enter your choice”)
scanf(“%d”,&ch);
switch(ch)
{
case 1:create();
break;
case 2: dispaly();
break;
default:exit(0);
}
}
}

2. Design, Develop and Implement a menu driven Program in C for the following Array
operations a. Inserting an Element (ELEM) at a given valid Position (POS) b. Deleting an
Element at a given valid Position POS) c. Display of Array Elements d. Exit. Support the
program with functions for each of the above operations.

#include<stdio.h>
#include<conio.h>
int n;

void read (int a[10])


{
int i;
printf("\n Enter the elements \n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
}
void print(int a[10])
{
int i;
printf("\nThe elements of the array are: ");
for(i=0;i<n;i++)
printf("%d ",a[i]);
}

void insert(int a[10], int ele, int pos)


{
int i;
for(i=n-1;i>=pos-1;i--)
a[i+1]=a[i];
a[pos-1]=ele;
n++;
}

int delete(int a[10],int pos)


{
int i,ele;
ele=a[pos-1];
for(i=pos-1;i<n;i++)
a[i]=a[i+1];
n--;
return ele;
}

int main()
{
int a[10],ch,ele,pos;
while(1)
{
printf("\nEnter your choice:\n1.Read\n2.Print\n3.Insert\n4.Delete\n5.Exit\n");
scanf(“%d",&ch);

switch(ch)
{
case 1:printf("\nEnter the number of elements ");
scanf("%d",&n);
read(a);
break;
case 2: print(a);
break;
case 3: printf("\nEnter the element to be inserted\n");
scanf("%d",&ele);
printf("\nEnter position of the element to be inserted\n");
scanf("%d",&pos);
insert(a,ele,pos);
break;
case 4: printf("\nEnter position of the element to be deleted\n");
scanf("%d",&pos);
ele=delete(a,pos);
printf("\nThe deleted element is:%d",ele);
break;
case 5:exit(0);
}
}
return 0;
}

3. Design, Develop and Implement a menu driven Program in C for the following operations
on STACK of Integers (Array Implementation of Stack with maximum size MAX) a. Push an
Element on to Stack b. Pop an Element from Stack c. Demonstrate Overflow and Underflow
situations on Stack d. Display the status of Stack e. Exit Support the program with appropriate
functions for each of the above operations

#include<stdio.h>
#define MAX 10
int top=-1;
int overflow()
{
if (top==MAX-1)
return 1;
else return 0;
}

int underflow()
{
if (top==-1)
return 1;
else return 0;
}

void push(int *s,int ele)


{
if(!overflow())
s[++top]=ele;
else
printf("stack overflow\n");
}

int pop(int *s)


{
if(!underflow())
return(s[top--]);
else
printf("stack underflow\n");
return(0);
}

void display(int *s)


{
int i;
if(underflow())
{
printf("stack underflow\n");
return;
}
printf("The stack contents are:\n");
for(i=0;i<=top;i++)
printf("%d\t",s[i]);
}
int palin(char *pal,int *s)
{
int i;
top=-1;
for(i=0;pal[i]!='\0';i++)
push(s,pal[i]-'0');
for(i=0;pal[i]!='\0';i++)
if (pal[i]!=(pop(s)+'0'))
return 0;
return 1;
}

int main()
{
int stack[MAX],ch,i,j,ele,p;
char str[10];
while(1)
{
printf("\nEnter your choice:\n1:PUSH\n2:POP\n3:CHECK
PALINDROME\n4:DISPALY\n5.EXIT\n");
scanf("%d",&ch);
switch(ch)
{
case 1: printf("\nEnter the element to be pushed: n");
scanf("%d",&ele);
push(stack,ele);
break;
case 2: ele=pop(stack);
if(ele!=0)
printf("\nThe deleted element is: %d\n",ele);
break;
case 3:printf("\nEnter the string ");
fflush(stdin);
gets(str);
p=palin(str,stack);
if(p) printf("\nThe given string is Palindrome");
else printf("\nThe given string is not a palindrome");
break;
case 4:display(stack);
break;
default:exit(0);
}
}
return 0;}

4,Design, Develop and Implement a Program in C for the following Stack Applications a.
Evaluation of Suffix expression with single digit operands and operators: +, -, *, /, %, ^

#include<stdio.h>
#include<ctype.h>
#include<process.h>
#include<string.h>

int stack[20], top;


void push(int);
int pop();
void eval(char post[20]);

int main()
{
char post[20];
top=-1;
printf(“\n enter the postfix expression:”);
gets(post);
eval(post);
printf(“\n the evaluated answer is: %d”,pop());
return 0;
}

void push(int ele)


{
stack[++top]=ele;
}

int pop()
{
return (stack[top--]);
}

void eval(char post[20])


{
char ch;
int i, b, a;
for(i=0;post[i];i++)
{
ch=post[i];
if(isdigit(ch));
push(ch-‘0’);

else
{
b=pop();
a=pop();
switch(ch)
{
case ‘+’:push(a+b);
break;
case ‘-‘:push(a-b);
break;
case ‘*’:push(a*b);
break;
case ‘/’:if(b==0)
{
printf(“\n Divide by zero error”);
return 0;
exit(0);
}
push(a/b);
default:printf(\ninvalid operation”);
}
}
}
}

5,Singly Linked List (SLL) of Integer Data


a. Create a SLL stack of N integer.
b. Display of SLL
c. Linear search.
Create a SLL queue of N Students Data
Concatenation of two SLL of integers

#include<stdio.h>
#include<stdlib.h>
struct node
{
int data;
struct node * link;
};
//struct node *head=NULL;

struct node * create_st(struct node *head,int n)


{
int i,item;
struct node *temp;
for( i=0;i<n;i++)
{
temp=malloc (sizeof(struct node));
printf("enter the item");
scanf("%d",&item);
temp->data=item;
temp->link=NULL;
if (head==NULL)
head=temp;
else
{
temp->link=head;
head=temp;
}
}
return head;
}
void create_q(struct node* head,int n)
{
int i,item;
struct node *temp,*temp1=head;
for( i=0;i<n;i++)
{
temp=malloc (sizeof(struct node));
printf("enter the item");
scanf("%d",&item);
temp->data=item;
temp->link=NULL;
if (head!=NULL)

{
while(temp1->link!=NULL)
temp1=temp1->link;
temp1->link=temp;
}
else
head=temp;
}
}
void display(struct node *head,int n)
{
int i;
struct node *temp=head;
for (i=1;i<=n;i++)
{
printf("%d\t",temp->data);

temp=temp->link;
}
}
void linear_search(struct node *head)
{
int key;
struct node *temp=head;
printf("enter key");
scanf("%d",&key);
while(temp!=NULL)
{
if(key==temp->data)
{
printf("Key found") ;
return;
}
temp=temp->link;
}
printf("Key notfound") ;
}
void concat()
{
int i,n1,n2,item;
struct node * sll1=NULL,*sll2=NULL,*temp1=sll1,*temp;
printf("enter n of SLL1\n");
scanf("%d",&n1);
printf("enter no of sll2\n");
scanf("%d",&n2);
sll1=create_st(sll1,n1);
display(sll1,n1);
sll2=create_st(sll2,n2);
display(sll2,n2);
printf("the concatenated list is:\n");
temp1=sll1;
while(temp1->link!=NULL)
temp1=temp1->link;
temp1->link=sll2;
temp=sll1;
for(i=1;i<=n1+n2;i++)
{
printf("%d\t",temp->data);
temp=temp->link;
}
}

void main()
{
struct node *head;
int ch,n;
while (1)
{
printf("\nEnter choice\n 1:Create SLL Stack\n 2:Create SLL Queue\n
3:Display\n4:Linear Search\n 5:Concatenation of SLLs \n 6:Exit\n");
scanf("%d",&ch);
switch(ch)
{
case 1: head=NULL;
printf("\nenter the no of nodes");
scanf("%d",&n);
head=create_st(head,n);
break;
case 2: head=NULL;
printf("\nenter the no of nodes");
scanf("%d",&n);
create_q(head,n);
break;
case 3: display(head,n);
break;
case 4: linear_search(head);
break;
case 5: concat();
break;
default: exit(0);
}

}
}

6.Design, Develop and Implement a menu driven Program in C for the following operations
on Doubly Linked List (DLL) of Professor Data with the fields: ID, Name, Branch, Area of
specialization
a. Create a DLL stack of N Students Data.
b. Create a DLL queue of N Students Data
c. Display the status of DLL and count the number of nodes in it.

#include<stdio.h>

#include<stdlib.h>
struct node
{
struct node * llink;
int id;
char name[10];
char branch[10];
char area_of_special[10];
struct node *rlink;
};
struct node *head=NULL;
int n;
void create_st()
{
int i;
struct node *temp;
printf("\nenter the no of nodes");
scanf("%d",&n);
for( i=0;i<n;i++)
{
temp=malloc (sizeof(struct node));
printf("enter the id");
scanf("%d",&temp->id);
printf("enter the name");
fflush(stdin);
gets(temp->name);
fflush(stdin);
printf("enter the brach");
gets(temp->branch);
fflush(stdin);
printf(" enter area of specialization");
gets(temp->area_of_special);
temp->llink=NULL;
temp->rlink=NULL;
if (head==NULL)
head=temp;
else
{
temp->rlink=head;
head->llink=temp;
head=temp;
}
}
}

void create_q()
{
int i;
struct node *temp,*temp1;
printf("\nenter the no of nodes");
scanf("%d",&n);
for( i=0;i<n;i++)
{
temp=malloc (sizeof(struct node));
printf("enter the id");
scanf("%d",&temp->id);
printf("enter the name");
fflush(stdin);
gets(temp->name);
printf("enter the brach");
fflush(stdin);
gets(temp->branch);
printf("enter area of specialization");
fflush(stdin);
gets(temp->area_of_special);
temp->llink=NULL;
temp->rlink=NULL;
temp1=head;
if (head==NULL)
head=temp;
else
{
while(temp1->rlink!=NULL)
temp1=temp1->rlink;
temp1->rlink=temp;
temp->llink=temp1;
}
}
}

void display()
{
int i;
struct node *temp=head;
printf("id name branch specialization\n");
printf("-----------------------------------\n");
for (i=1;i<=n;i++)
{
printf("%d\t",temp->id);
printf("%s\t",temp->name);
printf("%s\t",temp->branch);
printf("%s\t",temp->area_of_special);
temp=temp->rlink;
printf("\n");
}
printf("\n---------------------------------\n");
}
void main()
{
int ch;
while (1)
{
printf("\nEnter choice\n 1:Create DLL Stack\n 2:Create DLL Queue\n
3:Display\n4:Exit\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
create_st();
break;
case 2: create_q();
break;
case 3: display();
break;
default: exit(0);
}

}
}

7. Given an array of elements, construct a complete binary tree from this array in level order
fashion. That is, elements from left in the array will be filled in the tree level wise starting from
level 0.

Ex: Input : arr[] = {1, 2, 3, 4, 5, 6}


Output : Root of the following tree
1
/ \
2 3
/ \ / \
4 56 2.

#include<stdio.h>
#include<conio.h>
#include<alloc.h>
struct Node
{
int data;
struct Node * left;
struct Node * right;
};

struct Node* newNode(int data)


{
struct Node* node =malloc(sizeof(struct Node));
node->data = data;
node->left = node->right = NULL;
return (node);
}
struct Node* insertLevelOrder(int arr[], struct Node* root,
int i, int n)
{
if (i < n)
{
struct Node* temp = newNode(arr[i]);
root = temp;

root->left = insertLevelOrder(arr,
root->left, 2 * i + 1, n);

root->right = insertLevelOrder(arr,
root->right, 2 * i + 2, n);
}
return root;
}

void inOrder(struct Node* root)


{
if (root != NULL)
{
inOrder(root->left);
printf("%d\t",root->data);
inOrder(root->right);
}
}
void main()
{
int arr[] = { 1, 2, 3, 4, 5, 6, 6, 6, 6 };
int n = sizeof(arr)/sizeof(arr[0]);
struct Node* root = insertLevelOrder(arr, root, 0, n);
inOrder(root);
}

8.Design, Develop and Implement a menu driven Program in C for the following operations
on Binary Search Tree (BST) of Integers
a. Create a BST of N Integers
b. Traverse the BST in Inorder, Preorder and Post Order

#include<stdio.h>
struct node
{
int data;
struct node *left;
struct node *right;
};
struct node * newNode(int item)
{
struct node *temp=(struct node *) malloc(sizeof(struct node));
temp->data = item;
temp->left = temp->right = NULL;
return temp;
}
struct node* insert(struct node* node, int key)
{
if (node == NULL) return newNode(key);
if (key < node->data)
node->left = insert(node->left, key);
else if (key > node->data)
node->right = insert(node->right, key);
return node;
}

void inorder(struct node *root)


{
if (root != NULL)
{

inorder(root->left);
printf("%d \t", root->data);
inorder(root->right);
}
}
void preorder(struct node *root)
{
if (root != NULL)
{
printf("%d \t", root->data);
preorder(root->left);
preorder(root->right);
}
}

void postorder(struct node *root)


{
if (root != NULL)
{
postorder(root->left);
postorder(root->right);
printf("%d \t", root->data);
}
}

void main()
{
int n,i,ch,ch1,key,pos;
struct node *root=NULL;
while(1)
{
printf("\nEnter the choice\n1:Create BST\n 2:Traversal\n 3:Exit\n");
scanf("%d",&ch);
switch(ch)
{
case 1:printf("Enterthe no of nodes in the BST\n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{ printf("Enter the element to be iserted\n");
scanf("%d",&key);
root=insert(root,key);
}
break;
case 2:printf("Enter your choice\n1:
Preorder\n2:Inorder\n3:Postorder\n");
scanf("%d",&ch1);
if (ch1==1)
preorder(root);
else if (ch1==2)
inorder(root);
else postorder(root);
Break;
default: exit(0);
}
}
}
9.Design, Develop and implement a program in C for the following operations on Graph (G)
of cities a. Create a Graph of N cities using Adjacency Matrix. b. Print all the nodes reachable
from a given starting node in a diagraph using DFS/BFS method.
#include<stdio.h>
#include<conio.h>
int count=0;
void creategraph(int n,int a[10][10])
{
int i,j;
printf("enter the adjacency matrix\n");
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
scanf("%d",&a[i][j]);
}
void bfs(int a[10][10], int n, int source,int s[])
{
int f,r,q[10],u,v,i;
printf("enter the source vertex\n");
scanf("%d",&source);
printf("the nodes reachable are\n");
for(i=1;i<=n;i++)
s[i]=0;
f=r=0;
q[r]=source;
s[source]=1;
while(f<=r)
{
u=q[f++];
for(v=1;v<=n;v++)
{
if(a[u][v]==1 && s[v]==0)
{
printf("\n%d",v);
s[v]=1;
q[++r]=v;
}
}
}
}
int main()
{
int a[20][20],n,source,s[10],i,j,vis[10];
int ch;

while(1)
{ printf("\nEnter your choice\n1:Create graph\n2:Check Reachability\n3.Exit\n");
scanf("%d",&ch);
switch(ch)
{
case 1: printf("Enter the number of nodes:");
scanf("%d",&n);
creategraph(n,a);
break;
case 2: bfs(a,n,source,s);
break;
case 3: exit(0);
}
}
return 0;

}
10.Design and develop a program in C that uses Hash Function H:K->L as H(K)=K mod
m(reminder method) and implement hashing technique to map a given key K to the address
space L. Resolve the collision (if any) using linear probing.

#include<stdio.h>
#include<stdlib.h>
#definre max 100
int create(int num)
{
int key;
key=num%100;
return key;
}
void linear_prob(int a[max],int key,int num)
{
int flag=0,i,count=10;
if(a[key]==-1) a[key]=num;
else
{
for(i=10;i<max;i++)
{
if(a[i]!=-1) count++;
}
if(count==max)
{
printf(“\n hash table is full\n”);
display(a);
exit(1);
}
for(i=key+1;i<max;i++)
if(a[i]==-1)
{
a[i]=num;
flag=1;break;
}
for(i=10;i<key&&flag==0;i++)
if(a[i]==-1)
{
a[i]=num;
flag=1;break;
}
}
}
void display(int a[max])
{
int i;
printf(“\n the hash table is…\n”);
printf(“key/index\t employee id\n”);
printf(“………………………………………..\n”);
for(i=10;i<max;i++)
printf(“\n %d %d\n”, i, a[i]);
}
int main()
{
int a[max],num,key,i;
int ans;
printf(“collision handling by linear probing\n”);
for(i=10;i<max;i++) a[i]=-1;
do
{
printf(“\n enter the four digit number:”);
scanf(“%d”,&num);
key=create(num);
linear_pron(a,keyt,num);
printf(“do you want to continue?\n”);
scanf(“%d”,&ans);
}while(ans==1);
display(a);
}
Module-1
Introduction: Data Structures, Classifications (Primitive & Non-Primitive), Data structure
operations (Traversing, inserting, deleting, searching, and sorting). Review of Arrays.
Structures: Array of structures Self-Referential Structures. Dynamic Memory Allocation
Functions. Representation of Linear Arrays in Memory, dynamically allocated arrays and
Multidimensional Arrays. Demonstration of representation of Polynomials and Sparse
Matrices with arrays.

Textbook 1: Chapter 1: 1.2, Chapter 2: 2.2 - 2.7, Text Textbook 2: Chapter 1: 1.1 - 1.4, Chapter
3: 3.1 - 3.3, 3.5, 3.7, Chapter 4: 4.1 - 4.9, 4.14 Textbook 3: Chapter 1: 1.3
Laboratory Component:
1. Design, Develop and Implement a menu driven Program in C for the following Array
Operations a. Creating an Array of N Integer Elements b. Display of Array Elements with
Suitable Headings c. Exit. Support the program with functions for each of the above operations.
2. Design, Develop and Implement a menu driven Program in C for the following Array
operations
a. Inserting an Element (ELEM) at a given valid Position (POS)
b. Deleting an Element at a given valid Position POS)
c. Display of Array Elements
d. Exit.
Support the program with functions for each of the above operations. Teaching-Learning
Process Problem based learning (Implementation of different programs to illustrate application
of arrays and structures. https://www.youtube.com/watch?v=3Xo6P_V-qns&t=201s
https://ds2-iiith.vlabs.ac.in/exp/selection-sort/index.html https://ds1-iiith.vlabs.ac.in/data-
structures1/List%20of%20experiments.html

Module-2
Stacks: Definition, Stack Operations, Array Representation of Stacks, Stacks using Dynamic
Arrays. Different representation of expression. Stack Applications: Infix to postfix conversion,
Infix to prefix conversion, evaluation of postfix expression, recursion. Queues: Definition,
Array Representation of Queues, Queue Operations, Circular Queues, Queues and Circular
queues using Dynamic arrays, Dequeues, Priority Queues.
Textbook 1: Chapter 3: 3.1 -3.4, 3.6 Textbook 2: Chapter 6: 6.1 -6.4, 6.5, 6.7-6.13

Laboratory Component:
1. Design, Develop and Implement a menu driven Program in C for the following operations
on STACK of Integers (Array Implementation of Stack with maximum size MAX)
a. Push an Element on to Stack
b. Pop an Element from Stack
c. Demonstrate Overflow and Underflow situations on Stack
d. Display the status of Stack
e. Exit Support the program with appropriate functions for each of the above operations
2. Design, Develop and Implement a Program in C for the following Stack Applications a.
Evaluation of Suffix expression with single digit operands and operators: +, -, *, /, %, ^ b.
Solving Tower of Hanoi problem with n disks

Teaching-Learning Process Active Learning, Problem based learning


https://nptel.ac.in/courses/106/102/106102064/ https://ds1-iiith.vlabs.ac.in/exp/stacks-
queues/index.html

Module-3
Linked Lists: Definition, classification of linked lists. Representation of different types of
linked lists in Memory, Traversing, Insertion, Deletion, Searching, Sorting, and Concatenation
Operations on Singly linked list, Doubly Linked lists, Circular linked lists, and header linked
lists. Linked Stacks and Queues. Applications of Linked lists – Polynomials, Sparse matrix
representation. Programming Examples.
Textbook 1: Chapter 4: 4.1 – 4.4, 4.5.2, 4.7, 4.8, Textbook 2: Chapter 5: 5.1 – 5.9

Laboratory Component: 1. Singly Linked List (SLL) of Integer Data


a. Create a SLL stack of N integer.
b. Display of SLL
c. Linear search. Create a SLL queue of N Students Data Concatenation of two SLL of integers.
2. Design, Develop and Implement a menu driven Program in C for the following operationson
Doubly Linked List (DLL) of Professor Data with the fields: ID, Name, Branch, Area of
specialization
a. Create a DLL stack of N Professor’s Data.
b. Create a DLL queue of N Professor’s Data Display the status of DLL and count the number
of nodes in it.

Teaching-Learning Process MOOC, Active Learning, Problem solving based on linked lists.
https://nptel.ac.in/courses/106/102/106102064/ https://ds1-iiith.vlabs.ac.in/exp/linked-
list/basics/overview.html https://ds1-iiith.vlabs.ac.in/List%20of%20experiments.html
https://ds1-iiith.vlabs.ac.in/exp/linked-list/basics/overview.html https://ds1-
iiith.vlabs.ac.in/List%20of%20experiments.html

Module-4
Trees 1: Terminologies, Binary Trees, Properties of Binary trees, Array and linked
Representation of Binary Trees, Binary Tree Traversals - Inorder, postorder, preorder;
Threaded binary trees, Binary Search Trees – Definition, Insertion, Deletion, Traversal, and
Searching operation on Binary search tree. Application of Trees-Evaluation of Expression.

Textbook 1: Chapter 5: 5.1 –5.5, 5.7; Textbook 2: Chapter 7: 7.1 – 7.9

Laboratory Component:

1. Given an array of elements, construct a complete binary tree from this array in level order
fashion. That is, elements from left in the array will be filled in the tree level wise starting from
level 0. Ex: Input : arr[] = {1, 2, 3, 4, 5, 6} Output : Root of the following tree 1 / \ 2 3 / \ /\ 4
56

2. Design, Develop and Implement a menu driven Program in C for the following operations
on Binary Search Tree (BST) of Integers
a. Create a BST of N Integers
b. Traverse the BST in Inorder, Preorder and Post Order

Teaching-Learning Process Problem based learning http://www.nptelvideos.in/2012/11/data-


structures-andalgorithms.html https://ds1-iiith.vlabs.ac.in/exp/tree-traversal/index.html
https://ds1-iiith.vlabs.ac.in/exp/tree-traversal/depth-firsttraversal/dft-practice.html

Module-5
Trees 2: AVL tree, Red-black tree, Splay tree, B-tree. Graphs: Definitions, Terminologies,
Matrix and Adjacency List Representation of Graphs, Traversal methods: Breadth First Search
and Depth FirstSearch. Hashing: Hash Table organizations, Hashing Functions, Static and
Dynamic Hashing.
Textbook 1: Chapter 10:10.2, 10.3, 10.4, Textbook 2:7.10 – 7.12, 7.15 Chapter 11: 11.2,
Textbook 1: Chapter 6 : 6.1–6.2, Chapter 8 : 8.1-8.3, Textbook 2: 8.1 – 8.3, 8.5, 8.7 Textbook
3: Chapter 15:15.1, 15.2,15.3, 15.4,15.5 and 15.7

Laboratory Component:
1. Design, Develop and implement a program in C for the following operations on Graph (G)
of cities
a. Create a Graph of N cities using Adjacency Matrix.
b. Print all the nodes reachable from a given starting node in a diagraph using DFS/BFS
method.

2. Design and develop a program in C that uses Hash Function H:K->L as H(K)=K mod
m(reminder method) and implement hashing technique to map a given key K to the address
space L. Resolve the collision (if any) using linear probing

Teaching-Learning Process NPTL, MOOC etc. courses on trees and graphs.


http://www.nptelvideos.in/2012/11/data-structures-andalgorithms.html

MODULE1
Data Structures: A data structure is a way of organizing the data in memory. Using data
structure, we can store the data efficiently so that it can be accessed, processed and manipulated
easily. There are many data structures available, which can be chosen according to the problem
we are solving.
Ex:Array is a data structure.
We can declare an array as:
int a[10];
We are declaring an array of integers consisting of 10 elements. All the elements are of same
type integer.All the elements are stored in contiguous memory locations as shown in the figure
below:

10 20 30 40 50 60 70 80 90 100
a[0] a[1] a[2] a[3] a[4] a[5] a[6] a[7] a[8] a[9]

Fig:1.1 Storing array

Classifications (Primitive & Non-Primitive):Data structures are broadly categorized in two


categories, primitive and non-primitive.
Data structures
primitive data structures non-primitive data structures

Primitive data structures:

You might also like