Monday, May 17, 2010

Open Ended

How will you troubleshoot why your website is not performing

Java


  1. How many classloaders are instantiated in JVM by Default ? Ans: 1 (Primordial ClassLoader)  Details: http://www.javaworld.com/javaworld/jw-10-1996/jw-10-indepth.html
  2. What does volatile keyword in Java do ? 

Design Patterns


  1. What is  the difference between an Adapter and a Facade pattern. Why do you need both of them ?
    1. Adapter is for altering an interface. Facade is to provide a simplified interface for a complex subsystem
    2. Adapter hides the altered interface from the client. Facade still exposes the subsystem interface for advanced clients.
  2. How does decorator differ from Subclassing + overriding ?
  3. What is double checking strategy in Singleton pattern ?
    1. Declare the single instance to be volatile.
    2. Synchronize block for creating instance.
    3. Check for instance null just before entering and just after entering Synchronized block before creating var.
  4. How do we circumvent the problem of a class being Singleton across classLoaders also ?

Puzzles


  1. How many cars are there in USA ? (Similar .. Television sets)
  2. Party > n number of people are wearing white hats. Each can see others hat. Not their own. Everytime gatekeeper opens door to balcony and calls for white hat people to go up to balcony. How many calls is needed for all white hat people to leave the waiting room. 
    1. Ans : n Calls are required. Mathematical induction. 
  3. You've got someone working for you for seven days and a gold bar to pay them. The gold bar is segmented into seven connected pieces. You must give them a piece of gold at the end of every day. If you are only allowed to make two breaks in the gold bar, how do you pay your worker? 
    1. Ans: Divide into 2,1,4:  1st day: 1 piece, 2nd day: Take 1, Give: 2, 3rd day: Give 1, 4th day: Take 2,1 Give 4...go on 
  4. One train leaves Los Angeles at 15mph heading for New York. Another train leaves from New York at 20mph heading for Los Angeles on the same track. If a bird, flying at 25mph, leaves from Los Angeles at the same time as the train and flies back and forth between the two trains until they collide, how far will the bird have traveled?
    1.  Ans: Find the time for the Trains to collide. Say T. Then bird travelled:  25XT
  5. Imagine you are standing in front of a mirror, facing it. Raise your left hand. Raise your right hand. Look at your reflection. When you raise your left hand your reflection raises what appears to be his right hand. But when you tilt your head up, your reflection does too, and does not appear to tilt his/her head down. Why is it that the mirror appears to reverse left and right, but not up and down? 
    1. Ans: Draw a ray diagram to explain lateral inversion
  6. You have a bucket of jelly beans. Some are red, some are blue, and some green. With your eyes closed, pick out 2 of a like color. How many do you have to grab to be sure you have 2 of the same?
    1. Ans : 4  (Ref: Pigeon Hole Problem)
  7. There are four dogs/ants/people at four corners of a square of unit distance. At the same instant all of them start running with unit speed towards the person on their clockwise direction and will always run towards that target. How long does it take for them to meet and where?
    1. Answer : How ? . They will meet in the center and the distance covered by them is independent of the path they actually take (a spiral). 

Bitwise

Give a very good method to count the number of ones in a "n" (e.g. 32) bit number.

String manipulations



  1. Reverse a Character array in place in Order of n.

Complexity Of Algos



Algorithm questions


  1. Nth largest number in an array (Selection sort descending O(n^2)): Better method. Find the pivot and look at it's position. Details: Learn QuickSort (Complexity: O(n))
  2. Nth smallest number in an array (Selection sort ascending) Same as above
  3. How would you validate an XML document without using any APIs
  4. given two string arrays find if they contain same strings i.e {"a","b","ab"} and {"ab","ab","a","b"} are same but {"a","b"} and {"ab"} are different
  5. Design a  data structure that has order(1) time complexity for insert, update,delete, ispresent(key) operations
  6. Implement Find and Delete for binary tree.
  7. Given two sorted postive integer arrays A(n) and B(n) (W.L.O.G, let's say they are decreasingly sorted), we define a set S = {(a,b) | a \in A and b \in B}. Obviously there are n^2 elements in S. The value of such a pair is defined as Val(a,b) = a + b. Now we want to get the n pairs from S with largest values.

Wednesday, June 27, 2007

Requirement Specs

Adv Doc Mgmt

What it means?

A content management solution. Document is an entity by itself. Each is a wrapper over a attachments (file/folder). A document can have revisioning/versioning. Document would belong to Doc Categories. Each category is associated with a lifecycle that controls what phases the document goes through.
A document can have attachments. The attachment framework should allow upload(multiple).

Apart from this, each functionality/feature should be exposed as a service.

TechStack

usage of the latest technogies.
EJB 3.0, TopLink
JSF
WS/BPEL


Feature Priority
Description
Comments
1. Document Search
Must Have
Able to search documents fast. Support attributes based searching. But mostly this would be a simple search.

2. Document Detail
Must Have
Document Detail should typically be a single page, multiple feature functionality. As opposed to the was OA pages shape up, I feel we should try and incorporate as many features with as few clicks as possible

3. Create Document
Must have
Again a single page transaction would be ideal. Whether it can be done is to be seen.

4. Security
Must Have
Role based security. Entity types should be user or group. Roles can be given to user/group. Also, access is based on privileges which can be directly given to user/grp/role

5. Attachment
Must Have
Each Document incorporates Attachments. Attachments fwk should be able to use any third party client which could be over a WS or WebDAV. WebServices vendors should support versioning and other advanced content mgmt framework

6. Relationships
Nice to have
May not be implemented. I think we need increase the scope.

7. Document Categories
Must Have


8. Document lifecycle
Must Have


9. Bulk load document
Must have





Document Search
A simple search searching for keywords. We may need to to restrict the search to doc names etc. Attribute based search is a consideration.

UI
Should be a simple text box. Search could be embedded in all other pages

Document Detail

UI
A single page with all the information regarding the document such as
lifecycle phase
revision/version
attached files

Search would be embedded here.

Edit button should start edit inplace instead of moving to a different page

Create Document
Single page with all necessary info fed by the user

UI