Dsu Program
Dsu Program
a menu driven c program for insert and delete operations on linear and circular queue using array
#include <stdio.h>
int temp, i, j;
temp = arr[j];
arr[j + 1] = temp;
int i, key, j;
key = arr[i];
j = i - 1;
arr[j + 1] = arr[j];
j = j - 1;
arr[j + 1] = key;
}
minIndex = i;
minIndex = j;
temp = arr[i];
arr[i] = arr[minIndex];
arr[minIndex] = temp;
int main() {
int choice, n;
scanf("%d", &n);
int arr[n];
scanf("%d", &arr[i]);
}
printf("Menu:\n");
scanf("%d", &choice);
switch (choice) {
case 1:
bubbleSort(arr, n);
break;
case 2:
insertionSort(arr, n);
break;
case 3:
selectionSort(arr, n);
break;
default:
printf("Invalid choice!\n");
return 1;
printf("Sorted array:\n");
printf("\n");
return 0;
}
Output
Queue Operations:
1. Linear Enqueue
2. Linear Dequeue
3. Circular Enqueue
4. Circular Dequeue
7. Exit
Queue Operations:
1. Linear Enqueue
2. Linear Dequeue
3. Circular Enqueue
4. Circular Dequeue
7. Exit
Queue Operations:
1. Linear Enqueue
2. Linear Dequeue
3. Circular Enqueue
4. Circular Dequeue
5. Display Linear Queue
7. Exit
Queue Operations:
1. Linear Enqueue
2. Linear Dequeue
3. Circular Enqueue
4. Circular Dequeue
7. Exit