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]
4 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]4 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
It is vital to the organization and the success of the disaster recovery plan that the plan be thoroughly tested on a(n) _______
Andreyy89

Answer:

Regular Basis.

Explanation:

The plans should be clearly defined and checked regularly according to the set parameters. Also, there needs to evaluate one every week various types of environmental assessment have to be done. As the Disaster Recovery is a set of policies procedures and tools one needs to keep it updated to the current version. As any business needs to operate.

8 0
3 years ago
Janae started an essay on the computer at school. She would like to work on it when she gets home, but she does not have a flash
Marina86 [1]
A) it would be cloud computing
3 0
4 years ago
Read 2 more answers
Which of the following is a benefit, as well as a risk, associated with peer-to-peer networks?
Anna71 [15]
<span>Clients depend on a working main server to perform their jobs: no, p2p relies on a structure without a central server. 

</span><span>Individuals can easily add or remove devices from their network: yes, this is true.

</span><span>Requires an IT professional, but easy to add clients to server and give privileges: no, in p2p, the server doesn't play a role.
</span>
<span>Software is maintained on the server, allowing for easy access to upgrade programs for all users: this is not an aspect of p2p</span>
5 0
4 years ago
Read 2 more answers
We want to implement a data link control protocol on a channel that has limited bandwidth and high error rate. On the other hand
Korolek [52]

Answer:

Selective Repeat protocols

Explanation:

It is better to make use of the selective repeat protocol here. From what we have here, there is a high error rate on this channel.

If we had implemented Go back N protocol, the whole N packets would be retransmitted. Much bandwidth would be needed here.

But we are told that bandwidth is limited. So if packet get lost when we implement selective protocol, we would only need less bandwidth since we would retransmit only this packet.

6 0
3 years ago
A wet-carpet cleaner that carries its own water supply has water pressure created by a        A. faucet mixing valve.   B. manua
BARSIC [14]
Your answer is most likely C. motor-driven pump
5 0
3 years ago
Other questions:
  • 1. Create a view named customer_addresses that shows the shipping and billing addresses for each customer.
    15·1 answer
  • Which of the following devices electronically sorts mail by ZIP code? A. Fax modem B. Electronic organizer C. Optical character
    10·1 answer
  • What is the best approach to handling the expectation of privacy by employees in the event an investigation needs to be carried
    15·1 answer
  • A collection of related files that serves as a foundation for retrieving information is a: byte
    12·1 answer
  • A user has requested a field that counts the number of child records associated with a custom object. These custom objects have
    5·1 answer
  • In UML behavioral modeling, a message is _____. (Points : 6) a named location in memory where information is deposited and retri
    7·1 answer
  • Sharon is thinking about opening a bakery. She knows she wants to set her own hours, reduce her stress and make a profit. But sh
    14·1 answer
  • What directs the read/write arm of the hard drive to where data exists and accesses it upon the user's request?
    8·1 answer
  • Pls help!!!!!!!!!!!!
    13·2 answers
  • Consider the code block below. What is the value of amount when this method is called twice, the first time using cookieJar(7) a
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!