I have a simple code which gets a median form a file of intigers.
Here is part of it:
It works fine, but I heard that a better way of finding a median is by passing through the intigers in the file twice, first getting the total intigers and on the second pass getting an intiger in the middle (the median).
int total = 0 ;
int number = 0;
for (int i ; intiger_stream >> number ; i ++ )
total ++ ;
middle = (total + 1)/2 ;
cout << "Median : " << middle << endl;
I can't figureout how to find the median via that second method.
Could someone give me a hint.