Monday, December 2, 2013

Technical Problem 4


Given a number N, write a program that returns all possible combinations of numbers that add up to N, as lists. (Exclude the N+0=N)

For example, if N=4 return {{1,1,1,1},{1,1,2},{2,2},{1,3}}

Technical Interview Problem 3

 Design a component that will implement web browser history. the user goes to different site and once he press on history button you should display the last 5 (no duplicates allowed, and 5 can be any N later) if duplicates occur display the most recent one. so if user visit : G,A,B,C,A,Y and than press "history" we will display Y,A,C,B,G. and of course he can go later to two other websites and than press "history" we will show them than the previous 3. 

Technical Interview Problem 2

You visited a list of places recently, but you do not remember the 
order in which you visited them. You have with you the airplane 
tickets that you used for travelling. Each ticket contains just the 
start location and the end location. Can you reconstruct your journey?

Technical Interview Problem 1


given a dictionary of wrods,find the pair of word with following property:
1,the two word don't have same letter.
2,the multiple of the two word's length is maximum.
i give a simple O(n*n*k)(k is the average length of word) method.but i think there will be better one .

Write a method to convert base of given number


Wednesday, November 6, 2013

Understanding Garbage Collector

I have copied the following slides from a presentation given by CTO of Azul Systems.


- concurrent and parallel are orthogonal terms. All four combinations are possible.


- All modern jvm will be the precise as if they are not precise then they will not be able to move stuff and that will lead to fragmentation.


- So the availability of safe points is crucial.

- Compiler injects these safe points.

- If there are not well placed safe points, threads will have to wait for others to reach safe points so that GC cab be started.

-At these safe points, GC will issue an stop-the-world.





Sunday, September 1, 2013

Complex ballroom dancers problem

Imagine that threads represent ballroom dancers and that two kinds of dancers, leaders and followers, wait in two queues before entering the dance floor. When a leader arrives, it checks to see if there is follower waiting. If so, they can both proceeds. Otherwise it waits.

Similarly, when a follower arrives, it checks for a leader and either proceeds or waits, accordingly.

At a time there will be a single pair doing the dance. Once a pair leave, the other pair enters. As shown in the diagram.











We will have the following ballroom class -