注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
他们家问问题的次序都跟一模一样
我都打印了出来,不用翻页,就顺序读出来
求大米求大米
Q1 What is a hash table? What do you do to handle hash table collision?
Q2 Medianin a stream of integers
Q3 Whatis merge sort? What is quick sort? What are theirrelative advantages and disadvantages?
Q4 examples of pattern
Q5 Differences between threads and processes and how to communicate? IPC ITC
Q6 What is throughput? What is latency? What are their relationships?
solution
- What is a hash table? What do you do to handle hash table collision? 我答了最基本的hash function, hash into a slot, linear probing, chaining method, etc.
2 parts:array and hash function; a data structure that can map to . | Average | Worst case | | Space | O(n) | O(n) | | Search | O(1) | O(n) | | Insert | O(1) | O(n) | | Delete | O(1) | O(n) | [b]A hash function is any that can be used to map of arbitrary size to data of fixed size.
Separate chaining with linked lists[/b][b]open addressing,all entry records are stored in the bucket array itself. When a new entry hasto be inserted, the buckets are examined, starting with the hashed-to slot andproceeding in some probe sequence, until an unoccupied slot is found.[/b][b]Quadratic:H+1,H+4,H+9,H+16,H+25,…[/b]linear probing searches the table for the closest following free locationand inserts the new key there.- Median in a stream of integers - 我答了two heap的solution,然后补充说如果内存不够存stream可以用reservoir sampling sample一个subset来估算。
For thefirst two elements add smaller one to the maxHeap on the left, and bigger oneto the minHeap on the right. Then process stream data one by one, Step1: Add next item to one of the heaps if next item is smaller than maxH ">IPC: | | A record stored on disk, or a record synthesized on demand by a file server, which can be accessed by multiple processes. | | | A data stream sent over a network interface, either to a different process on the same computer or to another computer on the network. | | | A unidirectional data channel. Data written to the write end of the pipe is buffered by the operating system until it is read from the read end of the pipe. |
ITC: · Shared memory, like a variable or some other data structure · Synchronization primitives, like locks and sempahores · Events: wait, notify - What is throughput? What is latency? What are their relationships?
Latencyis the time involved to complete any sort of process. Throughput is the amountof information a sy canprocess within a given time period (actual rate that the information istransferred). Latency and throughput are not necessarily correlated, because ofdata density. A system that has high latency but can transfer a huge amount ofdata can still have higher throughput than a low-latency system. Throughtput is affected by latencyif protocol requires synchronous acknowledges of received data.
|