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
To begin importing data from an excel spreadsheet, click on the ____ tab on the ribbon.
Mamont248 [21]

Answer:

External data

Explanation:

The "external data" is one of the tabs on the ribbon. It is used for importing data from an excel spreadsheet.

Hope this helps!

3 0
3 years ago
Explain what happens if you try to open a file for reading that does not exist.
ZanzabumX [31]

Answer:

Exception is thrown and the file is created with 0 length.

Explanation:

While opening a file there is an error occur which shows the file does not exist that means an  exception is thrown.

And this error can be occur when the size of the file is very very low means the file is a size of 0 length. So to avoid this error we have to exceed its length from the zero length.

8 0
3 years ago
The four differences between binary and denary​
Andrei [34K]

Explanation:

Binary and denary

A number base indicates how many digits are available within a numerical system. Denary is known as base 10 because there are ten choices of digits between 0 and 9. For binary numbers there are only two possible digits available: 0 or 1. The binary system is also known as base 2.

mark me brainliest please

8 0
3 years ago
Sue conducted an experiment to determine which paper towel is the most absorbent among three different brands. She decides to pr
Triss [41]

Answer:

Its C

Explanation:

On Edg

7 0
3 years ago
A type of storage which holds data on a permanent basis for later use<br><br><br><br> Help please
nikdorinn [45]

Answer:

Permanent storage, also called persistent storage, is any computer data storage device that retains its data when the device is unpowered. A common example of permanent storage is the computer's hard drive or SSD.

Explanation:

4 0
3 years ago
Other questions:
  • Henry must choose which type of smart speaker to use in his home. He asked you to help him decide which one will best suit his n
    11·1 answer
  • Because many mobile devices and personal computers today are continually connected to the Internet, securing those devices again
    6·1 answer
  • A file named numbers.txt contains an unknown number of lines, each consisting of a single positive integer. Write some code that
    6·1 answer
  • Write a function findWithinThreshold that identifies the elements of a given array that are inside a threshold value. Takes the
    13·1 answer
  • The HTTP protocol operates at which layer?
    7·1 answer
  • Could someone please explain to me the an electrical circuit.
    13·2 answers
  • Not every organization integrates with the Internet, but all use some or most of the technology that gave rise to it.
    15·1 answer
  • Who wants brainlyest! NO LINKS how do you message someone on brainly
    10·2 answers
  • X274: Recursion Programming Exercise: Cannonballs Spherical objects, such as cannonballs, can be stacked to form a pyramid with
    7·1 answer
  • What is the answer ????​
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!