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
File Explorer contains ribbon tabs that can be used for various functions. Which ribbon tab provides options to open a new File
padilas [110]

Answer:

file

Explanation:

click on file

6 0
3 years ago
Out of a list of the values 8, 3, 30, 5, 15, and 6, what result would the MIN function return?
kondor19780726 [428]
Probably the minimum number in the given set so 5.
6 0
3 years ago
Read 2 more answers
Which of the following is a step in paraphrasing? Skim the original information to get a sense of what it is about. Select a few
Sedaia [141]
Select a few key words to change to your own words
4 0
3 years ago
Read 2 more answers
i need a moderator or someone to answer this :/ why do i keep getting notifications that i have a new chat or a new answer/comme
Lyrx [107]

Answer:

It happens to me as well. Maybe check emails?  It could also be a bug.

Explanation:

4 0
3 years ago
Read 2 more answers
Why do I have two random warnings?
Misha Larkins [42]
Just a guess, maybe you’ve been reported for having an incorrect answer two times? I’m really not sure I’m just trying to give out possibilities. Maybe if your a Brainly Helper you haven’t been active so they are giving you warnings? Does clicking on the warning tell you the reason for them? Maybe the system thinks your a robot? I’m not sure just trying to give possible reasons, but you could try contacting customer support, but they aren’t always the quickest at responding.

Have a good day!
8 0
3 years ago
Other questions:
  • What economic measure is at the highest level since the Great Depression?
    12·1 answer
  • A _________ is the broadcast of various types of media over the web.
    10·2 answers
  • What is the output of the following program? #include using namespace std; class TestClass { private: int val; void showVal() {
    5·1 answer
  • For a class project, Jerome builds a simple circuit with a battery and three light bulbs. On his way to school, Jerome drops his
    9·1 answer
  • True or false.the color attribute cannot recognized the hexadecimal code.
    7·2 answers
  • How to change screen brightness windows 10?
    7·1 answer
  • Suppose that f() is a function with a prototype like this: void f(________ head_ptr); // Precondition: head_ptr is a head pointe
    15·1 answer
  • To connect a peripheral device to a computer to exchange data, find the appropriate ________ for the device.
    7·1 answer
  • Combining two or more cells to make one is called​
    8·1 answer
  • The Freeze Panes feature would be most helpful for which situation?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!