Dsa Assignment 1 Anees
Dsa Assignment 1 Anees
SUBMITTED BY:
Anees Yameen
40096
BSSE(Spring) 2025
PROGRAM:
Data Structure and Algorithm
Assignment : 01
Tasks 1 to 4 :
Code Implementation :
#include <iostream>
#include <vector>
using namespace std;
void insertElement() {
int size;
vector<int> arr(size);
cout << "Enter the position to insert (0 to " << size << "): ";
return;
}
arr.push_back(0); // Temporarily increase size
void deleteElement() {
int size;
vector<int> arr(size);
}
int position;
cout << "Enter the position to delete (0 to " << size - 1 << "): ";
return;
void linearSearch() {
int size;
vector<int> arr(size);
int elementToSearch;
if (arr[i] == elementToSearch) {
if (index != -1) {
cout << "Element " << elementToSearch << " found at index " << index << endl;
} else {
cout << "Element " << elementToSearch << " not found in the array." << endl;
}
}
void binarySearch() {
int size;
vector<int> arr(size);
cout << "Enter the elements of the sorted array (in increasing order): ";
int elementToSearch;
int low = 0;
break;
} else {
if (index != -1) {
cout << "Element " << elementToSearch << " found at index " << index << endl;
} else {
cout << "Element " << elementToSearch << " not found in the array." << endl;
int main() {
int choice;
do {
switch (choice) {
case 1:
insertElement();
break;
case 2:
deleteElement();
break;
case 3:
linearSearch();
break;
case 4:
binarySearch();
break;
case 0:
break;
default:
Screenshot :