1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Anna71 [15]
3 years ago
5

Give a linear-time algorithm to sort the ratios of n given pairs of integers between 1 and n. I.e., we need to sort, within O(n)

time, n pairs of the form (ai , bi) where 1 ≤ ai ≤ n and 1 ≤ bi ≤ n using the sort key ai bi . Prove both run-time and correctness.
Computers and Technology
1 answer:
Volgvan3 years ago
8 0

Answer:

12

Explanation:

You might be interested in
Using Python I need to Prompt the user to enter in a numerical score for a Math Class. The numerical score should be between 0 a
yaroslaw [1]

Answer:

<em>The program doesn't use comments; See explanation section for detailed line by line explanation</em>

<em>Program starts here</em>

def lettergrade(subject,score):

     print(subject+": "+str(score))

     if score >= 90 and score <= 100:

           print("Letter Grade: A")

     elif score >= 80 and score <= 89:

           print("Letter Grade: B")

     elif score >= 70 and score <= 79:

           print("Letter Grade: C")

     elif score >= 60 and score <= 69:

           print("Letter Grade: D")

     elif score >= 0 and score <= 59:

           print("Letter Grade: F")

     else:

           print("Invalid Score")

maths = int(input("Maths Score: "))

english = int(input("English Score: "))

pe = int(input("PE Score: "))

science = int(input("Science Score: "))

arts = int(input("Arts Score: "))

lettergrade("Maths Class: ",maths)

lettergrade("English Class: ",english)

lettergrade("PE Class: ",pe)

lettergrade("Science Class: ",science)

lettergrade("Arts Class: ",arts)

Explanation:

The program makes the following assumptions:

Scores between 90–100 has letter grade A

Scores between 80–89 has letter grade B

Scores between 70–79 has letter grade C

Scores between 60–69 has letter grade D

Scores between 0–69 has letter grade E

<em>Line by Line explanation</em>

This line defines the lettergrade functions; with two parameters (One for subject or class and the other for the score)

def lettergrade(subject,score):

This line prints the the score obtained by the student in a class (e.g. Maths Class)

     print(subject+": "+str(score))

The italicized determines the letter grade using if conditional statement

<em>This checks if score is between 90 and 100 (inclusive); if yes, letter grade A is printed</em>

<em>      if score >= 90 and score <= 100:</em>

<em>            print("Letter Grade: A")</em>

<em />

<em>This checks if score is between 80 and 89 (inclusive); if yes, letter grade B is printed</em>

<em>      elif score >= 80 and score <= 89:</em>

<em>            print("Letter Grade: B")</em>

<em />

<em>This checks if score is between 70 and 79 (inclusive); if yes, letter grade C is printed</em>

<em>      elif score >= 70 and score <= 79:</em>

<em>            print("Letter Grade: C")</em>

<em />

<em>This checks if score is between 60 and 69 (inclusive); if yes, letter grade D is printed</em>

<em>      elif score >= 60 and score <= 69:</em>

<em>            print("Letter Grade: D")</em>

<em />

<em>This checks if score is between 0 and 59 (inclusive); if yes, letter grade F is printed</em>

<em>      elif score >= 0 and score <= 59:</em>

<em>            print("Letter Grade: F")</em>

<em />

<em>If input score is less than 0 or greater than 100, "Invalid Score" is printed</em>

<em>      else:</em>

<em>            print("Invalid Score")</em>

This line prompts the user for score in Maths class

maths = int(input("Maths Score: "))

This line prompts the user for score in English class

english = int(input("English Score: "))

This line prompts the user for score in PE class

pe = int(input("PE Score: "))

This line prompts the user for score in Science class

science = int(input("Science Score: "))

This line prompts the user for score in Arts class

arts = int(input("Arts Score: "))

The next five statements is used to call the letter grade function for each class

lettergrade("Maths Class: ",maths)

lettergrade("English Class: ",english)

lettergrade("PE Class: ",pe)

lettergrade("Science Class: ",science)

lettergrade("Arts Class: ",arts)

7 0
2 years ago
Uses of keyboard as a input device
KATRIN_1 [288]

helps us for typing letters, numbers and symbols etc.

3 0
3 years ago
Read 2 more answers
What is the reason that friction is present in surface to surface contact?
Andrej [43]
One surface is larger than the other surface
3 0
2 years ago
Differences between mechanical and optical mouse <br>Plz help me
lutik1710 [3]
Mechanical mouse has a ball that turns rollers inside. If friction is lost between the ball and the mousing surface, or between the ball and the rollers, the mouse fails to work. In order to assure good contact with the mousing surface, the ball must be fairly heavy. When you change directions with the mouse, you must make the ball change rolling directions--an action that inertia likes to prevent.

An optical mouse makes use of an LED and some optics to detect surface texture and the changes in it as the mouse is moved. There are no moving parts
7 0
3 years ago
Write a program that reads three integers as inputs, and outputs the largest of the three values.
AlexFokin [52]

The software is written in C++ and may be found in the explanation section below. C++ keywords and symbols are all capitalized. The least number of all three integers is determined via a nested if-else decision branch. After you've entered three integers, the application prints the least of them all.

<h3>What is the example of C++?</h3>

#include <iostream>

using namespace std;

int main() {

  int num1,num2,num3;

  cout<<"enter first integers"<<endl;

 cin>>num1;

  cout<<"enter second integers"<<endl;

  cin>>num2;

 cout<<"enter the third integers"<<endl;

  cin>>num3;

  if(num1<num2){

     if(num1<num3){

          cout<<"Smallest integer is "<<num1<<endl;

    } else{

          cout<<"Smallest integer is "<<num3<<endl;

      }

 }else {

 if(num2<num3){

    cout<<"Smallest integer is "<<num2<<endl;

} else{

    cout<<"Smallest integer is "<<num3<<endl;

     }

}

return 0;

}

Thus, it is written in C++ language.

For more details about C++ click here:

brainly.com/question/19581899

#SPJ1

3 0
1 year ago
Other questions:
  • A skier provides what in a landscape photograph of a mountain?
    14·2 answers
  • ​some forms use a _____ that contains icons or buttons that represent shortcuts for executing common commands.
    14·1 answer
  • Given three floating-point numbers x, y, and z, output x to the power of y, x to the power of (y to the power of z), the absolut
    9·1 answer
  • For which punctuation symbol will you use the ring finger of your right hand?
    9·1 answer
  • A new product was introduced in 2003, which functions as both an identification device and a medium of communication. It uses in
    8·1 answer
  • Should the existing system be replaced?This is a question that is asked during the _____ stage of the Systems Development Life C
    8·1 answer
  • Where ....................... the books that you borrowed? *
    5·1 answer
  • How do I make someone "Brainiest". <br> First person to reply will get "Brainiest"
    8·2 answers
  • WHAT ACTIONS CAUSE SPAM ON LINKEDIN?
    5·1 answer
  • a company recently implemented a secure sockets layer/transport layer security (ssl/tls) version that supports secure hashing al
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!