<?xml version="1.0" encoding="UTF-8" standalone="no"?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0"><channel><title>Freshers Interviews</title><description>Technical &amp; HR Interview Questions of Google,Microsoft,Yahoo and many more Companies.</description><managingEditor>noreply@blogger.com (chaitanya)</managingEditor><pubDate>Mon, 6 Apr 2026 15:37:29 +0530</pubDate><generator>Blogger http://www.blogger.com</generator><openSearch:totalResults xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">300</openSearch:totalResults><openSearch:startIndex xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">1</openSearch:startIndex><openSearch:itemsPerPage xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">25</openSearch:itemsPerPage><link>http://placementsindia.blogspot.com/</link><language>en-us</language><itunes:explicit>no</itunes:explicit><itunes:image href="http://placementsindia.blogspot.com"/><itunes:summary>Placement Papers of 220+ Companies,Technical Interview,Hr Interview Tips,Group Discussion Topics and answers,How to Prepare a Professional Resume,Get Off campus details and Get Most Commonly Asking Puzzles with solutions.</itunes:summary><itunes:subtitle>Freshers Placements</itunes:subtitle><itunes:owner><itunes:email>kchaitanyya@gmail.com</itunes:email></itunes:owner><item><title>Citrix Written Test Questions-1</title><link>http://placementsindia.blogspot.com/2008/01/citrix-interview-questions-1.html</link><category>Interviews</category><pubDate>Tue, 4 Nov 2008 19:14:00 +0530</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-32064785.post-2962532009321704836</guid><description>1. What is the output of this statement ?&lt;br /&gt;Printf(“%d”,printf(“%d %d”,2,2) &amp; printf(“%d %d ”, 2, 2));&lt;br /&gt;a. 22222 &lt;br /&gt;b. 22221&lt;br /&gt;c. It will give an error during compilation&lt;br /&gt;&lt;br /&gt;2. What is the output of this code snippet&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;main()&lt;br /&gt;{        int *p[10];&lt;br /&gt;         printf("%d %d\n",sizeof(*p),sizeof(p));&lt;br /&gt;         }&lt;br /&gt; &lt;/pre&gt;&lt;br /&gt;3. Function inlining is best used when &lt;br /&gt;a. In a small recursive function &lt;br /&gt;b. In large function where number of variables used is small&lt;br /&gt;c. In a large function where there are many loops and number of variables used is small&lt;br /&gt;d. None of these&lt;br /&gt;&lt;br /&gt;4. If there is a large quantum in round robin it will be equivalent to &lt;br /&gt;a. First come first serve &lt;br /&gt;b. Shortest job first&lt;br /&gt;c. Least recently used&lt;br /&gt;d. None of these&lt;br /&gt;&lt;br /&gt;5 . which of the following will lead to starvation&lt;br /&gt;a. Fifo &lt;br /&gt;b. Shortest job first &lt;br /&gt;c. Round robin&lt;br /&gt;d. Least recently used&lt;br /&gt;&lt;br /&gt;6 . if the address space is 192.168.36.16/28 which of the following  is the broadcast ip&lt;br /&gt;a. 192.168.36.0&lt;br /&gt;b. 192.168.36.1&lt;br /&gt;c. 192.168.36.255&lt;br /&gt;d. 192.168.36.31&lt;br /&gt;&lt;br /&gt;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&lt;br /&gt; a. 8/13&lt;br /&gt; b. 9/13&lt;br /&gt; c. 8/14&lt;br /&gt; d. 9/14&lt;br /&gt;&lt;br /&gt;8.  How many processes are created in this snippet?&lt;br /&gt; Main()&lt;br /&gt; {&lt;br /&gt;  Fork();&lt;br /&gt;  Fork() &amp;&amp; fork () || fork ();&lt;br /&gt;  Fork ();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;a. 15&lt;br /&gt;b.  19 &lt;br /&gt;c.  21&lt;br /&gt;d.  27&lt;br /&gt;e. 31&lt;br /&gt;&lt;br /&gt;9. which of the following is TRUE about the declaration const char * p &lt;br /&gt; a. the pointer cannot be changed but the value to which it points can be changed&lt;br /&gt; b. the value is constant but the pointer can be changed&lt;br /&gt; c. neither the value nor the pointer can be changed&lt;br /&gt; d. none of these&lt;br /&gt;&lt;br /&gt;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?&lt;br /&gt; a. delete the first element in the list&lt;br /&gt; b. insert a new element as a first element&lt;br /&gt; c. delete the last element of the list &lt;br /&gt; d. add a new element at the end of the list</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">267</thr:total><author>kchaitanyya@gmail.com (Unknown)</author></item><item><title>Citrix Written Test Questions-2</title><link>http://placementsindia.blogspot.com/2008/01/citrix-interview-questions-2.html</link><category>Interviews</category><pubDate>Sun, 26 Oct 2008 19:25:00 +0530</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-32064785.post-8312943584704646921</guid><description>11. Find the slope of the line joining the points (0,2) and (3, -2)&lt;br /&gt; a.  -4/3 &lt;br /&gt; b. ¾&lt;br /&gt; c. -3/4&lt;br /&gt; d. 4/3&lt;br /&gt;&lt;br /&gt;12. Solve for x in x^3+3x^2+5x+9=6&lt;br /&gt; a. -1&lt;br /&gt; b. 1&lt;br /&gt; c. -2 &lt;br /&gt; d. -3&lt;br /&gt;&lt;br /&gt;13. 73 to the base x is equivalent to 51 to the base y. which of the following may be the possible values of x and y&lt;br /&gt; a. 10, 12&lt;br /&gt; b. 8, 16&lt;br /&gt; c. 9, 13&lt;br /&gt; d.  8, 12&lt;br /&gt;&lt;br /&gt;14. Which of the following is independent of the operating system and machine architecture&lt;br /&gt; a. linker&lt;br /&gt; b. loader&lt;br /&gt; c. compiler&lt;br /&gt; d. debugger&lt;br /&gt;&lt;br /&gt;15. Which of the following restricts a process to the memory allocated to it&lt;br /&gt; a. stack pointers&lt;br /&gt; b. memory allocation hardware&lt;br /&gt; c. kernel&lt;br /&gt; d. none of these&lt;br /&gt;&lt;br /&gt;16. When a user logs out, what happens to the processes created by him?&lt;br /&gt; a. they’ll be killed&lt;br /&gt; b. aborted&lt;br /&gt; c. hang&lt;br /&gt; d. none of these&lt;br /&gt;&lt;br /&gt;17. What is the output of&lt;br /&gt;Main()&lt;br /&gt;{&lt;br /&gt; Struct node {&lt;br /&gt; Int a;&lt;br /&gt; Int b;&lt;br /&gt; Int c;&lt;br /&gt;};&lt;br /&gt;Struct node a = {2,4,5};&lt;br /&gt;Struct node *st;&lt;br /&gt;St = &amp;a;&lt;br /&gt;Printf(“%d”, *(int *)st);&lt;br /&gt;}&lt;br /&gt;a. 2 &lt;br /&gt;b. 3&lt;br /&gt;c. 7&lt;br /&gt;d. 11&lt;br /&gt;&lt;br /&gt;18. What is the output of &lt;br /&gt;Struct outer{&lt;br /&gt; Struct inner{&lt;br /&gt;  Int a = 10;&lt;br /&gt;}&lt;br /&gt;Int b = 5;&lt;br /&gt;}&lt;br /&gt;Main()&lt;br /&gt;{&lt;br /&gt; Struct inner new;&lt;br /&gt; Printf(“%d”, new.a)&lt;br /&gt;}&lt;br /&gt;a. It will give a compilation error &lt;br /&gt;b. 10&lt;br /&gt;c. 5 &lt;br /&gt;d. 15&lt;br /&gt;&lt;br /&gt;19. Thrashing is solved by &lt;br /&gt; a. increasing cpu bound processes &lt;br /&gt; b. reducing the degree of multi-programming&lt;br /&gt; c. increasing user processes&lt;br /&gt; d. none of these&lt;br /&gt;&lt;br /&gt;20. If t` is the reverse of t then what is the reverse of trs&lt;br /&gt; a. s’r’t’&lt;br /&gt; b. srt&lt;br /&gt; c. t’r’s’&lt;br /&gt; d. t’rs’</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">6</thr:total><author>kchaitanyya@gmail.com (Unknown)</author></item><item><title>Cisco Interview Questions</title><link>http://placementsindia.blogspot.com/2008/01/cisco-interview-questions.html</link><category>Cisco</category><category>Interviews</category><pubDate>Tue, 21 Oct 2008 13:24:00 +0530</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-32064785.post-6610604862444347795</guid><description>1)Explain an algorithm for path planning in a given map.&lt;br /&gt;&lt;br /&gt;2)Write a code to find the shortest path in a given graph.&lt;br /&gt;&lt;br /&gt;3)Write a code for minimal spanning tree &lt;br /&gt;&lt;br /&gt;4)How do you find existence of a cycle in the given graph.&lt;br /&gt;&lt;br /&gt;5)Explain OSI model. &lt;br /&gt;&lt;br /&gt;6)How do you find out the sizeof an object in Java.&lt;br /&gt;&lt;br /&gt;7)Given a byte, write a code to swap every two bits. [Using bit operators] Eg: Input: 10 01 11 01 Output: 01 10 11 10&lt;br /&gt;&lt;br /&gt;8)Write a Shell code which takes in as input several files and replaces each occurance of word “Nishant” with word “reddy”.&lt;br /&gt;&lt;br /&gt;9)What is VPN ?&lt;br /&gt;&lt;br /&gt;10)What are TCP/IP protocol , Routing algorithms , P2P file sharing , Routing protocols.&lt;br /&gt;&lt;br /&gt;11)Implement the above protocols in C.</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">5</thr:total><author>kchaitanyya@gmail.com (Unknown)</author></item><item><title>Cisco HR Interview Questions</title><link>http://placementsindia.blogspot.com/2008/01/cisco-hr-interview-questions.html</link><category>Cisco</category><category>HR Interviews</category><pubDate>Thu, 16 Oct 2008 13:30:00 +0530</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-32064785.post-7232110612856292734</guid><description>1)What are the names of your technical round interviewers &lt;br /&gt;&lt;br /&gt;2)Do you know my name ?&lt;br /&gt;&lt;br /&gt;3)Tell me about yourself, your family background... so on..&lt;br /&gt;&lt;br /&gt;4)What are you looking for in Cisco” or what attracts you or why do you want to join cisco. &lt;br /&gt;&lt;br /&gt;5)Tell me a situation/ issue where you identified a problem on your own, and drove to resolve it. &lt;br /&gt;&lt;br /&gt;6)Tell about most difficult team project u have worked on. &lt;br /&gt;&lt;br /&gt;7)What type of work environment is suitable and which environment you hate/is frustrating?&lt;br /&gt;&lt;br /&gt;8)Tell about the mistake you learned from&lt;br /&gt;&lt;br /&gt;9)Tell about accomplishment you are proud of...&lt;br /&gt;&lt;br /&gt;10)what have you learnt in 4 years of your BTech.&lt;br /&gt;&lt;br /&gt;11)Give an example of biggest/most demanding team leading or you have talked about some thing to a group like given a presentation or seminar etc..&lt;br /&gt;&lt;br /&gt;12)Describe a situation where you and your partner/professor had a conflicting view, but you were still able to get across your point or how did u get around obstacles that prevented you from completing the task/project.&lt;br /&gt;&lt;br /&gt;13)Tell a situation in which you took the lead without being asked to do so and why? or you saw some opportunity which came suddenly and how did u react? or you found some your results or your work which were not up to the mark, what did u do to rectify? or done more than what was required? or situations in which you found the job could be done much easier and others weren’t following it..? or did some job which doesnt come under your job role/description but was beneficial?&lt;br /&gt;&lt;br /&gt;14)Tell me about your values in your life.&lt;br /&gt;&lt;br /&gt;15)Tell us what do you know about our company.&lt;br /&gt;&lt;br /&gt;16)Tell me some of your strengths and weaknesses.. &lt;br /&gt;&lt;br /&gt;17)Interested in doing MS ?</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">13</thr:total><author>kchaitanyya@gmail.com (Unknown)</author></item><item><title>CapitalIQ Interview questions</title><link>http://placementsindia.blogspot.com/2008/01/capitaliq-interview-questions.html</link><category>Interviews</category><pubDate>Sun, 12 Oct 2008 18:33:00 +0530</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-32064785.post-1424483313383953392</guid><description>1. How are databases stored internally ?&lt;br /&gt;&lt;br /&gt;2. Can you think of any improvements to the storage of databases&lt;br /&gt;&lt;br /&gt;3. What is indexing in databases and how does it help ?&lt;br /&gt;&lt;br /&gt;4. Differences between search engine index and database index ?&lt;br /&gt;&lt;br /&gt;5. What is paging in operating system ?&lt;br /&gt;&lt;br /&gt;6. Explain the difference in different types of pagings in different situations – Constraints on the implementation&lt;br /&gt;&lt;br /&gt;7. How can you implement paging in databases ?&lt;br /&gt;&lt;br /&gt;8. What happens when you search for a value in a database ?&lt;br /&gt;&lt;br /&gt;9. What are the different types of cache available .. explained about L1 L2 and onchip offchip caches and their access times and cost&lt;br /&gt;&lt;br /&gt;10. What is an RDBMS ? What are the differences or relation between RDBMS and DBMS ?&lt;br /&gt;&lt;br /&gt;11. What are the different types of joins in a database. Explained every join[Natural,Inner outer etc ., ] with examples.</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total><author>kchaitanyya@gmail.com (Unknown)</author></item><item><title>CapitalIQ HR Interview Questions</title><link>http://placementsindia.blogspot.com/2008/01/capitaliq-hr-interview-questions.html</link><category>HR Interviews</category><pubDate>Tue, 7 Oct 2008 11:28:00 +0530</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-32064785.post-7754053912542190698</guid><description>1.General introduction stuff.&lt;br /&gt;&lt;br /&gt;2.Why capitalIQ ?&lt;br /&gt;&lt;br /&gt;3.What are the different challenges faced in general?&lt;br /&gt;&lt;br /&gt;4. What challenges did you face?&lt;br /&gt;&lt;br /&gt;5. What would you do if you were given 10 lakhs.&lt;br /&gt;&lt;br /&gt;6. What are your Past time activities.&lt;br /&gt;&lt;br /&gt;Director Round&lt;br /&gt;&lt;br /&gt;1. Explained about his company and work and the asked me to explain how I am a suitable candidate for the job.</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total><author>kchaitanyya@gmail.com (Unknown)</author></item><item><title>Infosys Setlabs Campus Interview</title><link>http://placementsindia.blogspot.com/2008/01/infosys-setlabs-campus-interview.html</link><category>Interviews</category><pubDate>Fri, 3 Oct 2008 10:41:00 +0530</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-32064785.post-3636845728420273120</guid><description>Written test was on aptitude and verbal. Its was more like a cat paper. &lt;br /&gt;&lt;br /&gt;There was one round of interview (kinda stress mostly on the projects). &lt;br /&gt;&lt;br /&gt;Questions: &lt;br /&gt;&lt;br /&gt;1) Tell me about yourself &lt;br /&gt;2) Tell me the projects you worked on &lt;br /&gt;3) Which project did you like the most and why ? He will ask you questions about your projects, why did you do this why not in this way … &lt;br /&gt;4) Ur future plans. &lt;br /&gt;5) Why Setlabs ?</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><author>kchaitanyya@gmail.com (Unknown)</author></item><item><title>ADP Campus Interview</title><link>http://placementsindia.blogspot.com/2008/01/adp-campus-interview.html</link><category>Interviews</category><pubDate>Fri, 26 Sep 2008 10:45:00 +0530</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-32064785.post-4059139719940519623</guid><description>&lt;b&gt;Technical Interview&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;1) What are the ways of representing floating point nos?&lt;br /&gt;&lt;br /&gt;2) What are various Datatypes?&lt;br /&gt;&lt;br /&gt;3) Write the code for tic-tac-toe game, 8 queens problem.&lt;br /&gt;&lt;br /&gt;4) Write the psuedo code for towers of hanoi and what if there were 4 towers instead of 3.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;HR Interview&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;1) What do you know about ADP? &lt;br /&gt;&lt;br /&gt;2) What is your dream company? and Why?&lt;br /&gt;&lt;br /&gt;3) How did you come to know about ADP? If you heard about this from your seniors, who are they and what did they tell you?&lt;br /&gt;&lt;br /&gt;4) And some common questions like Tell about yourself, Family Background etc.. and also the interviewer asks if you have any questions for him.</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><author>kchaitanyya@gmail.com (Unknown)</author></item><item><title>Fractural Analysis Latest Placements Interview</title><link>http://placementsindia.blogspot.com/2008/02/fractural-analysis-latest-placements.html</link><pubDate>Mon, 22 Sep 2008 09:27:00 +0530</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-32064785.post-4206512643771543167</guid><description>&lt;a href=http://placementsindia.blogspot.com/2008/02/fractural-analysis-latest-placements.html&gt;&lt;b&gt;Written test&lt;/b&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;In the written test few questions were asked based on the english and general knowledge and math aptitude.&lt;br /&gt;&lt;br /&gt;&lt;a href=http://placementsindia.blogspot.com/2008/02/fractural-analysis-latest-placements.html&gt;&lt;b&gt;Technical Interview&lt;/b&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;1. This interview was purely based on nlp and knowledge in information retrieval areas.&lt;br /&gt;&lt;br /&gt;2. Algorithm to implement IR systems using semantics. Example: If a user gives a query “book-review”. We need to retrieve web-pages that are really book-reviews of some other pages but not those web pages which contains the word book review.&lt;br /&gt;&lt;br /&gt;3. A scenario was given like this and i was to implement a search system. In that interview he gave me “food scenario”. If u r building a search engine what r things u will do. (We need to explain from initial steps such as raw data collection and structure data storage until search algorithm)…. These questions purely based on IEIR - NLP.&lt;br /&gt;&lt;br /&gt;4. If u r building a search engine what r all the problems u will face as a programmer (plan-design).&lt;br /&gt;&lt;br /&gt;5. Will u be fit for this company. so be aware of job profile carefully what r the things u know about work in fractal?&lt;br /&gt;&lt;br /&gt;6. In language translation questions regarding Machine-Translation systems /Rule based systems were asked ?</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><author>kchaitanyya@gmail.com (Unknown)</author></item><item><title>Ikoa semiconductors Interview-1</title><link>http://placementsindia.blogspot.com/2008/09/ikoa-semiconductors-interview-1.html</link><pubDate>Fri, 19 Sep 2008 18:41:00 +0530</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-32064785.post-6653660965514094628</guid><description>1st round : Aptitude (written test) - 30 min&lt;br /&gt;&lt;br /&gt;There were total 30 Multiple Choice questions. 2 for correct and -1 for wrong, pretty simple questions… doing PPTP questions would be more then enough for it.&lt;br /&gt;&lt;br /&gt;(Tips :- Don't attempt the question if you are not sure of the answer)&lt;br /&gt;&lt;br /&gt;2nd round : Technical (written test) - 60 min&lt;br /&gt;&lt;br /&gt;It was a descriptive paper, there were 12 questions covering topics from C/C++, Digital Logic Design, Computer Organization, Microprocessors (they were in impression that we have been taught C++ here)&lt;br /&gt;&lt;br /&gt;1. Define a structure class in C++.&lt;br /&gt;&lt;br /&gt;2. one question based on OOPS.&lt;br /&gt;&lt;br /&gt;3. A circuit diagram using CMOS was given and we were asked to find the logic expression.&lt;br /&gt;&lt;br /&gt;4. Three questions on State Diagram.&lt;br /&gt;&lt;br /&gt;5. Some questions on solving logic expressions&lt;br /&gt;&lt;br /&gt;6. write a C code for strlen().&lt;br /&gt;&lt;br /&gt;7. question on memory - like build a 2M X 32 memory using 64K X 8 memory cell.&lt;br /&gt;&lt;br /&gt;(Tips :- Try to attempt all the questions, since no negative marking and draw digram where ever possible, it add to the examiners comfort when they check the paper)</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><author>kchaitanyya@gmail.com (Unknown)</author></item><item><title>Ikoa semiconductors Interview-1</title><link>http://placementsindia.blogspot.com/2008/02/ikoa-semiconductors-interview-1.html</link><pubDate>Tue, 16 Sep 2008 18:41:00 +0530</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-32064785.post-5440995587229840918</guid><description>1st round : Aptitude (written test) - 30 min&lt;br /&gt;&lt;br /&gt;There were total 30 Multiple Choice questions. 2 for correct and -1 for wrong, pretty simple questions… doing PPTP questions would be more then enough for it.&lt;br /&gt;&lt;br /&gt;(Tips :- Don't attempt the question if you are not sure of the answer)&lt;br /&gt;&lt;br /&gt;2nd round : Technical (written test) - 60 min&lt;br /&gt;&lt;br /&gt;It was a descriptive paper, there were 12 questions covering topics from C/C++, Digital Logic Design, Computer Organization, Microprocessors (they were in impression that we have been taught C++ here)&lt;br /&gt;&lt;br /&gt;1. Define a structure class in C++.&lt;br /&gt;&lt;br /&gt;2. one question based on OOPS.&lt;br /&gt;&lt;br /&gt;3. A circuit diagram using CMOS was given and we were asked to find the logic expression.&lt;br /&gt;&lt;br /&gt;4. Three questions on State Diagram.&lt;br /&gt;&lt;br /&gt;5. Some questions on solving logic expressions&lt;br /&gt;&lt;br /&gt;6. write a C code for strlen().&lt;br /&gt;&lt;br /&gt;7. question on memory - like build a 2M X 32 memory using 64K X 8 memory cell.&lt;br /&gt;&lt;br /&gt;(Tips :- Try to attempt all the questions, since no negative marking and draw digram where ever possible, it add to the examiners comfort when they check the paper)</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><author>kchaitanyya@gmail.com (Unknown)</author></item><item><title>Latest MicroSoft Interview Questions</title><link>http://placementsindia.blogspot.com/2008/09/latest-microsoft-interview-questions.html</link><category>Microsoft</category><pubDate>Sat, 13 Sep 2008 19:52:00 +0530</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-32064785.post-4921625249820634968</guid><description>1)Given a Parent -Child binary tree ,build the child -sibling version of it?&lt;br /&gt; Minimize the space requirements wherever possible.&lt;br /&gt;&lt;br /&gt;2)Given a binary tree build a linked list of all its nodes such that the nodes of a level appear before the nodes of the next level?&lt;br /&gt;&lt;br /&gt;3)Given an infinite stream of bits with the bits  being appended at the highest significant position. give an algorithm to to say whether the number formed by using the sequence of bits that had been processed till then,  is divisible by 3 or not?&lt;br /&gt;&lt;br /&gt;4)Given a string S of words and no of character per line m ,with m being greater than the longest word in S,print S in a set of lines so that each line contains no more than m characters and no word split between 2 lines.&lt;br /&gt;&lt;br /&gt;5)Given an expression remove the unnecessary brackets in it with out creating an ambiguity in its execution.&lt;br /&gt;            input                                       output&lt;br /&gt;ex1:     (a+(b)+c)                                a+b+c&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ex2:   (a*b)+c                                                  a*b+c&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;6)Propose a tree based data structure to identify a node with nth rank with maximum efficiency   .&lt;br /&gt;&lt;br /&gt;7)Given a string S of alphabets and 2 characters a,b find the minimum distance between instances   of them such that position of a  &amp;lt;= position of b.&lt;br /&gt;&lt;br /&gt;8)Given an array of size n with first l positions filled with characters and a string s ,replace all the instances of  ’%’ with this string s,given that the lengh of the array is sufficient to handle these substitutions.&lt;br /&gt;&lt;p&gt;  input                                                             output&lt;br /&gt;&lt;/p&gt;&lt;p&gt;eg: abcdef%ghi%—— and “ppp”                  abcdefpppghippp&lt;/p&gt;&lt;br /&gt;&lt;p&gt;9)Given a binary tree verify whether it is a binary search tree or not?&lt;/p&gt;10)Write a C code to merge 2 binary search trees and do the same 2 merge linked lists.How is the former different when compared to the later.(Discuss the issues)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><author>kchaitanyya@gmail.com (Unknown)</author></item><item><title>Yahoo Interview Questions-2</title><link>http://placementsindia.blogspot.com/2007/12/yahoo-interview-questions-2.html</link><category>Interviews</category><category>yahoo</category><pubDate>Thu, 3 Jul 2008 11:38:00 +0530</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-32064785.post-870669428214528385</guid><description>&lt;ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Design a data structure such that given  a stream of numbers, you can find the maximum of the numbers at any point and also all the numbers.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array. Optimize the boundary conditions.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Find the common ancestor of two given nodes in a binary tree, how do you exploit the properties of a given BST for the same problem.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Given a function getsort(data),that sorts the data given. The function sorts in place and does not use any extra memory. How do you validate the function with respect to 1)it sorts 2) it does not use extra memory&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Explain the Traveling Salesman problem? What is an NP-complete problem? What is the Hamiltonian cycle problem?&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Find out the least common ancestor in a binary tree.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><author>kchaitanyya@gmail.com (Unknown)</author></item><item><title>Yahoo Interview Questions-1</title><link>http://placementsindia.blogspot.com/2007/12/yahoo-interview-questions-1.html</link><category>Interviews</category><category>yahoo</category><pubDate>Sun, 29 Jun 2008 11:34:00 +0530</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-32064785.post-605961379307681403</guid><description>&lt;ol&gt;&lt;br /&gt;&lt;li&gt;A modified insertion sort uses binary search to find the position of insertion. What would be the improvement in order realized?&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;class a{};&lt;br /&gt;main()&lt;br /&gt;{&lt;br /&gt;count &lt;&lt;&gt;&lt;br /&gt;}&lt;br /&gt;What is the output?&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;The linked list size is unknown and it is very large. Find out the N th element from the back end.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;What happens in the following code?&lt;br /&gt;char x[10],y[10];&lt;br /&gt;x=y;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Design a stack which supports push, pop, min and max operations in O(1).&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Design an NFA to accept a string of 0s and 1s.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Given a balanced BST tree, write a function to replace the root with a node that belongs to the original tree.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Explain what this function does&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;char *mystrcpy(char *s)&lt;br /&gt;{&lt;br /&gt;char des=char [MAXLEN];&lt;br /&gt;char * t=des;&lt;br /&gt;while(*s)&lt;br /&gt;{&lt;br /&gt;*++t=*++s;&lt;br /&gt;}&lt;br /&gt;return t;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Given that you have a server hit by around 400 million users, and you have log files that contain the user ids of all of them. How do you find the frequency of login of each user. (The log files are very huge!!)&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Explain Polymorphism, Encapsulation, Inheritance, operator overloading?&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><author>kchaitanyya@gmail.com (Unknown)</author></item><item><title>Latest DE Shaw Interview Questions</title><link>http://placementsindia.blogspot.com/2007/12/de-shaw-interview-questions-2.html</link><category>Interviews</category><pubDate>Fri, 27 Jun 2008 08:37:00 +0530</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-32064785.post-5559993525368056193</guid><description>&lt;span style="font-weight:bold;"&gt;Question1&lt;/span&gt;: Differentiate HTTP and HTTPS &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Question2&lt;/span&gt;: Discuss ACID properties of a database system.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Question3&lt;/span&gt;: Given a table Employee with only one field: Names, report all names with multiple entries.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Question4&lt;/span&gt;:Given two sequences s1,s2 and another sequence s3, find if s3 is formed by interleaving s1 and s2.[Example: s1:abcd s2:bcaa s3:abbccdaa].&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Question5&lt;/span&gt;: If a class B is inherited from a class A, B has a function foo which is also in A, how do you call foo function in A??&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Question6&lt;/span&gt;: If a class B is inherited public from a class A, what all the variables that can be accesses and those that cannot be.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Question7&lt;/span&gt;: List out the additional features of C++ over C when the latter is already available as a good programming language?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Question8&lt;/span&gt;: Can classes,protected variables or other features in C++ be implemented using C?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Question9&lt;/span&gt;: Define Deadlock&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Question20&lt;/span&gt;:Given a multi-threaded program How can you make it  run on a system that supports only a single thread execution? &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Question11&lt;/span&gt;:What are the Differences between a const char * and char const *?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Question12&lt;/span&gt;:What are the Differences between a reference variable and pointer variable in C++?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Question13&lt;/span&gt;What is a register variable and what are the limitations on it? What is an automatic variable?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Question14&lt;/span&gt;What are the Differences in memory allocation in array and pointer(stack and heap)?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Question15&lt;/span&gt;Find the missing element in a sorted array in most optimum running time (O(log n))</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><author>kchaitanyya@gmail.com (Unknown)</author></item><item><title>Latest Amazon Interview Questions -3</title><link>http://placementsindia.blogspot.com/2007/12/latest-amazon-interview-questions-3.html</link><category>Amazon</category><category>Interviews</category><pubDate>Thu, 19 Jun 2008 10:40:00 +0530</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-32064785.post-6496834981771849811</guid><description>1. How would you find the second largest element in an array using minimum no of comparisons?&lt;br /&gt;&lt;br /&gt;2. Write a C program for  level order traversal of a tree?&lt;br /&gt;&lt;br /&gt;3. You are given: 3 types of vehicles: Motorbike, Car, and a special type of car for the handicapped. &lt;br /&gt; 3 types of parking: Motorbike parking, Car parking, handicapped car parking.&lt;br /&gt;&lt;br /&gt;Motorbikes and cars can only park in their designated parkings, while the handicapped cars can park either in their own parking or the regular car parking.&lt;br /&gt;How would you model this as classes? Explain your methods.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;4. Given 2 tables: Employee(Employee_Name,Dept_No) Department(Dept_No, Dept_Name)&lt;br /&gt;&lt;br /&gt;Write an SQL query which outputs all the employees, and their department nos and names, including all those departments which have no employees working for them.&lt;br /&gt;&lt;br /&gt;6. Explain about Inodes?&lt;br /&gt;&lt;br /&gt;7.Give a Linux shell command to find all files in a directory which contain ip addresses.&lt;br /&gt;&lt;br /&gt;8. Given a table Employee which has columns name and salary, write an SQL query to find the employee with the second highest salary.&lt;br /&gt;&lt;br /&gt;9. Given a table of Player which contains Sno and player name, write a query which finds all possible Table Tennis doubles pairings.&lt;br /&gt;&lt;br /&gt;10.Given a string A, and a string B, and a dictionary, how would you convert A to B in the minimum no of operations, given that:&lt;br /&gt;&lt;br /&gt;i) All the intermediate words must be from the dictionary&lt;br /&gt;&lt;br /&gt;ii) An ‘operation’ is defined as:&lt;br /&gt;&lt;br /&gt;a) Delete any character from a string ex dog → do&lt;br /&gt;&lt;br /&gt;b) Insert any character into a string ex cat → cart&lt;br /&gt;&lt;br /&gt;c) Replace any character in the string with another ex cat → cot</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total><author>kchaitanyya@gmail.com (Unknown)</author></item><item><title>Latest Amazon Interview Questions -2</title><link>http://placementsindia.blogspot.com/2007/12/latest-amazon-interview-questions-2.html</link><category>Amazon</category><category>Interviews</category><pubDate>Mon, 9 Jun 2008 19:16:00 +0530</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-32064785.post-2183176560535559202</guid><description>1.Given a string,find the first un-repeated character in it? Give some test cases&lt;br /&gt;&lt;br /&gt;2.You are given a dictionary of all valid words. You have the following 3 operations permitted on a word:&lt;br /&gt;&lt;br /&gt;a) Delete a character&lt;br /&gt;&lt;br /&gt;b) Insert a character&lt;br /&gt;&lt;br /&gt;c) Replace a character&lt;br /&gt;&lt;br /&gt;Now given two words - word1 and word2 - find the minimum number of steps required to convert word1 to word2. (one operation counts as 1 step.)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3.Given a cube of size n*n*n (i.e made up of n^3 smaller cubes), find the number of smaller cubes on the surface. Extend this to k-dimension.&lt;br /&gt;&lt;br /&gt;4.What is a C array and illustrate the how is it different from a list.&lt;br /&gt;&lt;br /&gt;5. What is the time and space complexities of merge sort and when is it preferred  over quick sort?&lt;br /&gt;&lt;br /&gt;6. Write a function which takes as parameters one regular expression(only ? and * are the special characters) and a  string and returns whether the string matched the regular expression.&lt;br /&gt;&lt;br /&gt;7. Given n red balls and m blue balls and some containers, how would you distribute those balls among the containers such that the probability of picking a red ball is maximized, assuming that the user randomly chooses a container and then randomly picks a ball from that.&lt;br /&gt;&lt;br /&gt;8.Find the second largest element in an array with minimum no of comparisons and give the minimum no of comparisons needed on an array of size N to do the same.&lt;br /&gt;&lt;br /&gt;9. Given an array of size n ,containing every element from 1 to n+1, except one. Find the missing element.</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total><author>kchaitanyya@gmail.com (Unknown)</author></item><item><title>Latest Amazon Interview Questions -1</title><link>http://placementsindia.blogspot.com/2007/12/latest-amazaon-interview-questions-1.html</link><category>Amazon</category><category>Interviews</category><pubDate>Tue, 3 Jun 2008 21:57:00 +0530</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-32064785.post-4724590034739364171</guid><description>1. How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same&lt;br /&gt;&lt;br /&gt;2. Explain polymorphism  citing an example.&lt;br /&gt;&lt;br /&gt;3. What are the 4 basics of OOP?&lt;br /&gt;&lt;br /&gt;4. Define Data Abstraction. What is its importance?&lt;br /&gt;&lt;br /&gt;5. Given an array all of whose elements are positive numbers, find the maximum sum of a subsequence with the constraint  that no 2 numbers in the sequence should be adjacent in the array.&lt;br /&gt;&lt;br /&gt;Eg.&lt;br /&gt;&lt;br /&gt;i) 3 2 7 10 should return 13 (sum of 3 and 10)&lt;br /&gt;&lt;br /&gt;ii) 3 2 5 10 7 should return 15 (sum of 3, 5 and 7)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;6. Given a Binary Search Tree, write a program to print the kth smallest element without using any static/global variable. You can’t pass the value k to any function also. &lt;br /&gt;&lt;br /&gt;7.You are given some denominations of coins in an array (int denom[])and  infinite supply of all of them. Given an amount (int amount), find the minimum number of coins required to get the exact amount. What is the method called?&lt;br /&gt;&lt;br /&gt;8.Given an array of size n. It contains numbers in the range 1 to n. Each number is present at least once except for 1 number. Find the missing number.&lt;br /&gt;&lt;br /&gt;9.Given an array of size n. It contains numbers in the range 1 to n. Each number is present at least once except for 2 numbers. Find the missing numbers.&lt;br /&gt;&lt;br /&gt;10.Given an array of size n. It contains numbers in the range 1 to n. Find the  numbers which aren't present.</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">5</thr:total><author>kchaitanyya@gmail.com (Unknown)</author></item><item><title>Search In  A Young tableau - A Sorted Matrix</title><link>http://placementsindia.blogspot.com/2008/05/search-in-young-tableau-sorted-matrix.html</link><category>Algorithm Analysis</category><pubDate>Thu, 22 May 2008 10:31:00 +0530</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-32064785.post-8616626232370039183</guid><description>&lt;span style="font-weight: bold;"&gt;Young tableau : &lt;/span&gt;For our present discussion ,we confine this entity to a table which elements  are sorted  both column wise and row wise.The degree of orderliness  among the elements  is loosely bound that a row by row or column by column traversal of this matrix doesn't essentially list out the elements in a sorted manner.So the search on this matrix is not all that simple and straight forward as it looks like.&lt;br /&gt;In the following sections we will look at some interesting approaches to search for a key in this 2D array(after all it is!!).&lt;br /&gt;&lt;br /&gt;One interesting yet simple thing worth observing is that&lt;br /&gt;element A[i][j] is always &amp;gt; A[p][q]  for i &amp;gt; p  and j&amp;gt; q .&lt;br /&gt;The next 2 strategies are based on this simple fact.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Strategy1 - A grid search&lt;/span&gt;: About any element A[i][i] divide the matrix in to 4 quadrants.&lt;br /&gt;If the key K we are looking for is&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;  &amp;lt;A[i][j] then we can eliminate the lower right quadrant because all its elements are &amp;gt; A[i][j].&lt;/li&gt;&lt;br /&gt;&lt;li&gt;  &amp;lt;A[i][j] then we can eliminate the lower right quadrant because all its elements are &amp;gt; A[i][j].&lt;/li&gt;&lt;br /&gt;&lt;li&gt;=A[i][j]. then our search is over.The choice of this i can be done in a binary search manner.. reducing the search space by half.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;Now  we can search the 3 quadrants individually and hence recursively.&lt;br /&gt;&lt;br /&gt;T(N)=3*T(N/4)+O(1)  which  comes out to be O(N^(log3/log4)) which is  less than O(N).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Strategy2:&lt;/span&gt;Now we move a step further in reducing the search space.Iterate along the diagonal and find i such that A[i][i] &amp;lt;k and A[i+1][i+1] &amp;gt;k.Now we have only 2 search intervals to search for.&lt;br /&gt;&lt;br /&gt;T(N)=2*T(N/4)+O(N) which comes out to be O(N).&lt;br /&gt;&lt;br /&gt;Strategy3:One more interesting solution and smart solution that I found was(the credit goes to the geek named Novice in the discussion http://inder-gnu.blogspot.com/2008/01/find-element-in-row-and-column-sorted.html )  this.&lt;br /&gt;&lt;br /&gt;Start from the point in the last row first column. Every point to its right is greater than this point and every point on its top is smaller than this. So, if the point is greater than this point then move right otherwise move top. So, you will traverse at most 2*n points.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Well, these are 3 interesting solutions I could find till now and at this juncture ,it is not surprising if one wishes to compare these strategies to figure out the best and I don't even rule out any other solutions to this problem.So folks if you do any ,please  put them in the comments sections  and let others know.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Continued&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here are the C codes for the above discussed strategies.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Strategy1&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;strategy1&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;bool novice_search(int **grid,int size, int key,int &amp;amp;x,int &amp;amp;y)&lt;br /&gt;{&lt;br /&gt;        int i=size-1,j=0;&lt;br /&gt;        while(0&amp;lt;=i &amp;amp;&amp;amp; i&amp;lt;size &amp;amp;&amp;amp; 0&amp;lt;=j &amp;amp;&amp;amp; j&amp;lt;size)&lt;br /&gt;        {&lt;br /&gt;                if(grid[i][j]==key)&lt;br /&gt;                {&lt;br /&gt;                        x=i;&lt;br /&gt;                        y=j;&lt;br /&gt;                        return true;&lt;br /&gt;                }&lt;br /&gt;                else if(grid[i][j] &amp;lt;key)&lt;br /&gt;                {&lt;br /&gt;                        j++;&lt;br /&gt;                }&lt;br /&gt;                else&lt;br /&gt;                        i--;&lt;br /&gt;        }&lt;br /&gt;        return false;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;strategy2&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;bool quadra_partitionsearch(int **grid,int row_min,int row_max,int col_min,int col_max,int key,int &amp;amp;x,int &amp;amp;y)&lt;br /&gt;{&lt;br /&gt;        if((row_min &amp;gt; row_max) ||( col_min &amp;gt;col_max))&lt;br /&gt;                return false;&lt;br /&gt;        else if((row_min==row_max) &amp;amp;&amp;amp;(col_min==col_max))&lt;br /&gt;        {&lt;br /&gt;                if(grid[row_min][col_min]==key)&lt;br /&gt;                {&lt;br /&gt;                        x=row_min;&lt;br /&gt;                        y=col_min;&lt;br /&gt;                        return true;&lt;br /&gt;                }&lt;br /&gt;                else&lt;br /&gt;                        return false;&lt;br /&gt;        }&lt;br /&gt;        else if((grid[row_min][col_min] &amp;lt;=key) &amp;amp;&amp;amp; (grid[row_max][col_max]&amp;gt;=key))&lt;br /&gt;        {&lt;br /&gt;                int row_mid =(row_min +row_max)/2;&lt;br /&gt;                int col_mid =(col_min+col_max)/2;&lt;br /&gt;                bool flag;&lt;br /&gt;                //      cout &amp;lt;&amp;lt;row_min &amp;lt;&amp;lt;'\t' &amp;lt;&amp;lt;row_max&amp;lt;&amp;lt;'\t'&amp;lt;&amp;lt;col_min&amp;lt;&amp;lt;'\t'&amp;lt;&amp;lt;col_max&amp;lt;&amp;lt;'\n';&lt;br /&gt;                if(grid[row_mid][col_mid]==key)&lt;br /&gt;                {&lt;br /&gt;                        x=row_mid;&lt;br /&gt;                        y=col_mid;&lt;br /&gt;                        return true;&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                else if(grid[row_mid][col_mid]&amp;gt;key)&lt;br /&gt;                {&lt;br /&gt;                        if(quadra_partitionsearch(grid,row_min,row_mid,col_min,col_mid,key,x,y))&lt;br /&gt;                                return true;&lt;br /&gt;                }&lt;br /&gt;                else&lt;br /&gt;                {&lt;br /&gt;                        if(quadra_partitionsearch(grid,row_mid,row_max,col_mid+1,col_max,key,x,y))&lt;br /&gt;                                return true;&lt;br /&gt;                }&lt;br /&gt;                if(quadra_partitionsearch(grid,row_min,row_mid,col_mid+1,col_max,key,x,y))&lt;br /&gt;                        return true;&lt;br /&gt;                else if(quadra_partitionsearch(grid,row_mid+1,row_max,col_min,col_mid,key,x,y))&lt;br /&gt;                        return true;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;        return false;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;strategy3&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;bool binary_partitionsearch(int **grid,int row_min,int row_max,int col_min,int col_max,int key,int &amp;amp;x,int &amp;amp;y)&lt;br /&gt;{&lt;br /&gt;        if((row_min &amp;gt; row_max) ||( col_min &amp;gt;col_max))&lt;br /&gt;                return false;&lt;br /&gt;        else if((row_min==row_max) &amp;amp;&amp;amp;(col_min==col_max))&lt;br /&gt;        {&lt;br /&gt;                if(grid[row_min][col_min]==key)&lt;br /&gt;                {&lt;br /&gt;                        x=row_min;&lt;br /&gt;                        y=col_min;&lt;br /&gt;                        return true;&lt;br /&gt;                }&lt;br /&gt;                else&lt;br /&gt;                        return false;&lt;br /&gt;        }&lt;br /&gt;        else&lt;br /&gt;        {&lt;br /&gt;                if(grid[row_min][col_min] &amp;gt; key)&lt;br /&gt;                        return false;&lt;br /&gt;                int row_mid=row_min,col_mid=col_min;&lt;br /&gt;                while(grid[row_mid][col_mid] &amp;lt; key)&lt;br /&gt;                {&lt;br /&gt;                        row_mid++;&lt;br /&gt;                        col_mid++;&lt;br /&gt;                }&lt;br /&gt;                if(grid[row_mid][col_mid]==key)&lt;br /&gt;                {&lt;br /&gt;                        x=row_mid;&lt;br /&gt;                        y=col_mid;&lt;br /&gt;                        return true;&lt;br /&gt;                }&lt;br /&gt;                else&lt;br /&gt;                {&lt;br /&gt;                        if(binary_partitionsearch(grid,row_mid,row_max,col_min,col_mid-1,key,x,y))&lt;br /&gt;                                return true;&lt;br /&gt;                        return binary_partitionsearch(grid,row_min,row_mid -1,col_mid,col_max,key,x,y);&lt;br /&gt;                }&lt;br /&gt;        }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I tried to check which of them is efficient by noting the runtimes  and well all of them were quite close,though 2nd and 3rd approaches did mostly well compared to the first one.All these strategies worked more or less in the same manner on an grids of size varying from 100 to 1000.The last 2 strategies worked much better than the first one mostly.</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">12</thr:total><author>kchaitanyya@gmail.com (Unknown)</author></item><item><title>Solutions to Crazy Questions at Google Job Interview</title><link>http://placementsindia.blogspot.com/2008/05/solutions-to-crazy-questions-at-google.html</link><category>Google</category><pubDate>Wed, 14 May 2008 21:51:00 +0530</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-32064785.post-1731991309438576097</guid><description>We are providing solutions to the &lt;a href="http://tihomir.org/crazy-questions-at-google-job-interview/"&gt;Crazy Questions at Google Job Interview&lt;/a&gt; post By &lt;a href="http://tihomir.org/"&gt;Thiomir&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;How many golf balls can fit in a school bus?&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt; The point of the question isn't to see how golf balls you think are in the bus, but to see what your deduction skills are like. Do you just make a random guess or try to cop out by saying a lot, or do you actually try to come up with a legitimate answer by going through a logical series of steps.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;You are shrunk to the height of a nickel and your mass is proportionally reduced so as to maintain your original density. You are then thrown into an empty glass blender. The blades will start moving in 60 seconds. What do you do?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;You simply jump out. As you are scaled down, the ratio of muscle mass to total mass remains the same. Potential energy is given by E = mgh. So, if E/m is unchanged (where E is the energy expended in expanding your leg muscles, and m is your mass), then h is unchanged. Mini-me jumps as high as me. This is the reason why grass-hoppers can jump about as high as people.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;How much should you charge to wash all the windows in Seattle?&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;As crazy as it might sound, questions like these demonstrate your ability to think through a complex problem with little or no information. They expect you to take an educated guess. Most of the time you can ask them questions like - how many buildings are there in Seattle.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;How would you find out if a machine’s stack grows up or down in memory?&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;Instantiate a local variable. Call another function with a local. Look at the address of that function and then compare. If the function's local is higher, the stack grows away from address location 0; if the function's local is lower, the stack grows towards address location 0.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Explain a database in three sentences to your eight-year-old nephew.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;A database is like a file cabinet. The files, or data, is stored in it and can be arranged in categories. But unlike an actual file cabinet, you can do a lot more cool stuff with a database like being able to make it accessible through the internet.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;How many times a day does a clock’s hands overlap?&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;The Hour hand and Minute hand would be meeting exactly 11 times in 12 hours (Hour hand would have taken 1 clockwise round and Minute hand would have taken 12 clockwise rounds, so 12 - 1 = 11 rounds).&lt;br /&gt;&lt;br /&gt;result: First time hour and minute hands overlap will be 12 Hours / 11 = 01:05:27.27. So at this time only hour and minute hands would be overlapping and second hand will not be any near to them. Similarly for 2nd, 3rd, 4th, 5th, 6th, 7th, 8th, 9th and 10th overlap of hour and minute hand the Second hand wont be any nearby. So all 3 hands (hour, minute and Second) overlap only 2 times i.e. (0:0:0 and 12:0:0).&lt;br /&gt;&lt;br /&gt;Also we all know when we get our watches repaired, normally the repairman overlaps all the three hands to 12.&lt;br /&gt;&lt;br /&gt;If we are considering that the second hand is not present, then the rest two overlaps 22 times in 24 hours.&lt;br /&gt;&lt;br /&gt;There again is a catch, if we check the angles by which the hour hand and minute hand moves.&lt;br /&gt;&lt;br /&gt;The second hand moves 6 degree in a second. In that time the minute hand will move 6/60 degrees. and the hour hand will move 6/(60*12) degrees. now taking these things in the considerations. if we check the positions of the hour and minute hand in terms of angle from the marker 12, for our first rendezvous time, i.e. 01:05:27.27 sec.&lt;br /&gt;first thing that comes to my mind is that, there is fraction in the seconds. So that time can’t be measured. there will be no exact overlap. now lets calculate the angles:&lt;br /&gt;&lt;br /&gt;1 hour 5 mins and 27 seconds = 3600 + 5*60 + 27 = 3927 seconds.&lt;br /&gt;&lt;br /&gt;angle of hour hand = 3927 * 6/(60*12) = 32.725 degree.&lt;br /&gt;angle of minute hand = 3927 * 6/60 = 392.7 degree&lt;br /&gt;subtracting 360 degree from it we get - 32.7 degree.&lt;br /&gt;&lt;br /&gt;So at 01:05:27 both hands don’t overlap. Now for 01:05:28 :&lt;br /&gt;Angles : hour hand - 32.73333&lt;br /&gt;minute hand - 32.8&lt;br /&gt;so obviously they dont meet at 01:05:28 either.&lt;br /&gt;&lt;br /&gt;So they overlap at 12:00 and 24:00 only. So the answer is 2 only.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;You have to get from point A to point B. You don’t know if you can get there. What would you do?&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;Utilizing a “learn as you go” approach and applying collected knowledge and data along the way is the best way to proceed. Let’s break this down farther.&lt;br /&gt;&lt;br /&gt;Determine the amount of time you have to go from point A to point B. Spend the initial 20% of that time making a 360° search with the largest circumference possible with the in the time you have allowed.&lt;br /&gt;&lt;br /&gt;During that time, ask people, look for maps, clues, collect data, and knowledge. 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. Then you proceed on implementing your plan with predetermined intervals of reassessment and strategy improvements.&lt;br /&gt;&lt;br /&gt;This is the best chance you have reaching point B if you don’t know if you can get there.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Imagine you have a closet full of shirts. It’s very hard to find a shirt. So what can you do to organize your shirts for easy retrieval?&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;Let’s suppose there are&lt;br /&gt;a set of attributes of each shirt you are interested in: e.g. sleeve length, color, buttons (no buttons, fully button, partially buttoned from collar to chest level).&lt;br /&gt;Let’s say the closet is a simple wall closet with a single closet rod running the entire length of closet. On the left you put all the short sleeve shirts, and on the right the long sleeve shorts. You separate then long and short sleeve sides with a specially marked coat hanger. Then you separate each group into no buttonoed, partially buttoned, and fully button, using more specially marked hangers. 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, orange, yellow, green, blue, indigo, violet. Each monochrome ggroup is sorted left to right: white on the left, black on the right, and shades of grey in the middle, the darker greys on the right, the lighter on the left.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Every man in a village of 100 married couples has cheated on his wife. Every wife in the village instantly knows when a man other than her husband has cheated, but does not know when her own husband has. The village has a law that does not allow for adultery. Any wife who can prove that her husband is unfaithful must kill him that very day. The women of the village would never disobey this law. One day, the queen of the village visits and announces that at least one husband has been unfaithful. What happens?&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;1. There is only one cheat husband&lt;br /&gt;- If it is so then 99 wives knew it before. So the cheated wife got the idea from queen that her husband is cheating. So she will kill him. Next morning every wife will know there is no cheat husbands anymore.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2. There are more than one cheat husbands&lt;br /&gt;&lt;br /&gt;- In this case, all of the wives already had the idea prior to queen's information. Its just that the cheated wives knew the count which is one less than what the non-cheated wives' knew - thats all. i.e. if there were 2 cheat husbands then their wives knew the count is 1 and others knew its 2. So the queen just repeated the info saying "at least 1". Same goes to 2,3,4...100 cheat husbands. So in this case no wife kills her husband.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;In a country in which people only want boys, every family continues to have children until they have a boy. if they have a girl, they have another child. if they have a boy, they stop. what is the proportion of boys to girls in the country?&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;From pure probability,we get the expected number of girls born to be 1/2 with that of boys being 1.So the ratio is 2:1&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;If the probability of observing a car in 30 minutes on a highway is 0.95, what is the probability of observing a car in 10 minutes (assuming constant default probability)?&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;If the chance to see the car is 10 percent per minute, the first minute you have 10% chance, the second minute you have 10% of 90% = 9% (so total 19%), the third minute 10% of 81% (= 8,1%, total 27,1 %) ......&lt;br /&gt;As the chance for 30 minutes is 95 percent, the chance for 1 minute is 9.5% and for 10 minute 63.1 %.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;If you look at a clock and the time is 3:15, what is the angle between the hour and the minute hands? (The answer to this is not zero!)&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;7.5 degrees (the hour hand is 1/4th of the way between 3 and 4, the angle measure of that is 360/12 = 30 degrees between hours / 4 = 7.5 degrees).&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Four people need to cross a rickety rope bridge to get back to their camp at night. Unfortunately, they only have one flashlight and it only has enough light left for seventeen minutes. The bridge is too dangerous to cross without a flashlight, and it�s only strong enough to support two people at any given time. Each of the campers walks at a different speed. One can cross the bridge in 1 minute, another in 2 minutes, the third in 5 minutes, and the slow poke takes 10 minutes to cross. How do the campers make it across in 17 minutes?&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;1 and 2 cross, taking 2 minutes, 1 goes back carrying the flashlight total=3 minutes. 5 and 10 cross, taking 10 minutes totaltime now= 13 minutes, 2 goes back,total time now = 15 minutes. 1 and 2 cross again, taking 2 minutes making it 17 minutes.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;You are at a party with a friend and 10 people are present including you and the friend. your friend makes you a wager that for every person you find that has the same birthday as you, you get $1; for every person he finds that does not have the same birthday as you, he gets $2. would you accept the wager?&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;No.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;How many piano tuners are there in the entire world?&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;1) At first  list out all the piano manufacturing companies in the world.&lt;br /&gt;2) Then  look into their purchase records and find out the piano purchasers information.&lt;br /&gt;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.&lt;br /&gt;ii) Else if the piano is purchased for school then list out the students that opted the piano course in their music curriculum.&lt;br /&gt;iii) If the piano is purchased by a Church then  count the no of major or minor events of the church and count the piano users.&lt;br /&gt;sum up all the numbers to get more or less accurate piano users count.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;You have eight balls all of the same size. 7 of them weigh the same, and one of them weighs slightly more. How can you find the ball that is heavier by using a balance and only two weighings?&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;choose 6 balls and weigh 3 against 3&lt;br /&gt;- if they weigh the same, you have another weighing for the remaining 2 balls and you can find the heavier one&lt;br /&gt;- if they don’t weigh the same, from the group of 3 which was heavier, choose any 2 balls and weigh them:&lt;br /&gt;- if they weigh the same, the remaining ball is the heavier one; otherwise you just found the heavier one by weighing the 2 chosen balls.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;You have five pirates, ranked from 5 to 1 in descending order. The top pirate has the right to propose how 100 gold coins should be divided among them. But the others get to vote on his plan, and if fewer than half agree with him, he gets killed. 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.)&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;The highest ranked pirate gets 98 gold coins&lt;br /&gt;---Two pirates get 1 gold coin each&lt;br /&gt;---The other 2 pirates get nothing.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">13</thr:total><author>kchaitanyya@gmail.com (chaitanya)</author></item><item><title>Google Interview Questions</title><link>http://placementsindia.blogspot.com/2007/09/google-interview-questions.html</link><category>Google</category><pubDate>Wed, 30 Apr 2008 14:02:00 +0530</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-32064785.post-4988565250416814573</guid><description>&lt;span style="font-weight: bold;"&gt;&lt;a href="http://placementsindia.blogspot.com/2007/09/google-interview-questions.html"&gt;Google Interview Questions&lt;/a&gt; ::&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Total there are five Technical Interviews followed by Management round.&lt;br /&gt;&lt;br /&gt;So here are the questions.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;a href="http://placementsindia.blogspot.com/2007/09/google-interview-questions.html"&gt;Google Interview Round 1&lt;/a&gt; ::&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;What is the Space complexity of quick sort algorithm? how do find it?&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt; Quicksort has a space complexity of O(logn), even in the worst case, when it is carefully implemented such that&lt;br /&gt;    * in-place partitioning is used. This requires O(1).&lt;br /&gt;    * 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.&lt;br /&gt;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.&lt;br /&gt;&lt;br /&gt;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.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;What are dangling pointers?&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt; A dangling pointer is a pointer to storage that is no longer allocated. Dangling pointers are nasty bugs because they seldom crash the program until long after they have been created, which makes them hard to find. Programs that create dangling pointers often appear to work on small inputs, but are likely to fail on large or complex inputs.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Given that you can take one step or two steps forward from a given step. So find the total number of ways of reaching Nth step.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;The simple recurrence relation governing this problem is f(N)=f(N-1) +f(N-2)(why?),which is a fibonacci sequence.&lt;br /&gt;Nth state can be arrived directly by taking 2 step movement from N-2 or 1 step from N-1.Remember N-2 -&gt; N-1 -&gt; N is not a direct path from N-2th state to Nth state.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.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;You are given biased coin. Find unbiased decision out of it?&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;Throw the biased coin twice.Classify it as true for HT and false for TH.Both of these occur with probability=p*(1-p),hence unbiased. Ignore the other 2 events namely HH and TT.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;On a empty chessboard, a horse starts from a point( say location x,y) and it starts moving randomly, but once it moves out of board, it cant come inside. So what is the total probability that it stays within the board after N steps.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;a href="http://placementsindia.blogspot.com/2007/09/google-interview-questions.html"&gt;Google Interview Round 2&lt;/a&gt; ::&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;You have 1 to N-1 array and 1 to N numbers, and one number is missing, you need to find the missing the number. Now you have 1 to N-2 numbers, and two numbers missing. Find them.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;br /&gt;The question can be elucidated as follows.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 .Let S be the sum of the elements of the array.&lt;br /&gt;&lt;br /&gt;Sum of first N natural numbers=N*(N+1)/2 &lt;br /&gt;&lt;br /&gt;and S=N*(N+1)/2 - K.Now putting this other way around we get  K=N*(N+1)/2 -S !!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now the second part of the question says that there are 2 of the first N numbers missing.Let they be X and Y. &lt;br /&gt;&lt;br /&gt;We solve this problem by solving 2 essential equations.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;They are X+Y=N*(N+1)/2 -S----------&gt;(1)&lt;br /&gt;&lt;br /&gt;         X*Y=N!/P-------------------(2) where S and P are the cumulative sum and product of the array entries.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;You have cycle in linked list. Find it. Prove that time complexity is linear. Also find the node at which looping takes place.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;br /&gt;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.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.This is a O(N) solution.&lt;br /&gt;&lt;br /&gt; Now coming to the identification of the node at which looping took place.After our identification of cycle ,both the pointers P1 and P2 are at node N1.Now iterate the slow pointer to count the no of nodes in the cycle.(After traversing the whole cycle P1 and P2 shall again be at the same node).Let this size be K.Now take one of the pointers to the head node and count the no of nodes till N1.Let this number be X.Now use one of these pointers to reverse the cycle starting from N1.Only the cycle gets reversed.Now again traverse from head node to N1.Let the number of nodes this time be Y.Let the no of nodes from head to the start node of the cycle be Z&lt;br /&gt;&lt;br /&gt;Now X+Y=2*Z+K .Hence solve for K and then having figured out the start node  N2 of the cycle.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.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Questions on my project please be prepare well about your project&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;How do you search for a word in a large database.&lt;/li&gt;&lt;li&gt;How do you build address bar in say gmail. i.e. 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'.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;a href="http://placementsindia.blogspot.com/2007/09/google-interview-questions.html"&gt;Google Interview Round 3&lt;/a&gt; ::&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;You have given an array. Find the maximum and minimum numbers in less number of comparisons.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;br /&gt;only 3n/2 comparisons are necessary to find both the minimum and the maximum. To do this, we maintain the minimum and maximum elements seen thus far. Rather than processing each element of the input by comparing it against the current minimum and maximum, however, at a cost of two comparisons per element, we process elements in pairs. We compare pairs of elements from the input first with each other, and then compare the smaller to the current minimum and the larger to the current maximum, at a cost of three comparisons for every two elements.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;You have given an array from 1 to N and numbers also from 1 to N. But more than one number is missing and some numbers have repeated more than once. Find the algo with running time O(n).&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;All the numbers are positive to start with.Now, For each A[i], Check the sign of A[A[i]]. Make  A[A[i]] negative if it's positive. Report a repetition if it's negative.Finally all those entries i,for which A[i] is negative are present and those i for which A[i] is positive are absent.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;a href="http://placementsindia.blogspot.com/2007/09/google-interview-questions.html"&gt;Google Interview Round 4&lt;/a&gt; ::&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Three strings say A,B,C are given to you. Check weather 3rd string is interleaved from string A and B.&lt;br /&gt;&lt;pre&gt;       Ex: A="abcd" B="xyz" C="axybczd". answer is yes.&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;bool test(A,B,C)&lt;br /&gt;{&lt;br /&gt;  i=j=k=0;&lt;br /&gt;  while(k &lt; C.size())&lt;br /&gt;  {&lt;br /&gt;    if(i &lt; A.size() &amp;&amp; C[k]==A[i])&lt;br /&gt;     {i++,k++;&lt;br /&gt;     }&lt;br /&gt;    else if(j &lt; B.size() &amp;&amp; C[k]==B[j])&lt;br /&gt;    {&lt;br /&gt;      j++,k++;&lt;br /&gt;    }&lt;br /&gt;    else&lt;br /&gt;    return false  &lt;br /&gt;  }&lt;br /&gt;  return (i == A.size() &amp;&amp; j == B.size());&lt;br /&gt;} &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The above algorithm doesn't work when C[k]=A[i]=B[j], essentially throwing one in to a dilemma whether to accept the character from A or B.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Given two sorted arrays A and B. &lt;br /&gt;&lt;/li&gt;&lt;ol&gt;&lt;li&gt;Find the intersection of these arrays A and B.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;The intersection can be found by using a variation of merge routine of the merge sort.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;If array A is small and array B is too large. how will you proceed for getting intersection of those two arrays?&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;In this case for each entry of smaller array,we can run a binary search routine on the larger one to know its presence.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;a href="http://placementsindia.blogspot.com/2007/09/google-interview-questions.html"&gt;Google Interview Round 5&lt;/a&gt; ::&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;If you get into Google, which products are you going to work on?&lt;/li&gt;&lt;li&gt;What is TCP, UDP. what is reliability, unreliability, give examples of these?&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Transmission_Control_Protocol"&gt;Click Here To Read About TCP&lt;/a&gt;&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/User_Datagram_Protocol"&gt;Click Here To Read About UDP&lt;/a&gt;&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Reliability_%28computer_networking%29"&gt;Click Here To Read About Reliability&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;What is http protocol?&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/HTTP"&gt;Click Here To Read About HTTP&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;How does Google search engine works?&lt;/li&gt;&lt;li&gt;What is indexing, what is the input and output to it. how Google does that?&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;This was the interview i got from one of my friends. Discuss them here. &lt;span style="font-weight: bold;"&gt;If you had attended Google Interview share you interview experience with us&lt;/span&gt;.You can post the questions through comments section or you can mail me at kchaitanyya@gmail.com</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">11</thr:total><author>kchaitanyya@gmail.com (chaitanya)</author></item><item><title>Google Fresher&amp;#39;s latest Interview Questions</title><link>http://placementsindia.blogspot.com/2007/08/google-freshers-latest-interview.html</link><category>Google</category><pubDate>Wed, 23 Apr 2008 21:21:00 +0530</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-32064785.post-4790248902321255343</guid><description>&lt;a href="http://placementsindia.blogspot.com/2007/08/google-freshers-latest-interview.html"&gt;&lt;span style="font-weight: bold"&gt;Google telephonic Interview&lt;/span&gt;&lt;/a&gt;   &lt;ol&gt;   &lt;li&gt;Asked about my project. Prepare well to answer any type of questions that may arise in your project.They will just ask to explain about any one of the projects listed in your resume. &lt;/li&gt;    &lt;li&gt;In a plane, n points are given i.e. the input is (x1,y1),  (x2,y2)... (xn,yn). Now given these n points.Find the maximum number of collinear points.      &lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;       &lt;br /&gt;The duality algorithm would work. Find the point of intersection with maximum no of lines incident on it in the dual plane. It works in O(n^2). &lt;/li&gt;    &lt;li&gt;Write the code for finding the min of n number.      &lt;pre&gt;I gave:&lt;br /&gt;&lt;br /&gt;for(i=0;i&amp;lt;n;i++)&lt;br /&gt;{&lt;br /&gt;   if( a[i]&amp;lt;min )&lt;br /&gt;   {&lt;br /&gt;         min = a[i] ---- eq(i)&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Given that n numbers are from random sampling how many times (probability) does the line (i) be executed &lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt; &lt;br /&gt;&lt;br /&gt;    &lt;pre&gt;min=a[0];&lt;br /&gt;for(i=1;i&amp;lt;n;i++)&lt;br /&gt;{&lt;br /&gt;    if( a[i]&amp;lt;min )    &lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        min = a[i]; -------eq(i)  &lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;Once the variable min is initialized,the probability of a[i] &amp;lt; min is 1/2. So the expected number of occurances of equation i is (n-1)/2 . &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;span style="font-weight: bold"&gt;&lt;a href="http://placementsindia.blogspot.com/2007/08/google-freshers-latest-interview.html"&gt;Google Interview Round 2&lt;/a&gt;:&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;What is Bottom up parsing and what is top down parsing? &lt;br /&gt;    &lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt; &lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;&lt;strong&gt;Bottom-up&lt;/strong&gt; parsing is a strategy for analyzing unknown data relationships that attempts to identify the most fundamental units first, and then to infer higher-order structures from them. It attempts to build trees upward toward the start symbol. It occurs in the analysis of both natural languages and computer languages. &lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;&lt;strong&gt;Top-down&lt;/strong&gt; 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. It occurs in the analysis of both natural languages and computer languages. Please refer to these links for much better information. &lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Bottom-up_parsing"&gt;http://en.wikipedia.org/wiki/Bottom-up_parsing&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Top-down_parsing"&gt;http://en.wikipedia.org/wiki/Top-down_parsing&lt;/a&gt; &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;What is a symbol table? &lt;br /&gt;  &lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt; &lt;br /&gt;In computer science, a symbol table is a data structure used by a language translator such as a compiler or interpreter, where each identifier in a program's source code is associated with information relating to its declaration or appearance in the source, such as its type, scope level and sometimes its location.&lt;br /&gt;Check out &lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Symbol_table"&gt; http://en.wikipedia.org/wiki/Symbol_table&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;There is a portal with two billion users registered. 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. How do you handle this situation to make sure that the user gets the response quickly.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;br /&gt;Every row has a primary key. Suppose the primary key for this&lt;br /&gt;particular database is the name of the user then we can sort the names based&lt;br /&gt;on alphabets and do secondary indexing based on the starting alphabet . If&lt;br /&gt;the data is uniformly distributed we can go for multilevel indexing or&lt;br /&gt;hashing.Similarly if we have a registration number as the primary key then&lt;br /&gt;we can sort the table based on registration number and then do indexing&lt;br /&gt;either secondary level or multilevel or apply hashing techniques based on&lt;br /&gt;the distribution of data. Many efficient algorithms are available for&lt;br /&gt;indexing and hashing.&lt;br /&gt;&lt;br /&gt; &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;There are 8 identical balls. One of them is defective. It could be either heavier of lighter. Given a common balance how do you find the defective ball in least number of weighings.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;br /&gt;Weigh 3 balls against 3 others. &lt;br /&gt;      &lt;span style="font-weight:bold;"&gt;Case A:&lt;/span&gt; If, on the first weighing, the balls balance, then the defective is among the 2 remaining balls and can be                                              determined using 2 weighings making it a total of 3.&lt;br /&gt;&lt;br /&gt;      &lt;span style="font-weight:bold;"&gt;Case B&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;       &lt;span style="font-style:italic;"&gt;Step1:&lt;/span&gt; If, on the first weighing, the balls don't balance.&lt;br /&gt;                   If the balls do not balance on the first weighing, we know that the odd ball is one of the 6 balls that was weighed. We also know that the group of 2 unweighed balls are normal, and that one of the sides, let's say Side A, is heavier than the other (although we don't know whether the odd ball is heavy or light). &lt;br /&gt;       &lt;span style="font-style:italic;"&gt;Step 2 &lt;/span&gt;: Take 2 balls from the unweighed group and use them to replace 2 balls on Side A (the heavy side). Take the 2 balls from Side A and use them to replace 2 balls on Side B (which are removed from the scale). &lt;br /&gt;&lt;br /&gt;                  I. If the scale balances, we know that one of the 2 balls removed from the scale was the odd one. In this case, we know that the ball is also light. We can proceed with the third weighing amd determine the lighter of the 2 balls ,hance the defective.&lt;br /&gt;&lt;br /&gt;                 II. If the scale tilts to the other side, so that Side B is now the heavy side, we know that one of the three balls moved from Side A to Side B is the odd ball, and that it is heavy. We proceed with the third weighing and determine the heavier one ,the defective. &lt;br /&gt;&lt;br /&gt;                III. If the scale remains the same, we know that one of the two balls on the scale that was not shifted in our second weighing is the odd ball. 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).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;     &lt;span style="font-style:italic;"&gt;Step 3 (for Case B)&lt;/span&gt;: Weigh the ball from Side A against a normal ball. If the scale balances, the ball from Side B is the odd one, and is light. If the scale does not balance, the ball from Side A is the odd one, and is heavy.&lt;br /&gt;&lt;br /&gt; &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;You have all the English words with you. you would like to manage a dictionary so that you can look up when ever you have doubt. Which data structure would you like to use and why?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;br /&gt;Dozens of different data structures have been proposed for implementing dictionaries including hash tables, skip lists, and balanced/unbalanced binary search trees -- so choosing the right one can be tricky. Depending on the application, it is also a decision that can significantly impact performance.  In practice, it is more important to avoid using a bad data structure than to identify the single best option available.As the frequency of look ups for a word is also important,weighted binary search tree with weights in proportion to the frequency of lookups and determining the depth, can be effective.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Asked me about all the details of hash table and heaps. &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Write code for finding number of zeros in n!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;A zero in n! typically occurs when a multiple of 5 gets multiplied to an even number.We use this simple yet effective information to solve this problem.In the first n natural numbers,those divisible by 5 are always less than the no of even numbers.So it all boils down to  the power of 5 in the prime factorization of n! .&lt;br /&gt;This simple formula works for finding it  floor(n/5)+floor(n/25)+floor(n/125)+......&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;function zeros(int n)&lt;br /&gt;{&lt;br /&gt;  int count=0,k=5;&lt;br /&gt;while(n&gt;=k)&lt;br /&gt;{&lt;br /&gt; count+=n/k;&lt;br /&gt;        k*=5;&lt;br /&gt;}&lt;br /&gt;return count;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;this count is the number of o's in n!.&lt;br /&gt;  &lt;br /&gt; &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-weight: bold"&gt;&lt;a href="http://placementsindia.blogspot.com/2007/08/google-freshers-latest-interview.html"&gt;Google Interview Round 3&lt;/a&gt; :&lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;Write C++ class for the game Connect Four. [Connect Four (also known as Plot Four, Four In A Row, 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.] &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Given a stack and an input string of 1234.At any point you can do anyone of the follow &lt;br /&gt;    &lt;pre&gt;i. take the next input symbol and Enque.&lt;br /&gt;ii. you can pop as many as you can. When ever you&lt;br /&gt;pop an element it will be printed&lt;br /&gt;            (you cannot pop from an empty stack)&lt;/pre&gt;&lt;br /&gt;How many such permutations are possible on an input of size N?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;br /&gt; It is Nth catalan number.For a detailed solution look at question5 of &lt;a href= "http://placementsindia.blogspot.com/2007/09/stack-and-queue.html"&gt;Stacks and Queues&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;  &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Give an example of one permutation that this data structure cannot generate. &lt;br /&gt;    &lt;pre&gt;For Example:&lt;br /&gt;&lt;br /&gt;1234 is input.&lt;br /&gt;&lt;br /&gt;First push all 1,2,3,4 on to stack and pop all.&lt;br /&gt;    output will be 4321.&lt;/pre&gt;&lt;br /&gt;It means that this data structure can generate 4321.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;br /&gt;3124 &lt;br /&gt;       for a detailed solution please look at question7 of the post&lt;br /&gt; &lt;a href= "http://placementsindia.blogspot.com/2007/09/stack-and-queue.html"&gt;Stacks and Queues&lt;/a&gt;&lt;br /&gt;&lt;br /&gt; &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Question 2 was pretty easy right? Now do again the same question but the data structure this time around is a Deque. &lt;br /&gt;    &lt;pre&gt;Input: 12345&lt;br /&gt;Data Structure: Deque ( Doubly Que )&lt;br /&gt;&lt;br /&gt;Note: Deque is a data structure into which you can do enque&lt;br /&gt;    and deque from both sides.Some thing like this&lt;br /&gt;__________________________________&lt;br /&gt;enque ---&amp;gt; &amp;lt;----enque dequeue &amp;lt;---- -----&amp;gt;dequeue&lt;br /&gt;__________________________________&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt; &lt;br /&gt;It is N!. Guess why?(no constraints).Convince yourself by proving that every permutation can be generated by a set of valid operations.This prove can be using the principle of strong mathematical induction.So for this specific input the answer is 120.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Classic Egg Puzzle Problem You are given 2 eggs.You have access to a 100-store building. 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 th floor.Both eggs are identical.You need to figure out the highest floor of a 100-store building an egg can be dropped without breaking. Now the question is how many drops you need to make. You are allowed to break 2 eggs in the process.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt; &lt;br /&gt;Let "d" be the number of drops required to find out the max floor.we need to get the value of d.&lt;br /&gt;&lt;br /&gt;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 max of "d" drops, 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,so lets drop it from d + 'd-2' + 1 height suppose if it break there then you are left with 'd-2' drops.&lt;br /&gt;and so on until that sum is less than 100, it's like a linear search,&lt;br /&gt;&lt;br /&gt;in equations,&lt;br /&gt;&lt;br /&gt; (1+(d-1))+ (1+(d-2)) + .... &gt;= 100&lt;br /&gt;&lt;br /&gt;here we need to find out d&lt;br /&gt;&lt;br /&gt;from the above equation&lt;br /&gt;&lt;br /&gt;d(d + 1)/2 &gt;= 100&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;from above d is 14&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-weight: bold"&gt;&lt;a href="http://placementsindia.blogspot.com/2007/08/google-freshers-latest-interview.html"&gt;Google Interview Round 4&lt;/a&gt; :&lt;/span&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;Given n non overlapping intervals and an element. Find the interval into which this element falls.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt; &lt;br /&gt;we can extend binary search to intervals.(Assuming the intervals are sorted)&lt;br /&gt;consider interval [a,b].&lt;br /&gt;if (a-x)(b-x) &lt;=0 &lt;br /&gt;    then x belongs to [a,b].&lt;br /&gt;else&lt;br /&gt;     if x&gt;a &lt;br /&gt;    element can be present only in the intervals to its right. &lt;br /&gt;         so select the middle interval among them to it's right&lt;br /&gt;         and repeat the procedure.&lt;br /&gt;     else&lt;br /&gt;    element can be present only in the intervals to its left. &lt;br /&gt;         so select the middle interval among them to it's left&lt;br /&gt;         and repeat the procedure.&lt;br /&gt;&lt;br /&gt;The complexity of this problem is log(N) where N is the number of sorted non-overlapping intervals.&lt;br /&gt; &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Worst case is take all intervals one at a time and see whether the element lies in the interval or not.It will take O(n). So please give a solution that will do better than O(n). &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Now given that the n intervals are overlapping then how do you solve? The interviewer was concentrating more on the complexities (running, memory ..) &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt; &lt;br /&gt;If the above intervals are overlapping ,then they can be merged in O(N) and then the exact intervals can be resolved later.Otherwise ,we can identify one correct interval and then linear search on its left and right neighbourhood to find the other solutions.&lt;br /&gt;   &lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Write code for Random Sort? &lt;br /&gt;    &lt;pre&gt;Algorithm  is explained:&lt;br /&gt;&lt;br /&gt;Given an input array of size n. Random sort is sampling&lt;br /&gt;a new array from the given array and check whether the&lt;br /&gt;sampled array is sorted or not. If sorted return else&lt;br /&gt;sample again. The stress was on the&lt;br /&gt;code.&lt;/pre&gt;&lt;br /&gt;  &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-weight: bold"&gt;&lt;a href="http://placementsindia.blogspot.com/2007/08/google-freshers-latest-interview.html"&gt;Google Interview Round 5&lt;/a&gt;:&lt;/span&gt; This is Manager Round &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;Tell me an achievement that you have done in your non academics &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Tell me about one of your project &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Take a feature of C++ and tell me how you have implemented it in one of your project &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;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 &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;There is a routine already written to find the subtraction of two sets ( set A - set B) . Write test cases for testing it.Tell me how do you test the test cases you have written? &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;There is a printed book. The page numbers are not printed. Now the printing of page numbers is being done separately. If the total number of digits printed is 1095 then how many pages does the book have? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt; Well people,this is too simple a question ..so do give it a try..(no malice,too simple).Any queries then do shoot a comment.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">19</thr:total><author>kchaitanyya@gmail.com (chaitanya)</author></item><item><title>Yahoo Interview Questions</title><link>http://placementsindia.blogspot.com/2007/09/yahoo-interview-questions.html</link><category>yahoo</category><pubDate>Thu, 27 Mar 2008 13:33:00 +0530</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-32064785.post-6188022626064210064</guid><description>&lt;p&gt;&lt;span style="font-weight: bold;"&gt;Yahoo Telephonic Round:&lt;/span&gt;    &lt;br /&gt;  &lt;br /&gt;&lt;strong&gt;Design classes for the following problem. (C++)     &lt;br /&gt;&lt;/strong&gt;   &lt;br /&gt;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.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Solution :&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Customer class, Account class, Transaction class   &lt;br /&gt;Customer class contains an array of pointers to the account classes    &lt;br /&gt;Account class contains an array of pointers to its owner customer classes    &lt;br /&gt;Account class also contains an array of transactions associated to it.    &lt;br /&gt;Transaction class contains id or pointer the customer who did that transaction    &lt;br /&gt;In customer class write a function with prototype &lt;/p&gt; &lt;br /&gt;&lt;pre&gt;for (i in Accounts )&lt;br /&gt;{&lt;br /&gt; cout &amp;lt;&amp;lt; i.AccountName &amp;lt;&amp;lt; endl; &lt;br /&gt;} &lt;br /&gt;cin &amp;gt;&amp;gt; id; &lt;br /&gt;for(i in Accounts[id].transactions ) &lt;br /&gt;{ &lt;br /&gt; cout &amp;lt;&amp;lt; i.TransDetails &amp;lt;&amp;lt; endl;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;  &lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Yahoo Interview Round 1:&lt;/span&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;&lt;strong&gt;How to call a C++ function which is compiled with C++ compiler in C code?       &lt;br /&gt;&lt;/strong&gt;     &lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt; The C++ compiler must know that f(int,char,float) is to be called by a C compiler using the extern "C"construct:      &lt;br /&gt;    &lt;br /&gt;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.  &lt;br /&gt;  &lt;pre&gt;// This is C++ code &lt;br /&gt;// Declare f(int,char,float) using extern &amp;quot;C&amp;quot;: &lt;br /&gt;extern &amp;quot;C&amp;quot; void f(int i, char c, float x); &lt;br /&gt;... &lt;br /&gt;// Define f(int,char,float) in some C++ module: &lt;br /&gt;void f(int i, char c, float x)&lt;br /&gt;{ &lt;br /&gt;   ..... &lt;br /&gt;} &lt;/pre&gt;&lt;br /&gt;    &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;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) &lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;How do you initialize a static member of a class with return value of some function? &lt;/strong&gt;      &lt;blockquote&gt;       &lt;p&gt;&lt;strong&gt;Solution :&lt;/strong&gt;&lt;/p&gt;        &lt;p&gt;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. &lt;/p&gt;        &lt;p&gt;Consider the following class, A, with a static data member, _id: &lt;/p&gt;  &lt;pre&gt;   &lt;br /&gt;  //File: a.h&lt;br /&gt;   class A&lt;br /&gt;   {&lt;br /&gt;      public:&lt;br /&gt;      A();&lt;br /&gt;      int _id;&lt;br /&gt;   };&lt;/pre&gt;      &lt;p&gt;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: &lt;/p&gt;&lt;pre&gt;   // File: a.cc&lt;br /&gt;   int A::_id;&lt;/pre&gt;&lt;p&gt;Because no explicit initial value was specified, the compiler will implicitly initialize _id to zero. An explicit initialization can also be specified: &lt;/p&gt;     &lt;pre&gt;&lt;br /&gt;// File: a.cc&lt;br /&gt; int A::_id = 999;&lt;br /&gt; &lt;/pre&gt;    &lt;p&gt;In fact, C++ even allows arbitrary expressions to be used in initializers: &lt;/p&gt;    &lt;pre&gt;      // File: a.cc&lt;br /&gt;   int A::_id = GetId();    &lt;/pre&gt;  &lt;/blockquote&gt;   &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;How can one application use same API provided by different vendors at the same time? &lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;If you are given the name of the function at run time how will you invoke the function? &lt;/strong&gt;      &lt;blockquote&gt;       &lt;p&gt;&lt;strong&gt;Solution :&lt;/strong&gt;&lt;/p&gt;        &lt;ul&gt;         &lt;li&gt;Compile your program with --export-dynamic on the gcc command line &lt;/li&gt;          &lt;li&gt;Link with -ldl (dynamic library handling, needed for dlopen and dlsym &lt;/li&gt;          &lt;li&gt;Call dlopen() with a null parameter, meaning you aren't loading symbols from a file but from the current executable &lt;/li&gt;          &lt;li&gt;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). &lt;/li&gt;          &lt;li&gt;If dlsym() returns non-null, use the returned value as a function pointer to invoke your function. &lt;/li&gt;       &lt;/ul&gt;     &lt;/blockquote&gt;   &lt;/li&gt; &lt;/ol&gt; &lt;span style="font-weight: bold;"&gt;Yahoo Interview Round 2:&lt;/span&gt;   &lt;ol&gt;   &lt;li&gt;&lt;strong&gt;When will you use shell script/Perl ahead of C/C++? &lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;How does yahoo handles billions of requests, does it create a thread per request or a process? &lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;How does HTTP works? &lt;/strong&gt;      &lt;blockquote&gt;       &lt;p&gt;&lt;strong&gt;Solution :&lt;/strong&gt;HTTP Is a request-response protocol. &lt;/p&gt;        &lt;p&gt;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. &lt;/p&gt;     &lt;/blockquote&gt;   &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;How to count number of unique music titles downloaded from a log file which contains an entry of all music title downloaded? &lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;What is the difference between COM and CORBA? &lt;/strong&gt;      &lt;blockquote&gt;       &lt;p&gt;&lt;strong&gt;Solution :&lt;/strong&gt;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. &lt;/p&gt;     &lt;/blockquote&gt;   &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;What is web service? &lt;/strong&gt;      &lt;blockquote&gt;       &lt;p&gt;&lt;strong&gt;Solution :&lt;/strong&gt;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. &lt;/p&gt;     &lt;/blockquote&gt;   &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;I got only these two Rounds as of now, if I get any more I will post them here. &lt;span style="font-weight: bold;"&gt;If you have attended yahoo interview please share your experience and questions with us.&lt;/span&gt; You can mail them at kchaitanyya@gmail.com or you can comment here.Solutions for rest of questions will be provided later.if you know any of the questions which are unsolved please comment the solution. we will include.&lt;/p&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">16</thr:total><author>kchaitanyya@gmail.com (chaitanya)</author></item><item><title>Latest Microsoft Interview Questions</title><link>http://placementsindia.blogspot.com/2008/02/latest-microsoft-interview-questions.html</link><category>Microsoft</category><pubDate>Tue, 25 Mar 2008 14:59:00 +0530</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-32064785.post-6178698701005861209</guid><description>&lt;ol&gt;   &lt;li&gt;Given a Parent -Child binary tree ,build the child -sibling version of it? Minimize the space requirements wherever possible.     &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Given a binary tree build a linked list of all its nodes such that the nodes of a level appear before the nodes of the next level?     &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Given an infinite stream of bits with the bits being appended at the highest significant position. give an algorithm to to say &lt;a href="http://placementsindia.blogspot.com/2008/02/latest-microsoft-interview-questions.html"&gt;whether the number&lt;/a&gt; formed by using the sequence of bits that had been processed till then, is divisible by 3 or not?     &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Given a string S of words and no of character per line m ,with m being greater than the longest word in S,print S in a set of lines so that each line contains no more than m characters and no word split between 2 lines.     &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Given an expression remove the unnecessary brackets in it with out creating an ambiguity in its execution. &lt;code&gt;      &lt;br /&gt;&lt;/code&gt;&lt;code&gt;  input output &lt;/code&gt; &lt;br /&gt;&lt;code&gt;  ex1: (a+(b)+c) a+b+c       &lt;br /&gt;  ex2: (a*b)+c a*b+c &lt;/code&gt;     &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Propose a tree based data structure to identify a node with nth &lt;a href="http://placementsindia.blogspot.com/2008/02/latest-microsoft-interview-questions.html"&gt;rank with maximum&lt;/a&gt; efficiency .     &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Given a string S of alphabets and 2 characters a,b find the minimum distance between instances of them such that position of a &amp;lt;= position of b.     &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Given an array of size n with first l positions filled with characters and a string s ,replace all the instances of ’%’ with this string s,given that the length of the array is sufficient to handle these substitutions. &lt;br /&gt;&lt;code&gt;input output &lt;/code&gt;     &lt;br /&gt;&lt;code&gt;eg: abcdef%ghi%—— and “ppp” abcdefpppghippp &lt;/code&gt;     &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Given a binary tree verify whether it is a binary search tree or not?     &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Write a C code to merge 2 binary search trees and do the same 2 merge linked lists.How is the former different when compared to the later.(Discuss the issues)     &lt;br /&gt;    &lt;br /&gt;&lt;/li&gt; &lt;/ol&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">6</thr:total><author>kchaitanyya@gmail.com (Unknown)</author></item><item><title>Interview Questions on C Programming Variables</title><link>http://placementsindia.blogspot.com/2008/03/scope-of-c-programming-variables.html</link><category>CrackTheInterview</category><pubDate>Tue, 25 Mar 2008 14:37:00 +0530</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-32064785.post-3992193326007771896</guid><description>&lt;ol&gt;   &lt;li&gt;&lt;strong&gt;What is the difference between the declaration and the definition of a variable?&lt;/strong&gt;       &lt;p&gt;The definition is the one that actually allocates space, and provides an initialization value, if any.        &lt;br /&gt;There can be many declarations, but there must be exactly one definition. A definition tells the compiler to set aside storage for the variable. A declaration makes the variable known to parts of the program that may wish to use it. A variable might be defined and declared in the same statement. &lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Do Global variables start out as zero?&amp;#160; &lt;br /&gt;&lt;/strong&gt;      &lt;p&gt;Un initialized variables declared with the &amp;quot;static&amp;quot; keyword are initialized to zero. Such variables are implicitly initialized to the null pointer if they are pointers, and to 0.0F if they are floating point numbers.        &lt;br /&gt;Local variables start out containing garbage, unless they are explicitly initialized.         &lt;br /&gt;Memory obtained with malloc() and realloc() is likely to contain junk, and must be initialized. Memory obtained with calloc() is all-bits-0, but this is not necessarily useful for pointer or floating-point values (This is in contrast to Global pointers and Global floating point numbers, which start as zeroes of the right type). &lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Does C have boolean variable type?&lt;/strong&gt;       &lt;p&gt;No, C does not have a boolean variable type. One can use ints, chars, #defines or enums to achieve the same in C.        &lt;br /&gt;&lt;code&gt;         &lt;br /&gt;#define TRUE 1&amp;#160; &lt;br /&gt;#define FALSE 0&amp;#160; &lt;br /&gt;enum bool {false, true};           &lt;br /&gt;&lt;/code&gt;        &lt;br /&gt;An enum may be good if the debugger shows the names of enum constants when examining variables.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Where may variables be defined in C?&lt;/strong&gt;       &lt;p&gt;Outside a function definition (global scope, from the point of definition downward in the source code). Inside a block before any statements other than variable declarations (local scope with respect to the block).&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;To what does the term storage class refer? What are auto, static, extern, volatile, const classes?&lt;/strong&gt;       &lt;p&gt;This is a part of a variable declaration that tells the compiler how to interpret the variable's symbol. It does not in itself allocate storage, but it usually tells the compiler how the variable should be stored. Storage class specifiers help you to specify the type of storage used for data objects. Only one storage class specifier is permitted in a declaration this makes sense, as there is only one way of storing things and if you omit the storage class specifier in a declaration, a default is chosen. The default depends on whether the declaration is made outside a function (external declarations) or inside a function (internal declarations). For external declarations the default storage class specifier will be extern and for internal declarations it will be auto. The only exception to this rule is the declaration of functions, whose default storage class specifier is always extern.        &lt;br /&gt;Here are C's storage classes and what they signify:&lt;/p&gt;      &lt;ul&gt;       &lt;li&gt;auto - local variables. &lt;/li&gt;        &lt;li&gt;static - variables are defined in a nonvolatile region of memory such that they retain their contents though out the program's execution. &lt;/li&gt;        &lt;li&gt;register - asks the compiler to devote a processor register to this variable in order to speed the program's execution. The compiler may not comply and the variable looses it contents and identity when the function it which it is defined terminates. &lt;/li&gt;        &lt;li&gt;extern - tells the compiler that the variable is defined in another module. &lt;/li&gt;     &lt;/ul&gt;      &lt;br /&gt;In C, const and volatile are type qualifiers. The const and volatile type qualifiers are completely independent. A common misconception is to imagine that somehow const is the opposite of volatile and vice versa. This is wrong. The keywords const and volatile can be applied to any declaration, including those of structures, unions, enumerated types or typedef names. Applying them to a declaration is called qualifying the declaration?that's why const and volatile are called type qualifiers, rather than type specifiers.       &lt;ul&gt;       &lt;li&gt;const means that something is not modifiable, so a data object that is declared with const as a part of its type specification must not be assigned to in any way during the run of a program. The main intention of introducing const objects was to allow them to be put into read-only store, and to permit compilers to do extra consistency checking in a program. Unless you defeat the intent by doing naughty things with pointers, a compiler is able to check that const objects are not modified explicitly by the user. It is very likely that the definition of the object will contain an initializer (otherwise, since you can't assign to it, how would it ever get a value?), but this is not always the case. For example, if you were accessing a hardware port at a fixed memory address and promised only to read from it, then it would be declared to be const but not initialized. &lt;/li&gt;        &lt;li&gt;volatile tells the compiler that other programs will be modifying this variable in addition to the program being compiled. For example, an I/O device might need write directly into a program or data space. Meanwhile, the program itself may never directly access the memory area in question. In such a case, we would not want the compiler to optimize-out this data area that never seems to be used by the program, yet must exist for the program to function correctly in a larger context. It tells the compiler that the object is subject to sudden change for reasons which cannot be predicted from a study of the program itself, and forces every reference to such an object to be a genuine reference. &lt;/li&gt;        &lt;li&gt;const volatile - Both constant and volatile. &lt;/li&gt;     &lt;/ul&gt;      &lt;br /&gt;The &amp;quot;volatile&amp;quot; modifier       &lt;br /&gt;The volatile modifier is a directive to the compiler?s optimizer that operations involving this variable should not be optimized in certain ways. There are two special cases in which use of the volatile modifier is desirable. The first case involves memory-mapped hardware (a device such as a graphics adaptor that appears to the computer?s hardware as if it were part of the computer?s memory), and the second involves shared memory (memory used by two or more programs running simultaneously). Most computers have a set of registers that can be accessed faster than the computer?s main memory. A good compiler will perform a kind of optimization called ?redundant load and store removal.? The compiler looks for places in the code where it can either remove an instruction to load data from memory because the value is already in a register, or remove an instruction to store data to memory because the value can stay in a register until it is changed again anyway.       &lt;br /&gt;If a variable is a pointer to something other than normal memory, such as memory-mapped ports on a       &lt;br /&gt;peripheral, redundant load and store optimizations might be detrimental. For instance, here?s a piece of code that might be used to time some operation:       &lt;br /&gt;&lt;code&gt;       &lt;br /&gt;time_t time_addition(volatile const struct timer *t, int a)&amp;#160; &lt;br /&gt;{&amp;#160; &lt;br /&gt;&amp;#160; int n;&amp;#160; &lt;br /&gt;&amp;#160; int x;&amp;#160; &lt;br /&gt;&amp;#160; time_t then;&amp;#160; &lt;br /&gt;&amp;#160; x = 0;&amp;#160; &lt;br /&gt;&amp;#160; then = t-&amp;gt;value;&amp;#160; &lt;br /&gt;&amp;#160; for (n = 0; n &amp;lt; 1000; n++)&amp;#160; &lt;br /&gt;&amp;#160; {&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; x = x + a;&amp;#160; &lt;br /&gt;&amp;#160; }&amp;#160; &lt;br /&gt;&amp;#160; return t-&amp;gt;value - then;&amp;#160; &lt;br /&gt;}&amp;#160; &lt;br /&gt;&lt;/code&gt;      &lt;br /&gt;In this code, the variable t-&amp;gt;value is actually a hardware counter that is being incremented as time passes. The function adds the value of a to x 1000 times, and it returns the amount the timer was incremented by while the 1000 additions were being performed. Without the volatile modifier, a clever optimizer might assume that the value of t does not change during the execution of the function, because there is no statement that explicitly changes it. In that case, there?s no need to read it from memory a second time and subtract it, because the answer will always be 0. The compiler might therefore ?optimize? the function by making it always return 0. If a variable points to data in shared memory, you also don?t want the compiler to perform redundant load and store optimizations. Shared memory is normally used to enable two programs to communicate with each other by having one program store data in the shared portion of memory and the other program read the same portion of memory. If the compiler optimizes away a load or store of shared memory, communication between the two programs will be affected. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;What does the typedef keyword do?&lt;/strong&gt;       &lt;p&gt;This keyword provides a short-hand way to write variable declarations. It is not a true data typing mechanism, rather, it is syntactic &amp;quot;sugar coating&amp;quot;.        &lt;br /&gt;For example         &lt;br /&gt;&lt;code&gt;         &lt;br /&gt;typedef struct node           &lt;br /&gt;{           &lt;br /&gt;&amp;#160; int value;           &lt;br /&gt;&amp;#160; struct node *next;           &lt;br /&gt;}mynode;           &lt;br /&gt;&lt;/code&gt;        &lt;br /&gt;This can later be used to declare variables like this         &lt;br /&gt;&lt;code&gt;         &lt;br /&gt;mynode *ptr1;           &lt;br /&gt;and not by the lengthy expression           &lt;br /&gt;struct node *ptr1;           &lt;br /&gt;&lt;/code&gt;        &lt;br /&gt;There are three main reasons for using typedefs:&lt;/p&gt;      &lt;ul&gt;       &lt;li&gt;It makes the writing of complicated declarations a lot easier. This helps in eliminating a lot of clutter in the code. &lt;/li&gt;        &lt;li&gt;It helps in achieving portability in programs. That is, if we use typedefs for data types that are machine dependent, only the typedefs need to change when the program is ported to a new platform. &lt;/li&gt;        &lt;li&gt;It helps in providing better documentation for a program. For example, a node of a doubly linked list is better understood as ptrToList than just a pointer to a complicated structure. &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;What is the difference between constants defined through #define and the constant keyword?&lt;/strong&gt;       &lt;p&gt;A constant is similar to a variable in the sense that it represents a memory location (or simply, a value). It is different from a normal variable, in that it cannot change it's value in the proram - it must stay for ever stay constant. In general, constants are a useful because they can prevent program bugs and logical errors(errors are explained later). Unintended modifications are prevented from occurring. The compiler will catch attempts to reassign new values to constants.        &lt;br /&gt;Constants may be defined using the preprocessor directive #define. They may also be defined using the const keyword.         &lt;br /&gt;So whats the difference between these two?         &lt;br /&gt;&lt;code&gt;         &lt;br /&gt;#define ABC 5           &lt;br /&gt;and           &lt;br /&gt;const int abc = 5;           &lt;br /&gt;&lt;/code&gt;        &lt;br /&gt;There are two main advantages of the second one over the first technique. First, the type of the constant is defined. &amp;quot;pi&amp;quot; is float. This allows for some type checking by the compiler. Second, these constants are variables with a definite scope. The scope of a variable relates to parts of your program in which it is defined.         &lt;br /&gt;There is also one good use of the important use of the const keyword. Suppose you want to make use of some structure data in some function. You will pass a pointer to that structure as argument to that function. But to make sure that your structure is readonly inside the function you can declare the structure argument as const in function prototype. This will prevent any accidental modification of the structure values inside the function. &lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;What are Trigraph characters?&lt;/strong&gt;       &lt;p&gt;These are used when you keyboard does not support some special characters        &lt;br /&gt;&lt;code&gt;         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ??=&amp;#160;&amp;#160;&amp;#160; #           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ??(&amp;#160;&amp;#160;&amp;#160; [           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ??)&amp;#160;&amp;#160;&amp;#160; ]           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ??&amp;lt;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ??&amp;gt;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ??!&amp;#160;&amp;#160;&amp;#160; |           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ??/&amp;#160;&amp;#160;&amp;#160; \           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ??'&amp;#160;&amp;#160;&amp;#160; ^           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ??-&amp;#160;&amp;#160;&amp;#160; ~           &lt;br /&gt;&lt;/code&gt;&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;How are floating point numbers stored? Whats the IEEE format?&lt;/strong&gt;       &lt;p&gt;IEEE Standard 754 floating point is the most common representation today for real numbers on computers, including Intel-based PC's, Macintoshes, and most Unix platforms.        &lt;br /&gt;IEEE floating point numbers have three basic components: the sign, the exponent, and the mantissa. The mantissa is composed of the fraction and an implicit leading digit (explained below). The exponent base(2) is implicit and need not be stored.         &lt;br /&gt;The following figure shows the layout for single (32-bit) and double (64-bit) precision floating-point values. The number of bits for each field are shown (bit ranges are in square brackets):         &lt;br /&gt;&lt;code&gt;         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Sign&amp;#160;&amp;#160; Exponent&amp;#160;&amp;#160; Fraction&amp;#160;&amp;#160; Bias&amp;#160; &lt;br /&gt;--------------------------------------------------           &lt;br /&gt;Single Precision 1 [31] 8 [30-23]&amp;#160; 23 [22-00] 127&amp;#160; &lt;br /&gt;Double Precision 1 [63] 11 [62-52] 52 [51-00] 1023&amp;#160; &lt;br /&gt;&lt;/code&gt;        &lt;br /&gt;The sign bit is as simple as it gets. 0 denotes a positive number; 1 denotes a negative number. Flipping the value of this bit flips the sign of the number.         &lt;br /&gt;The exponent field needs to represent both positive and negative exponents. To do this, a bias is added to the actual exponent in order to get the stored exponent. For IEEE single-precision floats, this value is 127. Thus, an exponent of zero means that 127 is stored in the exponent field. A stored value of 200 indicates an exponent of (200-127), or 73. For reasons discussed later, exponents of -127 (all 0s) and +128 (all 1s) are reserved for special numbers. For double precision, the exponent field is 11 bits, and has a bias of 1023.         &lt;br /&gt;The mantissa, also known as the significand, represents the precision bits of the number. It is composed of an implicit leading bit and the fraction bits. To find out the value of the implicit leading bit, consider that any number can be expressed in scientific notation in many different ways. For example, the number five can be represented as any of these:         &lt;br /&gt;&lt;code&gt;         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 5.00 &amp;#215; 100           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 0.05 &amp;#215; 10 ^ 2           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 5000 &amp;#215; 10 ^ -3           &lt;br /&gt;&lt;/code&gt;        &lt;br /&gt;In order to maximize the quantity of representable numbers, floating-point numbers are typically stored in normalized form. This basically puts the radix point after the first non-zero digit. In normalized form, five is represented as 5.0 &amp;#215; 100. A nice little optimization is available to us in base two, since the only possible non-zero digit is 1. Thus, we can just assume a leading digit of 1, and don't need to represent it explicitly. As a result, the mantissa has effectively 24 bits of resolution, by way of 23 fraction bits.         &lt;br /&gt;So, to sum up:         &lt;br /&gt;&lt;code&gt;         &lt;br /&gt;1. The sign bit is 0 for positive, 1 for negative.&amp;#160; &lt;br /&gt;2. The exponent's base is two.&amp;#160; &lt;br /&gt;3. The exponent field contains 127 plus the true exponent for single-precision,&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160; or 1023 plus the true exponent for double precision.&amp;#160; &lt;br /&gt;4. The first bit of the mantissa is typically assumed to be 1.f, where f is the&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160; field of fraction bits.&amp;#160; &lt;br /&gt;&lt;/code&gt;&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;When should the register modifier be used?&lt;/strong&gt;       &lt;p&gt;The register modifier hints to the compiler that the variable will be heavily used and should be kept in the CPU?s registers, if possible, so that it can be accessed faster. There are several restrictions on the use of the register modifier.        &lt;br /&gt;First, the variable must be of a type that can be held in the CPU?s register. This usually means a single value of a size less than or equal to the size of an integer. Some machines have registers that can hold floating-point numbers as well. Second, because the variable might not be stored in memory, its address cannot be taken with the unary &amp;amp; operator. An attempt to do so is flagged as an error by the compiler. Some additional rules affect how useful the register modifier is. Because the number of registers is limited, and because some registers can hold only certain types of data (such as pointers or floating-point numbers), the number and types of register modifiers that will actually have any effect are dependent on what machine the program will run on. Any additional register modifiers are silently ignored by the compiler. Also, in some cases, it might actually be slower to keep a variable in a register because that register then becomes unavailable for other purposes or because the variable isn?t used enough to justify the overhead of loading and storing it. So when should the register modifier be used? The answer is never, with most modern compilers. Early C compilers did not keep any variables in registers unless directed to do so, and the register modifier was a valuable addition to the language. C compiler design has advanced to the point, however, where the compiler will usually make better decisions than the programmer about which variables should be stored in registers. In fact, many compilers actually ignore the register modifier, which is perfectly legal, because it is only a hint and not a directive. &lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;When should a type cast be used?&lt;/strong&gt;       &lt;p&gt;There are two situations in which to use a type cast.        &lt;br /&gt;The first use is to change the type of an operand to an arithmetic operation so that the operation will be performed properly.         &lt;br /&gt;The second case is to cast pointer types to and from void * in order to interface with functions that expect or return void pointers. For example, the following line type casts the return value of the call to malloc() to be a pointer to a foo structure.         &lt;br /&gt;&lt;code&gt;         &lt;br /&gt;struct foo *p = (struct foo *) malloc(sizeof(struct foo));&amp;#160; &lt;br /&gt;&lt;/code&gt;        &lt;br /&gt;A type cast should not be used to override a const or volatile declaration. Overriding these type modifiers can cause the program to fail to run correctly. A type cast should not be used to turn a pointer to one type of structure or data type into another. In the         &lt;br /&gt;rare events in which this action is beneficial, using a union to hold the values makes the programmer?s intentions clearer. &lt;/p&gt;      &lt;p&gt;       &lt;br /&gt;&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Can structures be assigned to variables and passed to and from functions?&lt;/strong&gt;       &lt;p&gt;Yes, they can!        &lt;br /&gt;But note that when structures are passed, returned or assigned, the copying is done only at one level (The data pointed to by any pointer fields is not copied!. &lt;/p&gt;      &lt;p&gt;       &lt;br /&gt;These Questions are taken from CrackTheInterview team.&lt;/p&gt;   &lt;/li&gt; &lt;/ol&gt;  </description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">11</thr:total><author>kchaitanyya@gmail.com (chaitanya)</author></item></channel></rss>