h*****u 发帖数: 979 | 1 How to pick the highest and lowest point from a stock's one day performance(
e.g. the price)?
because it is a time series data pool, you can't do the sorting process, so
how you get the highest price and the lowest price? |
p*****w 发帖数: 82 | 2 Do the bubble w/o swapping?
Complexity = T(n) |
p*******i 发帖数: 309 | 3 晕 大虾能再深入解释一下好么???
我怎么觉得应该上网查阿。 哈哈, 开玩笑! |
h*****u 发帖数: 979 | 4 yea, coud 2nd floor give us a more specific solution? |
h***n 发帖数: 4 | 5 javascript:
var prices;
var min=999;
var max=-999;
for(var x in prices) {
if(prices[x]
min=prices[x];
if(prices[x]>max)
max=prices[x];
}
debug(min, max); |
i*****r 发帖数: 1302 | 6 这问题...不就yahoo看一下high&low么??? |
p*****w 发帖数: 82 | 7 Step 1. You assume a Max value and Min value.
Step 2. Everytime, after you take in a new stock price, you compare that
value with the current Max and Min values, and update with new Max and Min
values.
Step 3. At the end of the day, your Max and Min values will be the values
you need.
Very similar with the Bubble Algorithm but without swapping.
Haven took the same approach. |