├── README.md
└── Student_Database_using_class_n_sorting.cpp
/README.md:
--------------------------------------------------------------------------------
1 | # DSAL Lab Assignment Code
2 | 23232_Abhishek Jadhav
3 |
4 | Class: SE10
5 |
6 | Batch: F10
7 |
8 | My DSAL Lab Assignments with C++ code files are stored in this repository.
9 | --------------------------------------------------------------------------
10 | >_________________________________________________________________________
11 | >
Index
12 | >
13 | >1.[`Assignment No. 1 - Searching and Sorting`](https://github.com/AbhishekJadhav2002/DSAL_Lab_Assignments/blob/master/Student_Database_using_class_n_sorting.cpp)
14 | >2.[`Assignment No. 2 - Circular Queue`](https://github.com/AbhishekJadhav2002/DSAL_Lab_Assignments/tree/Assignment_2-Queue)
15 | >3.[`Assignment No. 3 - Expression Conversion`](https://github.com/AbhishekJadhav2002/DSAL_Lab_Assignments/tree/Assignment_3-Expression_Conversion/Assignment_3-Expression_Conversion)
16 | >4.[`Assignment No. 4 - Expression Tree`](https://github.com/AbhishekJadhav2002/DSAL_Lab_Assignments/tree/Assignment_4-Expression_tree)
17 | >5.[`Assignment No. 5 - Binary Search Tree`](https://github.com/AbhishekJadhav2002/DSAL_Lab_Assignments/tree/Assignment_5-BST/Assignment_5-BST)
18 | >6.[`Assignment No. 6 - Threaded BST`](https://github.com/AbhishekJadhav2002/DSAL_Lab_Assignments/tree/Assignment_6-Threaded_BST/Assignment_6-ThreadedBST)
19 | >7.[`Assignment No. 7 - MST`](https://github.com/AbhishekJadhav2002/DSAL_Lab_Assignments/tree/Assignment_7-MST)
20 | >8.[`Assignment No. 8 - Dijkstra's Algorithm`](https://github.com/AbhishekJadhav2002/DSAL_Lab_Assignments/tree/Assignment_8-Dijikstra%E2%80%99s_Algorithm)
21 | >9.[`Assignment No. 9 - Heap Sort`](https://github.com/AbhishekJadhav2002/DSAL_Lab_Assignments/tree/Assignment_9-Heap_Sort)
22 | >10.[`Assignment No. 10 - File Handling`](https://github.com/AbhishekJadhav2002/DSAL_Lab_Assignments/tree/Assignment_10-File_Handling)
23 | >_________________________________________________________________________
24 |
25 |
26 | [21/09/2021]
27 |
28 | _***AssignmentNo. 1 >***_
29 |
30 | Student_Database_using_class_n_sorting.cpp ->
31 |
32 | Assignment 1 : Searching and Sorting
33 |
34 | Consider a student database of SEIT class (at least 15 records). Database contains different
35 | Fields of every student like Roll No, Name and SGPA.(array of structure)
36 | a. Design a roll call list, arrange list of students according to roll numbers in ascending
37 | order (Use Bubble Sort)
38 |
39 | b. Arrange list of students alphabetically. (Use Insertion sort)
40 |
41 | c. Arrange list of students to find out first ten toppers from a class. (Use Quick sort)
42 |
43 | d. Search students according to SGPA. If more than one student having same SGPA,
44 | then print list of all students having same SGPA.
45 |
46 | e. Search a particular student according to name using binary search without recursion.
47 | (all the student records having the presence of search key should be displayed)
48 | (Note: Implement either Bubble sort or Insertion Sort.)
49 |
50 | __________________________________________________________________________
51 |
52 | [28/09/2021]
53 |
54 | _***AssignmentNo. 2 >***_
55 |
56 | On Branch named -
57 | Assignment_2-Queue ->
58 |
59 | Assignment 2 : Circularqueue
60 |
61 | Implement Circular Queueusing Array. Perform following operations on it.
62 | a) Insertion (Enqueue)
63 | b) Deletion (Dequeue)
64 | c) Display
65 | (Note: Handle queue full condition by
66 | considering a fixed size of a queue.)
67 |
68 | __________________________________________________________________________
69 |
70 | [23/10/2021]
71 |
72 | _***AssignmentNo. 3 >***_
73 |
74 | On Branch named -
75 | Assignment_3-Expression_conversion ->
76 |
77 | Assignment 3 : Expression Conversion
78 |
79 | Implement stack as an abstract data type using singly linked list and use this ADT for conversion of infix expression to postfix,
80 | prefix and evaluation of postfix and prefix expression.
81 |
82 | __________________________________________________________________________
83 |
84 | [31/10/2021]
85 |
86 | _***AssignmentNo. 4 >***_
87 |
88 | On Branch named -
89 | Assignment_4-Expression_tree ->
90 |
91 | Assignment 4 : Expression Tree
92 |
93 | Construct an expression tree for postfix expression and perform recursive and non-recursive Inorder, Preorder and Postorder traversals.
94 |
95 | __________________________________________________________________________
96 |
97 | [05/11/2021]
98 |
99 | _***AssignmentNo. 5 >***_
100 |
101 | On Branch named -
102 | Assignment_5-BST ->
103 |
104 | Assignment 5 : BST
105 |
106 | Implement binary search tree and perform following operations:
107 | a) Insert (Handle insertion of duplicate entry)
108 | b) Delete
109 | c) Search
110 | d) Display tree (Traversal)
111 | e) Display - Depth of tree
112 | f) Display - Mirror image
113 | g) Create a copy
114 | h) Display all parent nodes with their child nodes
115 | i) Display leaf nodes
116 | j) Display tree level wise
117 |
118 | __________________________________________________________________________
119 |
120 | [07/11/2021]
121 |
122 | _***AssignmentNo. 6 >***_
123 |
124 | On Branch named -
125 | Assignment_6-Threaded_BST ->
126 |
127 | Assignment 6 : Threaded BST
128 |
129 | Implement In-order Threaded Binary Tree. Traverse the implemented tree in Pre- order too.
130 |
131 | __________________________________________________________________________
132 |
133 | [04/12/2021]
134 |
135 | _***AssignmentNo. 7 >***_
136 |
137 | On Branch named -
138 | Assignment_7-MST ->
139 |
140 | Assignment 7 : Minimum Spamming Tree
141 |
142 | Represent a graph of your college campus using adjacency list /adjacency matrix. Nodes should represent the various departments/institutes and links should represent
143 | the distance between them. Find minimum spanning tree using,
144 | a) Using Kruskal’s algorithm
145 | b) Using Prim’s algorithm
146 |
147 | __________________________________________________________________________
148 |
149 | [11/12/2021]
150 |
151 | _***AssignmentNo. 8 >***_
152 |
153 | On Branch named -
154 | Assignment_8-Dijikstra's_Algorithm ->
155 |
156 | Assignment 8 : Dijkstra's Algorithm
157 |
158 | Represent a graph of city using adjacency matrix /adjacency list. Nodes should represent the various landmarks and links should represent the distance between them.
159 | Find the shortest path using Dijkstra's algorithm from single source to all destination. Analyze the implemented algorithm for space and time complexity
160 |
161 | __________________________________________________________________________
162 |
163 | [13/12/2021]
164 |
165 | _***AssignmentNo. 9 >***_
166 |
167 | On Branch named -
168 | Assignment_9-Heap_Sort ->
169 |
170 | Assignment 9 : Implementation of Heap Sort
171 |
172 | Implement Heap sort to sort given set of values using max or min heap.
173 |
174 | __________________________________________________________________________
175 |
176 | [14/12/2021]
177 |
178 | _***AssignmentNo. 10 >***_
179 |
180 | On Branch named -
181 | Assignment_10-File_Handling ->
182 |
183 | Assignment 10 : File Handling
184 |
185 | Department maintains student’s database. The file contains roll number, name, division and address. Write a program to create a sequential file to store and maintain
186 | student data. It should allow the user to add, delete information of student. Display information of particular student. If record of student does not exist an
187 | appropriate message is displayed. If student record is found it should display the student details.
188 |
189 | __________________________________________________________________________
190 |
--------------------------------------------------------------------------------
/Student_Database_using_class_n_sorting.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | ============================================================================
3 | Name : Student_Database_using_class_n_sorting.cpp
4 | Author : 23232_Abhishek Jadhav
5 | Version : 1.0
6 | Copyright : Your copyright notice
7 | Description : DSAL Lab Assignment No. 1
8 | ============================================================================
9 | */
10 |
11 | #include
12 | using namespace std;
13 | struct name
14 | {
15 | char firstname[10];
16 | char lastname[12];
17 | };
18 |
19 |
20 | struct profile
21 | {
22 | name student_name;
23 | float SGPA;
24 | int Roll_no;
25 | };
26 |
27 |
28 | class student_data
29 | {
30 | private :
31 |
32 | struct profile std_db[15]={"Abhishek", "Jadhav", 9.89, 23232, "Abhijeet", "Ingle", 9.8, 23231, "Ronal", "Dhodia", 9.54, 23222, "Pratik", "Gabhale", 9.12, 23224, "Ayush", "Gala", 9.65, 23228, "Kunal", "Kachare", 9.5, 23235, "Mihir", "Inamdar", 9.01, 23230, "Sanika", "Joshi", 9.2, 23234, "Atharva", "Kinikar", 9.8, 23241, "Mrunal", "Kashid", 9.45, 23238, "Kalyani", "Nilpankar", 8.97, 23237, "Tanmay", "Goregaonkar", 8.85, 23227, "Shruti", "Jagdale", 9.74, 23233, "Sandesh", "Dholas", 8.86, 23223, "Akshay", "K", 8.98, 23242};
33 | int n = 15;
34 |
35 | public :
36 |
37 | void view(int n)
38 | {
39 | cout<<"\n\n Student Name SGPA Roll\n No. No.\n--------------------------------------------------------------\n";
40 | for (int i = 0; i <= n-1; i++)
41 | {
42 | cout<<" "<>- "<>- "<>n;
52 | cout<<"\n ------------ No. of Students to added : "< Enter Name of Student : ";
56 | cin>>std_db[i].student_name.firstname>>std_db[i].student_name.lastname;
57 | cout<<"\n > Enter Student SGPA : ";
58 | cin>>std_db[i].SGPA;
59 | cout<<"\n > Enter Student Roll no. : ";
60 | cin>>std_db[i].Roll_no;
61 | cout<<" --------------------------------------------------------------";
62 | }
63 | cout<<"---------------- Addition Done Successfully ! ----------------";
64 | student_data :: view(15);
65 | }
66 |
67 | void search_sgpa(float r) //linear search on SGPA
68 | {
69 | cout<<"\n\n< Searching in SGPA using Linear Search...>\n-----------------------------------------------";
70 | int t = 1;
71 | for (int i = 0; i < n; i++)
72 | {
73 | if(std_db[i].SGPA == r)
74 | {
75 | cout<<"\n\n#"<>- "<>- "<>m;
95 | int m_i = m - 1;
96 | for (int i = 0; i < 15; i++)
97 | {
98 | if ( i == m_i)
99 | {
100 | char stopModify = 'Y';
101 | while (stopModify == 'Y')
102 | {
103 | cout<<"\n# Modify - \t1. Name\t\t2. SGPA\t\t3. Student Roll no.\n Choice (1/2/3): ";
104 | int choice;
105 | cin>>choice;
106 | switch(choice)
107 | {
108 | case 1:
109 | cout<<" FirstName Surname\n > Enter Name of Student : ";
110 | cin>>std_db[i].student_name.firstname>>std_db[i].student_name.lastname;
111 | cout<<" -------- Changes Done Successfully ! --------";
112 | student_data :: view(15);
113 | break;
114 | case 2:
115 | cout<<"\n > Enter Student SGPA : ";
116 | cin>>std_db[i].SGPA;
117 | cout<<" -------- Changes Done Successfully ! --------";
118 | student_data :: view(15);
119 | break;
120 | case 3:
121 | cout<<"\n > Enter Student Roll_no : ";
122 | cin>>std_db[i].Roll_no;
123 | cout<<" -------- Changes Done Successfully ! --------";
124 | student_data :: view(15);
125 | break;
126 | default:
127 | cout<<" Invalid choice !\n -------------------------------------------";
128 | }
129 | cout<<"\nDo you want to continue modification (Y/N) ? : ";
130 | cin>>stopModify;
131 | cout<<" -------------------------------------------\n";
132 | }
133 | break;
134 | }
135 | else
136 | {
137 | cout<<"\n Student no. is out of range or Invalid input";
138 | }
139 | }
140 | }
141 |
142 | void sort_names(int n) //insertion sort for sorting names
143 | {
144 | for (int k=n-1; k>0; k--)
145 | {
146 | struct profile temp = std_db[k];
147 | int j = k-1;
148 | while (j >= 0 && strcmp(temp.student_name.firstname, std_db[j].student_name.firstname) < 0) //compares both the strings character by character
149 | {
150 | std_db[j+1] = std_db[j];
151 | j = j-1;
152 | }
153 | std_db[j+1] = temp;
154 | }
155 | }
156 |
157 | void sort_SGPA(int l, int k) //sorting SGPA using quick sorting
158 | {
159 | int r = k-1;
160 | if (l>=r) return;
161 | int i=l;
162 | int j=r+1;
163 | struct profile prec;
164 | int p = std_db[l].SGPA; //Select pivot element
165 | prec = std_db[l]; //temporarily storing pivot record prec
166 | while(1)
167 | {
168 | do{ i++; } while (std_db[i].SGPA < p && i <= r);
169 | do{ j--; } while (std_db[j].SGPA > p && j >= l);
170 | if(i >= j) break;
171 | struct profile temp;
172 | temp = std_db[j];
173 | std_db[j] = std_db[i];
174 | std_db[i] = temp;
175 | }
176 | std_db[l] = std_db[j];
177 | std_db[j] = prec;
178 | sort_SGPA(l,j); //left list
179 | sort_SGPA(j+1,r); //right list
180 | student_data :: view(10);
181 | }
182 |
183 | void sort_RollNo() //sorting roll no. in ascending order using bubble sort
184 | {
185 | for (int i = 0; i < n; i++)
186 | {
187 | for (int j = 0; j < n-1; j++)
188 | {
189 | if((std_db[j].Roll_no) < (std_db[j+1].Roll_no)) //Swapping
190 | {
191 | struct profile temp;
192 | temp = std_db[j];
193 | std_db[j] = std_db[j+1];
194 | std_db[j+1] = temp;
195 | }
196 | }
197 | }
198 | student_data :: view(n);
199 | }
200 |
201 | void search_name()
202 | {
203 | cout<<"\n Enter student name to be searched : ";
204 | char search[10];
205 | cin>>search;
206 | cout<<"\n< Searching name using Binary Search...>";
207 | int lower = 0, upper, mid;
208 | upper = n - 1;
209 | mid = (lower + upper)/2;
210 | student_data :: sort_names(n);
211 | while (lower <= upper)
212 | {
213 | if(strcmp(std_db[mid].student_name.firstname, search)<0)
214 | {
215 | lower = mid + 1;
216 | }
217 | else if(strcmp(std_db[mid].student_name.firstname, search)==0)
218 | {
219 | cout<<"\n\n# Details of Student with name "<>- "<>- "< upper)
233 | {
234 | cout<<"\n Student '"< 1. VIEW RECORDS\t> 2. ADD RECORDS\t> 3. MODIFY RECORD\t> 4. SEARCH SGPA\t> 5. SORT NAME\t\t> 6. SORT SGPA(Toppers)\t\t> 7. SORT ROLL NO.\t\t> 8. SEARCH NAME\t> 9. EXIT\n\t\t\t\t\t\t\t\t\tEnter choice (1/2/3/4/5/6/7/8/9): ";
252 | int choice;
253 | cin>>choice;
254 | switch(choice)
255 | {
256 | case 1:
257 | std.view(15);
258 | break;
259 | case 2:
260 | std.add();
261 | break;
262 | case 3:
263 | std.modify();
264 | break;
265 | case 4:
266 | cout<<"\n Enter Student SGPA to be searched : ";
267 | float r;
268 | cin>>r;
269 | std.search_sgpa(r);
270 | break;
271 | case 5:
272 | cout<<"\n< Sorting name alphabetically using Insertion Sort...>";
273 | std.sort_names(15);
274 | std.view(15);
275 | break;
276 | case 6:
277 | cout<<"\n< Sorting top 10 SGPA using Quick Sort...>";
278 | std.sort_SGPA(0, 10);
279 | break;
280 | case 7:
281 | cout<<"\n< Sorting Roll No. wise using Bubble Sort...>";
282 | std.sort_RollNo();
283 | break;
284 | case 8:
285 | std.search_name();
286 | break;
287 | case 9:
288 | cout<<" >Exited successful<\n --| END OF CODE |--";
289 | return 0;
290 | default :
291 | cout<<"\n Invalid choice !";
292 | }
293 | cout<<"\n\nDo you want to continue (Y/N) ? : ";
294 | cin>>stopApp;
295 | if (stopApp == 'N' | 'n')
296 | {
297 | cout<<" ----------------| END OF CODE |----------------\n";
298 | }
299 | }
300 | return 0;
301 | }
302 |
--------------------------------------------------------------------------------