<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;D0IHSXc8fCp7ImA9WhRQFko.&quot;"><id>tag:blogger.com,1999:blog-7512034136444690422</id><updated>2011-12-11T23:38:58.974-08:00</updated><category term="Quantitative" /><category term="Linked List" /><category term="Microsoft" /><category term="Data Structures" /><category term="Resume Tips" /><category term="Puzzle" /><category term="Algorithms" /><category term="Google" /><category term="C/C++" /><title>Questions from/for technical interviews: Part of www.technical-interview.com</title><subtitle type="html">This blog contains questions and answers from real interviews including Google and Microsoft.</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://the-technical-interview.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://the-technical-interview.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Administrator</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>52</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/QuestionsForGoogleAndMicrosoftInterviews" /><feedburner:info uri="questionsforgoogleandmicrosoftinterviews" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;CkcERX44eyp7ImA9WhdbFkU.&quot;"><id>tag:blogger.com,1999:blog-7512034136444690422.post-1792633964059662791</id><published>2011-10-15T05:00:00.001-07:00</published><updated>2011-10-15T05:00:04.033-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-10-15T05:00:04.033-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Data Structures" /><category scheme="http://www.blogger.com/atom/ns#" term="Algorithms" /><title>Classify the Hashing Functions based on the various methods by which the key value is found</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7512034136444690422-1792633964059662791?l=the-technical-interview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/xYGrnYLWx-dSFh2SZEbH_eXC9m8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/xYGrnYLWx-dSFh2SZEbH_eXC9m8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/xYGrnYLWx-dSFh2SZEbH_eXC9m8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/xYGrnYLWx-dSFh2SZEbH_eXC9m8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~4/yitIAUhBHSQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://the-technical-interview.blogspot.com/feeds/1792633964059662791/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://the-technical-interview.blogspot.com/2011/10/classify-hashing-functions-based-on.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/1792633964059662791?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/1792633964059662791?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~3/yitIAUhBHSQ/classify-hashing-functions-based-on.html" title="Classify the Hashing Functions based on the various methods by which the key value is found" /><author><name>Administrator</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://the-technical-interview.blogspot.com/2011/10/classify-hashing-functions-based-on.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEIGQ3Y5fip7ImA9WhdUFE0.&quot;"><id>tag:blogger.com,1999:blog-7512034136444690422.post-5671671675465585089</id><published>2011-09-30T10:08:00.000-07:00</published><updated>2011-09-30T10:08:42.826-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-30T10:08:42.826-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Algorithms" /><title>Common multiple</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div style="color: blue;"&gt;Q: Given two numbers m and n, write a method to return the first number r that is&lt;br /&gt;
divisible by both (e.g., the least common multiple).&lt;/div&gt;&lt;div style="color: blue;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="color: blue;"&gt;A:&lt;/div&gt;&lt;span style="color: blue; font-weight: bold;"&gt;The Approach: &lt;/span&gt;&lt;br style="color: blue;" /&gt;&lt;span style="color: blue;"&gt;What does it mean for r to be divisible by m and n? It means that all the primes in m must go into r, and all primes in n must be in r. What if m and n have primes in common?&lt;/span&gt;&lt;br style="color: blue;" /&gt;&lt;br style="color: blue;" /&gt;&lt;span style="color: blue;"&gt;For example, if m is divisible by 3^5 and n is divisible by 3^7, what does this mean about r? It means r must be divisible by 3^7.&lt;/span&gt;&lt;br style="color: blue;" /&gt;&lt;br style="color: blue;" /&gt;&lt;span style="color: blue; font-weight: bold;"&gt;The Rule&lt;/span&gt;&lt;span style="color: blue;"&gt;: For each prime p such that p^a \ m (e.g., m is divisible by p^a) and p^b \ n, r must be divisible by p^max(a, b)&lt;/span&gt;&lt;br style="color: blue;" /&gt;&lt;br style="color: blue;" /&gt;&lt;span style="color: blue; font-weight: bold;"&gt;The Algorithm:&lt;/span&gt;&lt;br style="color: blue;" /&gt;&lt;span style="color: blue;"&gt;Define q to be 1.&lt;/span&gt;&lt;br style="color: blue;" /&gt;&lt;span style="color: blue;"&gt;for each prime number p less than m and n:&lt;/span&gt;&lt;br style="color: blue;" /&gt;&lt;span style="color: blue;"&gt;find the largest a and b such that p^a \ m and p^b \ n&lt;/span&gt;&lt;br style="color: blue;" /&gt;&lt;span style="color: blue;"&gt;let q = q * p^max(a, b)&lt;/span&gt;&lt;br style="color: blue;" /&gt;&lt;span style="color: blue;"&gt;return q&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7512034136444690422-5671671675465585089?l=the-technical-interview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/GvZwTAh5c5c_kx7IvXDiHJ5mBLE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/GvZwTAh5c5c_kx7IvXDiHJ5mBLE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/GvZwTAh5c5c_kx7IvXDiHJ5mBLE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/GvZwTAh5c5c_kx7IvXDiHJ5mBLE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~4/B5WHQNG74Hc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://the-technical-interview.blogspot.com/feeds/5671671675465585089/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://the-technical-interview.blogspot.com/2011/09/common-multiple.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/5671671675465585089?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/5671671675465585089?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~3/B5WHQNG74Hc/common-multiple.html" title="Common multiple" /><author><name>Administrator</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://the-technical-interview.blogspot.com/2011/09/common-multiple.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUQHR3czcCp7ImA9Wx5SFUs.&quot;"><id>tag:blogger.com,1999:blog-7512034136444690422.post-2624237251064499563</id><published>2010-08-11T14:40:00.001-07:00</published><updated>2010-08-11T14:48:56.988-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-08-11T14:48:56.988-07:00</app:edited><title>Nice Book for your Interview</title><content type="html">&lt;a href="http://technical-interview.com/Interview_Book.aspx"&gt;Cracking the Coding Interview: Fourth Edition (308 page e-book / PDF)&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7512034136444690422-2624237251064499563?l=the-technical-interview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/FyhYAPJQ1da3JBOzG_U3pVyYlNI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/FyhYAPJQ1da3JBOzG_U3pVyYlNI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/FyhYAPJQ1da3JBOzG_U3pVyYlNI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/FyhYAPJQ1da3JBOzG_U3pVyYlNI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~4/3Zvm_tTQM_Q" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://the-technical-interview.blogspot.com/feeds/2624237251064499563/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://the-technical-interview.blogspot.com/2010/08/nice-book.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/2624237251064499563?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/2624237251064499563?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~3/3Zvm_tTQM_Q/nice-book.html" title="Nice Book for your Interview" /><author><name>Administrator</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://the-technical-interview.blogspot.com/2010/08/nice-book.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU4FSX4_cSp7ImA9WxFUGU0.&quot;"><id>tag:blogger.com,1999:blog-7512034136444690422.post-9188227597388945931</id><published>2010-06-30T06:18:00.003-07:00</published><updated>2010-06-30T06:18:38.049-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-06-30T06:18:38.049-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C/C++" /><title>How do you do dynamic memory allocation in C applications? List advantages and disadvantages of dynamic memory allocation vs. static memory allocation.</title><content type="html">How do you do dynamic memory allocation in C applications? List advantages and disadvantages of dynamic memory allocation vs. static memory allocation.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Answer:&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
 &lt;br /&gt;
In C, malloc, calloc and realloc are used to allocate memory dynamically. In C++, new(), is usually used to allocate objects. Some advantages and disadvantages of dynamic memory allocation are:&lt;br /&gt;
&lt;br /&gt;
Advantages:&lt;br /&gt;
&lt;br /&gt;
    • Memory is allocated on an as-needed basis. This helps remove the inefficiencies inherent to static memory allocation (when the amount of memory needed is not known at compile time and one has to make a guess).&lt;br /&gt;
&lt;br /&gt;
Disadvantages:&lt;br /&gt;
&lt;br /&gt;
    • Dynamic memory allocation is slower than static memory allocation. This is because dynamic memory allocation happens in the heap area.&lt;br /&gt;
    • Dynamic memory needs to be carefully deleted after use. They are created in non-contiguous area of memory segment.&lt;br /&gt;
    • Dynamic memory allocation causes contention between threads, so it degrades performance when it happens in a thread.&lt;br /&gt;
    • Memory fragmentation.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7512034136444690422-9188227597388945931?l=the-technical-interview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/0oB_EQjIU7z2tsK7WaZBgQJLSyU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/0oB_EQjIU7z2tsK7WaZBgQJLSyU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/0oB_EQjIU7z2tsK7WaZBgQJLSyU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/0oB_EQjIU7z2tsK7WaZBgQJLSyU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~4/mUrtYhqwowI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://the-technical-interview.blogspot.com/feeds/9188227597388945931/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://the-technical-interview.blogspot.com/2010/06/how-do-you-do-dynamic-memory-allocation.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/9188227597388945931?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/9188227597388945931?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~3/mUrtYhqwowI/how-do-you-do-dynamic-memory-allocation.html" title="How do you do dynamic memory allocation in C applications? List advantages and disadvantages of dynamic memory allocation vs. static memory allocation." /><author><name>Administrator</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://the-technical-interview.blogspot.com/2010/06/how-do-you-do-dynamic-memory-allocation.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU8NQH4ycCp7ImA9WxFUGU0.&quot;"><id>tag:blogger.com,1999:blog-7512034136444690422.post-1545914274352605271</id><published>2010-06-30T06:18:00.001-07:00</published><updated>2010-06-30T06:18:11.098-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-06-30T06:18:11.098-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C/C++" /><title>What are references in C++? Why do you need them when you have pointers?</title><content type="html">What are references in C++? Why do you need them when you have pointers?&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Answer:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
A reference variable is actually just a pointer that reduces syntactical clumsiness related with pointers in C (reference variables are internally implemented as a pointer; it’s just that programmers can't use it the way they use pointers).&lt;br /&gt;
&lt;br /&gt;
As a side note, a reference must refer to some object at all times, but a pointer can point to NULL. In this way, references can be more efficient when you know that you'll always have an object to point to, because you don't have to check against NULL:&lt;br /&gt;
void func(MyClass &amp;obj)&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
    obj.Foo();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
Is better than:&lt;br /&gt;
void func(MyClass *obj)&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
    if (obj) obj-&gt;Foo();&lt;br /&gt;
&lt;br /&gt;
}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7512034136444690422-1545914274352605271?l=the-technical-interview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/wM3BVL8V7-opXW8dkscMx-nKeYY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/wM3BVL8V7-opXW8dkscMx-nKeYY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/wM3BVL8V7-opXW8dkscMx-nKeYY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/wM3BVL8V7-opXW8dkscMx-nKeYY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~4/KVogsMSLQu0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://the-technical-interview.blogspot.com/feeds/1545914274352605271/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://the-technical-interview.blogspot.com/2010/06/what-are-references-in-c-why-do-you.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/1545914274352605271?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/1545914274352605271?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~3/KVogsMSLQu0/what-are-references-in-c-why-do-you.html" title="What are references in C++? Why do you need them when you have pointers?" /><author><name>Administrator</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://the-technical-interview.blogspot.com/2010/06/what-are-references-in-c-why-do-you.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU8CRHk6eyp7ImA9WxFUGU0.&quot;"><id>tag:blogger.com,1999:blog-7512034136444690422.post-4946000510749261392</id><published>2010-06-30T06:17:00.001-07:00</published><updated>2010-06-30T06:17:45.713-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-06-30T06:17:45.713-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C/C++" /><title>What leads to code-bloating in C++?</title><content type="html">What leads to code-bloating in C++?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Answer:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Inline functions and templates, if not used properly, may lead to code bloating. Multiple Inheritance may also lead to code bloating (this is because the sub classes will end up getting members from all the base classes even if only few members will suffice). Techniques to avoid code blot are discussed in “Effective C++ programming”.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7512034136444690422-4946000510749261392?l=the-technical-interview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/AecRp9FKwJ3_5JI0uawLUIzgSUU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/AecRp9FKwJ3_5JI0uawLUIzgSUU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/AecRp9FKwJ3_5JI0uawLUIzgSUU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/AecRp9FKwJ3_5JI0uawLUIzgSUU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~4/wPeCIt5bOcM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://the-technical-interview.blogspot.com/feeds/4946000510749261392/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://the-technical-interview.blogspot.com/2010/06/what-leads-to-code-bloating-in-c.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/4946000510749261392?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/4946000510749261392?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~3/wPeCIt5bOcM/what-leads-to-code-bloating-in-c.html" title="What leads to code-bloating in C++?" /><author><name>Administrator</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://the-technical-interview.blogspot.com/2010/06/what-leads-to-code-bloating-in-c.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkcCQXg5eip7ImA9WxFRGE4.&quot;"><id>tag:blogger.com,1999:blog-7512034136444690422.post-4787229559965458489</id><published>2010-05-02T12:54:00.000-07:00</published><updated>2010-05-02T12:54:20.622-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-05-02T12:54:20.622-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C/C++" /><title>how to write delay code in c</title><content type="html">how to write delay code in c?&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Ans&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
To perform an efficient delay you need to use a non standard function provided by the operating system for example sleep(...) in Linux or Sleep(...) in Windows.&lt;br /&gt;
&lt;br /&gt;
There is no standard way of efficiently delaying without using processor cycles.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7512034136444690422-4787229559965458489?l=the-technical-interview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/kkCMGKwIUV_sYF-G1z46iUKuyH8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/kkCMGKwIUV_sYF-G1z46iUKuyH8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/kkCMGKwIUV_sYF-G1z46iUKuyH8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/kkCMGKwIUV_sYF-G1z46iUKuyH8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~4/NC-FKusGhc8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://the-technical-interview.blogspot.com/feeds/4787229559965458489/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://the-technical-interview.blogspot.com/2010/05/how-to-write-delay-code-in-c.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/4787229559965458489?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/4787229559965458489?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~3/NC-FKusGhc8/how-to-write-delay-code-in-c.html" title="how to write delay code in c" /><author><name>Administrator</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://the-technical-interview.blogspot.com/2010/05/how-to-write-delay-code-in-c.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A08MSHg-fyp7ImA9WxFRGE8.&quot;"><id>tag:blogger.com,1999:blog-7512034136444690422.post-6924204694491721722</id><published>2010-05-02T12:50:00.000-07:00</published><updated>2010-05-02T12:51:29.657-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-05-02T12:51:29.657-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Linked List" /><title>Detect merged linked list</title><content type="html">Given the pointers to 2 linked list, how will we find out if they are merged? i.e. at some point they point to the same address. &lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Ans&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Pick one of the lists and traverse it from head to tail. For each node encountered, compare it to the head pointer of the other list. If you find a match then the second list is embedded within the first list.&lt;br /&gt;
&lt;br /&gt;
If you don't find a match, then repeat the procedure by traversing the second list.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7512034136444690422-6924204694491721722?l=the-technical-interview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/zuv5kE-R9URsAht6jqENkwYX9Dg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/zuv5kE-R9URsAht6jqENkwYX9Dg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/zuv5kE-R9URsAht6jqENkwYX9Dg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/zuv5kE-R9URsAht6jqENkwYX9Dg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~4/pCo5Z6344qA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://the-technical-interview.blogspot.com/feeds/6924204694491721722/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://the-technical-interview.blogspot.com/2010/05/linked-lists.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/6924204694491721722?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/6924204694491721722?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~3/pCo5Z6344qA/linked-lists.html" title="Detect merged linked list" /><author><name>Administrator</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://the-technical-interview.blogspot.com/2010/05/linked-lists.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0QBQH8yeSp7ImA9WxFRGE8.&quot;"><id>tag:blogger.com,1999:blog-7512034136444690422.post-1182856504221325548</id><published>2010-05-02T12:42:00.000-07:00</published><updated>2010-05-02T12:42:31.191-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-05-02T12:42:31.191-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Linked List" /><title>Linked list</title><content type="html">How does one find a loop in a singly linked list in O(n) time using constant memory? you cannot modify the list in any way (and constant memory means the amount of memory required for the solution cannot be a function of n)&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
Ans&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
One way to detect a loop is to iterate over the list with 2 pointers at the same time where one is iterating at double speed. If the 2 pointers are ever equal after they iterate once and before they both reach an end, there's a loop.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7512034136444690422-1182856504221325548?l=the-technical-interview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/AWibQKmCTT3-wg2CrTAHexAioOU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/AWibQKmCTT3-wg2CrTAHexAioOU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/AWibQKmCTT3-wg2CrTAHexAioOU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/AWibQKmCTT3-wg2CrTAHexAioOU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~4/FcmhGfhtkEI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://the-technical-interview.blogspot.com/feeds/1182856504221325548/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://the-technical-interview.blogspot.com/2010/05/linked-list.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/1182856504221325548?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/1182856504221325548?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~3/FcmhGfhtkEI/linked-list.html" title="Linked list" /><author><name>Administrator</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://the-technical-interview.blogspot.com/2010/05/linked-list.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU8HQnw4eSp7ImA9WxFRF0k.&quot;"><id>tag:blogger.com,1999:blog-7512034136444690422.post-2038994177413670995</id><published>2010-05-01T12:57:00.000-07:00</published><updated>2010-05-01T12:57:13.231-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-05-01T12:57:13.231-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Data Structures" /><category scheme="http://www.blogger.com/atom/ns#" term="C/C++" /><category scheme="http://www.blogger.com/atom/ns#" term="Algorithms" /><title>Which recursive sorting technique always makes recursive calls to sort subarrays that are about half size of the original array?</title><content type="html">&lt;b&gt;Answer&lt;/b&gt;: Mergesort always makes recursive calls to sort subarrays that are about half size of the original array, resulting in O(n log n) time.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7512034136444690422-2038994177413670995?l=the-technical-interview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/VsknO2r6sACl7XiLSOVQ2b17BxQ/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/VsknO2r6sACl7XiLSOVQ2b17BxQ/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/VsknO2r6sACl7XiLSOVQ2b17BxQ/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/VsknO2r6sACl7XiLSOVQ2b17BxQ/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~4/19Q0dmQtmRk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://the-technical-interview.blogspot.com/feeds/2038994177413670995/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://the-technical-interview.blogspot.com/2010/05/which-recursive-sorting-technique.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/2038994177413670995?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/2038994177413670995?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~3/19Q0dmQtmRk/which-recursive-sorting-technique.html" title="Which recursive sorting technique always makes recursive calls to sort subarrays that are about half size of the original array?" /><author><name>Administrator</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://the-technical-interview.blogspot.com/2010/05/which-recursive-sorting-technique.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUAMR3o_eCp7ImA9WxFRF0k.&quot;"><id>tag:blogger.com,1999:blog-7512034136444690422.post-1471879934447908970</id><published>2010-05-01T12:56:00.001-07:00</published><updated>2010-05-01T12:56:26.440-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-05-01T12:56:26.440-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C/C++" /><title>What is the difference between an external iterator and an internal iterator? Describe an advantage of an external iterator.</title><content type="html">&lt;b&gt;Ans&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
An internal iterator is implemented with member functions of the class that has items to step through. .An external iterator is implemented as a separate class that can be "attach" to the object that has items to step through. .An external iterator has the advantage that many difference iterators can be active simultaneously on the same object.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7512034136444690422-1471879934447908970?l=the-technical-interview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/6lQua-ZqGcHQvUrimYrG5G1iwrE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/6lQua-ZqGcHQvUrimYrG5G1iwrE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/6lQua-ZqGcHQvUrimYrG5G1iwrE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/6lQua-ZqGcHQvUrimYrG5G1iwrE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~4/vXSUYfpWpXU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://the-technical-interview.blogspot.com/feeds/1471879934447908970/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://the-technical-interview.blogspot.com/2010/05/what-is-difference-between-external.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/1471879934447908970?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/1471879934447908970?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~3/vXSUYfpWpXU/what-is-difference-between-external.html" title="What is the difference between an external iterator and an internal iterator? Describe an advantage of an external iterator." /><author><name>Administrator</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://the-technical-interview.blogspot.com/2010/05/what-is-difference-between-external.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUAASHc9eip7ImA9WxFRF0k.&quot;"><id>tag:blogger.com,1999:blog-7512034136444690422.post-6565465598739455247</id><published>2010-05-01T12:55:00.001-07:00</published><updated>2010-05-01T12:55:49.962-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-05-01T12:55:49.962-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Data Structures" /><category scheme="http://www.blogger.com/atom/ns#" term="Microsoft" /><title>What are the advantages and disadvantages of B-star trees over Binary trees?</title><content type="html">&lt;b&gt;Ans&lt;/b&gt;&lt;br /&gt;
A1 B-star trees have better data structure and are faster in search than Binary trees, but it’s harder to write codes for B-start trees.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7512034136444690422-6565465598739455247?l=the-technical-interview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/-Ji-HzpVG22nLgGPn9mfMEp2hII/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-Ji-HzpVG22nLgGPn9mfMEp2hII/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/-Ji-HzpVG22nLgGPn9mfMEp2hII/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-Ji-HzpVG22nLgGPn9mfMEp2hII/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~4/mRh72pwKHhw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://the-technical-interview.blogspot.com/feeds/6565465598739455247/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://the-technical-interview.blogspot.com/2010/05/what-are-advantages-and-disadvantages.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/6565465598739455247?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/6565465598739455247?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~3/mRh72pwKHhw/what-are-advantages-and-disadvantages.html" title="What are the advantages and disadvantages of B-star trees over Binary trees?" /><author><name>Administrator</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://the-technical-interview.blogspot.com/2010/05/what-are-advantages-and-disadvantages.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck8NR3w_eip7ImA9WxFRFUo.&quot;"><id>tag:blogger.com,1999:blog-7512034136444690422.post-8806804977589431491</id><published>2010-04-29T12:54:00.001-07:00</published><updated>2010-04-29T12:54:56.242-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-29T12:54:56.242-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Google" /><category scheme="http://www.blogger.com/atom/ns#" term="Puzzle" /><title>Google Puzzle</title><content type="html">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;b&gt;&lt;br /&gt;
Ans&lt;/b&gt;&lt;br /&gt;
ou 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;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7512034136444690422-8806804977589431491?l=the-technical-interview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/gG6SNkj6adEzItn1wd87FhB6KOI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/gG6SNkj6adEzItn1wd87FhB6KOI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/gG6SNkj6adEzItn1wd87FhB6KOI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/gG6SNkj6adEzItn1wd87FhB6KOI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~4/rMa4D2YMCjI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://the-technical-interview.blogspot.com/feeds/8806804977589431491/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://the-technical-interview.blogspot.com/2010/04/google-puzzle.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/8806804977589431491?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/8806804977589431491?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~3/rMa4D2YMCjI/google-puzzle.html" title="Google Puzzle" /><author><name>Administrator</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://the-technical-interview.blogspot.com/2010/04/google-puzzle.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkECRHk_fyp7ImA9WxFRFUo.&quot;"><id>tag:blogger.com,1999:blog-7512034136444690422.post-8063664557092963052</id><published>2010-04-29T12:51:00.000-07:00</published><updated>2010-04-29T12:51:05.747-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-29T12:51:05.747-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Algorithms" /><title>Euclidean algorithm</title><content type="html">Write an algorithm for finding the greatest common divisor of two integers.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Ans&lt;/b&gt;&lt;br /&gt;
function gcd(  a,b : Integer ) returns Integer&lt;br /&gt;
{&lt;br /&gt;
 if ( b != 0 )&lt;br /&gt;
    return gcd( b, a mod b ) &lt;br /&gt;
 return abs(a)&lt;br /&gt;
}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7512034136444690422-8063664557092963052?l=the-technical-interview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/ArEsDwJSzogKlXMopqzz1zHN7Wo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ArEsDwJSzogKlXMopqzz1zHN7Wo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/ArEsDwJSzogKlXMopqzz1zHN7Wo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ArEsDwJSzogKlXMopqzz1zHN7Wo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~4/pcbSKcgAqbU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://the-technical-interview.blogspot.com/feeds/8063664557092963052/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://the-technical-interview.blogspot.com/2010/04/euclidean-algorithm.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/8063664557092963052?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/8063664557092963052?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~3/pcbSKcgAqbU/euclidean-algorithm.html" title="Euclidean algorithm" /><author><name>Administrator</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://the-technical-interview.blogspot.com/2010/04/euclidean-algorithm.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkIFRno5fip7ImA9WxFRFUo.&quot;"><id>tag:blogger.com,1999:blog-7512034136444690422.post-4029347773850071881</id><published>2010-04-29T12:48:00.000-07:00</published><updated>2010-04-29T12:48:37.426-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-29T12:48:37.426-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Google" /><category scheme="http://www.blogger.com/atom/ns#" term="Microsoft" /><category scheme="http://www.blogger.com/atom/ns#" term="Algorithms" /><title>Majority element</title><content type="html">Given an array of size N ,we need to find the majority element if it exists ,as efficiently as possible. A majority element in an array of size N is any element which is present more than N/2 times.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Ans&lt;/b&gt;&lt;br /&gt;
Naive approach:&lt;br /&gt;
&lt;br /&gt;
Just scan the array element wise and then make a count of the frequency of each of the distinct elements present in the array and if any element's count is more than N/2 then it is the majority element, otherwise it doesn't exist!!&lt;br /&gt;
&lt;br /&gt;
One needn't ponder much on the complexity of this bruteforce approach.&lt;br /&gt;
&lt;br /&gt;
This requires O(N) additional space and O(N) time.&lt;br /&gt;
&lt;br /&gt;
Recursive Approach:&lt;br /&gt;
&lt;br /&gt;
Here’s a divide-and-conquer algorithm:&lt;br /&gt;
&lt;br /&gt;
function majority (A[1 . . . N])&lt;br /&gt;
&lt;br /&gt;
if N = 1: return A[1]&lt;br /&gt;
&lt;br /&gt;
let AL , AR be the first and second halves of A&lt;br /&gt;
&lt;br /&gt;
ML = majority(AL ) and MR = majority(AR )&lt;br /&gt;
&lt;br /&gt;
if neither half has a majority:&lt;br /&gt;
&lt;br /&gt;
return ‘‘no majority’’&lt;br /&gt;
&lt;br /&gt;
else:&lt;br /&gt;
&lt;br /&gt;
check whether either ML or MR is a majority element of A&lt;br /&gt;
&lt;br /&gt;
if so, return that element; else return ‘‘no majority’’&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7512034136444690422-4029347773850071881?l=the-technical-interview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/gqQSFZIUKI-ymIgNYm91PJaY__M/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/gqQSFZIUKI-ymIgNYm91PJaY__M/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/gqQSFZIUKI-ymIgNYm91PJaY__M/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/gqQSFZIUKI-ymIgNYm91PJaY__M/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~4/uZBIwAKFvLI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://the-technical-interview.blogspot.com/feeds/4029347773850071881/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://the-technical-interview.blogspot.com/2010/04/majority-element.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/4029347773850071881?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/4029347773850071881?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~3/uZBIwAKFvLI/majority-element.html" title="Majority element" /><author><name>Administrator</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://the-technical-interview.blogspot.com/2010/04/majority-element.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkMCRHczeSp7ImA9WxFRFE0.&quot;"><id>tag:blogger.com,1999:blog-7512034136444690422.post-7745939754313514424</id><published>2010-04-27T13:34:00.000-07:00</published><updated>2010-04-27T13:34:25.981-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-27T13:34:25.981-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Algorithms" /><title>Divide a = a1a2 · · · aN by d using long division</title><content type="html">&lt;b&gt;Solution&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
B1 &lt;--  a1 {Bi is what we divide d into in step i}&lt;br /&gt;
i &lt;--  1&lt;br /&gt;
while i &lt;= N do&lt;br /&gt;
qi &lt;--  largest integer such that d × qi &lt;= Bi; {qi is the ith digit of the quotient q}&lt;br /&gt;
if i &lt;= N − 1 then&lt;br /&gt;
Bi+1 &lt;--  10 × (Bi − d × qi) + ai+1&lt;br /&gt;
end if&lt;br /&gt;
i &lt;--  i + 1;&lt;br /&gt;
end while&lt;br /&gt;
r &lt;--   BN − d × qN {r is the remainder}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7512034136444690422-7745939754313514424?l=the-technical-interview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/zUaOsgyJroYS8gpjsrCR-sQSAXE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/zUaOsgyJroYS8gpjsrCR-sQSAXE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/zUaOsgyJroYS8gpjsrCR-sQSAXE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/zUaOsgyJroYS8gpjsrCR-sQSAXE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~4/T23ZV60XB5I" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://the-technical-interview.blogspot.com/feeds/7745939754313514424/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://the-technical-interview.blogspot.com/2010/04/divide-a1a2-by-d-using-long-division.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/7745939754313514424?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/7745939754313514424?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~3/T23ZV60XB5I/divide-a1a2-by-d-using-long-division.html" title="Divide a = a1a2 · · · aN by d using long division" /><author><name>Administrator</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://the-technical-interview.blogspot.com/2010/04/divide-a1a2-by-d-using-long-division.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkQHRn4ycCp7ImA9WxFRFE0.&quot;"><id>tag:blogger.com,1999:blog-7512034136444690422.post-8575475398839085503</id><published>2010-04-27T13:32:00.000-07:00</published><updated>2010-04-27T13:32:17.098-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-27T13:32:17.098-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Algorithms" /><title>Algorithm Sum N numbers in a list (or array) named values</title><content type="html">&lt;b&gt;Solution&lt;/b&gt;&lt;br /&gt;
sum &lt;--  0;&lt;br /&gt;
index &lt;--  1;&lt;br /&gt;
while index &lt;= N do&lt;br /&gt;
sum  &lt;-- sum + values[index ];&lt;br /&gt;
index &lt;--  index + 1;&lt;br /&gt;
end while&lt;br /&gt;
print sum;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7512034136444690422-8575475398839085503?l=the-technical-interview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/si-eIOFS49s196ThO5fTGQvkPLo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/si-eIOFS49s196ThO5fTGQvkPLo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/si-eIOFS49s196ThO5fTGQvkPLo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/si-eIOFS49s196ThO5fTGQvkPLo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~4/fQJCF1Z40JA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://the-technical-interview.blogspot.com/feeds/8575475398839085503/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://the-technical-interview.blogspot.com/2010/04/algorithm-sum-n-numbers-in-list-or.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/8575475398839085503?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/8575475398839085503?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~3/fQJCF1Z40JA/algorithm-sum-n-numbers-in-list-or.html" title="Algorithm Sum N numbers in a list (or array) named values" /><author><name>Administrator</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://the-technical-interview.blogspot.com/2010/04/algorithm-sum-n-numbers-in-list-or.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0MMQ3w9fyp7ImA9WxFREE0.&quot;"><id>tag:blogger.com,1999:blog-7512034136444690422.post-6816498567105486619</id><published>2010-04-22T23:51:00.000-07:00</published><updated>2010-04-22T23:51:22.267-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-22T23:51:22.267-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Linked List" /><title>Write functions Insert and Remove which add and remove nodes from ordered single linked list based on the Node value</title><content type="html">&lt;b&gt;Q:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Write functions Insert and Remove which add and remove nodes from ordered single linked list based on the Node value&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;A:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
public Node Insert(Node head, int value)&lt;br /&gt;
  {&lt;br /&gt;
        if (head == null || value &lt; head.value)&lt;br /&gt;
            return new Node(value, head);&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
            head.next = Insert(head.next, value);&lt;br /&gt;
            return head;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7512034136444690422-6816498567105486619?l=the-technical-interview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/4Si8rsKYdrLRRejtookSmg8El9w/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/4Si8rsKYdrLRRejtookSmg8El9w/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/4Si8rsKYdrLRRejtookSmg8El9w/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/4Si8rsKYdrLRRejtookSmg8El9w/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~4/GiUzw544UpI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://the-technical-interview.blogspot.com/feeds/6816498567105486619/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://the-technical-interview.blogspot.com/2010/04/write-functions-insert-and-remove-which.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/6816498567105486619?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/6816498567105486619?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~3/GiUzw544UpI/write-functions-insert-and-remove-which.html" title="Write functions Insert and Remove which add and remove nodes from ordered single linked list based on the Node value" /><author><name>Administrator</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://the-technical-interview.blogspot.com/2010/04/write-functions-insert-and-remove-which.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0QNSX84cCp7ImA9WxFREE0.&quot;"><id>tag:blogger.com,1999:blog-7512034136444690422.post-3319182382029482835</id><published>2010-04-22T23:49:00.001-07:00</published><updated>2010-04-22T23:49:58.138-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-22T23:49:58.138-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Linked List" /><title>Write a function which will test whether or not there is a cycle in a single linked list</title><content type="html">&lt;b&gt;Q:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Write a function which will test whether or not there is a cycle in a single linked list&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;A:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
public bool hasLoop(Node head)&lt;br /&gt;
    {&lt;br /&gt;
       Node first = head;&lt;br /&gt;
        Node second = head;&lt;br /&gt;
        while (first &amp;&amp; second &amp;&amp;&lt;br /&gt;
                  first.Next &amp;&amp; second.Next &amp;&amp;&lt;br /&gt;
                  second.Next.Next)&lt;br /&gt;
       {&lt;br /&gt;
            first = first.Next;&lt;br /&gt;
           second = second.Next.Next;&lt;br /&gt;
           if (first == second)&lt;br /&gt;
           {&lt;br /&gt;
                // Found loop&lt;br /&gt;
                return true;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return false;&lt;br /&gt;
   }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7512034136444690422-3319182382029482835?l=the-technical-interview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/tqcs_ChTV3SZuY8kM8dcimU6lmE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/tqcs_ChTV3SZuY8kM8dcimU6lmE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/tqcs_ChTV3SZuY8kM8dcimU6lmE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/tqcs_ChTV3SZuY8kM8dcimU6lmE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~4/GqjsOveWqfA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://the-technical-interview.blogspot.com/feeds/3319182382029482835/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://the-technical-interview.blogspot.com/2010/04/write-function-which-will-test-whether.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/3319182382029482835?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/3319182382029482835?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~3/GqjsOveWqfA/write-function-which-will-test-whether.html" title="Write a function which will test whether or not there is a cycle in a single linked list" /><author><name>Administrator</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://the-technical-interview.blogspot.com/2010/04/write-function-which-will-test-whether.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0QGRnkzeyp7ImA9WxFREE0.&quot;"><id>tag:blogger.com,1999:blog-7512034136444690422.post-9192866012092410164</id><published>2010-04-22T23:48:00.000-07:00</published><updated>2010-04-22T23:48:47.783-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-22T23:48:47.783-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Linked List" /><title>Write a function which will print values from the single linked list in the reverse order in O(n) time. No changes to the list can be made and no additional data structures can be used</title><content type="html">&lt;b&gt;Q:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Write a function which will print values from the single linked list in the reverse order in O(n) time. No changes to the list can be made and no additional data structures can be used”&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;A:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
public void PrintInReverseOrder (Node head)&lt;br /&gt;
 {&lt;br /&gt;
    if (head != null)&lt;br /&gt;
    {&lt;br /&gt;
      PrintInReverseOrder(head.next);&lt;br /&gt;
      Console.WriteLine(head.value);&lt;br /&gt;
    };&lt;br /&gt;
  }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7512034136444690422-9192866012092410164?l=the-technical-interview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/hlD6GK35XVN6D_9lS3yK755nM7A/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/hlD6GK35XVN6D_9lS3yK755nM7A/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/hlD6GK35XVN6D_9lS3yK755nM7A/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/hlD6GK35XVN6D_9lS3yK755nM7A/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~4/8HL6iWgF_PI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://the-technical-interview.blogspot.com/feeds/9192866012092410164/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://the-technical-interview.blogspot.com/2010/04/write-function-which-will-print-values.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/9192866012092410164?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/9192866012092410164?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~3/8HL6iWgF_PI/write-function-which-will-print-values.html" title="Write a function which will print values from the single linked list in the reverse order in O(n) time. No changes to the list can be made and no additional data structures can be used" /><author><name>Administrator</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://the-technical-interview.blogspot.com/2010/04/write-function-which-will-print-values.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0YDQH8-cSp7ImA9WxFREE0.&quot;"><id>tag:blogger.com,1999:blog-7512034136444690422.post-3742652033897187265</id><published>2010-04-22T23:46:00.000-07:00</published><updated>2010-04-22T23:46:11.159-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-22T23:46:11.159-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Linked List" /><title>Compute the sum of all the values in the nodes of a single linked list</title><content type="html">&lt;b&gt;Q:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Compute the sum of all the values in the nodes of a single linked list&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
A:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
public int getSum(Node head)   &lt;br /&gt;
{       &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
if (head == null)   return 0;       &lt;br /&gt;
       else           &lt;br /&gt;
        return getSum(head.next) + head.value;&lt;br /&gt;
&lt;br /&gt;
}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7512034136444690422-3742652033897187265?l=the-technical-interview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Yzm6W1x8HRGALGKRA9oCH0LrlYo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Yzm6W1x8HRGALGKRA9oCH0LrlYo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Yzm6W1x8HRGALGKRA9oCH0LrlYo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Yzm6W1x8HRGALGKRA9oCH0LrlYo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~4/33HWkIdgJt4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://the-technical-interview.blogspot.com/feeds/3742652033897187265/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://the-technical-interview.blogspot.com/2010/04/compute-sum-of-all-values-in-nodes-of.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/3742652033897187265?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/3742652033897187265?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~3/33HWkIdgJt4/compute-sum-of-all-values-in-nodes-of.html" title="Compute the sum of all the values in the nodes of a single linked list" /><author><name>Administrator</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://the-technical-interview.blogspot.com/2010/04/compute-sum-of-all-values-in-nodes-of.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0YGQn06fip7ImA9WxFREE0.&quot;"><id>tag:blogger.com,1999:blog-7512034136444690422.post-3893808584358947027</id><published>2010-04-22T23:45:00.001-07:00</published><updated>2010-04-22T23:45:23.316-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-22T23:45:23.316-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Linked List" /><title>Calculate length of the linked list</title><content type="html">&lt;b&gt;Q:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Calculate length of the linked list&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;A:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
public int getLength(Node head)   &lt;br /&gt;
{&lt;br /&gt;
 if (head == null)&lt;br /&gt;
        return 0;&lt;br /&gt;
  else           &lt;br /&gt;
      return length(head.next) + 1;&lt;br /&gt;
   &lt;br /&gt;
}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7512034136444690422-3893808584358947027?l=the-technical-interview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/8O2grafZunwYoJRB9sJ4w2qjdWw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8O2grafZunwYoJRB9sJ4w2qjdWw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/8O2grafZunwYoJRB9sJ4w2qjdWw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8O2grafZunwYoJRB9sJ4w2qjdWw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~4/oW9Nn5D0Ub0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://the-technical-interview.blogspot.com/feeds/3893808584358947027/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://the-technical-interview.blogspot.com/2010/04/calculate-length-of-linked-list.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/3893808584358947027?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/3893808584358947027?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~3/oW9Nn5D0Ub0/calculate-length-of-linked-list.html" title="Calculate length of the linked list" /><author><name>Administrator</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://the-technical-interview.blogspot.com/2010/04/calculate-length-of-linked-list.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0cCQXo6cCp7ImA9WxFREE0.&quot;"><id>tag:blogger.com,1999:blog-7512034136444690422.post-4220534080408256819</id><published>2010-04-22T23:44:00.000-07:00</published><updated>2010-04-22T23:44:20.418-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-22T23:44:20.418-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Linked List" /><title>Reverse a Singly Linked List</title><content type="html">&lt;b&gt;Q:&lt;/b&gt;&lt;br /&gt;
Reverse a Singly Linked List&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;A:&lt;/b&gt;&lt;br /&gt;
public Node Reverse(Node head)    &lt;br /&gt;
{&lt;br /&gt;
        Node next;&lt;br /&gt;
        Node current;&lt;br /&gt;
        current = head;&lt;br /&gt;
        Node Result = null;&lt;br /&gt;
        while (current != null)&lt;br /&gt;
          { &lt;br /&gt;
             next = current.next; &lt;br /&gt;
              current.next = result;&lt;br /&gt;
              result = current;&lt;br /&gt;
              current = next;&lt;br /&gt;
          }       &lt;br /&gt;
               return (result);   &lt;br /&gt;
}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7512034136444690422-4220534080408256819?l=the-technical-interview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/J8_Oopz9XQOaNVv7o6hSbE8wY-A/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/J8_Oopz9XQOaNVv7o6hSbE8wY-A/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/J8_Oopz9XQOaNVv7o6hSbE8wY-A/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/J8_Oopz9XQOaNVv7o6hSbE8wY-A/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~4/F767Ob0nTd8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://the-technical-interview.blogspot.com/feeds/4220534080408256819/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://the-technical-interview.blogspot.com/2010/04/reverse-singly-linked-list.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/4220534080408256819?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/4220534080408256819?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~3/F767Ob0nTd8/reverse-singly-linked-list.html" title="Reverse a Singly Linked List" /><author><name>Administrator</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://the-technical-interview.blogspot.com/2010/04/reverse-singly-linked-list.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0cERX0_fCp7ImA9WxFREE0.&quot;"><id>tag:blogger.com,1999:blog-7512034136444690422.post-4934734191240702500</id><published>2010-04-22T23:43:00.001-07:00</published><updated>2010-04-22T23:43:24.344-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-22T23:43:24.344-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Linked List" /><title>What are the advantages and disadvantages of linked list structure vs. arrays?</title><content type="html">&lt;b&gt;Q:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
What are the advantages and disadvantages of linked list structure vs. arrays?&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;A:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Linked lists allow only sequential access to elements O(n) while arrays allow random access O(1). Linked lists requires an extra storage for references, which often makes them impractical for lists of small data items such as characters or Boolean values. From the over side, size of array is restricted to declaration. Insertion/Deletion of values in arrays are very expensive comparing to linked list and requires memory reallocation. Elements can be inserted into linked lists indefinitely, while an array will eventually.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7512034136444690422-4934734191240702500?l=the-technical-interview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/AaUFPe4aCaHrJrYHUbyw08ENZiA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/AaUFPe4aCaHrJrYHUbyw08ENZiA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/AaUFPe4aCaHrJrYHUbyw08ENZiA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/AaUFPe4aCaHrJrYHUbyw08ENZiA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~4/UkDei_015Ro" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://the-technical-interview.blogspot.com/feeds/4934734191240702500/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://the-technical-interview.blogspot.com/2010/04/what-are-advantages-and-disadvantages.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/4934734191240702500?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/4934734191240702500?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~3/UkDei_015Ro/what-are-advantages-and-disadvantages.html" title="What are the advantages and disadvantages of linked list structure vs. arrays?" /><author><name>Administrator</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://the-technical-interview.blogspot.com/2010/04/what-are-advantages-and-disadvantages.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Dk4ARX08eCp7ImA9WxFREE0.&quot;"><id>tag:blogger.com,1999:blog-7512034136444690422.post-7203548296479627305</id><published>2010-04-22T23:42:00.000-07:00</published><updated>2010-04-22T23:42:24.370-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-22T23:42:24.370-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Linked List" /><title>What is the difference between array and linked list?</title><content type="html">&lt;b&gt;Q:&lt;/b&gt;&lt;br /&gt;
What is the difference between array and linked list?&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;A:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The main difference between the linked list and the array is that while the array is a static data structure (with fix number of elements), the linked list - dynamic data structure. In terms of complexity, the linked list is usually more efficient as to the space it uses, however, algorithms for linked lists are usually more complicated that those of the array.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7512034136444690422-7203548296479627305?l=the-technical-interview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/ITx93LaOylM_hP4iemxpGGewxH4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ITx93LaOylM_hP4iemxpGGewxH4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/ITx93LaOylM_hP4iemxpGGewxH4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ITx93LaOylM_hP4iemxpGGewxH4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~4/wMRlfEsb3cU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://the-technical-interview.blogspot.com/feeds/7203548296479627305/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://the-technical-interview.blogspot.com/2010/04/what-is-difference-between-array-and.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/7203548296479627305?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7512034136444690422/posts/default/7203548296479627305?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/QuestionsForGoogleAndMicrosoftInterviews/~3/wMRlfEsb3cU/what-is-difference-between-array-and.html" title="What is the difference between array and linked list?" /><author><name>Administrator</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://the-technical-interview.blogspot.com/2010/04/what-is-difference-between-array-and.html</feedburner:origLink></entry></feed>

