0% found this document useful (0 votes)
22 views12 pages

Lab Manual For Exp No 01

The document outlines an experiment for B.Tech. students focusing on data structures and algorithms, aiming to teach the selection and implementation of appropriate data structures. It includes tasks for programming in C/C++, identifying suitable data structures for specific scenarios, and understanding the implications of data structure choice on program efficiency. The document also covers prerequisites, expected outcomes, and theoretical concepts related to data structures.

Uploaded by

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

Lab Manual For Exp No 01

The document outlines an experiment for B.Tech. students focusing on data structures and algorithms, aiming to teach the selection and implementation of appropriate data structures. It includes tasks for programming in C/C++, identifying suitable data structures for specific scenarios, and understanding the implications of data structure choice on program efficiency. The document also covers prerequisites, expected outcomes, and theoretical concepts related to data structures.

Uploaded by

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

SVKM’s NMIMS

Mukesh Patel School of Technology Management & Engineering


Computer Engineering Department
Program: B.Tech. CSBS Sem II

Course: Data Structures and Algorithms

Experiment No.01
PART A
(PART A : TO BE REFERRED BY STUDENTS)

A.1 Aim:
Introduction to Data Structures. Select and implement appropriate data structure to solve the
given problem.

A.2 Prerequisite:
1. Knowledge of different types of data structures.

2. Fundamental concepts of C\C++.

A.3 Outcome:
After successful completion of this experiment students will be able to

1. Identify the need of appropriate selection of data structure


2. Identify the steps of appropriate data structure selection.
3. Explore the effect of appropriate data structure selection.
4. Differentiate types of data structure based on their organization
of data.
5. Implement appropriate selected data structure to solve the given
problem
6. Enlist the applications of different data structures.

A.4 Theory:
A.4.1. Introduction of Data structure
● The data may be organized into many different ways. The logical
and mathematical model of a particular organization of data is called
data structure.
● A data structure helps you to understand the relationship of one
data element with the other and organize it within the memory.
● Data structure specified following:
o Organization of data
o Accessing methods
o Degree of associativity
o Processing alternatives for information
● Classification of data structure:

● Primitive data structure:


o Basic structures
o Directly operated upon by the machine instructions
● Non- Primitive data structures:
o Derived from primitive data structure.
o Emphasize on structuring of a group of homogenous or
heterogeneous data structures.
o Ex: Arrays, Lists, Files
● Various data structure:
A.5 Procedure/Algorithm:
A.5.1:

TASK 1:

Write a C/C++ program of array to perform following (1D Array)


i. Perform the reading and writing of the array.
ii. Find the highest and lowest element in an array.
iii. Delete an element from an array (by passing array to the function)
iv. Program to traverse an array.
v. Reverse a order of elements in the array

TASK 2:

A program has to be written that takes in student data like roll number, name and grade. It
displays the same in the order of entry. It should have a function to provide the user option to
choose to display a particular student's details given the name or the roll number.

TASK 3:

Identify suitable data structure for given scenarios. Specify the reason for it.

1. To implement a system for reversing a word.


2. To implement a printer spooler so that jobs can be printed in the order of the
arrival.
3. To represent an image in a form of bitmap.
4. For representing a city region telephone network.
5. To store information about the directories and files in a system.
6. To implement a system for parsing syntax.
7. To implement back functionality in web browsers.
8. To record the sequence of all the pages browsed in one session.
9. To process network packets coming to the router.
10.To represent machines on the internet and to find optimal paths between
source machine and destination machine to send data.
11.To represent connections\relations in social networking sites.
12.Google maps to travel from your home to office in minimum time.

**********************
PART B
(PART B : TO BE COMPLETED BY STUDENTS)

(Students must submit the soft copy as per following segments


within two hours of the practical. The soft copy must be uploaded
on the Blackboard or emailed to the concerned lab in charge
faculties at the end of the practical in case the there is no Black
board access available)

Roll No. E043 Name: Parag Shirke

Class :BTech Batch : 2

Date of Experiment: 11/2/21 Date of Submission

Grade : Time of Submission:

Date of Grading:

B.1 Software Code written by student:


(Paste your code completed during the 2 hours of practical in the lab here)

Task 1:
Task 2:
B.2 Input and Output:

Task 1:
Task 2:
B.3 Identified data structure with reason: (Task 3)

1. Stack can be used to implement a system for reversing a word


because it follows the principle of Last in first out(LIFO). This means
the last element inserted in the stack is given out first.
2. Queue can be used to implement a printer spooler so that jobs
can be printed in the order of the arrival because Queue follows
the First in First Out (FIFO) rule that is the item that goes in first is
the item that comes out first.
3. To represent an image in the form of a bitmap, a suitable data
structure would be a 2-dimensional array. This is because a
bitmap is a way to represent an image by using a grid of individual
pixels, where each pixel is represented by a color.
4. A graph cab be used to represent a city region telephone
network. A graph data structure can be used to represent the
connections between different telephone exchanges in the city
region.
5. A tree can be used to store information about the directories and
files in a system. A tree data structure can be used to represent the
hierarchical structure of directories and files in a file system.
6.
7. A stack can be used to implement back functionality in web
browsers. This is because it uses the principle of last in first out
(LIFO). This means the last element inserted in the stack is given out
first.
8. An array can be used to record the sequence of all pages
browsed in one session. An array can be used to store the URLs of
the pages visited in a session and a variable such as an integer
index can be used to keep track of the current position in the array.
9. A queue can be used to process network packets coming to a
router. A queue is a first-in, first-out (FIFO) data structure, which
means that the first element added to the queue is the first one to
be removed. This is an appropriate data type for processing network
packets because packets are usually processed in the order in which
they are received, and the router needs to handle each packet in
the order it was received.
10. A graph is typically used to represent machines on the internet
and to find optimal paths between a source machine and a
destination machine to send data. In a graph, each machine is
represented as a node, and the connections between them
are represented as edges. Different graph algorithms can be used to
find the shortest path between two nodes in the graph.
11. A graph is commonly used to represent connections or
relationships in social networking sites. In a graph, each user is
represented as a node, and the connections between them are
represented as edges.
12. A graph is commonly used to represent the roads and
connections in mapping services like Google Maps. Each intersection
or junction is represented as a node, and the roads connecting them
are represented as edges. The edges can be weighted to represent
the distance or travel time along that road. Different graph
algorithms can be used to find the shortest path between two nodes
in the graph, which can be used to determine the fastest route for a
given trip.

B.4 Conclusion:

After completion of this experiment, we have a knowledge of


data structures. We are now able to select amongst different
data structure and use it efficiently to solve the given problem.
Differentiate types of data structure based on their organization
of data.

B.5 Question of Curiosity


Q1. Why is appropriate selection of data structure important in computer
programming?
Ans: The appropriate selection of a data structure is important in
computer programming because it can greatly impact the efficiency
and performance of a program. Different data structures have
different strengths and weaknesses, and choosing the right one for
the task at hand can make a significant difference in terms of speed
and memory usage.

Q2. What if the number of elements in an array are less than or greater
than the length specified?
Ans: When the number of elements are less than the number of
elements specified at the initialization then the other elements have
a null value or value is zero, and when the number of elements are
more than the number of elements specified at the start of the array
then the program shows a segmentation error.

Q3. What values are stored in remaining places of an array if specified


length is less than specified?
Ans: When the number of elements in the array are less than
the specified length at the initialization then at the remaining
places in the array the value that is stored is zero.

************************

You might also like