ass1
ass1
#include <string>
struct Student {
int roll_no;
string name;
float sgpa;
};
int j = i;
j--;
}
int i = l;
int j = h;
while (i < j) {
swap(s[l], s[j]);
return j;
if (l < h) {
quickSortSGPA(arr, l, pi - 1);
quickSortSGPA(arr, pi + 1, h);
}
// Linear search using SGPA
if (s[i]->sgpa == SGPA) {
if (!found) {
cout << "Students with SGPA " << SGPA << ":\n";
found = true;
cout << "Roll no. " << s[i]->roll_no << ", Name: " << s[i]->name
<< ", SGPA: " << s[i]->sgpa << "\n";
if (!found) {
cout << "No Students with SGPA " << SGPA << "\n";
int left = 0;
int right = n - 1;
return -1;
int left = 0;
int right = n - 1;
return -1;
}
}
int main() {
int n;
cin >> n;
Student* s[n];
cout << "Enter details for student " << i + 1 << "\n";
}
int c;
while (ans) {
cout << "For Bubble sort -> 1 \nFor Insertion sort -> 2 \nFor Quick
sort using SGPA -> 3 \nLinear Search -> 4 \nBinary Search using SGPA ->
5 \nBinary Search using name -> 6 \nExit -> 7 \n";
cin >> c;
switch (c) {
case 1:
bubbleSort(s, n);
displayStudentDetails(s, n);
break;
case 2:
insertionSort(s, n);
displayStudentDetails(s, n);
break;
case 3:
quickSortSGPA(s, 0, n - 1);
displayToppers(s, n);
break;
case 4: {
float SGPA;
linearSearchSGPA(s, n, SGPA);
break;
case 5: {
float SGPA;
if (index != -1) {
cout << "Student found: Roll no. " << s[index]->roll_no << ",
Name: " << s[index]->name << ", SGPA: " << s[index]->sgpa <<endl;
} else {
break;
case 6: {
string NAME;
if (index != -1) {
cout << "Student found: Roll no. " << s[index]->roll_no << ",
Name: " << s[index]->name << ", SGPA: " << s[index]->sgpa <<endl;
} else {
break;
case 7:
ans = false;
break;
default:
continue;
}
return 0;