<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>Free Question Bank &#187; Articles</title> <atom:link href="http://www.freequestionbank.com/category/articles/feed/" rel="self" type="application/rss+xml" /><link>http://www.freequestionbank.com</link> <description>Just another WordPress weblog</description> <lastBuildDate>Sat, 20 Feb 2010 05:10:08 +0000</lastBuildDate> <generator>http://wordpress.org/?v=2.9.1</generator> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Interview Questions on C Programming</title><link>http://www.freequestionbank.com/articles/interview-questions-on-c-programming/</link> <comments>http://www.freequestionbank.com/articles/interview-questions-on-c-programming/#comments</comments> <pubDate>Tue, 12 May 2009 02:54:54 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Articles]]></category> <category><![CDATA[c programming]]></category> <category><![CDATA[c++]]></category> <category><![CDATA[Interview]]></category> <category><![CDATA[Question]]></category><guid
isPermaLink="false">http://www.freequestionbank.com/blog/?p=566</guid> <description><![CDATA[ 
What is the difference between the declaration and the definition of a variable?The definition is the one that actually allocates ...]]></description> <content:encoded><![CDATA[<p> </p><li><strong>What is the difference between the declaration and the definition of a variable?</strong>The definition is the one that actually allocates space, and provides an initialization value, if any. <br
/> 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.</li><li><strong>Do Global variables start out as zero?  <br
/> </strong>Un initialized variables declared with the &#8220;static&#8221; 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. <br
/> Local variables start out containing garbage, unless they are explicitly initialized. <br
/> 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).</li><li><strong>Does C have boolean variable type?</strong>No, C does not have a boolean variable type. One can use ints, chars, #defines or enums to achieve the same in C. <br
/> <code><br
/> #define TRUE 1  <br
/> #define FALSE 0  <br
/> enum bool {false, true}; <br
/> </code><br
/> An enum may be good if the debugger shows the names of enum constants when examining variables.</li><li><strong>Where may variables be defined in C?</strong>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).</li><li><strong>To what does the term storage class refer? What are auto, static, extern, volatile, const classes?</strong>This is a part of a variable declaration that tells the compiler how to interpret the variable&#8217;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. <br
/> Here are C&#8217;s storage classes and what they signify:</p><ul><li>auto &#8211; local variables.</li><li>static &#8211; variables are defined in a nonvolatile region of memory such that they retain their contents though out the program&#8217;s execution.</li><li>register &#8211; asks the compiler to devote a processor register to this variable in order to speed the program&#8217;s execution. The compiler may not comply and the variable looses it contents and identity when the function it which it is defined terminates.</li><li>extern &#8211; tells the compiler that the variable is defined in another module.</li></ul><p>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&#8217;s why const and volatile are called type qualifiers, rather than type specifiers.</p><ul><li>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&#8217;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.</li><li>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.</li><li>const volatile &#8211; Both constant and volatile.</li></ul><p>The &#8220;volatile&#8221; modifier <br
/> 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. <br
/> If a variable is a pointer to something other than normal memory, such as memory-mapped ports on a <br
/> 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: <br
/> <code><br
/> time_t time_addition(volatile const struct timer *t, int a)  <br
/> {  <br
/>   int n;  <br
/>   int x;  <br
/>   time_t then;  <br
/>   x = 0;  <br
/>   then = t-&gt;value;  <br
/>   for (n = 0; n &lt; 1000; n++)  <br
/>   {  <br
/>     x = x + a;  <br
/>   }  <br
/>   return t-&gt;value - then;  <br
/> }  <br
/> </code><br
/> In this code, the variable t-&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.</li><li><strong>What does the typedef keyword do?</strong>This keyword provides a short-hand way to write variable declarations. It is not a true data typing mechanism, rather, it is syntactic &#8220;sugar coating&#8221;. <br
/> For example <br
/> <code><br
/> typedef struct node <br
/> { <br
/>   int value; <br
/>   struct node *next; <br
/> }mynode; <br
/> </code><br
/> This can later be used to declare variables like this <br
/> <code><br
/> mynode *ptr1; <br
/> and not by the lengthy expression <br
/> struct node *ptr1; <br
/> </code><br
/> There are three main reasons for using typedefs:</p><ul><li>It makes the writing of complicated declarations a lot easier. This helps in eliminating a lot of clutter in the code.</li><li>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.</li><li>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.</li></ul></li><li><strong>What is the difference between constants defined through #define and the constant keyword?</strong>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&#8217;s value in the proram &#8211; 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. <br
/> Constants may be defined using the preprocessor directive #define. They may also be defined using the const keyword. <br
/> So whats the difference between these two? <br
/> <code><br
/> #define ABC 5 <br
/> and <br
/> const int abc = 5; <br
/> </code><br
/> There are two main advantages of the second one over the first technique. First, the type of the constant is defined. &#8220;pi&#8221; 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. <br
/> 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.</li><li><strong>What are Trigraph characters?</strong>These are used when you keyboard does not support some special characters <br
/> <code><br
/>     ??=    # <br
/>     ??(    [ <br
/>     ??)    ] <br
/>     ??&lt;    { <br
/>     ??&gt;    } <br
/>     ??!    | <br
/>     ??/    \ <br
/>     ??'    ^ <br
/>     ??-    ~ <br
/> </code></li><li><strong>How are floating point numbers stored? Whats the IEEE format?</strong>IEEE Standard 754 floating point is the most common representation today for real numbers on computers, including Intel-based PC&#8217;s, Macintoshes, and most Unix platforms. <br
/> 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. <br
/> 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): <br
/> <code><br
/>                  Sign   Exponent   Fraction   Bias  <br
/> -------------------------------------------------- <br
/> Single Precision 1 [31] 8 [30-23]  23 [22-00] 127  <br
/> Double Precision 1 [63] 11 [62-52] 52 [51-00] 1023  <br
/> </code><br
/> 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. <br
/> 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. <br
/> 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: <br
/> <code><br
/>         5.00 × 100 <br
/>         0.05 × 10 ^ 2 <br
/>         5000 × 10 ^ -3 <br
/> </code><br
/> 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 × 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&#8217;t need to represent it explicitly. As a result, the mantissa has effectively 24 bits of resolution, by way of 23 fraction bits. <br
/> So, to sum up: <br
/> <code><br
/> 1. The sign bit is 0 for positive, 1 for negative.  <br
/> 2. The exponent's base is two.  <br
/> 3. The exponent field contains 127 plus the true exponent for single-precision,  <br
/>    or 1023 plus the true exponent for double precision.  <br
/> 4. The first bit of the mantissa is typically assumed to be 1.f, where f is the  <br
/>    field of fraction bits.  <br
/> </code></li><li><strong>When should the register modifier be used?</strong>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. <br
/> 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; 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.</li><li><strong>When should a type cast be used?</strong>There are two situations in which to use a type cast. <br
/> The first use is to change the type of an operand to an arithmetic operation so that the operation will be performed properly. <br
/> 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. <br
/> <code><br
/> struct foo *p = (struct foo *) malloc(sizeof(struct foo));  <br
/> </code><br
/> 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 <br
/> rare events in which this action is beneficial, using a union to hold the values makes the programmer?s intentions clearer.</p><p> </li><li><strong>Can structures be assigned to variables and passed to and from functions?</strong>Yes, they can! <br
/> 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!.</li> ]]></content:encoded> <wfw:commentRss>http://www.freequestionbank.com/articles/interview-questions-on-c-programming/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Latest Microsoft Interview Questions</title><link>http://www.freequestionbank.com/articles/latest-microsoft-interview-questions-2/</link> <comments>http://www.freequestionbank.com/articles/latest-microsoft-interview-questions-2/#comments</comments> <pubDate>Tue, 12 May 2009 02:53:53 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Articles]]></category> <category><![CDATA[Interview]]></category> <category><![CDATA[Microsoft]]></category> <category><![CDATA[Question]]></category><guid
isPermaLink="false">http://www.freequestionbank.com/blog/?p=564</guid> <description><![CDATA[ 
Given a Parent -Child binary tree ,build the child -sibling version of it? Minimize the space requirements wherever possible. 
Given a ...]]></description> <content:encoded><![CDATA[<p> </p><li>Given a Parent -Child binary tree ,build the child -sibling version of it? Minimize the space requirements wherever possible. </li><li>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? </li><li>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? </li><li>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. </li><li>Given an expression remove the unnecessary brackets in it with out creating an ambiguity in its execution. <code><br
/> </code><code>input output </code><br
/> <code>ex1: (a+(b)+c) a+b+c <br
/> ex2: (a*b)+c a*b+c </code></li><li>Propose a tree based data structure to identify a node with nth rank with maximum efficiency . </li><li>Given a string S of alphabets and 2 characters a,b find the minimum distance between instances of them such that position of a &lt;= position of b. </li><li>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. <br
/> <code>input output </code><br
/> <code>eg: abcdef%ghi%—— and “ppp” abcdefpppghippp </code></li><li>Given a binary tree verify whether it is a binary search tree or not? </li><li>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) </li> ]]></content:encoded> <wfw:commentRss>http://www.freequestionbank.com/articles/latest-microsoft-interview-questions-2/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Yahoo Interview Questions</title><link>http://www.freequestionbank.com/articles/yahoo-interview-questions-3/</link> <comments>http://www.freequestionbank.com/articles/yahoo-interview-questions-3/#comments</comments> <pubDate>Tue, 12 May 2009 02:52:52 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Articles]]></category> <category><![CDATA[Interview]]></category> <category><![CDATA[Question]]></category> <category><![CDATA[yahoo]]></category><guid
isPermaLink="false">http://www.freequestionbank.com/blog/?p=562</guid> <description><![CDATA[Design classes for the following problem. (C++) A Customer Can have multiple bank accounts A Bank account can be owned by ...]]></description> <content:encoded><![CDATA[<p><strong>Design classes for the following problem. (C++) <br
/> </strong><br
/> 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.</p><p><strong>Solution :</strong></p><p>Customer class, Account class, Transaction class <br
/> Customer class contains an array of pointers to the account classes <br
/> Account class contains an array of pointers to its owner customer classes <br
/> Account class also contains an array of transactions associated to it. <br
/> Transaction class contains id or pointer the customer who did that transaction <br
/> In customer class write a function with prototype</p><pre>for (i in Accounts )
{
 cout &lt;&lt; i.AccountName &lt;&lt; endl;
}
cin &gt;&gt; id;
for(i in Accounts[id].transactions )
{
 cout &lt;&lt; i.TransDetails &lt;&lt; endl;
}</pre><p><span>Yahoo Interview Round 1:</span> </p><ol><li><strong>How to call a C++ function which is compiled with C++ compiler in C code? <br
/> </strong><br
/> <strong>Solution:</strong> The C++ compiler must know that f(int,char,float) is to be called by a C compiler using the extern &#8220;C&#8221;construct: </p><p>The extern &#8220;C&#8221; 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&#8217;t supported by C, you can&#8217;t make several overloaded functions simultaneously callable by a C program. </p><pre>// This is C++ code
// Declare f(int,char,float) using extern "C":
extern "C" void f(int i, char c, float x);
...
// Define f(int,char,float) in some C++ module:
void f(int i, char c, float x)
{
   .....
}</pre></li><li><strong>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)</strong></li><li><strong>How do you initialize a static member of a class with return value of some function?</strong><br
/><blockquote><p><strong>Solution :</strong></p><p>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.</p><p>Consider the following class, A, with a static data member, _id:</p><pre>
  //File: a.h
   class A
   {
      public:
      A();
      int _id;
   };</pre><p>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:</p><pre>   // File: a.cc
   int A::_id;</pre><p>Because no explicit initial value was specified, the compiler will implicitly initialize _id to zero. An explicit initialization can also be specified:</p><pre>
// File: a.cc
 int A::_id = 999;</pre><p>In fact, C++ even allows arbitrary expressions to be used in initializers:</p><pre>      // File: a.cc
   int A::_id = GetId();</pre></blockquote></li><li><strong>How can one application use same API provided by different vendors at the same time?</strong></li><li><strong>If you are given the name of the function at run time how will you invoke the function?</strong><br
/><blockquote><p><strong>Solution :</strong></p><ul><li>Compile your program with &#8211;export-dynamic on the gcc command line</li><li>Link with -ldl (dynamic library handling, needed for dlopen and dlsym</li><li>Call dlopen() with a null parameter, meaning you aren&#8217;t loading symbols from a file but from the current executable</li><li>Call dlsym() with the name of the function you&#8217;ll be calling. Note that C++ modifies function names, so If you&#8217;re trying this with C++, you&#8217;d have to either declare this function as extern &#8220;C&#8221;, or figure out what name the function has after compiling. (On unix, you could run nm -s on the object file for this).</li><li>If dlsym() returns non-null, use the returned value as a function pointer to invoke your function.</li></ul></blockquote></li></ol><p><span>Yahoo Interview Round 2:</span></p><ol><li><strong>When will you use shell script/Perl ahead of C/C++?</strong></li><li><strong>How does yahoo handles billions of requests, does it create a thread per request or a process?</strong></li><li><strong>How does HTTP works?</strong><br
/><blockquote><p><strong>Solution :</strong>HTTP Is a request-response protocol.</p><p>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.</p></blockquote></li><li><strong>How to count number of unique music titles downloaded from a log file which contains an entry of all music title downloaded?</strong></li><li><strong>What is the difference between COM and CORBA?</strong><br
/><blockquote><p><strong>Solution :</strong>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.</p></blockquote></li><li><strong>What is web service?</strong><br
/><blockquote><p><strong>Solution :</strong>Web Service is defined as &#8220;a software system designed to support interoperable Machine to Machine interaction over a network.&#8221; 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.</p></blockquote></li></ol> ]]></content:encoded> <wfw:commentRss>http://www.freequestionbank.com/articles/yahoo-interview-questions-3/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Google Fresher Interview Questions &#8211; round 5 (management round)</title><link>http://www.freequestionbank.com/articles/google-fresher-interview-questions-round-5-management-round/</link> <comments>http://www.freequestionbank.com/articles/google-fresher-interview-questions-round-5-management-round/#comments</comments> <pubDate>Tue, 12 May 2009 02:51:20 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Articles]]></category> <category><![CDATA[google]]></category> <category><![CDATA[Interview]]></category> <category><![CDATA[Question]]></category><guid
isPermaLink="false">http://www.freequestionbank.com/blog/?p=558</guid> <description><![CDATA[ 
Tell me an achievement that you have done in your non academics
Tell me about one of your project
Take a feature ...]]></description> <content:encoded><![CDATA[<p> </p><li>Tell me an achievement that you have done in your non academics</li><li>Tell me about one of your project</li><li>Take a feature of C++ and tell me how you have implemented it in one of your project</li><li>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</li><li>There is a routine already written to find the subtraction of two sets ( set A &#8211; set B) . Write test cases for testing it.Tell me how do you test the test cases you have written?</li><li>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? </li> ]]></content:encoded> <wfw:commentRss>http://www.freequestionbank.com/articles/google-fresher-interview-questions-round-5-management-round/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Google Fresher Interview Questions &#8211; round 4</title><link>http://www.freequestionbank.com/articles/google-fresher-interview-questions-round-4/</link> <comments>http://www.freequestionbank.com/articles/google-fresher-interview-questions-round-4/#comments</comments> <pubDate>Tue, 12 May 2009 02:47:54 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Articles]]></category> <category><![CDATA[google]]></category> <category><![CDATA[Interview]]></category> <category><![CDATA[Question]]></category><guid
isPermaLink="false">http://www.freequestionbank.com/blog/?p=556</guid> <description><![CDATA[ 
Given n non overlapping intervals and an element. Find the interval into which this element falls.
Solution: 
we can extend binary search ...]]></description> <content:encoded><![CDATA[<p> </p><li>Given n non overlapping intervals and an element. Find the interval into which this element falls.<p><strong>Solution:</strong> <br
/> we can extend binary search to intervals.(Assuming the intervals are sorted)<br
/> consider interval [a,b].<br
/> if (a-x)(b-x) &lt;=0 <br
/> then x belongs to [a,b].<br
/> else<br
/> if x&gt;a <br
/> element can be present only in the intervals to its right. <br
/> so select the middle interval among them to it&#8217;s right<br
/> and repeat the procedure.<br
/> else<br
/> element can be present only in the intervals to its left. <br
/> so select the middle interval among them to it&#8217;s left<br
/> and repeat the procedure.</p><p>The complexity of this problem is log(N) where N is the number of sorted non-overlapping intervals.</li><li>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).</li><li>Now given that the n intervals are overlapping then how do you solve? The interviewer was concentrating more on the complexities (running, memory ..) <p><strong>Solution:</strong> <br
/> 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.</li><li>Write code for Random Sort? <pre>Algorithm  is explained:

Given an input array of size n. Random sort is sampling
a new array from the given array and check whether the
sampled array is sorted or not. If sorted return else
sample again. The stress was on the
code.</pre><div><span><br
/> </span></div></li> ]]></content:encoded> <wfw:commentRss>http://www.freequestionbank.com/articles/google-fresher-interview-questions-round-4/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Google Fresher Interview Questions &#8211; round 3</title><link>http://www.freequestionbank.com/articles/google-fresher-interview-questions-round-3/</link> <comments>http://www.freequestionbank.com/articles/google-fresher-interview-questions-round-3/#comments</comments> <pubDate>Tue, 12 May 2009 02:47:30 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Articles]]></category> <category><![CDATA[google]]></category> <category><![CDATA[Interview]]></category> <category><![CDATA[Question]]></category><guid
isPermaLink="false">http://www.freequestionbank.com/blog/?p=554</guid> <description><![CDATA[ 
Write C++ class for the game Connect Four. [Connect Four (also known as Plot Four, Four In A Row, and ...]]></description> <content:encoded><![CDATA[<p> </p><li>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.]</li><li>Given a stack and an input string of 1234.At any point you can do anyone of the follow <pre>i. take the next input symbol and Enque.
ii. you can pop as many as you can. When ever you
pop an element it will be printed
            (you cannot pop from an empty stack)</pre><p>How many such permutations are possible on an input of size N?</p><p><strong>Solution:</strong><br
/> It is Nth catalan number.For a detailed solution look at question5 of Stacks and Queues</li><li>Give an example of one permutation that this data structure cannot generate. <pre>For Example:

1234 is input.

First push all 1,2,3,4 on to stack and pop all.
    output will be 4321.</pre><p>It means that this data structure can generate 4321.</p><p><strong>Solution:</strong><br
/> 3124 <br
/> for a detailed solution please look at question7 of the post<br
/> Stacks and Queues</li><li>Question 2 was pretty easy right? Now do again the same question but the data structure this time around is a Deque. <pre>Input: 12345
Data Structure: Deque ( Doubly Que )

Note: Deque is a data structure into which you can do enque
    and deque from both sides.Some thing like this
__________________________________
enque ---&gt; &lt;----enque dequeue &lt;---- -----&gt;dequeue
__________________________________</pre><p><strong>Solution:</strong> <br
/> 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.</li><li>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.<p><strong>Solution:</strong> <br
/> Let &#8220;d&#8221; be the number of drops required to find out the max floor.we need to get the value of d.</p><p>let&#8217;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 &#8220;d&#8221; drops, so first we will drop it from height &#8220;d&#8221; if it doesn&#8217;t break at a height &#8220;d&#8221; then we are left with &#8220;d-1&#8243; drops,so lets drop it from d + &#8216;d-2&#8242; + 1 height suppose if it break there then you are left with &#8216;d-2&#8242; drops.<br
/> and so on until that sum is less than 100, it&#8217;s like a linear search,</p><p>in equations,</p><p>(1+(d-1))+ (1+(d-2)) + &#8230;. &gt;= 100</p><p>here we need to find out d</p><p>from the above equation</p><p>d(d + 1)/2 &gt;= 100</p><p>from above d is 14</li> ]]></content:encoded> <wfw:commentRss>http://www.freequestionbank.com/articles/google-fresher-interview-questions-round-3/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Google Fresher Interview Questions &#8211; round 2</title><link>http://www.freequestionbank.com/articles/google-fresher-interview-questions-round-2/</link> <comments>http://www.freequestionbank.com/articles/google-fresher-interview-questions-round-2/#comments</comments> <pubDate>Tue, 12 May 2009 02:46:43 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Articles]]></category> <category><![CDATA[google]]></category> <category><![CDATA[Interview]]></category> <category><![CDATA[Question]]></category><guid
isPermaLink="false">http://www.freequestionbank.com/blog/?p=552</guid> <description><![CDATA[ 
What is Bottom up parsing and what is top down parsing? 
Solution: 
Bottom-up parsing is a strategy for analyzing unknown data relationships that ...]]></description> <content:encoded><![CDATA[<p> </p><li>What is Bottom up parsing and what is top down parsing? <p><strong>Solution:</strong> </p><p><strong>Bottom-up</strong> 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. </p><p><strong>Top-down</strong> 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. </p><p><a
href="http://en.wikipedia.org/wiki/Bottom-up_parsing">http://en.wikipedia.org/wiki/Bottom-up_parsing</a> </p><p><a
href="http://en.wikipedia.org/wiki/Top-down_parsing">http://en.wikipedia.org/wiki/Top-down_parsing</a></li><li>What is a symbol table? <p><strong>Solution:</strong> <br
/> 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&#8217;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.<br
/> Check out <br
/> <a
href="http://en.wikipedia.org/wiki/Symbol_table">http://en.wikipedia.org/wiki/Symbol_table</a></li><li>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.<p><strong>Solution:</strong><br
/> Every row has a primary key. Suppose the primary key for this<br
/> particular database is the name of the user then we can sort the names based<br
/> on alphabets and do secondary indexing based on the starting alphabet . If<br
/> the data is uniformly distributed we can go for multilevel indexing or<br
/> hashing.Similarly if we have a registration number as the primary key then<br
/> we can sort the table based on registration number and then do indexing<br
/> either secondary level or multilevel or apply hashing techniques based on<br
/> the distribution of data. Many efficient algorithms are available for<br
/> indexing and hashing.</li><li>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.<p><strong>Solution:</strong><br
/> Weigh 3 balls against 3 others. <br
/> <span>Case A:</span> 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.</p><p><span>Case B</span>:</p><p><span>Step1:</span> If, on the first weighing, the balls don&#8217;t balance.<br
/> 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&#8217;s say Side A, is heavier than the other (although we don&#8217;t know whether the odd ball is heavy or light). <br
/> <span>Step 2 </span>: 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). </p><p>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.</p><p>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. </p><p>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&#8217;t know whether the odd ball is heavy or light).</p><p><span>Step 3 (for Case B)</span>: 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.</li><li>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?<p><strong>Solution:</strong><br
/> Dozens of different data structures have been proposed for implementing dictionaries including hash tables, skip lists, and balanced/unbalanced binary search trees &#8212; 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.</li><li>Asked me about all the details of hash table and heaps.</li><li>Write code for finding number of zeros in n!<p><strong>Solution:</strong></p><p>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! .<br
/> This simple formula works for finding it floor(n/5)+floor(n/25)+floor(n/125)+&#8230;&#8230;</p><pre>
function zeros(int n)
{
  int count=0,k=5;
while(n&gt;=k)
{
 count+=n/k;
        k*=5;
}
return count;
}</pre><p>this count is the number of o&#8217;s in n!.</li> ]]></content:encoded> <wfw:commentRss>http://www.freequestionbank.com/articles/google-fresher-interview-questions-round-2/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Google Fresher Interview Questions &#8211; round 1</title><link>http://www.freequestionbank.com/articles/google-fresher-interview-questions-round-1/</link> <comments>http://www.freequestionbank.com/articles/google-fresher-interview-questions-round-1/#comments</comments> <pubDate>Tue, 12 May 2009 02:46:09 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Articles]]></category> <category><![CDATA[google]]></category> <category><![CDATA[Interview]]></category> <category><![CDATA[Question]]></category><guid
isPermaLink="false">http://www.freequestionbank.com/blog/?p=550</guid> <description><![CDATA[ 
Asked about my project. Prepare well to answer any type of questions that may arise in your project.They will just ...]]></description> <content:encoded><![CDATA[<p> </p><li>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.</li><li>In a plane, n points are given i.e. the input is (x1,y1), (x2,y2)&#8230; (xn,yn). Now given these n points.Find the maximum number of collinear points. <br
/> <strong>Solution:</strong> <br
/> 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).</li><li>Write the code for finding the min of n number.<pre>I gave:

for(i=0;i&lt;n;i++)
{
   if( a[i]&lt;min )
   {
         min = a[i] ---- eq(i)
   }
}</pre><p>Given that n numbers are from random sampling how many times (probability) does the line (i) be executed </p><p><strong>Solution:</strong> </p><pre>min=a[0];
for(i=1;i&lt;n;i++)
{
    if( a[i]&lt;min )
    {

        min = a[i]; -------eq(i)
    }

}</pre><p>Once the variable min is initialized,the probability of a[i] &lt; min is 1/2. So the expected number of occurances of equation i is (n-1)/2 .</li> ]]></content:encoded> <wfw:commentRss>http://www.freequestionbank.com/articles/google-fresher-interview-questions-round-1/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Google Interview Questions &#8211; round 5</title><link>http://www.freequestionbank.com/articles/google-interview-questions-round-5/</link> <comments>http://www.freequestionbank.com/articles/google-interview-questions-round-5/#comments</comments> <pubDate>Tue, 12 May 2009 02:44:52 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Articles]]></category> <category><![CDATA[google]]></category> <category><![CDATA[Interview]]></category> <category><![CDATA[Question]]></category><guid
isPermaLink="false">http://www.freequestionbank.com/blog/?p=548</guid> <description><![CDATA[ 
If you get into Google, which products are you going to work on?
What is TCP, UDP. what is reliability, unreliability, ...]]></description> <content:encoded><![CDATA[<p> </p><li>If you get into Google, which products are you going to work on?</li><li>What is TCP, UDP. what is reliability, unreliability, give examples of these?<p><strong>Solution:</strong><br
/> <a
href="http://en.wikipedia.org/wiki/Transmission_Control_Protocol">Click Here To Read About TCP</a><br
/> <a
href="http://en.wikipedia.org/wiki/User_Datagram_Protocol">Click Here To Read About UDP</a><br
/> <a
href="http://en.wikipedia.org/wiki/Reliability_%28computer_networking%29">Click Here To Read About Reliability</a></li><li>What is http protocol?<p><strong>Solution:</strong><br
/> <a
href="http://en.wikipedia.org/wiki/HTTP">Click Here To Read About HTTP</a></li><li>How does Google search engine works?</li><li>What is indexing, what is the input and output to it. how Google does that?</li> ]]></content:encoded> <wfw:commentRss>http://www.freequestionbank.com/articles/google-interview-questions-round-5/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Google Interview Questions &#8211; round 4</title><link>http://www.freequestionbank.com/articles/google-interview-questions-round-4/</link> <comments>http://www.freequestionbank.com/articles/google-interview-questions-round-4/#comments</comments> <pubDate>Tue, 12 May 2009 02:44:04 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Articles]]></category> <category><![CDATA[google]]></category> <category><![CDATA[Interview]]></category> <category><![CDATA[Question]]></category><guid
isPermaLink="false">http://www.freequestionbank.com/blog/?p=546</guid> <description><![CDATA[ 
Three strings say A,B,C are given to you. Check weather 3rd string is interleaved from string A and B.
...]]></description> <content:encoded><![CDATA[<p> </p><li>Three strings say A,B,C are given to you. Check weather 3rd string is interleaved from string A and B.<pre>       Ex: A="abcd" B="xyz" C="axybczd". answer is yes.</pre><p><strong>Solution:</strong></p><pre>
bool test(A,B,C)
{
  i=j=k=0;
  while(k &lt; C.size())
  {
    if(i &lt; A.size() &amp;&amp; C[k]==A[i])
     {i++,k++;
     }
    else if(j &lt; B.size() &amp;&amp; C[k]==B[j])
    {
      j++,k++;
    }
    else
    return false
  }
  return (i == A.size() &amp;&amp; j == B.size());
}</pre><p>The above algorithm doesn&#8217;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.</li><li>Given two sorted arrays A and B. </li><ol><li>Find the intersection of these arrays A and B.<p><strong>Solution:</strong>The intersection can be found by using a variation of merge routine of the merge sort.</li><li>If array A is small and array B is too large. how will you proceed for getting intersection of those two arrays?<p><strong>Solution:</strong>In this case for each entry of smaller array,we can run a binary search routine on the larger one to know its presence.</li></ol> ]]></content:encoded> <wfw:commentRss>http://www.freequestionbank.com/articles/google-interview-questions-round-4/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- This site's performance optimized by W3 Total Cache. Dramatically improve the speed and reliability of your blog!

Learn more about our WordPress Plugins: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (user agent is rejected)
Database Caching 7/12 queries in 0.378 seconds using disk

Served from: p3slh049.shr.phx3.secureserver.net @ 2010-09-10 00:20:57 -->