Showing posts with label interview questions. Show all posts
Showing posts with label interview questions. Show all posts
Saturday, March 10, 2012
Java Spring and Hibernate Interview Questions
Tags : hibernate interview questions, interview questions, spring and hibernate interview questions, spring interview questions, Studies
Wednesday, September 14, 2011
Yahoo Interview
1) There is a n x n grid of 1's and 0's. Find the i , where i is the row
containing all 1's and all 0's(except the intersection point). Should do
it in less than 25 comparisons
..
2) Use 2 stacks to implement a queue. Followed up with making the
access to the Data structure concurrently.
3) C++ question was good, implement a c++ class such that it allows us
to add data members at runtime.
4)Implement a transaction manager in a database server. The discussion
involved a lot of stuff about transaction logs.
5) How do you tune an application. Creating indexes.
6) Some SQL performance tuning questions on creating indexes.
7) can you write a foo() in c? If so how can u do it?
8) vector implementation questions.
9) Almost everyone asked about my language.(except ppl who attended my talk).
containing all 1's and all 0's(except the intersection point). Should do
it in less than 25 comparisons
..
2) Use 2 stacks to implement a queue. Followed up with making the
access to the Data structure concurrently.
3) C++ question was good, implement a c++ class such that it allows us
to add data members at runtime.
4)Implement a transaction manager in a database server. The discussion
involved a lot of stuff about transaction logs.
5) How do you tune an application. Creating indexes.
6) Some SQL performance tuning questions on creating indexes.
7) can you write a foo() in c? If so how can u do it?
8) vector implementation questions.
9) Almost everyone asked about my language.(except ppl who attended my talk).
Yahoo Interview Questions
Yahoo Telephonic Round:
Design classes for the following problem. (C++)
A Customer Can have multiple bank accounts A Bank account can be owned by multiple customers When customer logs in he sees list of account, on clicking on an account he sees list of transactions.
Solution :
Customer class, Account class, Transaction class
Customer class contains an array of pointers to the account classes
Account class contains an array of pointers to its owner customer classes
Account class also contains an array of transactions associated to it.
Transaction class contains id or pointer the customer who did that transaction
In customer class write a function with prototype
for (i in Accounts ) { cout << i.AccountName << endl; } cin >> id; for(i in Accounts[id].transactions ) { cout << i.TransDetails << endl; }
Yahoo Interview Round 1:
- How to call a C++ function which is compiled with C++ compiler in C code?
Solution: The C++ compiler must know that f(int,char,float) is to be called by a C compiler using the extern "C"construct:
The extern "C" line tells the compiler that the external information sent to the linker should use C calling conventions and name mangling (e.g., preceded by a single underscore). Since name overloading isn't supported by C, you can't make several overloaded functions simultaneously callable by a C program.
// This is C++ code // Declare f(int,char,float) using extern "C": extern "C" void f(int i, char c, float x); ... // Define f(int,char,float) in some C++ module: void f(int i, char c, float x) { ..... }
- When you deliver your C++ headers and C++ library of a class (what all can you change in the class so that application using your class does not need to recompile the code)
- How do you initialize a static member of a class with return value of some function?
Solution :
Static data members are shared by all object instances of that class. Each class instance sees and has access to the same static data. The static data is not part of the class object but is made available by the compiler whenever an object of that class comes into scope. Static data members, therefore, behave as global variables for a class. One of the trickiest ramifications of using a static data member in a class is that it must be initialized, just once, outside the class definition, in the source file. This is due to the fact a header file is typically seen multiple times by the compiler. If the compiler encountered the initialization of a variable multiple times it would be very difficult to ensure that variables were properly initialized. Hence, exactly one initialization of a static is allowed in the entire program.
Consider the following class, A, with a static data member, _id:
//File: a.h class A { public: A(); int _id; };
The initialization of a static member is done similarly to the way global variables are initialized at file scope, except that the class scope operator must be used. Typically, the definition is placed at the top of the class source file:
// File: a.cc int A::_id;
Because no explicit initial value was specified, the compiler will implicitly initialize _id to zero. An explicit initialization can also be specified:
// File: a.cc int A::_id = 999;
In fact, C++ even allows arbitrary expressions to be used in initializers:
// File: a.cc int A::_id = GetId();
- How can one application use same API provided by different vendors at the same time?
- If you are given the name of the function at run time how will you invoke the function?
Solution :
- Compile your program with --export-dynamic on the gcc command line
- Link with -ldl (dynamic library handling, needed for dlopen and dlsym
- Call dlopen() with a null parameter, meaning you aren't loading symbols from a file but from the current executable
- Call dlsym() with the name of the function you'll be calling. Note that C++ modifies function names, so If you're trying this with C++, you'd have to either declare this function as extern "C", or figure out what name the function has after compiling. (On unix, you could run nm -s on the object file for this).
- If dlsym() returns non-null, use the returned value as a function pointer to invoke your function.
- When will you use shell script/Perl ahead of C/C++?
- How does yahoo handles billions of requests, does it create a thread per request or a process?
- How does HTTP works?
Solution :HTTP Is a request-response protocol.
For example, a Web browser initiates a request to a server, typically by opening a TCP/IP connection. The request itself comprises o a request line, o a set of request headers, and o an entity. The server sends a response that comprises o a status line, o a set of response headers, and o an entity. The entity in the request or response can be thought of simply as the payload, which may be binary data. The other items are readable ASCII characters. When the response has been completed, either the browser or the server may terminate the TCP/IP connection, or the browser can send another request.
- How to count number of unique music titles downloaded from a log file which contains an entry of all music title downloaded?
- What is the difference between COM and CORBA?
Solution :COM is linked to Microsoft and CORBA to UNIX,Moreover, COM objects require installation on the machine from where it is being used .CORBA is ORB (Object request broker) , and also its a specification owned by OMG, which is open. Not owned by a company. So we cannot say that it only belongs to Unix. Corba servers can run on windows NT, and CORBA clients can run on Unix.
- What is web service?
Solution :Web Service is defined as "a software system designed to support interoperable Machine to Machine interaction over a network." Web services are frequently just Web APIs that can be accessed over a network, such as the Internet, and executed on a remote system hosting the requested services.
Saturday, June 18, 2011
Google Placement Paper and Sample Paper
Tags : google interview questions, Google Placement Paper and Sample Paper, interview questions
Google Placement Paper and Sample Paper
1. Solve this cryptic equation, realizing of course that values for M and E could be interchanged. No leading zeros are allowed.WWWDOT - GOOGLE = DOTCOM
This can be solved through systematic application of logic. For example, cannot be equal to 0, since . That would make , but , which is not possible.
Here is a slow brute-force method of solution that takes a few minutes on a relatively fast machine:
This gives the two solutions
777589 - 188106 == 589483
777589 - 188103 == 589486
Here is another solution using Mathematica's Reduce command:
A faster (but slightly more obscure) piece of code is the following:
Faster still using the same approach (and requiring ~300 MB of memory):
Even faster using the same approach (that does not exclude leading zeros in the solution, but that can easily be weeded out at the end):
Here is an independent solution method that uses branch-and-prune techniques:
And the winner for overall fastest:
2. Write a haiku describing possible methods for predicting search traffic seasonality.
MathWorld's search engine
seemed slowed this May. Undergrads
prepping for finals.
3. 1
1 1
2 1
1 2 1 1
1 1 1 2 2 1
What's the next line?
312211. This is the "look and say" sequence in which each term after the first describes the previous term: one 1 (11); two 1s (21); one 2 and one 1 (1211); one 1, one 2, and two 1's (111221); and so on. See the look and say sequence entry on MathWorld for a complete write-up and the algebraic form of a fascinating related quantity known as Conway's constant.
4. You are in a maze of twisty little passages, all alike. There is a dusty laptop here with a weak wireless connection. There are dull, lifeless gnomes strolling around. What dost thou do?
A) Wander aimlessly, bumping into obstacles until you are eaten by a grue.
B) Use the laptop as a digging device to tunnel to the next level.
C) Play MPoRPG until the battery dies along with your hopes.
D) Use the computer to map the nodes of the maze and discover an exit path.
E) Email your resume to Google, tell the lead gnome you quit and find yourself in whole different world [sic].
In general, make a state diagram . However, this method would not work in certain pathological cases such as, say, a fractal maze. For an example of this and commentary, see Ed Pegg's column about state diagrams and mazes .
5. What's broken with Unix?
Their reproductive capabilities.
How would you fix it?
[This exercise is left to the reader.]
6. On your first day at Google, you discover that your cubicle mate wrote the textbook you used as a primary resource in your first year of graduate school. Do you:
A) Fawn obsequiously and ask if you can have an autograph.
B) Sit perfectly still and use only soft keystrokes to avoid disturbing her concentration
C) Leave her daily offerings of granola and English toffee from the food bins.
D) Quote your favorite formula from the textbook and explain how it's now your mantra.
E) Show her how example 17b could have been solved with 34 fewer lines of code.
[This exercise is left to the reader.]
7. Which of the following expresses Google's over-arching philosophy?
A) "I'm feeling lucky"
B) "Don't be evil"
C) "Oh, I already fixed that"
D) "You should never be more than 50 feet from food"
E) All of the above
[This exercise is left to the reader.]
8. How many different ways can you color an icosahedron with one of three colors on each face?
For an asymmetric 20-sided solid, there are possible 3-colorings . For a symmetric 20-sided object, the Polya enumeration theorem can be used to obtain the number of distinct colorings. Here is a concise Mathematica implementation:
What colors would you choose?
[This exercise is left to the reader.]
9. This space left intentionally blank. Please fill it with something that improves upon emptiness.
For nearly 10,000 images of mathematical functions, see The Wolfram Functions Site visualization gallery .
10. On an infinite, two-dimensional, rectangular lattice of 1-ohm resistors, what is the resistance between two nodes that are a knight's move away?
This problem is discussed in J. Cserti's 1999 arXiv preprint . It is also discussed in The Mathematica GuideBook for Symbolics, the forthcoming fourth volume in Michael Trott's GuideBook series, the first two of which were published just last week by Springer-Verlag. The contents for all four GuideBooks, including the two not yet published, are available on the DVD distributed with the first two GuideBooks.
11. It's 2PM on a sunny Sunday afternoon in the Bay Area. You're minutes from the Pacific Ocean, redwood forest hiking trails and world class cultural attractions. What do you do?
[This exercise is left to the reader.]
12. In your opinion, what is the most beautiful math equation ever derived?
There are obviously many candidates. The following list gives ten of the authors' favorites:
1. Archimedes' recurrence formula : , , ,
2. Euler formula :
3. Euler-Mascheroni constant :
4. Riemann hypothesis: and implies
5. Gaussian integral :
6. Ramanujan's prime product formula:
7. Zeta-regularized product :
8. Mandelbrot set recursion:
9. BBP formula :
10. Cauchy integral formula:
An excellent paper discussing the most beautiful equations in physics is Daniel Z. Freedman's " Some beautiful equations of mathematical physics ." Note that the physics view on beauty in equations is less uniform than the mathematical one. To quote the not-necessarily-standard view of theoretical physicist P.A.M. Dirac, "It is more important to have beauty in one's equations than to have them fit experiment."
13. Which of the following is NOT an actual interest group formed by Google employees?
A. Women's basketball
B. Buffy fans
C. Cricketeers
D. Nobel winners
E. Wine club
[This exercise is left to the reader.]
14. What will be the next great improvement in search technology?
Semantic searching of mathematical formulas. See http://functions.wolfram.com/About/ourvision.html for work currently underway at Wolfram Research that will be made available in the near future.
15. What is the optimal size of a project team, above which additional members do not contribute productivity equivalent to the percentage increase in the staff size?
A) 1
B) 3
C) 5
D) 11
E) 24
[This exercise is left to the reader.]
16. Given a triangle ABC, how would you use only a compass and straight edge to find a point P such that triangles ABP, ACP and BCP have equal perimeters? (Assume that ABC is constructed so that a solution does exist.)
This is the isoperimetric point , which is at the center of the larger Soddy circle. It is related to Apollonius' problem . The three tangent circles are easy to construct: The circle around has diameter , which gives the other two circles. A summary of compass and straightedge constructions for the outer Soddy circle can be found in " Apollonius' Problem: A Study of Solutions and Their Connections" by David Gisch and Jason M. Ribando.
17. Consider a function which, for a given whole number n, returns the number of ones required when writing out all numbers between 0 and n. For example, f(13)=6. Notice that f(1)=1. What is the next largest n such that f(n)=n?
The following Mathematica code computes the difference between [the cumulative number of 1s in the positive integers up to n] and [the value of n itself] as n ranges from 1 to 500,000:
The solution to the problem is then the first position greater than the first at which data equals 0:
which are the first few terms of sequence A014778 in the On-Line Encyclopedia of Integer Sequences.
Checking by hand confirms that the numbers from 1 to 199981 contain a total of 199981 1s:
18. What is the coolest hack you've ever written?
While there is no "correct" answer, a nice hack for solving the first problem in the SIAM hundred-dollar, hundred-digit challenge can be achieved by converting the limit into the strongly divergent series:
and then using Mathematica's numerical function SequenceLimit to trivially get the correct answer (to six digits),
You must tweak parameters a bit or write your own sequence limit to get all 10 digits.
[Other hacks are left to the reader.]
19. 'Tis known in refined company, that choosing K things out of N can be done in ways as many as choosing N minus K from N: I pick K, you the remaining.
This simply states the binomial coefficient identity .
Find though a cooler bijection, where you show a knack uncanny, of making your choices contain all K of mine. Oh, for pedantry: let K be no more than half N.
'Tis more problematic to disentangle semantic meaning precise from the this paragraph of verbiage peculiar.
20. What number comes next in the sequence: 10, 9, 60, 90, 70, 66, ?
A) 96
B) 1000000000000000000000000000000000\
0000000000000000000000000000000000\
000000000000000000000000000000000
C) Either of the above
D) None of the above
This can be looked up and found to be sequence A052196 in the On-Line Encyclopedia of Integer Sequences, which gives the largest positive integer whose English name has n letters. For example, the first few terms are ten, nine, sixty, ninety, seventy, sixty-six, ninety-six, …. A more correct sequence might be ten, nine, sixty, googol, seventy, sixty-six, ninety-six, googolplex. And also note, incidentally, that the correct spelling of the mathematical term " googol" differs from the name of the company that made up this aptitude test.
The first few can be computed using the NumberName function in Eric Weisstein's MathWorld packages:
A mathematical solution could also be found by fitting a Lagrange interpolating polynomial to the six known terms and extrapolating:
21. In 29 words or fewer, describe what you would strive to accomplish if you worked at Google Labs.
[This exercise is left to the reader.]
Subscribe to:
Posts (Atom)