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
goblinko [34]
3 years ago
5

Write pseudocode to solve the following problem: You are given an array A[1 . . . n] whose each element is a point of the plane

(x, y). You need to sort the array so that points with lower x-coordinate come earlier, but among points with the same x-coordinate, the ones with larger y-coordinate come earlier. So, for example if the array contains, (1, 2),(1, 4),(7, 10),(11, 3),(14, 1),(7, 2) The output in this case should be: (1, 4),(1, 2),(7, 10),(7, 2),(11, 3),(14, 1). Analyze the running time of your algorithm as a function of n.
Computers and Technology
1 answer:
bixtya [17]3 years ago
5 0

Answer:

Answer explained below

Explanation:

void bubbleSort(int X[], int Y[], int n)

{

   int i, j;

   for (i = 0; i < n-1; i++)      

     

   // Last i elements are already in place

   for (j = 0; j < n-i-1; j++)

       if (X[j] > X[j+1])

{

swap(X[j],X[j+1])

swap(Y[j],Y[j+1]);

}

       if (X[j] == X[j+1]&&Y[j]<Y[j+1])

{

swap(X[j],X[j+1])

swap(Y[j],Y[j+1]);

}

}

Since the above algorithm contains 2 nested loops over n.

So, it is O(n^2)

You might be interested in
Algorithm of how to calculate the area of a square.
USPshnik [31]

Answer:

In order to calculate area of a square, 'A' be the area of square and the length of the square be 'a'. Then we need to calculate A= a*a. Step 2 :- Accept as input, the length of the sides of the square, and store the value in variable a. Step 3 :- Calculate the area of the square (a*a) and store in a variable A.

Explanation:

3 0
2 years ago
Read 2 more answers
Describe the information technology industry today
Volgvan

Answer:

The information technology (IT) sector includes companies that produce software, hardware, or semiconductor equipment, and companies that provide internet or related services.

Explanation:

6 0
2 years ago
Write the code for invoking a method named sendObject. There is one argument for this method which is of type Customer. Assume t
kodGreya [7K]

Answer:

sendObject(John_Doe);

Explanation:

The above code has been written in Java.

Since the calling class is the same that declares it, to invoke the method, simply call its name with its argument(s) in a pair parentheses. The name of the method is "sendObject" and its argument is a reference to an object of type Customer saved in a variable called "John_Doe". This can be written as follows:

sendObject(John_Doe);

Hope this helps!

3 0
3 years ago
Please describe the role of games in modern society!
ohaa [14]
It is to Entertainment.
5 0
2 years ago
Read 2 more answers
Write an algorithm and draw a flowchart for switching off a machine after it has made 500 glass bottles. use an appropriate cond
masha68 [24]

The algorithm is as follows:

1. Start

2. bottles = 0

3. While bottles != 500

3.1 Create bottle

3.2 bottle = bottle + 1

4. Switch off machine

5. Stop

Explanation:

This begins the algorithm

1. Start

This initializes bottles to 0

2. bottles = 0

The loop is repeated until 500 bottles is created

3. While bottles != 500

This creates a new bottle

3.1 Create bottle

This increments the number of bottles by 1

3.2 bottle = bottle + 1

This switches of the machine after all bottles are created

4. Switch off machine

End algorithm

5. Stop

THANKS

4 0
3 years ago
Other questions:
  • What would be the desired output of a home security system?
    6·1 answer
  • An undesirable jagged appearance is referred to as
    7·2 answers
  • You have a server called server1 that is running windows server 2012. what command would you use to delete the ptr record for 10
    5·1 answer
  • ________ are websites that provide collections of content from all over the world wide web a. aggregators b. social networks c.
    6·1 answer
  • Convert the binary number into a hexadecimal number.
    7·1 answer
  • Which of the following is the correct ordering of operating systems, oldest to newest?
    5·2 answers
  • A blue NFiPA label indicates: A) Health Hazard B) Special information C) Flammability D) Reactivity
    6·2 answers
  • A person who creates a computer virus is a (1)system analyst (2) techician(3) programmer​
    11·2 answers
  • Which branch of science helps avoid or minimize stress-related injuries at workplace?
    14·1 answer
  • College entrance requirements are the expectations for admission.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!