Suppose you are given a task to rank the students. You have gotten the marks and id of the students. Now your task is to rank the students based on their marks using a sorting algorithm. However, you have to keep in mind that your sorting algorithms perform the minimum number of swapping operations. Input: The first line of the input file will contain an integer N (1 ≤ N≤ 1000). The second line will contain N integers, representing the Student ID, Si ( 1 ≤ Si ≤ 1000 ). The next line will contain the N integer, Sm (1 ≤ Sm≤ 1000), which denotes the obtained mark of the corresponding students. Output: You have to show the Student Id and obtained marks in descending order based on their obtained mark. If two or more students get the same mark, then students with the lower ID will get prioritized. See the input and output for a better understanding. Input 1: 7 7493251 40 50 50 20 10 10 10 Input 2: 4 7253 80 60 80 50 Output 1: ID: 4 Mark: 50 ID: 9 Mark: 50 ID: 7 Mark: 40 ID: 3 Mark: 20 ID: 1 Mark: 10 ID: 2 Mark: 10 ID: 5 Mark: 10 Output 2: ID: 5 Mark: 80 ID: 7 Mark: 80 ID: 2 Mark: 60 ID: 3 Mark: 50 Please note, you have to take the input from an input4.txt file, and show the output in an output4.txt file.
Python use
Introduction
Python Programming:
Python is a well-liked option for both novice and seasoned developers since it is a high-level, interpreted, overall programming language that is simple to learn and use. It contains a big software library, supports a variety of development methodologies, including object-oriented, procedural, and functional programming, and is helpful for a variety of projects, including web development, scientific computing, data analysis, and artificial intelligence.
Sorting Algorithm:
A sorting algorithm is a method for rearranging elements of a list in a specific order, typically in ascending or descending order. The most common orders are numerical or lexicographical (i.e., alphabetic) orders. Sorting algorithms can be implemented in many programming languages and are used in a variety of applications, such as data structures, databases, and search engines. Some examples of sorting algorithms are:
- Bubble sort
- Insertion sort
- Selection sort
- Quick sort
- Merge sort
- Heap sort
The efficiency of a sorting algorithm is usually measured by its time complexity, which determines the amount of time it takes to sort a list of elements as a function of the size of the list.
Find:
Rank Students Based on Marks
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images