DSA Lab 1,2
DSA Lab 1,2
Submitted by
Mohammad Ahmed
Instructor
Miss. Bushra Haq
Assistant professor, Department of Computer Science,
Faculty of Information & Communication Technology, BUITEMS, Quetta.
Lab Engineer
Engr. Ali Israr
Lab Engineer, Department of Electrical Engineering,
Faculty of Information & Communication Technology, BUITEMS, Quetta.
Session Fall – 2024
LAB MANUAL Data Structures and Algorithms
CERTIFICATE
TABLE OF CONTENTS
Contents
List of Experiments
List of Experiments
Sr.No CLO Experiments
1 1 Implementation of Array ADT.
2 1
Write a program to implement below array operations using method
“Insertion, Deletion, Traversing”
.
3 1
4 1 .
5 1
6 2 .
7 1 .
8 2
9 2
10 1
11 1
12 2
13 2
14 2
LAB MANUAL Data Structures and Algorithms
Tools:
Eclipse IDE
JDK
Dev C++
Theory:
The array is a basic abstract data type that holds an ordered collection of items accessible by
an integer index. These items can be anything from primitive types such as integers to more
complex types like instances of classes. Arrays have one property: they store and retrieve
items using an integer index. An item is stored in each index and can be retrieved at a later
time by specifying the same index. The way these indices work is specific to the
implementation, but you can usually just think of them as the slot number in the array that the
value occupies. Look at the image below:
Array:
An array is a type of linear data structure that is defined as a collection of elements with same or
different data types. They exist in both single dimension and multiple dimensions. These data
structures come into picture when there is a necessity to store multiple elements of similar nature
together at one place.
Arrays are represented as a collection of buckets where each bucket stores one element. These
buckets are indexed from '0' to 'n-1', where n is the size of that particular array.
The basic operations in the Arrays are insertion, deletion, searching, display, traverse, and update.
These operations are usually performed to either modify the data in the array or to report the status of
the array.
LAB MANUAL Data Structures and Algorithms
Output:
Output:
Output:
Output:
OUTPUT:
LAB MANUAL Data Structures and Algorithms
Rubrics:
Tools:
Eclipse IDE
JDK
Dev C++
Theory:
LAB MANUAL Data Structures and Algorithms
Task-1:
LAB MANUAL Data Structures and Algorithms
Output
Task-2:
Write a program to swap first and last element of an integer 1-D array
Output
LAB MANUAL Data Structures and Algorithms
Task-3:
Write a program to reverse the element of an integer 1-D array.
Output
Task-4:
Write a program to merge to array using methods.
LAB MANUAL Data Structures and Algorithms
Output
Constrains:
Your method should take two arrays as arguments and return merged array
Observations:
in this lab we learned that How to insert and print array elements. we also get the knowledge to Display
Array Elements Using Loop and take Inputs from User and Store Them in an Array.
LAB MANUAL Data Structures and Algorithms
Rubrics: