subject

You are given an array x of int elements along with an int variable n that contains the number of elements in the array. There are no duplicates in this array. You are also given an int variable m that has been declared. Assign to m the median value of the array. NOTE: The median of a set of numbers is the number in the set such that there are as many numbers above that value as there are below. If the set has an even number of members, the median is the average of the pair of numbers such that there are as many numbers above the pair as there are below. EXAMPLE 1: Given 5 8 1 9 7 the median is 7 because there are two numbers below (1 5) and two numbers above (8 9). EXAMPLE 2: Given 3 7 1 4 6 9 the median is the average of 4 and 6 because there are two numbers above 4 and 6 (7 9) and two numbers below (3 1). Were using myprogramminglab for homework now and for some reason it's not liking a lot of what I'm trying to turn in. For the question above my code is below. I through in a bubblesort so I could find the median but is still telling me my code is wrong. int *x;int n;int m;bool swap;int index, temp;x = new int [n];do{swap = false;for(int count=0; count<(n-1); count++){if(x[count] > x[count + 1]){temp = x[count];x[count]= x[count+1];x[count+1]= temp;swap = true;}}}while (swap);int index=0, m=0;if ((n%2) !=0){index = ((n - 1)/2);m = x[index];}else{index = ((n-1)/2);m = ((x[index] + x[index+1])/2);}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 12:30
Some of the first computer games were created in the early 1970s by college students experimenting after hours to see what the were capable of doing.
Answers: 3
question
Computers and Technology, 23.06.2019 21:30
Write a fragment of code that reads in strings from standard input, until end-of-file and prints to standard output the largest value. you may assume there is at least one value. (cascading/streaming logic, basic string processing)
Answers: 3
question
Computers and Technology, 24.06.2019 00:20
Describe a data structures that supports the stack push and pop operations and a third operation findmin, which returns the smallest element in the data structure, all in o(1) worst-case time.
Answers: 2
question
Computers and Technology, 24.06.2019 00:40
What is the error in the following pseudocode? module main() call raisetopower(2, 1.5) end module module raisetopower(real value, integer power) declare real result set result = value^power display result end module
Answers: 1
You know the right answer?
You are given an array x of int elements along with an int variable n that contains the number of el...
Questions
question
Mathematics, 18.03.2021 03:30
question
Mathematics, 18.03.2021 03:30
question
Social Studies, 18.03.2021 03:30
question
Mathematics, 18.03.2021 03:30
question
Mathematics, 18.03.2021 03:30
Questions on the website: 13722363