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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Python use

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.
Transcribed Image Text: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.
Expert Solution
Step 1

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

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Constants and Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education