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
When a defendant pleads guilty to one offense just to have another offense dropped, this is what type of plea bargain
uranmaximum [27]
<h2>Answer:</h2>

The answer is sentenced plea bargain

<h2>Explanation:</h2>

sentence bargaining occurs when a defendant agrees to plead guilty to the stated charge in return for a lighter sentence. Typically this must be reviewed by a judge, and many jurisdictions simply don't allow it. In sentence bargaining, they plead guilty agreeing in advance what sentence will be given; however, this sentence can still be denied by the judge.

4 0
3 years ago
Read 2 more answers
You are looking to buy a laptop on a budget and want to save money by not purchasing an extended service agreement with the manu
Reika [66]

Answer:

Since you probably are looking forward to maintaining and repairing the laptop yourself after the warranty has expired, you will need to gain access to the product's documents and spare parts. For this reason, you should choose manufacturers such as Lenovo and Dell. These allow anybody to access their service manual on their sites for free while also letting available documentation about the way to dismantle their computers and other alternatives to buy spare parts somewhere else than their authorized service centers.

4 0
3 years ago
Please help me with this question. I don’t get it
Lelechka [254]
A - they all use microprocessors to compute and store data.
3 0
3 years ago
Read 2 more answers
Which relation is created with the primary key associated with the relationship or associative entity, plus any non-key attribut
konstantin123 [22]

Answer:

- Transform binary or unary M:N relationship or associative entity with its own key.

Explanation:

Transform binary relation is described as the method through which a decimal can easily be converted into binary while the unary relationship is described as a relationship in which both the two participants occurs from the same entity.

In the given case, 'transform binary or unary M:N relationship' can be created using 'the primary key linked with the relationship plus any non-key aspects of the relationship and the primary keys of the related entities' as it displays the existence of a relationship between the occurrences of a similar set of the entity i.e. associative entity here.

5 0
3 years ago
An element in a web page that connects to a different location in the same page or a different page is a _____.
Softa [21]
I believe it would be the anchor element.

<a href="#"></a>

Correct me if I'm wrong.
3 0
3 years ago
Other questions:
  • What is requirement analysis
    8·1 answer
  • A process that allows software-based networked computers to run multiple operating systems and programs and share storage is cal
    5·1 answer
  • _____ are likely to support bigger government, social welfare programs, and legalized abortion.
    8·2 answers
  • True or False
    10·2 answers
  • Select the correct answer.
    13·1 answer
  • Question 4 of 20
    5·1 answer
  • In 2009 to 2010, 1 in 10 social network users:
    10·1 answer
  • Some one help pls will mark brainless !!!!!
    13·1 answer
  • Launa is reviewing several videos from her friends doing the latest dance challenge before they are published on their own
    11·1 answer
  • Can someone please explain to me how the points work when you ask a question? Worth 30 points I think, I still don't know how th
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!