michael.sapozhnikov
BAN USER
- 0of 0 votes
AnswersYou have a binary tree. Print node values starting from the root going level by level, i.e. first line has root node's value, second line has two child node's values, third line - left and right child nodes values of the root's left child then left and right child nodes values of the root's right child, and so on.
- michael.sapozhnikov in United States| Report Duplicate | Flag | PURGE
Bloomberg LP Java Developer Algorithm
4+4+5
- michael.sapozhnikov March 13, 2012They are both implementations of the List interface. LinkedList implements it with doubly linked list, ArrayList implements it with dynamically resized array.
For LinkedList: {{
get is O(n),
add is O(1),
remove is O(n),
iterator.remove is O(1).}}
For the ArrayList: {{
get is O(1),
add is O(1) amortized, i.e. once in a while when array must be resized you pay
performance, so in worst case it is O(n),
remove is O(n).
}}
Immutable object is an object which once created, it's content cannot be changed.
E.g. standard Java classes: String, Integer, Boolean, Character, Byte, Short, Long, Float, Double, BigDecimal, BigInteger.
Immutable objects are automatically thread safe.
Following your advise for a systematic approach this could be thought of a little bit differently and of course giving the same result. As before person A takes any sit, there are 4! arrangements for B,C,D and E. Considering only arrangements where person B sits next to A, out of all these arrangements we are interested only in those that either start with B (=3!) or end with B (=3!), so the probability of A and B sitting next to each other is (2*3!)/4!=1/2 = 50%. This is basically the same as hello world did before without combining A and B in one unit but counting through separately.
- michael.sapozhnikov March 03, 2012You just verified that my answer was correct. I as thinking a little bit differently. No matter where one of these two people sits (say person A) the second one (B) has 4 choices, where 2 out of theses 4 choices are next to A, so probability is 2/4 = 1/2=50% chance.
- michael.sapozhnikov March 02, 2012
Rehashing
- michael.sapozhnikov March 29, 2012Linear Probing
Quadratic Probing