DSA Practical File - MCA
DSA Practical File - MCA
Submitted To Submitted By
Dr. Rajesh Verma Vineet Kumar
Professor Roll No- 2200160140035
15. Program to search the element from the array by using the Linear 18
search method..
16. Program to search the element from array by using Binary search 19
method
Signature ……………………….
#include <stdio.h>
int arr[count];
create_array(count, arr);
printf(">>> Output\n");
return 0;
}
#include <stdio.h>
return 0;
}
#include <stdio.h>
#include <stdlib.h>
printf(">>> Before\n");
for (int i = 0; i < length; i++)
printf("Element %d: %d\n", i, arr[i] = rand());
length++;
printf(">>> After\n");
for (int i = 0; i < length; i++)
printf("Element %d: %d\n", i, arr[i]);
return EXIT_SUCCESS;
}
#include <stdio.h>
#include <stdlib.h>
printf(">>> Before\n");
for (int i = 0; i < length; i++)
printf("Element %d: %d\n", i, arr[i] = rand());
printf(">>> After\n");
for (int i = 0; i < length; i++)
printf("Element %d: %d\n", i, arr[i]);
return EXIT_SUCCESS;
}
#include <stdio.h>
#include <stdlib.h>
printf(">>> Before\n");
for (int i = 0; i < length; i++)
printf("Element %d: %d\n", i, arr[i] = rand());
printf(">>> After\n");
for (int i = 0; i < length; i++)
printf("Element %d: %d\n", i, arr[i]);
return EXIT_SUCCESS;
}
#include <stdio.h>
#include <stdlib.h>
printf(">>> Before\n");
for (int i = 0; i < length; i++)
printf("Element %d: %d\n", i, arr[i] = 13 * (i + 1));
int i = length;
for (; input < arr[i - 1]; i--)
arr[i] = arr[i - 1];
arr[i] = input;
length++;
printf(">>> After\n");
for (int i = 0; i < length; i++)
printf("Element %d: %d\n", i, arr[i]);
return EXIT_SUCCESS;
}
#include <stdio.h>
#include <stdlib.h>
return EXIT_SUCCESS;
}
#include <stdio.h>
#include <stdlib.h>
if (count == 0) {
printf("Invalid input!");
return 1;
}
count--;
arr = realloc(arr, count);
for (int i = 0; i < count; i++)
printf("Element at %d: %d\n", i, arr[i]);
return EXIT_SUCCESS;
}
#include <stdio.h>
#include <stdlib.h>
return EXIT_SUCCESS;
}
#include <stdio.h>
#include <stdio.h>
#include <stdio.h>
#include <stdio.h>
#include <stdio.h>
if (j <= i)
return;
int mid = (i + j) / 2;
merge_sort(arr, i, mid);
merge_sort(arr, mid + 1, j);
int pointer_left = i;
int pointer_right = mid + 1;
return 0;
}
#include <stdio.h>
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
return EXIT_SUCCESS;
}
#include <stdio.h>
return 0;
}
#include <stdio.h>
#include <stdlib.h>
struct node { int data; struct node *next; };
1. At the beginning
2. At the end
3. After given node information
4. In the sorted info Linked List.
#include <stdio.h>
#include <stdlib.h>
struct node {
int data;
struct node *next;
};
#include <stdio.h>
#include <stdlib.h>
struct node {
int data;
struct node *next;
};
#include <stdio.h>
#include <stdlib.h>
struct node {
int data;
struct node *next;
};
#include <stdio.h>
#include <stdlib.h>
struct node {
int data;
struct node *next;
};
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
struct node {
int data;
struct node *next;
};
push(&a, 15);
push(&a, 10);
push(&a, 5);
push(&b, 20);
push(&b, 3);
push(&b, 2);
return EXIT_SUCCESS;
}
#include <stdio.h>
#include <stdlib.h>
struct node {
int coeff;
int pow;
struct node *next;
};
#include <stdio.h>
#include <stdlib.h>
struct node {
int coeff;
int pow;
struct node *next;
};
void polynomial_add(struct node *p1, struct node *p2, struct node *result) {
while (p1->next && p2->next) {
if (p1->pow > p2->pow) {
result->pow = p1->pow;
result->coeff = p1->coeff;
p1 = p1->next;
} else if (p1->pow < p2->pow) {
result->pow = p2->pow;
result->coeff = p2->coeff;
p2 = p2->next;
} else {
result->pow = p1->pow;
result->coeff = p1->coeff + p2->coeff;
p1 = p1->next;
p2 = p2->next;
}
result->next = (struct node *)malloc(sizeof(struct node));
#include <stdio.h>
#include <stdlib.h>
struct node { int data; struct node *next; struct node *prev; };
#include <stdio.h>
#include <stdlib.h>
struct node {
int data;
struct node *next;
struct node *prev;
};
#include <stdio.h>
#include <stdlib.h>
struct node {
int data;
struct node *next;
struct node *prev;
};
#include <stdio.h>
while (exponent != 0) {
result *= base;
--exponent;
}