Citrix written test

1. What is the output of this statement ? Printf(³%d´,printf(³%d %d´,2,2) &printf(³%d %d ´, 2, 2)); a. 22222 b. 22221 c. It will give an error during compilation 2. What is the output of this code snippet

main() { int *p[10]; printf("%d %d\n",sizeof(*p),sizeof(p)); }

3. Function inlining is best used when a. In a small recursive function b. In large function where number of variables used is small c. In a large function where there are many loops and number of variables used is small d. None of these 4. If there is a large quantum in round robin it will be equivalent to a. First come first serve b. Shortest job first c. Least recently used d. None of these 5 .which of the following will lead to starvation a. Fifo b. Shortest job first c. Round robin d. Least recently used 6 . if the address space is which of the following is the broadcast ip a. b. c. d. 7. if there are 9 yellow balls, 3 red balls and 2 green balls. What is the probability that the second ball picked is yellow given the first ball is yellow a. 8/13 b. 9/13 c. 8/14 d. 9/14 8. How many processes are created in this snippet? Main()

{ Fork(); Fork() && fork () || fork (); Fork (); } a. 15 b. 19 c. 21 d. 27 e. 31 9. which of the following is TRUE about the declaration const char * p a. the pointer cannot be changed but the value to which it points can be changed b. the value is constant but the pointer can be changed c. neither the value nor the pointer can be changed d. none of these 10. If F and L are the pointers to the first and last elements in a linked list, then which of the following operations is dependent on the length of the list? a. delete the first element in the list b. insert a new element as a first element c. delete the last element of the list d. add a new element at the end of the list

1. What is the Space complexity of quick sort algorithm? how do find it? Solution: Quicksort has a space complexity of O(logn), even in the worst case, when it is carefully implemented such that * in-place partitioning is used. This requires O(1). * After partitioning, the partition with the fewest elements is (recursively) sorted first, requiring at most O(logn) space. Then the other partition is sorted using tail-recursion or iteration. The version of quicksort with in-place partitioning uses only constant additional space before making any recursive call. However, if it has made O(logn) nested recursive calls, it needs to store a constant amount of information from each of them. Since the best case makes at most O(logn) nested recursive calls, it uses O(logn) space. The worst case makes O(n) nested recursive calls, and so needs O(n) space. However, if we consider sorting arbitrarily large lists, we have to keep in mind that our variables like left and right can no longer be considered to occupy constant space; it takes O(logn) bits to index into a list of n items. Because we have variables like this in every stack frame, in reality quicksort requires O(log2n) bits of space in the best and average case and O(nlogn) space in the worst case. This isn't too terrible, though, since if the list contains mostly distinct elements, the list itself will also occupy O(nlogn) bits of space.


What are dangling pointers?

but once it moves out of board. 3.Hence the no of solutions is no of ways to reach N-2th step and then directly taking a 2 jump step to N + no of ways to reach N-1th step and then taking 1 step advance. So find the total number of ways of reaching Nth step.which is a fibonacci sequence.Remember N-2 -> N-1 -> N is not a direct path from N-2th state to Nth state. Nth state can be arrived directly by taking 2 step movement from N-2 or 1 step from N1.Let S be the sum of the elements of the array. 5. . but are likely to fail on large or complex inputs.Classify it as true for HT and false for TH. Google Interview Round 2 :: 1. Now you have 1 to N-2 numbers. a horse starts from a point( say location x.Now putting this other way around we get K=N*(N+1)/2 -S !! Now the second part of the question says that there are 2 of the first N numbers missing. and two numbers missing. Programs that create dangling pointers often appear to work on small inputs.hence unbiased. On a empty chessboard. You are given biased coin. Solution:The simple recurrence relation governing this problem is f(N)=f(N-1) +f(N2)(why?). and one number is missing. 4.K. Sum of first N natural numbers=N*(N+1)/2 and S=N*(N+1)/2 . So what is the total probability that it stays within the board after N steps.Let they be X and Y.Solution: A dangling pointer is a pointer to storage that is no longer allocated.Given an array of size N-1 containing numbers less than N and with out any duplicates!! We knew that there is a number missing from the array say K . You have 1 to N-1 array and 1 to N numbers. Find them. which makes them hard to find. Dangling pointers are nasty bugs because they seldom crash the program until long after they have been created. you need to find the missing the number. Find unbiased decision out of it? Solution:Throw the biased coin twice.Both of these occur with probability=p*(1-p).y) and it starts moving randomly. Solution: The question can be elucidated as follows. Given that you can take one step or two steps forward from a given step. it cant come inside. Ignore the other 2 events namely HH and TT.

Now iterate the slow pointer to count the no of nodes in the cycle. They are X+Y=N*(N+1)/2 -S---------->(1) X*Y=N!/P-------------------(2) where S and P are the cumulative sum and product of the array entries.Hence solve for K and then having figured out the start node N2 of the cycle. 2.Now use one of these pointers to reverse the cycle starting from N1. Now coming to the identification of the node at which looping took place. You have cycle in linked list. Also find the node at which looping takes place. Rather than processing each element of the input by comparing it against the current minimum and maximum. we process elements in pairs.This is a O(N) solution.Let the no of nodes from head to the start node of the cycle be Z Now X+Y=2*Z+K . Solution: only 3n/2 comparisons are necessary to find both the minimum and the maximum. How do you build address bar in say gmail. Google Interview Round 3 :: 1.Now as the cycle is reversed having figured out this start node its next node is the looping nodes so set the looping nodes next pointer to NULL and reverse the list further till you reach N2. 5. if you press 'r' then you get all email starting from 'r'. and if you press 'ra' then you will get emails starting from 'ra'. Solution: The problem of checking whether there is a cycle or not can be solved using 2 pointers one moving in increments of 1 and the other in increments of 2. however.both the pointers P1 and P2 are at node N1.Let this size be K. we maintain the minimum and maximum elements seen thus far.Only the cycle gets reversed. i.Now again traverse from head node to N1. You have given an array.Now take one of the pointers to the head node and count the no of nodes till N1. Find the maximum and minimum numbers in less number of comparisons.If there is a cycle then these 2 pointers meet at some node say N1 inside the cycle otherwise the fast pointer reaches the end of the list.e. 3. To do this. Find it. at a cost of two comparisons per element. How do you search for a word in a large database.We solve this problem by solving 2 essential equations.Let this number be X. Prove that time complexity is linear.Let the number of nodes this time be Y. Questions on my project please be prepare well about your project 4.After our identification of cycle . We compare pairs of elements from the .(After traversing the whole cycle P1 and P2 shall again be at the same node).

B.C) { i=j=k=0.C are given to you.B.Finally all those entries i. Three strings say A. and then compare the smaller to the current minimum and the larger to the current maximum. For each A[i]. Google Interview Round 4 :: 1. Check the sign of A[A[i]].size()). } else return false } return (i == A.size() && j == B. Solution: bool test(A. while(k <C. Report a repetition if it's negative. Make A[A[i]] negative if it's positive.k++. at a cost of three comparisons for every two elements. Check weather 3rd string is interleaved from string A and B. 2.size() && C[k]==B[j]) { j++. .k++. Solution:All the numbers are positive to start with. Given two sorted arrays A and B. Find the algo with running time O(n). } else if(j <B.input first with each other.Now. You have given an array from 1 to N and numbers also from 1 to N.for which A[i] is negative are present and those i for which A[i] is positive are absent. essentially throwing one in to a dilemma whether to accept the character from A or B. answer is yes. 2.size() && C[k]==A[i]) {i++. But more than one number is missing and some numbers have repeated more than once.size()) { if(i <A. } The above algorithm doesn't work when C[k]=A[i]=B[j]. Ex: A="abcd" B="xyz" C="axybczd".

Prepare well to answer any type of questions that may arise in your project. Solution:The intersection can be found by using a variation of merge routine of the merge sort. 2. 2. It works in O(n^2). n points are given i. Now given these n points. the input is (x1.i<n.. for(i=1. 3.They will just ask to explain about any one of the projects listed in your resume. unreliability. UDP.i++) { if( a[i]<min ) { . Find the intersection of these arrays A and B.1.we can run a binary search routine on the larger one to know its presence. which products are you going to work on? What is TCP. 1. (x2. Write the code for finding the min of n number.i<n.e.. (xn.eq(i) } } Given that n numbers are from random sampling how many times (probability) does the line (i) be executed Solution: min=a[0]. give examples of these? Asked about my project. 2. Solution: The duality algorithm would work. Google Interview Round 5 :: 1. I gave: for(i=0. Find the point of intersection with maximum no of lines incident on it in the dual plane.yn). If you get into Google.y2).what is reliability. If array A is small and array B is too large. In a plane. how will you proceed for getting intersection of those two arrays? Solution:In this case for each entry of smaller array.Find the maximum number of collinear points.y1).i++) { if( a[i]<min ) { min = a[i] ---.

org/wiki/Bottom-up_parsing http://en. Google Interview Round 2: 1. It attempts to build trees upward toward the start symbol. It occurs in the analysis of both natural languages and computer languages. So the expected number of occurances of equation i is (n-1)/2 .the probability of a[i] < min is 1/2. where each identifier in a program's source code is associated with information relating to its declaration or appearance in the source.wikipedia. .min = a[i] 2. Please refer to these links for much better information. It occurs in the analysis of both natural languages and computer languages. and then to infer higher-order structures from them. -------eq(i) } } Once the variable min is initialized. Check out http://en. scope level and sometimes its location. Top-down parsing is a strategy of analyzing unknown data relationships by hypothesizing general parse tree structures and then considering whether the known fundamental structures are compatible with the hypothesis. such as its type. a symbol table is a data structure used by a language translator such as a compiler or interpreter. What is a symbol table? Solution: In computer science. What is Bottom up parsing and what is top down parsing? Solution: Bottom-up parsing is a strategy for analyzing unknown data relationships that attempts to identify the most fundamental units first.wikipedia.

we know that one of the three balls moved from Side A to Side B is the odd ball. and that one of the sides. Solution: Every row has a primary key.hance the defective. We proceed with the third weighing and determine the heavier one . We also know that the group of 2 unweighed balls are normal. then the defective is among the 2 remaining balls and can be determined using 2 weighings making it a total of 3.3. is heavier than the other (although we don't know whether the odd ball is heavy or light). If you store all the 2 billion users in a conventional databases it will take more time to retrieve the data about a particular user when that user tries to login. We also know that the unmoved ball from Side A is heavier than the unmoved ball on Side B (though we don't know whether the odd ball is heavy or light). It could be either heavier of lighter. Case A: If.the defective. There is a portal with two billion users registered. Step 2 : Take 2 balls from the unweighed group and use them to replace 2 balls on Side A (the heavy side). If the scale tilts to the other side. We can proceed with the third weighing amd determine the lighter of the 2 balls . Case B: Step1: If. How do you handle this situation to make sure that the user gets the response quickly.Similarly if we have a registration number as the primary key then we can sort the table based on registration number and then do indexing either secondary level or multilevel or apply hashing techniques based on the distribution of data. we know that the ball is also light. Suppose the primary key for this particular database is the name of the user then we can sort the names based on alphabets and do secondary indexing based on the starting alphabet . on the first weighing. the balls don't balance. . 4. If the scale remains the same. we know that the odd ball is one of the 6 balls that was weighed. on the first weighing. Given a common balance how do you find the defective ball in least number of weighings. let's say Side A. II. III. Solution: Weigh 3 balls against 3 others. Many efficient algorithms are available for indexing and hashing. the balls balance. I. There are 8 identical balls. If the balls do not balance on the first weighing. and that it is heavy. we know that one of the 2 balls removed from the scale was the odd one. we know that one of the two balls on the scale that was not shifted in our second weighing is the odd ball. If the scale balances. If the data is uniformly distributed we can go for multilevel indexing or hashing. Take the 2 balls from Side A and use them to replace 2 balls on Side B (which are removed from the scale). One of them is defective. In this case. so that Side B is now the heavy side.

it is more important to avoid using a bad data structure than to identify the single best option available. 6. In practice.. skip lists. and balanced/unbalanced binary search trees -. the ball from Side B is the odd one. This simple formula works for finding it floor(n/5)+floor(n/25)+floor(n/125)+.weighted binary search tree with weights in proportion to the frequency of lookups and determining the depth. 5.. . } return count. the ball from Side A is the odd one. can be effective.In the first n natural numbers.We use this simple yet effective information to solve this problem.Step 3 (for Case B): Weigh the ball from Side A against a normal ball. Asked me about all the details of hash table and heaps.As the frequency of look ups for a word is also important..those divisible by 5 are always less than the no of even numbers. and is heavy. k*=5. If the scale does not balance. Write code for finding number of zeros in n! Solution: A zero in n! typically occurs when a multiple of 5 gets multiplied to an even number. Depending on the choosing the right one can be tricky. while(n>=k) { count+=n/k. you would like to manage a dictionary so that you can look up when ever you have doubt. } this count is the number of o's in n!. function zeros(int n) { int count=0. Which data structure would you like to use and why? Solution: Dozens of different data structures have been proposed for implementing dictionaries including hash tables. 7. it is also a decision that can significantly impact performance. If the scale balances.So it all boils down to the power of 5 in the prime factorization of n! .k=5. You have all the English words with you... and is light.

2.] 2. Given a stack and an input string of 1234. Four In A Row.At any point you can do anyone of the follow i. Give an example of one permutation that this data structure cannot generate. Solution: 3124 for a detailed solution please look at question7 of the post Stacks and Queues . For Example: 1234 is input. Write C++ class for the game Connect Four. take the next input symbol and Enque. ii. When ever you pop an element it will be printed (you cannot pop from an empty stack) How many such permutations are possible on an input of size N? Solution: It is Nth catalannumber.4 on to stack and pop all. [Connect Four (also known as Plot Four.Google Interview Round 3 : 1. output will be 4321. First push all 1. and Four In A Line) is a two-player board game in which the players take turns in dropping discs into a seven column grid with the objective of getting four of one's own discs in a line.For a detailed solution look at question5 of Stacks and Queues 3. It means that this data structure can generate 4321.3. you can pop as many as you can.

You have access to a 100-store building. so max of "d" drops. Question 2 was pretty easy right? Now do again the same question but the data structure this time around is a Deque.. Now the question is how many drops you need to make. >= 100 here we need to find out d from the above equation d(d + 1)/2 >= 100 .. You are allowed to break 2 eggs in the process.Both eggs are identical.This prove can be using the principle of strong mathematical induction.You need to figure out the highest floor of a 100-store building an egg can be dropped without breaking. Eggs can be very hard or very fragile means it may break if dropped from the first floor or may not even break if dropped from 100 thfloor..solets drop it from d + 'd-2' + 1 height suppose if it break there then you are left with 'd-2' drops. Classic Egg Puzzle Problem You are given 2 eggs.we need to get the value of d. Solution: Let "d" be the number of drops required to find out the max floor.Some thing like this __________________________________ enque ---><----enquedequeue<---. so first we will drop it from height "d" if it doesn't break at a height "d" then we are left with "d-1" drops.----->dequeue __________________________________ Solution: It is N!. let's say if we drop from height d then if it breaks then we have d-1 floors to check for the second egg .So for this specific input the answer is 120. 5. (1+(d-1))+ (1+(d-2)) + . and so on until that sum is less than 100. it's like a linear search. in equations.Convince yourself by proving that every permutation can be generated by a set of valid operations. Input: 12345 Data Structure: Deque( DoublyQue ) Note: Deque is a data structure into which you can do enque and deque from both sides. Guess why?(no constraints).4.

Now given that the n intervals are overlapping then how do you solve? The interviewer was concentrating more on the complexities (running. The complexity of this problem is log(N) where N is the number of sorted non-overlapping intervals. else if x>a element can be present only in the intervals to its right. else element can be present only in the intervals to its left. Solution: we can extend binary search to intervals.from above d is 14 Google Interview Round 4 : 1. so select the middle interval among them to it's left and repeat the procedure.It will take O(n).b]. memory .then they can be merged in O(N) and then the exact intervals can be resolved later. . so select the middle interval among them to it's right and repeat the procedure.) Solution: If the above intervals are overlapping . Worst case is take all intervals one at a time and see whether the element lies in the interval or not. Given n non overlapping intervals and an element.(Assuming the intervals are sorted) consider interval [a..we can identify one correct interval and then linear search on its left and right neighbourhood to find the other solutions. Find the interval into which this element falls. if (a-x)(b-x) <=0 then x belongs to [a. So please give a solution that will do better than O(n).b].Otherwise . 3. 2.

Write code for Random Sort? Algorithm is explained: Given an input array of size n. Random sort is sampling a new array from the given array and check whether the sampled array is sorted or not. Write test cases for testing it.(nomalice.. Tell me an achievement that you have done in your non academics 2. If the total number of digits printed is 1095 then how many pages does the book have? Solution: Well people. Now the printing of page numbers is being done separately. If sorted return else sample again.too simple). By taking one of your project as example tell me how you have taken care of software engineering where you would have handled more data 5. Tell me about one of your project 3.4. Google Interview Round 5: This is Manager Round 1.this is too simple a question .so do give it a try. Take a feature of C++ and tell me how you have implemented it in one of your project 4. There is a routine already written to find the subtraction of two sets ( set A .Tell me how do you test the test cases you have written? 6.Any queries then do shoot a comment. The page numbers are not printed.set B) . There is a printed book. .. The stress was on the code.

how many buildings are there in Seattle. 4. 3. if the function's local is lower. the stack grows away from address location 0. or data. Call another function with a local. Minime jumps as high as me. Solution:A database is like a file cabinet. The blades will start moving in 60 seconds. Do you just make a random guess or try to cop out by saying a lot. Potential energy is given by E = mgh. How much should you charge to wash all the windows in Seattle? Solution:As crazy as it might sound.We are providing solutions to the Crazy Questions at Google Job Interview post ByThiomir 1. What do you do? Solution:You simply jump out. How many golf balls can fit in a school bus? Solution: The point of the question isn't to see how golf balls you think are in the bus. This is the reason why grass-hoppers can jump about as high as people. 5. then h is unchanged. Explain a database in three sentences to your eight-year-old nephew. 6. How many times a day does a clock¶s hands overlap? Solution:The Hour hand and Minute hand would be meeting exactly 11 times in 12 hours (Hour . Most of the time you can ask them questions like . You are shrunk to the height of a nickel and your mass is proportionally reduced so as to maintain your original density. the ratio of muscle mass to total mass remains the same. questions like these demonstrate your ability to think through a complex problem with little or no information. if E/m is unchanged (where E is the energy expended in expanding your leg muscles. If the function's local is higher. 2. but to see what your deduction skills are like. or do you actually try to come up with a legitimate answer by going through a logical series of steps. and m is your mass). The files. But unlike an actual file cabinet. You are then thrown into an empty glass blender. As you are scaled down. Look at the address of that function and then compare. is stored in it and can be arranged in categories. the stack grows towards address location 0. How would you find out if a machine¶s stack grows up or down in memory? Solution:Instantiate a local variable. So. you can do a lot more cool stuff with a database like being able to make it accessible through the internet. They expect you to take an educated guess.

Determine the amount of time you have to go from point A to point B.7 degree. (0:0:0 and 12:0:0). Also we all know when we get our watches repaired. collect data. so 12 . 6th.7 degree subtracting 360 degree from it we get . angle of hour hand = 3927 * 6/(60*12) = 32. then the rest two overlaps 22 times in 24 hours. first thing that comes to my mind is that. if we check the angles by which the hour hand and minute hand moves.27 sec. there is fraction in the seconds. During that time. nowlets calculate the angles: 1 hour 5 mins and 27 seconds = 3600 + 5*60 + 27 = 3927 seconds. for our first rendezvous time. If we are considering that the second hand is not present. You have to get from point A to point B. 8th. 01:05:27.hand would have taken 1 clockwise round and Minute hand would have taken 12 clockwise rounds.8 so obviously they dont meet at 01:05:28 either. Then you proceed on implementing your plan with predetermined intervals of reassessment and strategy improvements. 4th. 9th and 10th overlap of hour and minute hand the Second hand wont be any nearby. Similarly for 2nd. normally the repairman overlaps all the three hands to 12. So the answer is 2 only. i. 7. There again is a catch. At the end of the initial 360° search take an objective look at all the information you have obtained and you calculate the risk of failure you are willing to live with. Create a plan and a strategy based on your assessment of where you believe point B to be. clues. and the hour hand will move 6/(60*12) degrees.73333 minute hand .1 = 11 rounds). So they overlap at 12:00 and 24:00 only. if we check the positions of the hour and minute hand in terms of angle from the marker 12. 3rd. .e.32. Spend the initial 20% of that time making a 360° search with the largest circumference possible with the in the time you have allowed. angle of minute hand = 3927 * 6/60 = 392.32. Let¶s break this down farther. So that time can¶t be measured. now taking these things in the considerations. result: First time hour and minute hands overlap will be 12 Hours / 11 = 01:05:27. look for maps. So at this time only hour and minute hands would be overlapping and second hand will not be any near to them.e. So at 01:05:27 both hands don¶t overlap. Now for 01:05:28 : Angles : hour hand . minute and Second) overlap only 2 times i. The second hand moves 6 degree in a second. ask people. 7th.725 degree.27. What would you do? Solution:Utilizing a ³learn as you go´ approach and applying collected knowledge and data along the way is the best way to proceed. there will be no exact overlap. In that time the minute hand will move 6/60 degrees. So all 3 hands (hour. and knowledge.32. You don¶t know if you can get there. 5th.

thats all. Next morning every wife will know there is no cheat husbands anymore.4. The village has a law that does not allow for adultery.. i. every family continues to have children until they have a boy. they have another child. and fully button. On the left you put all the short sleeve shirts. buttons (no buttons. if they have a boy. In a country in which people only want boys.So the ratio is 2:1 . So what can you do to organize your shirts for easy retrieval? Solution:Let¶s suppose there are a set of attributes of each shirt you are interested in: e. One day. and on the right the long sleeve shorts. if there were 2 cheat husbands then their wives knew the count is 1 and others knew its 2. Let¶s say the closet is a simple wall closet with a single closet rod running the entire length of closet. sleeve length. It¶s very hard to find a shirt. 2. partially buttoned. violet.In this case.e. The women of the village would never disobey this law. 8. So in this case no wife kills her husband. There is only one cheat husband . partially buttoned from collar to chest level). Any wife who can prove that her husband is unfaithful must kill him that very day. fully button. Its just that the cheated wives knew the count which is one less than what the non-cheated wives' knew . Imagine you have a closet full of shirts. What happens? Solution:1. orange. green. So the cheated wife got the idea from queen that her husband is cheating. and shades of grey in the middle. There are more than one cheat husbands .If it is so then 99 wives knew it before. they stop. Then each sub group is separated into colored and monochrome sub-sub-groups (specially marked hangers aren¶t needed for separators unless you are color blind) Then each colored group is sorted left to right according to the color spectrum: ROYGBIV: red. Then you separate each group into no buttonoed. blue. if they have a girl. the darker greys on the right. yellow. 9.3. using more specially marked hangers. So she will kill him. Every man in a village of 100 married couples has cheated on his wife. the queen of the village visits and announces that at least one husband has been unfaithful. but does not know when her own husband has. what is the proportion of boys to girls in the country? Solution:From pure probability.100 cheat husbands. You separate then long and short sleeve sides with a specially marked coat hanger.g.This is the best chance you have reaching point B if you don¶t know if you can get there. 10. indigo. color. Same goes to 2. black on the right. So the queen just repeated the info saying "at least 1".we get the expected number of girls born to be 1/2 with that of boys being 1. the lighter on the left.. Every wife in the village instantly knows when a man other than her husband has cheated. Each monochrome ggroup is sorted left to right: white on the left. all of the wives already had the idea prior to queen's information.

2 goes back. the first minute you have 10% chance. your friend makes you a wager that for every person you find that has the same birthday as you..5 degrees (the hour hand is 1/4th of the way between 3 and 4. Unfortunately. the second minute you have 10% of 90% = 9% (so total 19%). As the chance for 30 minutes is 95 percent. How do the campers make it across in 17 minutes? Solution:1 and 2 cross. One can cross the bridge in 1 minute. he gets $2. taking 10 minutes totaltime now= 13 minutes.. 2) Then look into their purchase records and find out the piano purchasers information. total 27. what is the angle between the hour and the minute hands? (The answer to this is not zero!) Solution:7. 15. 3) i) If the purchase is made by an individual or a house hold then the piano is played at best case by all the people of the house.95.. and the slow poke takes 10 minutes to cross.. 1 and 2 cross again. How many piano tuners are there in the entire world? Solution:1) At first list out all the piano manufacturing companies in the time now = 15 minutes. iii) If the piano is purchased by a Church then count the no of major or minor events of the church . taking 2 minutes making it 17 minutes. ii) Else if the piano is purchased for school then list out the students that opted the piano course in their music curriculum. 14. You are at a party with a friend and 10 people are present including you and the friend. what is the probability of observing a car in 10 minutes (assuming constant default probability)? Solution:If the chance to see the car is 10 percent per minute. for every person he finds that does not have the same birthday as you.1 %) . 12. taking 2 minutes. The bridge is too dangerous to cross without a flashlight. the third minute 10% of 81% (= 8. 13. and it s only strong enough to support two people at any given time. If the probability of observing a car in 30 minutes on a highway is 0.11. 1 goes back carrying the flashlight total=3 minutes. another in 2 minutes.5% and for 10 minute 63. would you accept the wager? Solution:No. Four people need to cross a rickety rope bridge to get back to their camp at night.1%. Each of the campers walks at a different speed. the chance for 1 minute is 9. 5 and 10 cross. the angle measure of that is 360/12 = 30 degrees between hours / 4 = 7. you get $1. If you look at a clock and the time is 3:15.5 degrees).1 %. they only have one flashlight and it only has enough light left for seventeen minutes. the third in 5 minutes.

greens together and blue together. there are 3 men and 3 lions on one side that need to be taken across using a boat that can carry 2 entities at a time(irrespective of being a lion and man). and one of them weighs slightly more.) Solution:The highest ranked pirate gets 98 gold coins ---Two pirates get 1 gold coin each ---The other 2 pirates get nothing. and if fewer than half agree with him. 3)Find the minimum and maximum element in an array in least possible number of comparisons? 4)A river separates two banks. find the groups of anagrams in it. 16.and count the piano users. The top pirate has the right to propose how 100 gold coins should be divided among them. Do not restrict solution to ASCII characters. Then code it to make it a generic program that solves the puzzle for X men and Y lions. he gets killed. .g. you could have unigram codes as well. Code the function and write the test cases. the remaining ball is the heavier one.if they weigh the same. 17. from the group of 3 which was heavier. as then the lions would eat the man/men. otherwise you just found the heavier one by weighing the 2 chosen balls. 7 of them weigh the same. subject to the condition that at no point can you have more number of lions than men on any bank.if they weigh the same. ranked from 5 to 1 in descending order. e. you have another weighing for the remaining 2 balls and you can find the heavier one . You have eight balls all of the same size. choose any 2 balls and weigh them: . Write a perfect code for the same to return a node pointer. 5)Given an array of red. sum up all the numbers to get more or less accurate piano users count. green and blue balls arrange them in groups of all red together. How can you find the ball that is heavier by using a balance and only two weighings? Solution:choose 6 balls and weigh 3 against 3 .if they don¶t weigh the same. (satin& stain). 1) Given an parentheses tree as a string form the tree again. But the others get to vote on his plan. How should he allocate the gold in order to maximize his share but live to enjoy it? (Hint: One pirate ends up with 98 percent of the gold. Solve the puzzle. (1(2(3)(4))()) Output 1 ----2 null ----34 2) Given a very long list of words. You have five pirates. Do in a single scan of the array.

You are given a function that gets the frequency of a given query. Strategy Pattern 7. at any instant get the top twenty queries that are hitting the server. 5. A queue (FILO) and a stack (FIFO) can be made from each other. 8)Find the first non-zero digit from the right in 100! (Factorial of hundred). What size of array should be sufficient to solve the above problem. delete. getmin/max and their orders) 10)Millions of queries hit a server.6)Merge two linked lists without using extra memory. fourth. eighth and tenth word in the file. Hi. Refactoring 6. By perfection it is meant. Write a code for the same. When in doubt use hash tables 4. shippable and with exception handling. where ³hello´ occurs as the first. insert. Can an int store hundred factorial. 7)Given three strings A=³hello´ B=³bye´ C=³welcome´ and the occurrences of each of them in a file as occur_A=[1 4 8 10] similarly for B and C. Strong and weak references . 9)Discussion on heaps(all functions. makeheap. Sort Algorithms 2. Here are ten things you can brush up on that *might* help 1. The big O (efficiency) 3. find the smalled snippet of words that contains all the three. Write a perfect code for the same.

Collections 10. Boiler plate code .8. Lazy loading 9.