Nayan DS
Nayan DS
Data Structures
(3130702)
Bachelor of Engineering in
Information and Communication Technology
[Semester - 3]
Enrolment No
Name
Branch
Academic Term
Institute Name
satisfactorily completed the Practical work for the subject Data structure
Place: ___________
Date: ___________
Preface
Main motto of any laboratory/practical/field work is for enhancing required skills as well as
creating ability amongst students to solve real time problem by developing relevant
competencies in psychomotor domain. By keeping in view, GTU has designed competency
focused outcome-based curriculum for engineering degree programs where sufficient weightage
is given to practical work. It shows importance of enhancement of skills amongst the students
and it pays attention to utilize every second of time allotted for practical amongst students,
instructors and faculty members to achieve relevant outcomes by performing the experiments
rather than having merely study type experiments. It is must for effective implementation of
competency focused outcome-based curriculum that every practical is keenly designed to serve
as a tool to develop and enhance relevant competency required by the various industry among
every student. These psychomotor skills are very difficult to develop through traditional chalk
and board content delivery method in the classroom. Accordingly, this lab manual is designed
to focus on the industry defined relevant outcomes, rather than old practice of conducting
practical to prove concept and theory.
By using this lab manual students can go through the relevant theory and procedure in advance
before the actual performance which creates an interest and students can have basic idea prior to
performance. This in turn enhances pre-determined outcomes amongst students. Each
experiment in this manual begins with competency, industry relevant skills, course outcomes as
well as practical outcomes (objectives). The students will also achieve safety and necessary
precautions to be taken while performing practical.
This manual also provides guidelines to faculty members to facilitate student centric lab
activities through each experiment by arranging and managing necessary resources in order that
the students follow the procedures with required safety and necessary precautions to achieve the
outcomes. It also gives an idea that how students will be assessed by providing rubrics.
Data Structures is a core course in all computer science undergraduate curricula. The course is
the basis for understanding several data structures and also algorithms that operate on them. The
course forms the foundation for almost all computer science subjects: compilers, operating
systems, databases, AI and software engineering. The course comes with a lab in most
universities in India. The associated lab in university curricula focuses on implementation of
algorithms operating on the data structures, i.e., coding programs on the data structures and
algorithms.
Data Structure (3130702) Enrollment No
DTE’s Vision
Institute’s Vision
To create an ecosystem for proliferation of socially responsible and technically sound engineers,
innovators and entrepreneurs.
Institute’s Mission
Department’s Vision
To equip students with the necessary skills in data science to become proficient professionals
capable of leveraging technology to deliver effective and sustainable solutions for real-world
challenges.
Department’s Mission
To cultivate highly skilled data scientists who excel in technical proficiency while embodying
social responsibility.
To establish state-of-the-art academic infrastructure and advanced facilities, dedicated to
providing comprehensive training in the field of data science for students.
To foster collaborations with industry, government bodies, and research & development
institutes, aiming to enhance the professional growth of faculty and students.
To leverage data science techniques to address challenges and solve problems pertinent to
both industry and society.
To create an environment that supports both research and entrepreneurship.
Data Structure (3130702) Enrollment No
Basic knowledge of Engineering including software and hardware which helps data
scientist to collect and preprocess data based on problem domain.
Possess technical and research skill to solve problems faced by industry and society using
data science techniques.
Acquire basic engineering, design, analysis, implementation and testing skills which help
them to solve real life problem of industry and society.
Shows professionalism in the field of data science by acquiring skills for research,
entrepreneurship and higher study.
To be employable by keeping pace with frequently changing technology using lifelong
learning skill.
To showcase professionalism at workplace and social life by being supportive and having
legal and ethical responsibilities.
Data Structure (3130702) Enrollment No
Sr. CO CO CO CO CO
Practical Outcome/Title of experiment
No. 1 2 3 4 5
1. Classification of Data Structure and Stack
1.1 Classify various data structures
1.2 Implement a program for stack that performs
following operations using array. (a) PUSH (b) POP
(c) PEEP (d) CHANGE (e) DISPLAY
1.3 Implement a program to convert infix notation to
postfix notation using stack. √ √ √
1.4 Write a program to implement Tower of Hanoi
problem.
1.5 Identify widely used application which use stack
data structure for implementation of its important
feature.
2. Queue
2.1 Write a program to implement QUEUE using arrays
that performs following operations (a) INSERT (b)
DELETE (c) DISPLAY
2.2 Write a program to implement Circular Queue using
arrays that performs following operations. (a) √ √
INSERT (b) DELETE (c) DISPLAY
2.3 Identify widely used application which use Queue
data structure for implementation of its important
feature.
3. Singly linked list
3.1 Write a menu driven program to implement √ √
following operations on the singly linked list.
Data Structure (3130702) Enrollment No
8. Searching
8.1 Write a program to implement Linear Search.
8.2 Write a program to implement Binary Search.
8.3 Identify widely used application which use √ √
Searching technique for implementation of its
important feature.
9. Sorting
9.1 Write a program to implement Quick Sort
9.2 Write a program to implement Merge Sort
9.3 Write a program to implement Bubble Sort
√ √
9.4 Identify widely used application which use Sorting
technique for implementation of its important
feature.
10 Hashing and File Structure
10.1 Write a program to create hash table and handle
the collision using linear probing.
10.2 Write a program to demonstrate the file
primitives
√ √
such as fopen, fclose, fprintf.
10.3 Identify widely used application which use
Hashing technique for implementation of its
important feature.
Data Structure (3130702) Enrollment No
Industry Relevant Skills
The following industry relevant competencies are expected to be developed in the student by
undertaking the practical work of this laboratory.
1. Will be able to classify data structures and identify storage representation of
primitive and non-primitive data structures
2. Will be able to implement various operations on Stack, Queue, Link list, Tree,
Graph, Hashing and File operations.
3. Will be able to understand need of sorting and searching for various applications
4. Will be able to apply various data structure to design real time applications in
efficient manner.
1. Teacher should provide the guideline with demonstration of practical to the students
with all features.
2. Teacher shall explain basic concepts/theory related to the experiment to the students
before starting of each practical
3. Involve all the students in performance of each experiment.
4. Teacher is expected to share the skills and competencies to be developed in the
students and ensure that the respective skills and competencies are developed in the
students after the completion of the experimentation.
5. Teachers should give opportunity to students for hands-on experience after the
demonstration.
6. Teacher may provide additional knowledge and skills to the students even though not
covered in the manual but are expected from the students by concerned industry.
7. Give practical assignment and assess the performance of students based on task
assigned to check whether it is as per the instructions or not.
8. Teacher is expected to refer complete curriculum of the course and follow the
guidelines for implementation.
1. Students are expected to carefully listen to all the theory classes delivered by the faculty
members and understand the COs, content of the course, teaching and examination
scheme, skill set to be developed etc.
2. Students will have to perform experiments on computer system on which C/C++ compiler
is installed to execute programs of data structure.
3. Students should develop programs and execute all the programs using C/C++ compiler.
Students have to show output of each program in their practical file.
4. Students are instructed to submit practical list as per given sample list shown on next page.
5. Student should develop a habit of submitting the experimentation work as per the schedule
and s/he should be well prepared for the same.
Data Structure (3130702) Enrollment No
Common Safety Instructions
Index
(Progressive Assessment Sheet)
Date
Date of Assessme Sign. of
Sr. Page of Remar
No.
Objective(s) of Experiment submiss nt Teacher
No. perfor ks
ion Marks with date
mance
Theory:
Data Structure
Data structures are a fundamental concept in computer science that enable efficient storage and
manipulation of data. They are used to organize and store data in a manner that allows for optimal
performance of algorithms. The selection of a suitable data structure begins with the choice of an
abstract data type, which defines the operations that can be performed on the data. Well-designed
data structures can perform a wide range of critical operations while using minimal resources such
as execution time and memory space. In essence, data structure introduction refers to the
arrangement of data in a computer's memory in a way that enables rapid access by the processor
for the required calculations.
Stack
A stack is a data structure that follows the last-in first-out (LIFO) principle, meaning that objects
are inserted and removed from the container in a particular order. In pushdown stacks, only two
Page No
Data Structure (3130702) Enrollment No
operations are allowed: pushing an item onto the stack, and popping an item off the top of the
stack. Access to the stack is limited, as elements can only be added and removed from the top.
When an item is pushed onto the stack, it becomes the new top item. Conversely, when an item is
popped off the stack, it is removed from the top.
To illustrate this concept, consider a stack of books. Just as you can only remove the top book,
you can only add a new book to the top of the stack. A stack can also have a limited capacity. If
the stack is already full and there is no space to add a new item, it is said to be in an overflow
state. On the other hand, if the stack is empty and an item is removed, it is in an underflow state,
meaning that no items are present in the stack to be removed.
A stack is an abstract data structure that operates on the LIFO principle, where the last item added
is the first item to be removed. Items can be inserted and deleted at one end called the top,
creating a structure that resembles a closed tube on one side.
(1) PUSH
(2) POP
Page No
Data Structure (3130702) Enrollment No
1. Primitive data structures: Primitive data structures are simple data structures
constructed using the standard data types of a computer language. Examples of
primitive data structures include variables, arrays, pointers, structures, unions, and
more. These structures are used to build more complex data structures
Linear data structures are arranged as a continuous set of data elements in the memory
and can be constructed using array data types. In linear data structures, the adjacency
relationship between data elements is maintained.
Add an element
Delete an element
Traverse
Sort the list of elements
Search for a data element
Stack
Queue
Tables
List
Linked Lists.
Page No
Data Structure (3130702) Enrollment No
Non-linear data structures are not arranged in a continuous manner and include data
structures such as trees and graphs. These structures can be used to represent complex
relationships between data elements.
Add elements
Delete elements
Display the elements
Sort the list of elements
Search for a data element
Tree
Decision tree
Graph
Forest
1.2 Implement a program for stack that performs following operations using array.
(a) PUSH (b) POP (c) PEEP (d) CHANGE (e) DISPLAY
Program:
#include <stdio.h>
#include <stdlib.h>
#define MAX 5
struct Stack
{
int items[MAX];
int top;
};
Page No
Data Structure (3130702) Enrollment No
int isFull(struct Stack *s)
{
return s->top == MAX - 1;
}
Page No
Data Structure (3130702) Enrollment No
int main()
{
struct Stack *s = createStack();
int choice, value, index;
while (1)
{
printf("\nStack Operations: \n");
printf("1. PUSH\n2. POP\n3. PEEP\n4. CHANGE\n5. DISPLAY\n6. EXIT\n");
printf("Enter your choice: ");
scanf("%d", &choice);
Page No
Data Structure (3130702) Enrollment No
switch (choice)
{
case 1:
printf("Enter the value to push: ");
scanf("%d", &value);
push(s, value);
break;
case 2:
pop(s);
break;
case 3:
peep(s);
break;
case 4:
printf("Enter the position to change: ");
scanf("%d", &index);
printf("Enter the new value: ");
scanf("%d", &value);
change(s, index, value);
break;
case 5:
display(s);
break;
case 6:
exit(0);
default:
printf("Invalid choice! Please enter a valid option.\n");
}
}
return 0;
}
Page No
Data Structure (3130702) Enrollment No
Output:
Page No
Data Structure (3130702) Enrollment No
1.3 Implement a program to convert infix notation to postfix notation using stack.
Program:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
Page No
Data Structure (3130702) Enrollment No
if (isEmpty(*top))
{
printf("Stack underflow\n");
return '\0';
}
Stack *temp = *top;
*top = (*top)->next;
char popped = temp->data;
free(temp);
return popped;
}
Page No
Data Structure (3130702) Enrollment No
int k = 0;
postfix[k++] = infix[i];
}
else if (infix[i] == '(')
{
push(&stack, infix[i]);
}
else if (infix[i] == ')')
{
while (!isEmpty(stack))
{
postfix[k++] = pop(&stack);
}
postfix[k] = '\0';
}
int main()
{
char infix[100], postfix[100];
Page No
Data Structure (3130702) Enrollment No
scanf("%s", infix);
infixToPostfix(infix, postfix);
return 0;
}
Output:
Program:
#include <stdio.h>
void main()
{
int n;
printf("\n Enter the number of rings: ");
scanf("%d", &n);
move(n,'A', 'C', 'B');
}
void move(int n, char source, char dest, char spare)
{
if (n==1)
printf("\n Move from %c to %c",source,dest);
else
{
move(n-1, source, spare, dest);
move(1, source, dest, spare);
move(n-1, spare, dest, source);
}
}
Page No
Data Structure (3130702) Enrollment No
Output:
1.5 Identify widely used application which use stack data structure for implementation of its
important feature.
Stack Applications:
1. Stack is used by compilers to check for balancing of parentheses, brackets and braces.
2. Stack is used to evaluate a postfix expression.
3. Stack is used to convert an infix expression into postfix/prefix form.
4. In recursion, all intermediate arguments and return values are stored on the processor’s
stack.
5. During a function call the return address and arguments are pushed onto a stack and on
return they are popped off.
6. Depth first search uses a stack data structure to find an element from a graph.
Observations:
Conclusion:
Quiz:
Suggested Reference:
Completenes
Problem Coding
Logic s
Rubric Understandin Standards Q&A Tota
Building (2) and accuracy
s g (2) (2) l
(2)
Avg. Good Avg. Good Avg. Goo Avg. Good Avg. Goo
(1) (2) (1) (2) (1) d (2) (1) (2) (1) d (2)
Marks
Page No
Data Structure (3130702) Enrollment No
Experiment No: 2
AIM : Queue
2.1 Write a program to implement QUEUE using arrays that performs following
operations (a)INSERT (b) DELETE (c) DISPLAY
2.2 Write a program to implement Circular Queue using arrays that performs following
operations. (a) INSERT (b) DELETE (c) DISPLAY
2.3 Identify widely used application which uses Queue data structure for implementation
of its important feature.
Theory:
Queue
A queue is a data structure that follows the First In, First Out (FIFO) principle. It is a special type
of list where items are inserted at the rear and deleted from the front end. Queues can be
compared to real-world scenarios, such as people waiting in line at a bank.
Queue
Circular Queue
D-Queue
Page No
Data Structure (3130702) Enrollment No
Priority Queue
2.1 Write a program to implement QUEUE using arrays that performs following
operations. (a)INSERT (b) DELETE (c) DISPLAY
Program:
#include <stdio.h>
#include <stdlib.h>
#define MAX 5
struct Queue {
int items[MAX];
int front;
int rear;
};
Page No
Data Structure (3130702) Enrollment No
q->items[q->rear] = value;
printf("Inserted %d\n", value);
}
}
int main() {
struct Queue* q = createQueue();
int choice, value;
while (1) {
printf("\nQueue Operations: \n");
printf("1. INSERT\n2. DELETE\n3. DISPLAY\n4. EXIT\n");
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice) {
case 1:
printf("Enter the value to insert: ");
scanf("%d", &value);
insert(q, value);
break;
Page No
Data Structure (3130702) Enrollment No
case 2:
delete(q);
break;
case 3:
display(q);
break;
case 4:
exit(0);
default:
printf("Invalid choice! Please enter a valid option.\n");
}
}
return 0;
}
Output:
Page No
Data Structure (3130702) Enrollment No
2.2 Write a program to implement Circular Queue using arrays that performs following
Page No
Data Structure (3130702) Enrollment No
operations. (a) INSERT (b) DELETE (c) DISPLAY
Program:
#include <stdio.h>
#include <stdlib.h>
#define MAX 5
struct CircularQueue
{
int items[MAX];
int front;
int rear;
};
Page No
Data Structure (3130702) Enrollment No
}
cq->rear = (cq->rear + 1) % MAX;
cq->items[cq->rear] = value;
printf("Inserted %d\n", value);
}
}
cq->front = -1;
cq->rear = -1;
}
else
{
cq->front = (cq->front + 1) % MAX;
}
}
}
Page No
Data Structure (3130702) Enrollment No
printf("\n");
}
}
int main()
{
struct CircularQueue *cq = createQueue();
int choice, value;
while (1)
{
printf("\nCircular Queue Operations: \n");
printf("1. INSERT\n2. DELETE\n3. DISPLAY\n4. EXIT\n");
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice)
{
case 1:
printf("Enter the value to insert: ");
scanf("%d", &value);
insert(cq, value);
break;
case 2:
delete (cq);
break;
case 3:
display(cq);
break;
case 4:
exit(0);
default:
printf("Invalid choice! Please enter a valid option.\n");
}
}
return 0;
}
Output:
Page No
Data Structure (3130702) Enrollment No
Page No
Data Structure (3130702) Enrollment No
2.3 Identify widely used application which uses Queue data structure for implementation
of its important feature.
The queue data structure is widely used in various applications to manage tasks in an
orderly manner, following a first-in, first-out (FIFO) approach. In operating systems,
queues are essential for process scheduling, such as in Round Robin algorithms, where
processes are executed in the order they arrive. Networking devices like routers and
switches use queues to manage data packet transmission efficiently, while web servers rely
on queues to handle user requests under heavy load. In messaging systems like RabbitMQ
and Apache Kafka, queues enable reliable and asynchronous communication between
distributed services. Additionally, queues are employed in call centers for managing
incoming calls, in printers for scheduling print jobs, and in algorithms like breadth-first
search (BFS) to explore graph nodes level by level. These applications demonstrate the
importance of queues in ensuring organized and efficient task management across various
domains.
Observations:
Conclusion:
Quiz:
Suggested Reference:
Page No
Data Structure (3130702) Enrollment No
Completenes
Problem Coding
Logic s
Rubric Understandin Standards Q&A Tota
Building (2) and accuracy
s g (2) (2) l
(2)
Avg. Good Avg. Good Avg. Goo Avg. Good Avg. Goo
(1) (2) (1) (2) (1) d (2) (1) (2) (1) d (2)
Marks
Page No
Data Structure (3130702) Enrollment No
Experiment No: 3
3.1 Write a menu driven program to implement following operations on the singly linked
list.
(a) Insert a node at the front of the linked list.
(b) Insert a node at the end of the linked list.
(c) Insert a node such that linked list is in ascending order. (According to INFO field)
(d) Delete a first node of the linked list.
(e) Delete a node before specified position.
(f) Delete a node after specified position.
3.2 Write a program to implement stack using linked list
3.3 Write a program to implement queue using linked list.
Theory:
A linked list is a type of data structure that stores a collection of non-sequential data items. Unlike
arrays, linked lists are dynamic and their size can be changed during program execution. Each
data item in a linked list has a pointer that holds the memory address of the next data item in the
list. The data items in a linked list may not be stored in consecutive memory locations, but their
pointers make it easy to access them in any order.
Page No
Data Structure (3130702) Enrollment No
A singly linked list, also known as a linear linked list, is a type of linked list in which all nodes are
connected together sequentially. Each node in a singly linked list contains data and a pointer to
the next node. The last node's pointer is set to null. The limitation of a singly linked list is that it
can only be traversed in one direction, in a forward direction.
Insert
- Insert at first position
- Insert at last position
- Insert into ordered list
Delete
Traverse list (Print list)
Copy linked list
3.1 Write a menu driven program to implement following operations on the singly linked
list.
(a) Insert a node at the front of the linked list.
(b) Insert a node at the end of the linked list.
(c) Insert a node such that linked list is in ascending order.(According to INFO field)
(d) Delete a first node of the linked list.
(e) Delete a node before specified position.
(f) Delete a node after specified position.
Program:
Output:
Program:
Output:
Program:
Page No
Data Structure (3130702) Enrollment No
// Write code of your program here
Output:
Observations:
Conclusion:
Quiz:
(1) Which are the operations on singly link list?
(2) State the limitation of singly link list
(3) Compare array and singly link list
Suggested Reference:
Completenes
Problem Coding
Logic s
Rubric Understandin Standards Q&A Tota
Building (2) and accuracy
s g (2) (2) l
(2)
Avg. Good Avg. Good Avg. Goo Avg. Good Avg. Goo
(1) (2) (1) (2) (1) d (2) (1) (2) (1) d (2)
Marks
Page No
Data Structure (3130702) Enrollment No
Experiment No: 4
4.1 Write a program to implement following operations on the doubly linked list.
(a) Insert a node at the front of the linked list.
(b) Insert a node at the end of the linked list.
(c) Delete a last node of the linked list.
(d) Delete a node before specified position.
Theory:
A doubly linked list is a data structure where each node contains data and two pointers - one to
point to the previous node (LPTR) and another to point to the next node (RPTR). The main
advantage of a doubly linked list is that we can traverse it in any direction, either forward or
backward. Another advantage is that we can delete a node with ease since we have pointers to
both the previous and next nodes. In contrast, a node on a singly linked list cannot be removed
unless we have a pointer to its predecessor. However, the drawback of a doubly linked list is that
it requires more memory than a singly linked list since we need an extra pointer to point to the
previous node. In the image, L and R denote the leftmost and rightmost nodes in the list,
respectively. The left link of the L node and the right link of the R node are both NULL,
indicating the end of the list for each direction.
Page No
Data Structure (3130702) Enrollment No
Operations on doubly linked list
Insert
- Insert at first position
- Insert at last position
- Insert into ordered list
Delete
Traverse list (Print list)
Copy linked list
4.1 Write a program to implement following operations on the doubly linked list.
(a) Insert a node at the front of the linked list.
(b) Insert a node at the end of the linked list.
(c) Delete a last node of the linked list.
(d) Delete a node before specified position.
Program:
Output:
Program:
Output:
Program:
Output:
Page No
Data Structure (3130702) Enrollment No
(d) Delete a node before specified position.
Program:
Output:
Observations:
Conclusion:
Quiz:
(1) Explain structure of a node of doubly link list
(2) Which is the main advantage of doubly link list?
(3) What is the drawback of doubly link list?
Suggested Reference:
Completenes
Problem Coding
Logic s
Rubric Understandin Standards Q&A Tota
Building (2) and accuracy
s g (2) (2) l
(2)
Avg. Good Avg. Good Avg. Goo Avg. Good Avg. Goo
(1) (2) (1) (2) (1) d (2) (1) (2) (1) d (2)
Marks
Page No
Data Structure (3130702) Enrollment No
Experiment No: 5
5.1 Write a program to implement following operations on the circular linked list.
(a) Insert a node at the end of the linked list.
(b) Insert a node before specified position.
(c) Delete a first node of the linked list.
(d) Delete a node after specified position.
5.2 Identify widely used application which uses linked list for implementation of its
important feature.
Theory:
A circular linked list is similar to a singly linked list, except that the last node points to the first
node, creating a circular arrangement of nodes. Unlike a singly linked list, it does not contain null
pointers. Traversal can only be done in one direction, i.e., the forward direction. The biggest
advantage of a circular linked list is that it saves time when we want to go from the last node to
the first node because it directly points to the first node. A good example of an application where
a circular linked list can be used is a time-sharing problem that can be solved by the operating
system.
Page No
Data Structure (3130702) Enrollment No
Operations on circular linked list
Insert
- Insert at first position
- Insert at last position
- Insert into ordered list
Delete
Traverse list (Print list)
5.1 Write a program to implement following operations on the circular linked list.
(a) Insert a node at the end of the linked list.
(b) Insert a node before specified position.
(c) Delete a first node of the linked list.
(d) Delete a node after specified position.
Program:
Output:
Program:
Output:
Program:
Output:
Program:
Page No
Data Structure (3130702) Enrollment No
Output:
5.2 Identify widely used application which uses linked list for implementation of its
important feature.
Observations:
Conclusion:
Quiz:
Suggested Reference:
Page No
Data Structure (3130702) Enrollment No
(2)
Avg. Good Avg. Good Avg. Goo Avg. Good Avg. Goo
(1) (2) (1) (2) (1) d (2) (1) (2) (1) d (2)
Marks
Experiment No: 6
AIM : Tree
Theory:
A binary search tree is a binary tree in which each node possessed a key that satisfy the
following conditions
1. All key (if any) in the left sub tree of the root precedes the key in the root.
2. The key in the root precedes all key (if any) in the right sub tree.
3. The left and right sub tree sub trees of the root are again search trees.
Operations on tree
Page No
Data Structure (3130702) Enrollment No
The most common operations performed on tree structure are that of traversal. This is a procedure
by which each node in the tree is processed exactly once in a systematic manner.
1. Pre-order Traversal
2. In-order Traversal
3. Post-order Traversal
Pre-order
In-order
Post-order
Program:
Output:
6.2 Implement recursive tree traversing methods in-order, preorder and post-order
traversal.
Program:
Page No
Data Structure (3130702) Enrollment No
// Write code of your program here
Output:
6.3 Identify widely used applications which use Tree data structure for implementation
of its important feature.
Observations:
Conclusion:
Quiz:
Suggested Reference:
Completenes
Problem Coding
Logic s
Rubric Understandin Standards Q&A Tota
Building (2) and accuracy
s g (2) (2) l
(2)
Avg. Good Avg. Good Avg. Goo Avg. Good Avg. Goo
(1) (2) (1) (2) (1) d (2) (1) (2) (1) d (2)
Page No
Data Structure (3130702) Enrollment No
Marks
Experiment No: 7
AIM : Graph
Theory:
Graph:
A graph G can be defined as a non-empty set of vertices or nodes (V) and a set of edges (E) that
represents the relationship or connection between those nodes. The edges can be defined as a
mapping from E to pairs of elements of V. A graph can be represented as G = (V, E), where V
represents the set of nodes and E represents the set of edges. Each edge of the graph G can be
associated with a pair of nodes of the graph. If an edge X belongs to E and is associated with a
pair of nodes (u, v), where u and v belong to V, then we say that edge X connects node u and node
v.
DFS is a graph traversal algorithm that is similar to the preorder traversal of a tree. The traversal
Page No
Data Structure (3130702) Enrollment No
can start from any vertex vi of the graph. Initially, the vertex vi is visited, and then all the adjacent
vertices to vi are traversed recursively using DFS. As a graph can have cycles, we need to avoid
revisiting a node. To achieve this, when a vertex V is visited, it is marked as visited and should
not be selected for traversal again.
Breadth First Search (BFS) starts from a vertex v0 and marks it as visited. Then, all the
vertices adjacent to v0 are visited next.
Let the vertices adjacent to v0 be v1, v2, v3, and v4. These vertices are marked as visited.
All unvisited vertices adjacent to v1, v2, v3, and v4 are visited next.
The above process continues until all vertices are visited.
The algorithm for BFS maintains a list of vertices that have been visited but not explored
for adjacent vertices. This list is stored in a queue.
The queue initially contains the starting vertex.
In each iteration, a vertex is removed from the queue, and its adjacent vertices, which have
not been visited yet, are added to the queue.
The algorithm terminates when the queue becomes empty.
Program:
Output:
7.2 Identify widely used applications which use graphs data structure for implementation
of its important feature.
Observations:
Conclusion:
Quiz:
Suggested Reference:
Completenes
Problem Coding
Logic s
Rubric Understandin Standards Q&A Tota
Building (2) and accuracy
s g (2) (2) l
(2)
Avg. Good Avg. Good Avg. Goo Avg. Good Avg. Goo
(1) (2) (1) (2) (1) d (2) (1) (2) (1) d (2)
Marks
Page No
Data Structure (3130702) Enrollment No
Experiment No: 8
AIM : Searching
Theory:
Linear/Sequential Search
Linear search, also known as sequential search, is a technique used in computer science to
find a specific value in a list by sequentially checking each of its elements one at a time
until the desired one is found.
It is the simplest search algorithm and a form of brute-force search. Its worst-case cost is
proportional to the number of elements in the list.
Binary Search
If we have an array that is sorted, we can use a much more efficient algorithm called
Page No
Data Structure (3130702) Enrollment No
Binary Search.
In Binary Search, we divide the array into two equal halves and compare the middle
element with the search element.
If the middle element is equal to the search element, we have found the element and return
its index; otherwise, if the middle element is less than the search element, we look at the
right part of the array, and if the middle element is greater than the search element, we
Program:
Output:
Program:
Output:
8.3 Identify widely used applications which use Searching technique for implementation
of its important feature.
Observations:
Conclusion:
Quiz:
Suggested Reference:
Completenes
Problem Coding
Logic s
Rubric Understandin Standards Q&A Tota
Building (2) and accuracy
s g (2) (2) l
(2)
Avg. Good Avg. Good Avg. Goo Avg. Good Avg. Goo
(1) (2) (1) (2) (1) d (2) (1) (2) (1) d (2)
Marks
Page No
Data Structure (3130702) Enrollment No
Experiment No: 9
AIM : Sorting
Theory:
Bubble sort
Bubble sort, also known as sinking sort, is a comparison-based sorting algorithm. It works by
repeatedly scanning through the list to be sorted, comparing adjacent elements and swapping them
if they are not in the correct order. In each pass through the list, the largest element bubbles up to
the top. The algorithm repeats these processes until no more swaps are needed, indicating that the
list is sorted. Although it is simple to understand and implement, bubble sort has a worst-case and
average time complexity of O(n^2), making it too slow for large inputs. Insertion sort is a more
efficient alternative for small lists.
Merge Sort
Page No
Data Structure (3130702) Enrollment No
DIVIDE: Partition the n-element sequence to be sorted into two sub sequences of
n/2 elements each.
CONQUER: Sort the two sub sequences recursively using the merge sort.
COMBINE: Merge the two sorted sub sequences of size n/2 each to produce the
sorted sequence consisting of n elements.
Quick Sort
Quicksort is currently the fastest known sorting algorithm and often the most practical choice for
sorting, with an average expected running time of O(n log(n)). Its operation consists of the
following steps:
Pick an element from the array, known as a pivot.
Reorder the array so that all elements with values less than the pivot are placed before it,
while all elements with values greater than the pivot come after it (elements with equal
values can go either way). This operation is called partitioning, and at the end of it, the
pivot is in its final position.
Recursively apply the above steps to the sub-arrays of elements with smaller and greater
values, respectively. Quicksort, like merge sort, is a divide-and-conquer recursive
algorithm.
The basic divide-and-conquer process for sorting a sub array is given in the following
three easy steps:
Divide
Conquer
Combine
Program:
Output:
Program:
Output:
Page No
Data Structure (3130702) Enrollment No
Program:
Output:
9.4 Identify widely used applications which use Sorting technique for implementation
of its important feature.
Observations:
Conclusion:
Quiz:
Suggested Reference:
Page No
Data Structure (3130702) Enrollment No
Completenes
Problem Coding
Logic s
Rubric Understandin Standards Q&A Tota
Building (2) and accuracy
s g (2) (2) l
(2)
Avg. Good Avg. Good Avg. Goo Avg. Good Avg. Goo
(1) (2) (1) (2) (1) d (2) (1) (2) (1) d (2)
Marks
Page No
Data Structure (3130702) Enrollment No
Experiment No: 10
10.1 Write a program to create hash table and handle the collision using linear probing.
10.2 Write a program to demonstrate the file primitives such as fopen, fclose, fprintf.
10.3 Identify widely used applications which use Hashing technique for implementation of
its important feature.
Theory:
Hashing
Hashing is a method used to map a large number of data items to a smaller table by utilizing a
hashing function. This technique transforms a range of key values into a range of indexes of an
array.There are two different forms of hashing.
Hashing Functions
1. Division-Method
2. Folding Method
3. Algebraic Coding
4. Multiplicative Hashing
5. Digit Analysis
6. Mid-square Methods
7. Length Dependent Method
File
In computing, a file is a group of records, where each record comprises one or more fields that
have the same sequence. Typically, each field has a predetermined length.
1. Sequential files
2. Direct files
3. Index files
4. Indexed Sequential files
5. Relative files
1. Creation
2. Insertion
3. Deletion
Page No
Data Structure (3130702) Enrollment No
4. Updation
5. Reading
6. Searching
10.1 Write a program to create hash table and handle the collision using linear probing.
Program:
Output:
10.2 Write a program to demonstrate the file primitives such as fopen, fclose, fprintf.
Program:
Output:
10.3 Identify widely used applications which use Hashing technique for implementation of
its important feature.
Observations:
Conclusion:
Quiz:
Suggested Reference:
Completenes
Problem Coding
Logic s
Rubric Understandin Standards Q&A Tota
Building (2) and accuracy
s g (2) (2) l
(2)
Avg. Good Avg. Good Avg. Goo Avg. Good Avg. Goo
(1) (2) (1) (2) (1) d (2) (1) (2) (1) d (2)
Marks
Page No