You are not logged in. Please login at www.codechef.com to post your questions!

×

median of n numbers without using array

java program to find median of n numbers without using array

asked 10 Aug, 11:19

h7214's gravatar image

0★h7214
1
accept rate: 0%


If language-specific libraries are not intended then:

If the numbers are already sorted as they arrive then a LinkedList and using the two pointers approach would find the median, else a balanced binary search tree could be built to find the median.

link

answered 10 Aug, 16:00

utkalsinha's gravatar image

6★utkalsinha
806118
accept rate: 11%

In principle, if you are handling values one by one, you will need to retain at least the first half of the values (if you know the eventual count of values) to ensure that you do not discard the median.

By contrast you can calculate the mean of a stream of values continuously. without retaining any data value after updating the mean.

link

answered 10 Aug, 18:26

joffan's gravatar image

3★joffan
1125
accept rate: 3%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1,166

question asked: 10 Aug, 11:19

question was seen: 51 times

last updated: 10 Aug, 16:00