DSA10
DSA10
AIM :-
To implement a student enrollment system for a university where students can register using
their IDs, managed by an AVL tree.
TASK :-
1. Construct the AVL tree based on the following student IDs:
o Student A: 2023001
o Student B: 2023005
○ Student C: 2023003
○ Student D: 2023002
○ Student E: 2023008
○ Student F: 2023004
○ Student G: 2023007
○ Student H: 2023006
○ Student I: 2023009
○ Student J: 2023010
2. Insert the ID’s into the AVL tree one by one in the following order:
3. Ensure that the AVL tree remains balanced after each insertion. The balance factor of
every node must be either -1, 0, or +1. Use AVL tree rotations (left, right, left-right, and
right-left) as needed to maintain balance.
4. After the tree is constructed, perform an in-order traversal of the AVL tree and return
the students based on student id in sorted order.
ALGORITHM :-
Step 1: START
struct student {
int id;
struct student *left;
struct student *right;
int balance;
};
int main() {
struct student *root = NULL;
int choice = 1, ht_in, dt;
while(choice) {
printf("Enter student ID: ");
scanf("%d", &dt);
root = insert(root, dt, &ht_in);
print_tree(root, 0);
printf("\nEnter 0 to end: ");
scanf("%d", &choice);
}
return 0;
}
SAMPLE OUTPUT :-
RESULT :-
Thus, the implementation of the student enrollment system using an AVL tree was
successfully completed and executed.