Mostly QQ challenges.
Q: is select() blocking or non-blocking?
A: Yes select() takes a timeout argument to specify the blocking interval!
A: More interestingly, https://stackoverflow.com/questions/5351994/will-read-ever-block-after-select/5352634#5352634 says after select(), you should use read() which normally won’t block.
Q: server uses socket() listen() bind() accept(). How about client side?
Q1: if a producer thread uses select to send packets to multiple receivers by tcp and a single receiver has very low capacity, what would happen?
Q1b: select() would show the producer’s socket as writable or failed?
Q1c: what if producer keeps sending? What happens next?
%%A: the producers function stack will get an error code
Q1d: what if UDP rather than TCP
%%A: then no error would occur in the producer system. The slow consumer would be left unnoticed.
%%Q: can a socket specify a wild card for its local port?
Q: fastest IPC method between producer and consumer? OK you said shared memory, so how do you synchronize the producer and consumer? %%A: use a named sys-V semaphore in the kernel
Q: how does the producer/consumer actually use the shared memory? %%A: memory mapped file
Q: Only a 5L and a 3L pail and a running tap. How to get exactly 4L water in the 5L pail?
Q: you are a given a bag of coins (like 1c 1c 1c 5c 5c 10c 25c). Tell me whats the smallest exact payment thats impossible. Every payment must be exact. Hint: sort the coins first, then a clever O(1) single-pass will do. Q: given a list of integers, find if any pair adds up to 18
%%A: in one pass, build a hashset of brown items i.e. every item processed so far. For every new (i.e green) item, compute the partner, and look for it in the hashset. If not there, then add the green item as a brown item.
Q: given a singly linked list with a start node and null-end node, print each node in reverse, without using any “new” implicitly/explicitly
Q: Given an arbitrary directed graph where each parent node has 0 to K children, write a function hasCycle() to check for existence of cycle, visiting each node and each edge once only..
%%A: My verbal algorithm — use breadth-first traversal to trace every branch from root to a leaf node. Detect cycle in each branch. We cant simply keep a seen hashtable, because a node seen twice could be visited on two branches.
Whenever we branch out to 2 child branches, duplicate the parent branch, so that each child branch object has a full path from root.
Each branch object could be a (possibly linked) hashset.
 for instrumentation.
Q: given a blackbox utility function String convert(String), write a parallelized Collection parellelConvert(Collection theSequence)
Requirement: theSequence need to be maintained. Size of input is preserved Requirement: Out of 100 items in theSequence, #3 and #5 might be identical, but they still need to show up as “converted” in the output
Requirement: converter uses a very slow and expensive remote system, so we don’t want to send it the same string twice.
%%Q: is countdown latch and join() implemented using wait/notify? %%Q: readResolve vs readObject
%%Q: can CMS ever stop the world?
%%Q: CMS is used in which region of the heap?
Q: what if you suspect theres leak?
Q: what can cause mem leak in java?
%%A: registered listeners; static variables pointing to a collection
Q: why is swing memory footprint so bad?
Q: how do you mark a memory region as always resident?
Q: array blocking queue — when would it block?
%%A: I think a circular array is the underlying.