Skip to main content

Timeline for Median of a Vector assignment

Current License: CC BY-SA 4.0

9 events
when toggle format what by license comment
Feb 12, 2022 at 23:34 history edited Toby Speight
edited tags
Oct 30, 2018 at 22:45 vote accept Ulivax
Oct 30, 2018 at 6:55 answer added Snowhawk timeline score: 4
Oct 30, 2018 at 0:30 comment added papagaga Printing is an idea but I feel like it's not pertinent here. You should be able to use the median after computing it. At this point, you could consider that the problem wasn't well thought out in the first place, or consider that certain inputs are invalid (empty vector, or uniform, even-sized vector) and ask for another one.
Oct 30, 2018 at 0:20 comment added Ulivax I was thinking about that and the only method I could think of was to print the vector and in the middle show the median value between the exact number of elements adjacent to computed value.
Oct 30, 2018 at 0:17 comment added papagaga besides you can't solve the problem in certain cases, such as a vector of even size filled with only one number ( [2,2,2,2] for instance): there's is no number such as "exactly as many elements come before it in the sequence as come after it". So what will you do about it?
Oct 30, 2018 at 0:13 comment added papagaga you need to take of the case where temps.size() == 0, because it fits the temps.size() % 2 == 0 but then temps[temps.size() / 2 - 1] will backfire
Oct 29, 2018 at 22:12 history edited 200_success CC BY-SA 4.0
added 22 characters in body; edited tags
Oct 29, 2018 at 22:01 history asked Ulivax CC BY-SA 4.0