注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号
x
讲真 面twosigma真的不是我的本意 对于一个转专业的学生来说 这种公司真的是去找虐 我把简历放到学校的link board上 hr来找我的我 电面还是那些题:
我把自己准备时候的面经打包发上来 有些东西是我自己的理解 可能不太对或者不准确
今天收到了onsite邀请 本着去纽约旅游一波的心态还是觉得去一趟吧
- Hashmap 的 collision control? How does Hashtable works (follow up: how does open addressing works? What's the problem of linear probing?
How does hash table works? 1. A table of buckets (an array of buckets), using the array index to denote each bucket. 2. For each entry <key, value>, it goes to one of the buckets, the bucket index is determined by a hash function applied on key and the size of array.
Key ———(hash func) —> hash ——-(get_index hashcode % array.length())——->index——>bucket
hash map can only hash one null key, and it’s always mapped to bucket 0.
collision control: - (close addressing) Separate chaining: they will be assigned to the list - open addressing:starting with the hashed-to slot and proceeding in some probe sequence, until an unoccupied slot is found.
Linear probling(open addressing): 1. Probe: To give a key x, and get its index h(x); and continue to the adjacent cells h(x) + 1, h(x) + 2 …if find a cell whose stored key is x, then returned the value from that cell. Otherwise, if an empty cell is found, then return the key is not present in the dictionary. 2. Insertion: follow the same steps: find the an empty cell or a cell whose stored key is x: if the insertion cell cause the load factor of the table to grow above the threshold, will cause rehashing: the whole table will be replaced by a new table(bigger one). Normally, if the size is lager than 1/2, causing the load factor to stay between 1/4 to 1/2. 3. Deletion: Lazy deletion: key-value pairs is removed by replacing the value by a special flag value indicating a deleted key. But there’s some shortcomings for this way.: will contribute to the load factor of the hash table. With this strategy, it may become necessary to rehash all the remaining key-value pairs when too many cell are occupied by deleted keys.
3. Process 与 thread的区别:
不同process之间有不同的address space 但是thread是share memory的 线程的优点: 不需要额外分配内存 通信方便 但是会有线程安全问题 一个挂了另一个也会挂 process 有context switch have high overhea s.push(tmp); } else if(sign == '-') { ss.push(-tmp); } if(sign == '*') { int t = ss.top(); ss.pop(); ss.push(t * tmp); } else if(sign == '/') { int t = ss.top(); ss.pop(); ss.push(t / tmp); } tmp = 0; sign = s[i]; } } while(!ss.empty()) { res = res + ss.top(); ss.pop(); } return res; } };
|