Assignment 1 Code
Assignment 1 Code
#include<string.h>
struct student {
int rollno;
char stdname[20];
float SGPA;
};
int main() {
int ch, i;
accept(data);
switch(ch) {
case 1:
bubbleSort(data);
display(data);
break;
case 2:
insertSort(data);
display(data);
break;
case 3:
quickSort(data, 0, size-1);
displayTop(data);
break;
case 4:
search(data);
break;
case 5:
binarysearch(data);
break;
default:
}
void accept(struct student list[4]) {
cout << "\n" << list[i].rollno << "\t" << list[i].stdname << "\t" << list[i].SGPA;
cout << "\n" << list[i].rollno << "\t" << list[i].stdname << "\t" << list[i].SGPA;
temp = list[j];
list[j] = list[j+1];
list[j+1] = temp;
temp = list[k];
int j = k-1;
list[j+1] = list[j];
--j;
list[j+1] = temp;
int pivot, i, j;
pivot = first;
i = first;
j = last;
while(i < j) {
i++;
while(list[j].SGPA < list[pivot].SGPA)
j--;
if(i < j) {
temp = list[i];
list[i] = list[j];
list[j] = temp;
temp = list[pivot];
list[pivot] = list[j];
list[j] = temp;
float SGPA;
if(SGPA == list[i].SGPA)
cout << "\n" << list[i].rollno << "\t" << list[i].stdname << "\t" << list[i].SGPA;
cout << "\n Enter name of student you want to search: ";
lower = mid + 1;
cout << "\n" << list[mid].rollno << "\t" << list[mid].stdname << "\t" << list[mid].SGPA;
break;
} else
upper = mid - 1;