由买买提看人间百态

topics

全部话题 - 话题: stepsize
(共0页)
r*********n
发帖数: 4553
1
来自主题: JobHunting版 - Twitter电面经
他的意思是
ifstream in("file.name", ios::binary|ios::in|ios::ate);
然后in的streampos指向文件末尾,你可以定义一个int stepsize,然后
in.seekg(-stepsize, ios::cur)
in.read(char_array, stepsize),然后再去parse char_array,用"\n"作为delimiter
。当然你可能把一个word拆开成两半,所以还要handle一下这种边界情况。
p******c
发帖数: 40
2
来自主题: Stock版 - 花街面试题 - 老宋喝绿茶
~43.9 left?
import math
totalDistance=100.0
rate=0.5
totalQty=300.0
stepsize=0.01
maxCarry=50.0
eps=1e-8
while(totalDistance>eps and totalQty>eps):
totalDistance-=stepsize
ntimes=math.ceil(totalQty/maxCarry)
totalQty-=(2*ntimes-1)*stepsize*rate
print totalQty
b*****y
发帖数: 163
3
来自主题: Computation版 - 问个专业问题,请帮助看看

The analysis using Taylor's series expansion assumes that function f(x)
is continuously differentiable up to desired order, which is not always
true in most cases. That's what I think why higher order approximation
fails.
If f(x) satisfies the continuous differentiable condition upto desired
order. One can always render higher accuracy under higher order scheme
for certain approximation, when stepsize is taken small enough.
Moreover, there is a trade off between stepsize and machine epsilon,
th
a*m
发帖数: 14
4
最近面了好几个公司,把题目和经验分享一下攒人品求祝福:
Amazon 两轮:
Round 1:
1. C++ Copy Constructor, 包括接口和deep vs. shallow的区别,这题答得一般,有些
细节没搞得特别透彻
2. Hash Table的实现和技术要点 (仔细看过一遍wiki就没问题了)
3. Large file, multiple lines, how to get any line in equal probablity. 这题
可以问得很深入,比如文件太大内存无法装入如何办。
我回答的思路:
内存够文件内容就都装入内存,然后randomGenerator选一行,one pass
内存不够可以记录每行的偏移值在内存,这样之后可以fseek到那一行去读取
如果偏移值都放不下,可以divide into ranges, 当然这个range的stepsize不好选,可
以预估,也可以动态改变(到这一层其实大致给些思路就ok了)
Round 2:
1. Research problem
2. How to build a service to generate ... 阅读全帖
b*****c
发帖数: 1103
5
找一点到已知n点距离的和 最短,距离函数不是欧几里德距离,但是个凸函数
如果是欧几里德距离,就是几何geometric median, O(n), wiki就找到
如果答案要求是在原来n点内找,那就没办法O(n)啦
b*****c
发帖数: 1103
6
总是wrong answer
b*****c
发帖数: 1103
7
连自己generate的部分test cases都不过
b*****c
发帖数: 1103
8
恳求数学达人回答
j********x
发帖数: 2330
9
来自主题: CS版 - 问一个算法题 (转载)
用循环来模拟递归
int level = 0;
int* recurIndex = new int[numberOfParameter];
for(inti = 0; i < numberOfParameter; ++i) {
recurIndex[i] = (end - start) / stepSize + 1;
}
while(1) {
相当于有一个n位的证书,每一位的进制由其对应的变量的取值个数决定。然后从最
低位开始减少/增加,直到最高位到极限
}
K*****N
发帖数: 117
10
来自主题: Computation版 - 问个专业问题,请帮助看看
very nice. that's exactly what i am considering.
but, if i say, by the same stepsize, does mean that higher order algorithm
give higher accuracy??
K*****N
发帖数: 117
11
来自主题: Computation版 - let me ask a question again
you suggest me to test:
if (fabs(y[i])+fabs(yscal[i]*eps)) > fabs(y[i])
printf("double is enough\n");
in that case, eps for double could be much smaller. but that's probably
not the right way to test, since the algorithm is not as what you and I had
thought. bascially, it compare:
if ( delta1 < yscal[i]*eps )
next step;
else
decrease the stepsize;
where delta1 is the estimated error.
so in such case, eps could be much smaller.
but your other suggestion is very helpful for me. thank u v
h***o
发帖数: 539
12
来自主题: Computation版 - let me ask a question again
hehe...in this case it really depends on which variable is
the smallest, yscale or stepsize.
(共0页)