Professional Documents
Culture Documents
BASED
LAB TASK
REPORT
Sorting National Level Cut-Off Scores in Higher Secondary
School Certificate Examination using Merge and Quicksort
Algorithms.
Submitted by
MOUNIKA M K
202IT172
JULY 2023
DECLARATION
I affirm that the lab task work titled “Sorting National Level Cut-Off Scores in Higher
Secondary School Certificate Examination using Merge and Quicksort Algorithms.” is
being submitted as the record of original work done by us under the guidance of Mrs. R.
Leelavathi, Assistant Professor, Department of Information Technology.
MOUNIKA M K(202IT172)
LEELAVATHI R
ASSISTANT PROFESSOR
DEPT OF INFORMATION TECHNOLOGY
TABLE OF CONTENTS
3 Methodology proposed 5
4 Coding 6
5 Output 8
6 Conclusion 9
7 References 9
1. TITLE OF THE TASK
The objective of this task is to sort the national level cut-off scores obtained
ascending order. The sorting process will be implemented using two popular
making processes.
3. METHODOLOGY PROPOSED
1.MERGE SORT:
#include <iostream>
#include <vector>
using namespace std;
void merge(vector<int>& arr, int low, int mid, int high) {
int left_size = mid - low + 1;
int right_size = high - mid;
vector<int> left(left_size), right(right_size);
for (int i = 0; i < left_size; i++)
left[i] = arr[low + i];
for (int i = 0; i < right_size; i++)
right[i] = arr[mid + 1 + i];
int i = 0, j = 0, k = low;
while (i < left_size && j < right_size) {
if (left[i] <= right[j]) {
arr[k] = left[i];
i++;
} else {
arr[k] = right[j];
j++;
}k++;
}
while (i < left_size) {
arr[k] = left[i];
i++; k++;
}
while (j < right_size) {
arr[k] = right[j];
j++; k++;
}
}
void merge_sort(vector<int>& arr, int low, int high) {
if (low >= high)
return;
int mid = low + (high - low) / 2;
merge_sort(arr, low, mid);
merge_sort(arr, mid + 1, high);
merge(arr, low, mid, high);
}
int main() {
// Replace the elements in this vector with the national level cut-off scores
vector<int> cutOffScores = {87, 91, 78, 95, 83, 88, 89, 94, 90, 85};
// Applying Merge Sort
merge_sort(cutOffScores, 0, cutOffScores.size() - 1);
// Displaying sorted scores after Merge Sort
cout << "Sorted Scores (Merge Sort): ";
for (int score : cutOffScores)
cout << score << " ";
cout << endl;
return 0;
}
2.QUICK SORT:
#include <iostream>
#include <vector>
int main() {
// Replace the elements in this vector with the national level cut-off scores
vector<int> cutOffScores = {87, 91, 78, 95, 83, 88, 89, 94, 90, 85};
// Applying Quicksort
quicksort(cutOffScores, 0, cutOffScores.size() - 1);
return 0;
}
5. OUTPUT:
1.MERGE SORT:
2.QUICK SORT:
6. CONCLUSION
7. REFERENCES
2. Quicksort - https://www.geeksforgeeks.org/quick-sort/
3. Cormen, T. H., Leiserson, C. E., Rivest, R. L., & Stein, C. (2009). Introduction
to Algorithms (3rd ed.). The MIT Press.
PROCESS PLAN
Proposed Process Plan Actual Plan Executed
Skill: DESIGN AND ANALYSIS OF ALGORITHMS LAB Date: 23/07/2023 Name: MOUNIKA M K
REFLECTION SHEET
S/N Problems Counter measures status
Status legend:
OUTCOME BASED LAB TASK
RUBRICS FORM