SpiralFlex
Well-Known Member
- Joined
- Dec 18, 2010
- Messages
- 6,960
- Gender
- Female
- HSC
- N/A
You're solution assumes the middle elements (averaged) is the median, this is not the median.my array is not sorted
You're solution assumes the middle elements (averaged) is the median, this is not the median.my array is not sorted
What is the medianYou're solution assumes the middle elements (averaged) is the median, this is not the median.
You are confused by 'linked lists'? Or something else? Because it's understandable if you're confused with linked lists if you haven't been taught that concept yet.what does unsorted mean
also I don't understand your given question
Ah ok, so i just need to sort my array and then find the average of the two middle numbers?Median means middle when the array is sorted so the numbers are in ascending order (taking average of two middle I case of even no. of elements).
yeah I haven't done Linked lists yetYou are confused by 'linked lists'? Or something else? Because it's understandable if you're confused with linked lists if you haven't been taught that concept yet.
It's a way of storing data, you point to a 'node' which stores the value and the pointer to the next node... so on until it reaches the end (points to nothing/NULL).
use a sorting algorithmI have a solution but its wayyyyyyyy to long. It involves sorting the array an then finding the middle term. (I havn't done sorting before so maybe thats why im so bad at it)
That's understandable sorting is 2nd semester work. This is a solution, however this isn't the optimal one.I have a solution but its wayyyyyyyy to long. It involves sorting the array an then finding the middle term. (I havn't done sorting before so maybe thats why im so bad at it)
How is this related?turntaker goes to UoW.
Is there a simple 1st sem solutionThat's understandable sorting is 2nd semester work. This is a solution, however this isn't the optimal one.
The naive solution most 1917 student's would give would probably be sort it then take the median as you are doing. Just bare in mind in computing it is never the first solution that comes in mind that is the most efficient, you will learn this if you take further comp courses in unsw.Is there a simple 1st sem solution
he probably implies that I may have covered sorting algorithms, which I have.How is this related?
yea, but I think thats kinda cheating lol (since C probably doesn't have a method that sorts)Unless your sorting algorithm is better than O(nlogn) you're better off using Array#sort (in Java, at least)
Why rewrite code that already exists? Besides, C has qsort that's basically the same thingyea, but I think thats kinda cheating lol (since C probably doesn't have a method that sorts)
On yeah true hahaWhy rewrite code that already exists? Besides, C has qsort that's basically the same thing
Waiting for the repOoooh this is a good idea for a thread