<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2682781734368178743</id><updated>2012-01-26T00:57:24.596-08:00</updated><category term='puzzles'/><category term='Questions-List'/><category term='String Manipulation'/><category term='Dynamic Programming'/><category term='Linked List'/><category term='Array'/><category term='Microsoft'/><category term='Databases'/><category term='Data Structures'/><category term='MySpace'/><category term='Tree'/><category term='.NET/C#'/><title type='text'>Technical Interview Questions</title><subtitle type='html'>Answers to frequently asked programming interview questions and puzzles asked at google, microsoft, amazon, yahoo, facebook, MySpace, and such for SDE/Developer and SDET positions.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>avid gardener</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>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-2294893240870146828</id><published>2010-08-01T23:52:00.000-07:00</published><updated>2010-08-01T23:57:53.113-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Array'/><title type='text'>Reverse Minesweeper</title><summary type='text'>Question: The interviewer first discussed the game of minesweeper and the gave a reverse minesweeper problem where the specifications were as follows:
1. A block of M rows by N columns is given
2. Each item can either be a mine or not a mine
3. The location of the mines in the block is given by the character *
4. Normal/safe squares are marked by '.' (dots)

See the below table and write a </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/2294893240870146828/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2010/08/reverse-minesweeper.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/2294893240870146828'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/2294893240870146828'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2010/08/reverse-minesweeper.html' title='Reverse Minesweeper'/><author><name>avid gardener</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></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-3715056147845986624</id><published>2009-11-23T10:26:00.000-08:00</published><updated>2009-11-23T10:27:08.883-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET/C#'/><title type='text'>How and why to prevent class inheritance in C#/.NET</title><summary type='text'>Question: In .NET/C#, how does one prevent a class from being inherited by another class? In other words can the inheritance of class be blocked? Also, what is the reason one might want to block the inheritance chain?

The sealed keyword/modified in .NET can be used to block derivation from a class. An attempt to inherit from a class marked as sealed will result in a compile time error. Also, a </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/3715056147845986624/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2009/11/csharp-sealed-class-inheritance-block.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/3715056147845986624'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/3715056147845986624'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2009/11/csharp-sealed-class-inheritance-block.html' title='How and why to prevent class inheritance in C#/.NET'/><author><name>avid gardener</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></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-3916417625412212850</id><published>2009-11-16T04:01:00.000-08:00</published><updated>2009-11-16T04:01:08.102-08:00</updated><title type='text'>Difference Between calloc, malloc, and realloc</title><summary type='text'>Question: What is the difference between malloc(), calloc(), and realloc()

malloc, calloc, and realloc are functions used for memory allocation in C/C++ languages. There are some fundamental differences on how the above functions work.
realloc() 
First of all realloc() is actually a reallocation function. It is used to resize a previously allocated (using malloc(), calloc(), or realloc()) block </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/3916417625412212850/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2009/11/difference-between-calloc-malloc-and.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/3916417625412212850'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/3916417625412212850'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2009/11/difference-between-calloc-malloc-and.html' title='Difference Between calloc, malloc, and realloc'/><author><name>avid gardener</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>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-6009214993109752429</id><published>2009-11-03T20:02:00.000-08:00</published><updated>2009-11-03T20:02:29.544-08:00</updated><title type='text'>Must Read Books for Technical/Programming Interview Preparation</title><summary type='text'>Coding, Program Design and Interview Questions:
Programming Interviews Exposed: Secrets to Landing Your Next Job ~ John Mongan, Noah Suojanen, and Eric Giguère
Programming Pearls (2nd Edition) ~ Jon Bentley
Expert C Programming: Deep C Secrets ~ Peter van der Linden
Puzzles for Programmers and Pros ~ Dennis Shasha
More Programming Pearls: Confessions of a Coder ~ Jon Bentley
Programming </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/6009214993109752429/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2009/11/must-read-books-for-technicalprogrammin.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/6009214993109752429'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/6009214993109752429'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2009/11/must-read-books-for-technicalprogrammin.html' title='Must Read Books for Technical/Programming Interview Preparation'/><author><name>avid gardener</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>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-558934194029345602</id><published>2009-04-02T15:48:00.001-07:00</published><updated>2009-04-03T19:35:59.519-07:00</updated><title type='text'>Implement Two stacks using one array</title><summary type='text'>Problem: How to implement/code two stacks using one array.
Solution: The obvious solution is to have the two stacks at the two ends of the array. The stacks will grow in opposite direction. When the two stacks collide and there is no more room in the array the stacks will over flow. This problem is probably one of the easier problems and targeted towards exercising your array index manipulation </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/558934194029345602/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2009/04/implement-two-2-stacks-one-1-array.html#comment-form' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/558934194029345602'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/558934194029345602'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2009/04/implement-two-2-stacks-one-1-array.html' title='Implement Two stacks using one array'/><author><name>avid gardener</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><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_MaVk85uAEFM/SdVCAIJjR-I/AAAAAAAAFXE/Je425O9ajNU/s72-c/TwoStacksOneArray.png' height='72' width='72'/><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-7594621564260669939</id><published>2009-03-22T23:28:00.001-07:00</published><updated>2009-03-23T00:10:38.789-07:00</updated><title type='text'>Determine and display all anagrams in a string array</title><summary type='text'>Question: Given an array of strings (string[] inputStrings). Devise a way and write the code to determine and display all the anagrams in the array.

Solution: With any interview question one should get the specifics of the problem and the input data before designing the solution. In this particular case, we should ask about the approximate number of strings in the array, average length of each </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/7594621564260669939/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2009/03/anagrams-string-array-print.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/7594621564260669939'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/7594621564260669939'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2009/03/anagrams-string-array-print.html' title='Determine and display all anagrams in a string array'/><author><name>avid gardener</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>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-6978494098156841435</id><published>2009-03-03T18:15:00.000-08:00</published><updated>2009-04-16T18:32:00.420-07:00</updated><title type='text'>Print 2D Array Matrix Spiral Order</title><summary type='text'>Question: Given a 2D array / matrix of integers. Write a program to print the elements in spiral order. Consider a matrix as show in the diagram to the right. The desired output of the program should be as: 1,2,3,4,8,12,16,20,19,18,17,13,9,5,6, 7,11,15,14,10.








Solution: There are several ways to solve this problem, but I am mentioning a method that is intuitive to understand and easy to </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/6978494098156841435/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2009/03/print-2d-array-matrix-spiral-order.html#comment-form' title='13 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/6978494098156841435'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/6978494098156841435'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2009/03/print-2d-array-matrix-spiral-order.html' title='Print 2D Array Matrix Spiral Order'/><author><name>avid gardener</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><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_MaVk85uAEFM/Sa3lmg7NtaI/AAAAAAAAFHw/w1vE2ZS4n0g/s72-c/matrix-spiral-print.png' height='72' width='72'/><thr:total>13</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-6084917774087430049</id><published>2009-03-01T17:02:00.000-08:00</published><updated>2009-03-01T17:50:40.281-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MySpace'/><category scheme='http://www.blogger.com/atom/ns#' term='Tree'/><category scheme='http://www.blogger.com/atom/ns#' term='Data Structures'/><title type='text'>DNA Sequence Pattern Match/ String Search Problem</title><summary type='text'>Question: The DNA double helix consists of a long strand of four bases:  adenine (abbreviated A), cytosine (C), guanine (G) and thymine (T).  Thus, it can be represented as a long string containing the characters A, C, G, and T. The field of bio-informatics involves storing and searching of DNA sequence data. What is a good data structure to facilitate storage and string match/search operation on</summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/6084917774087430049/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2009/03/dna-sequence-pattern-match-search.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/6084917774087430049'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/6084917774087430049'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2009/03/dna-sequence-pattern-match-search.html' title='DNA Sequence Pattern Match/ String Search Problem'/><author><name>avid gardener</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></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-4245134015631281445</id><published>2009-02-20T14:33:00.000-08:00</published><updated>2009-02-20T15:38:43.151-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Databases'/><title type='text'>Database Isolation Levels in Sql Server and ADO.NET</title><summary type='text'>Isolation level refers to I in the ACID properties for a Transaction. ACID stands for Atomicity, Consistency, Isolation, Durability. Isolation level refers to sensitivity of a database transaction to other changes in other transactions. You can set the isolation level for a transaction using the following command in T-SQL:

SET TRANSACTION ISOLATION LEVEL &lt;level name&gt;

&lt;level name&gt; can be one of </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/4245134015631281445/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2009/02/isolation-levels-sql-server-adonet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/4245134015631281445'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/4245134015631281445'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2009/02/isolation-levels-sql-server-adonet.html' title='Database Isolation Levels in Sql Server and ADO.NET'/><author><name>avid gardener</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></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-2882977221019260239</id><published>2009-02-19T11:40:00.000-08:00</published><updated>2009-02-20T15:55:40.760-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Databases'/><title type='text'>Database Normalization Basics</title><summary type='text'>First Normal Form (1NF):
Identify related groups of data (ex: orders, customers, products) and create separate tables for each group.All tables should have a Primary Key identifying an individual row in a table.No two columns in a table should have the same information and each column can contain only one attribute.In essence 1st normal form is about removing redundant data and creating tables </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/2882977221019260239/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2009/02/database-normalization-basics-normal.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/2882977221019260239'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/2882977221019260239'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2009/02/database-normalization-basics-normal.html' title='Database Normalization Basics'/><author><name>avid gardener</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>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-3908539204663226869</id><published>2009-02-18T14:29:00.000-08:00</published><updated>2010-07-27T23:42:01.715-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Databases'/><title type='text'>SQL Server Index Fragmentation and Resolution</title><summary type='text'>What is Index Fragmentation and how do you resolve it in SQL Server? 
Answer: I came across and excellent article on index fragmentation and 4 ways to resolve it  on Sql-Server-Performace.com which describes it in great detail.</summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/3908539204663226869/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2009/02/sql-server-index-fragmentation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/3908539204663226869'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/3908539204663226869'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2009/02/sql-server-index-fragmentation.html' title='SQL Server Index Fragmentation and Resolution'/><author><name>avid gardener</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></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-5859452822652535231</id><published>2009-02-10T14:39:00.000-08:00</published><updated>2009-02-20T16:19:48.707-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Array'/><category scheme='http://www.blogger.com/atom/ns#' term='Microsoft'/><title type='text'>Find an Item in a Sorted Array with Shifted Elements</title><summary type='text'>Problem: You are given a sorted array with shifted elements. Elements can be shifted to the left or right by 'i' number of places. The sign of 'i' denotes the direction of the shift. For positive 'i' direction of shift is right and left for negative 'i'.

For example, consider the sorted array 2, 3, 4, 8, 10, 11. A shift of 3 places to the right would be denoted by i=2 and the shifted array would</summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/5859452822652535231/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2009/02/sorted-array-shifted-elements-search.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/5859452822652535231'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/5859452822652535231'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2009/02/sorted-array-shifted-elements-search.html' title='Find an Item in a Sorted Array with Shifted Elements'/><author><name>avid gardener</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><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_MaVk85uAEFM/SZIkYwSos0I/AAAAAAAAEww/LfhkEwJ3FTo/s72-c/sorted-array-shifted-elements.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-9011241534226262987</id><published>2009-02-01T21:39:00.001-08:00</published><updated>2009-02-23T14:31:12.570-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Databases'/><title type='text'>Database SQL Interview Questions</title><summary type='text'>Write a SQL Query to find first day of month?Why there is a performance difference between two similar queries that uses UNION and UNION ALL?How to choose between a Clustered Index and a Non-Clustered Index?How you can minimize deadlock situations in a database server? When you should use low fill factor?Explain First, Second, and Third database normalization form with examples?What are the </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/9011241534226262987/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2009/02/database-sql-interview-questions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/9011241534226262987'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/9011241534226262987'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2009/02/database-sql-interview-questions.html' title='Database SQL Interview Questions'/><author><name>avid gardener</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></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-8426659995757249102</id><published>2009-01-28T19:23:00.001-08:00</published><updated>2009-02-20T16:20:26.738-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Array'/><title type='text'>Array: Find the number with odd number of occurrences</title><summary type='text'>Problem: You are given an array containing positive integers. All the integers occur even number of times except one. Find this special integer.

Solution: A naive approach would be to loop over the elements of the given array and keep a count of each integer in a hash table or another counter array. But, this quickly becomes unfeasible as the range of integers could be 2^31 (one less). This is </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/8426659995757249102/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2009/01/integer-array-odd-even-occurrences-find.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/8426659995757249102'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/8426659995757249102'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2009/01/integer-array-odd-even-occurrences-find.html' title='Array: Find the number with odd number of occurrences'/><author><name>avid gardener</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>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-5381821053975293449</id><published>2009-01-21T13:49:00.000-08:00</published><updated>2009-02-20T16:22:46.089-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Microsoft'/><category scheme='http://www.blogger.com/atom/ns#' term='Dynamic Programming'/><title type='text'>Fibonacci Sequence Dynamic Programming</title><summary type='text'>Problem: Write the code for nth Fibonacci number.

Solution: There are basically two approaches to solving the Fibonacci problem. Lets looks at the definition of Fibonacci series first.

The Fibonacci series is defined as follows

F(n) = 0 for n = 0
       1 for n = 1
       F(n-1) + F(n-2) for n &gt; 1

If we translate that to the C language we get:


int RecursiveFibonacci(int n)
{
    if(n == 0) </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/5381821053975293449/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2009/01/fibonacci-sequence-dynamic-programming.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/5381821053975293449'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/5381821053975293449'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2009/01/fibonacci-sequence-dynamic-programming.html' title='Fibonacci Sequence Dynamic Programming'/><author><name>avid gardener</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>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-8119601356425414622</id><published>2009-01-14T15:18:00.000-08:00</published><updated>2009-02-20T16:17:57.861-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Data Structures'/><title type='text'>Store a stream of numbers along with the counts</title><summary type='text'>Problem: Given a stream of numbers, suggest a data structure to store the numbers in the stream along with their number of occurrences.

Solution:
Before solving any problem make sure you lay down all the assumptions you are making and validate them with the interviewer.

Assumptions here:
The numbers are 32 bit integers. The size of the set (cardinality) is very small compared to the possible </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/8119601356425414622/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2009/01/stream-of-numbers-count-data-structure.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/8119601356425414622'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/8119601356425414622'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2009/01/stream-of-numbers-count-data-structure.html' title='Store a stream of numbers along with the counts'/><author><name>avid gardener</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></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-1793555483001238794</id><published>2009-01-13T14:21:00.000-08:00</published><updated>2009-02-20T15:39:09.224-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='puzzles'/><title type='text'>Fly plane around the world half fuel puzzle</title><summary type='text'>There is an air force base on an island.  You are given a plane to fly around the world without landing (except at the island where you started). The island lies on the equator and you will be flying around the equator, essentially a circle.  The plane can carry enough fuel for half the journey. You can take help from other planes that can transfer fuel to your plane instantaneously while in </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/1793555483001238794/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2009/01/fly-plane-around-world-half-fuel-puzzle.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/1793555483001238794'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/1793555483001238794'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2009/01/fly-plane-around-world-half-fuel-puzzle.html' title='Fly plane around the world half fuel puzzle'/><author><name>avid gardener</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>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-7888480353953766961</id><published>2009-01-13T14:19:00.000-08:00</published><updated>2009-04-29T20:03:32.993-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Microsoft'/><title type='text'>Microsoft Developer Interview Questions</title><summary type='text'>---------------------------- Interview 1 ---------------------------------
- Why is a database useful? Why not use a file instead?
- What are stored procedures and what are the benefits?
- Write a program to get the nth Fibonacci number
- Discussion about patterns and practices
- What is database normalization? When would you use it and when would you not?
What data can be left denormalized in a </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/7888480353953766961/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2009/01/microsoft-developer-interview-questions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/7888480353953766961'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/7888480353953766961'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2009/01/microsoft-developer-interview-questions.html' title='Microsoft Developer Interview Questions'/><author><name>avid gardener</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></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-284463428017531536</id><published>2009-01-07T12:48:00.000-08:00</published><updated>2009-10-26T18:53:21.761-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Array'/><title type='text'>Merge 2 Sorted Arrays (one has empty slots)</title><summary type='text'>Question: There are two sorted arrays A1 and A2. Array A1 is full where as array A2 is partially empty and number of empty slots are just enough to accommodate all elements of A1. Write a program to merge the two sorted arrays to fill the array A2. You cannot use any additional memory and expected run time is O(n).

Solution: The trick to solving this problem is to start filling the destination </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/284463428017531536/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2009/01/merge-sorted-arrays-empty-slots.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/284463428017531536'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/284463428017531536'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2009/01/merge-sorted-arrays-empty-slots.html' title='Merge 2 Sorted Arrays (one has empty slots)'/><author><name>avid gardener</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><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_MaVk85uAEFM/SuZRXUdu3HI/AAAAAAAAGfg/iV0pz8OzI6M/s72-c/merge-two-sorted-arrays-in-place.png' height='72' width='72'/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-6190083236128718044</id><published>2009-01-03T19:46:00.001-08:00</published><updated>2009-01-03T20:07:56.008-08:00</updated><title type='text'>Largest Sum Sub-Sequence Integer Array</title><summary type='text'>Problem: Given an array on n integers, find a contiguous sub-sequence / subarray with largest sum.
Example: For an array of following elements { -1, 2, -4, 1, 3, -2 }, the sub-sequence with largest sum is 1,3

Solution:


 static int Find_Max_Sum_Sub_Sequence(int[] array)
        {
            //historical max and corresponding indexes
            int maxSoFar = 0;
            int maxStart = 0;
</summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/6190083236128718044/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2009/01/largest-sum-sub-sequence-integer-array.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/6190083236128718044'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/6190083236128718044'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2009/01/largest-sum-sub-sequence-integer-array.html' title='Largest Sum Sub-Sequence Integer Array'/><author><name>avid gardener</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>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-445375387686374362</id><published>2008-12-30T23:50:00.001-08:00</published><updated>2008-12-31T02:11:22.491-08:00</updated><title type='text'>Dynamic Programming Questions</title><summary type='text'>1. Longest Common Subsequence http://en.wikipedia.org/wiki/Longest_common_subsequence_problem

2.longest common substring problem http://en.wikipedia.org/wiki/Longest_common_substring_problem</summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/445375387686374362/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/dynamic-programming-questions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/445375387686374362'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/445375387686374362'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/dynamic-programming-questions.html' title='Dynamic Programming Questions'/><author><name>avid gardener</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></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-8412514251340435880</id><published>2008-12-29T22:57:00.000-08:00</published><updated>2008-12-29T23:08:46.900-08:00</updated><title type='text'>Object Oriented Programmings OOPS Concepts</title><summary type='text'>Explain polymorphism with examples

What are the 4 basics of OOP?

Define Data Abstraction. What is its importance?</summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/8412514251340435880/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/object-oriented-programmings-oops.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/8412514251340435880'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/8412514251340435880'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/object-oriented-programmings-oops.html' title='Object Oriented Programmings OOPS Concepts'/><author><name>avid gardener</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>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-4891417086972693446</id><published>2008-12-29T19:43:00.000-08:00</published><updated>2008-12-29T23:01:40.635-08:00</updated><title type='text'>Design Questions</title><summary type='text'>Design a class library for writing card games.

Design an elevator control system. Buttons are present on every floor and supporting multiple elevators. (What objects/methods/properties/how components communicate)

How would you design the infrastructure front half of a very large web ecommerce site? what if it was very personalized? (how sessions are handled? where and what you can cache? how to</summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/4891417086972693446/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/design-questions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/4891417086972693446'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/4891417086972693446'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/design-questions.html' title='Design Questions'/><author><name>avid gardener</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></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-1492391711553464006</id><published>2008-12-29T19:17:00.000-08:00</published><updated>2011-02-20T16:29:18.959-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Questions-List'/><title type='text'>Questions</title><summary type='text'>Array
How would you detect a repeated element in an integer array?
Design an algorithm and write code to find two numbers in an array whose sum equals a given value.
Given an array of size N in which every number is between 1 and N, determine if there are any duplicates in it. You are allowed to destroy the array if you like.
Given an array containing both positive and negative integers and </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/1492391711553464006/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/questions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/1492391711553464006'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/1492391711553464006'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/questions.html' title='Questions'/><author><name>avid gardener</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></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-6855321219089330630</id><published>2008-12-28T20:04:00.000-08:00</published><updated>2008-12-28T22:27:52.775-08:00</updated><title type='text'>Virtual Functions/Methods Runtime-Polymorphism</title><summary type='text'>Question: Explain the significance of virtual methods and describe how they are invoked?
Virtual methods are used to support runtime polymorphism in object oriented languages.</summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/6855321219089330630/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/virtual-methods-runtime-polymorphism.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/6855321219089330630'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/6855321219089330630'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/virtual-methods-runtime-polymorphism.html' title='Virtual Functions/Methods Runtime-Polymorphism'/><author><name>avid gardener</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></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-3983506511981845114</id><published>2008-12-28T19:55:00.000-08:00</published><updated>2008-12-28T20:02:35.769-08:00</updated><title type='text'>Difference between an interface and an abstract class</title><summary type='text'>Two most important differences are:
1. A class can implement several interfaces but can inherit from a single abstract class (or any class for that matter)

2. Interfaces do not contain any implementation while abstract classes can contain some default implementation of methods.</summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/3983506511981845114/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/difference-between-interface-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/3983506511981845114'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/3983506511981845114'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/difference-between-interface-and.html' title='Difference between an interface and an abstract class'/><author><name>avid gardener</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></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-3697086262294635009</id><published>2008-12-28T19:18:00.001-08:00</published><updated>2009-02-20T16:21:04.791-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Array'/><title type='text'>Function to perform Binary Search on a Sorted Array</title><summary type='text'>Problem: Write a function to perform a binary search on a Sorted Array.

Solution: The recursive solution below runs in O(log(n)) because the problem size is halved with each recursive call. 


// returns the index of the target element if found, else returns -1
        static int Binary_Search(int[] arr, int start, int end, int target)
        {
           int medianIndex = (end - start) /2 + </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/3697086262294635009/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/binary-search-sorted-array.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/3697086262294635009'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/3697086262294635009'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/binary-search-sorted-array.html' title='Function to perform Binary Search on a Sorted Array'/><author><name>avid gardener</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>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-3892540748699403420</id><published>2008-12-28T18:50:00.001-08:00</published><updated>2008-12-28T19:01:39.889-08:00</updated><title type='text'>Telephone Words Using Recursion</title><summary type='text'>Problem: Given a telephone number print or produce all the possible telephone words or combinations of letters that can represent the given telephone number.

Solution:  O(3 ^ n) (approximately - since there are 2 digits that have 4 letters)


    class Program
    {
        static void Main(string[] args)
        {
            int[] phoneNumber = new int[]{2,3,4};
            List telephoneWords</summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/3892540748699403420/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/telephone-words-using-recursion.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/3892540748699403420'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/3892540748699403420'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/telephone-words-using-recursion.html' title='Telephone Words Using Recursion'/><author><name>avid gardener</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></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-99820712795665066</id><published>2008-12-28T17:33:00.000-08:00</published><updated>2008-12-28T18:18:25.654-08:00</updated><title type='text'>String: Combinations Using Recursion</title><summary type='text'>Problem: Given a string of N characters, write a program to produce all combination  of the characters. String "abc" should produce "a", "b", "c", "ab" , "ac", "bc", "abc".

Solution: The recursive solution proposed below runs in O(2 ^ n).

Pseudo Code: 

1. If input string length = 1 
      return a list with the input string in it
2. if input string length &gt; 1
      a. Get list of combinations </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/99820712795665066/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/string-combinations-using-recursion.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/99820712795665066'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/99820712795665066'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/string-combinations-using-recursion.html' title='String: Combinations Using Recursion'/><author><name>avid gardener</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>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-7043108011910756638</id><published>2008-12-28T15:03:00.001-08:00</published><updated>2012-01-13T14:49:45.931-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='String Manipulation'/><title type='text'>String: Permutations Using Recursion</title><summary type='text'>Problem: Write the code for producing/printing permutations of the characters in a string. For example: If "abc" is the input string, output permutations should be "abc", "bac", "bca", "acb", "cab", "cba". 
Solution: There are at least 2 approaches to solving this problem. Even though both approaches use recursion, there is a subtle difference between the two. The second approach uses more number</summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/7043108011910756638/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/algorithm-permutations-string.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/7043108011910756638'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/7043108011910756638'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/algorithm-permutations-string.html' title='String: Permutations Using Recursion'/><author><name>avid gardener</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>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-5471377701850355532</id><published>2008-12-26T00:27:00.001-08:00</published><updated>2008-12-28T15:00:32.822-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='String Manipulation'/><title type='text'>String: Convert Integer to String itoa</title><summary type='text'>
// val: integer that needs to be converted to string representation
// destBuffer: buffer where the output string will be written
// radix: is the radix of the numbering system (10 for decimal, 16 for Hexadecimal,
// 2 for binary)

char * my_itoa(int val, char * destBuffer, int radix)
{
   if(val == 0)
   {
      destBuffer = "0";
      return destBuffer;
   }

   bool isNeg = false;
   // if </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/5471377701850355532/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/convert-integer-to-string-itoa-radix.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/5471377701850355532'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/5471377701850355532'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/convert-integer-to-string-itoa-radix.html' title='String: Convert Integer to String itoa'/><author><name>avid gardener</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></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-1245068973836975713</id><published>2008-12-25T20:29:00.000-08:00</published><updated>2009-02-20T16:06:07.009-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='String Manipulation'/><title type='text'>String: Convert String To Integer atoi</title><summary type='text'>Problem: Implement atoi function in C language and give the test cases. atoi function converts a string to an integer.
The function prototype is as follows:
         int my_atoi(const char str[]);
Solution: 
The key is to be able to find out the int value of a numeric character. 
ASCII value of a numeric character - ASCII value of the character '0' = int value of numeric character.
Ex: '8' - '0' </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/1245068973836975713/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/atoi-convert-string-to-integer.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/1245068973836975713'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/1245068973836975713'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/atoi-convert-string-to-integer.html' title='String: Convert String To Integer atoi'/><author><name>avid gardener</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></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-1186164916497387726</id><published>2008-12-25T16:25:00.000-08:00</published><updated>2009-02-20T16:05:16.954-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='String Manipulation'/><title type='text'>String: Remove Specified Characters</title><summary type='text'>Problem: You are given 2 strings. The first string is the input string that needs to be cleaned (in place) and the second string contains characters that need to be removed from the the first string. For example if string1 = "teetotaller" and removeString= "ae" then the output (cleaned string) will look like "ttotllr".

Solution:
The naive approach is as follows:
Create an output buffer the same </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/1186164916497387726/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/remove-specified-characters-from-string.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/1186164916497387726'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/1186164916497387726'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/remove-specified-characters-from-string.html' title='String: Remove Specified Characters'/><author><name>avid gardener</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></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-4330600788851858262</id><published>2008-12-25T13:31:00.000-08:00</published><updated>2009-02-20T16:06:49.796-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='String Manipulation'/><title type='text'>String: Find First Non-Repeated Character</title><summary type='text'>Problem: Find the 1st non-repeated character in a string. Example: teetotaller
The 1st non-repeated character is o.

Solution: The solution involves keeping track of what characters in the string have a count of more than one. The choice of data structure we will use depends on the type of string. If the string is an ASCII string with 256 possible values then an array of size 256 would be </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/4330600788851858262/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/find-first-nonrepeated-character-string.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/4330600788851858262'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/4330600788851858262'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/find-first-nonrepeated-character-string.html' title='String: Find First Non-Repeated Character'/><author><name>avid gardener</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>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-7903121319478777691</id><published>2008-12-25T12:17:00.000-08:00</published><updated>2009-02-20T16:09:45.092-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tree'/><title type='text'>Tree: Find Lowest Common Ancestor</title><summary type='text'>
Problem: Given a binary search tree and 2 values find the lowest common ancestor.

Solution: Lets take a sample tree and see what finding the lowest ancestor means.  The figure to the left shows the sample tree. To take an example, lets say the problem asked us to find the lowest common ancestor for nodes 10 and 14. Visually we can tell that node 12 is the lowest common ancestor. 15 is also a </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/7903121319478777691/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/tree-lowest-common-ancestor-find.html#comment-form' title='13 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/7903121319478777691'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/7903121319478777691'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/tree-lowest-common-ancestor-find.html' title='Tree: Find Lowest Common Ancestor'/><author><name>avid gardener</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><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_MaVk85uAEFM/SVPtWxKQ5aI/AAAAAAAAEZY/VI9qoFjIenM/s72-c/tree-lowest-common-ancestor.png' height='72' width='72'/><thr:total>13</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-3609790042855435559</id><published>2008-12-25T11:13:00.000-08:00</published><updated>2009-02-20T16:10:30.983-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tree'/><title type='text'>Tree: PreOrder Traversal without Recursion</title><summary type='text'>Problem: Write the code for pre-order traversal of a binary tree without recursion.

Solution: Most problems involving binary trees can be solved by using recursion. Recursion is inherent to trees. But, keep in mind that recursion has a memory overhead because of the additional stack space required for the recursive method calls. Sometime interviewers will ask to solve problems related to trees </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/3609790042855435559/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/tree-preorder-traversal-without.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/3609790042855435559'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/3609790042855435559'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/tree-preorder-traversal-without.html' title='Tree: PreOrder Traversal without Recursion'/><author><name>avid gardener</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></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-7368553050026140180</id><published>2008-12-24T20:25:00.000-08:00</published><updated>2009-02-20T16:13:09.027-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tree'/><title type='text'>Tree: Traversal (PreOrder, InOrder, PostOrder)</title><summary type='text'>Problem: What are the different ways of traversing a non-empty Tree?


Solution: Tree traversal can be divided into 2 major methods. First is Depth-First-Traversal and the second is Breadth-First-Traversal. 

Depth-First-Traversal(DFT or DFS): The idea is to recursively keep visiting the nodes in the left branch. When all nodes are visited in the left branch, visit the right branch recursively </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/7368553050026140180/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/tree-traversal-preorder-inorder.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/7368553050026140180'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/7368553050026140180'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/tree-traversal-preorder-inorder.html' title='Tree: Traversal (PreOrder, InOrder, PostOrder)'/><author><name>avid gardener</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>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-2008871399679006373</id><published>2008-12-24T19:18:00.000-08:00</published><updated>2009-04-02T15:46:23.969-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Data Structures'/><title type='text'>Implement a Queue using two Stacks</title><summary type='text'>Problem: Implement a queue using 2 stacks

Solution: The solution involves using one of the stacks as inbox stack. Incoming items are pushed onto this stack. The other stack is used as an outbox. When items need to be dequeued from the Queue and the outbox stack is empty, all the items from the inbox stack are popped and pushed on to the outbox stack. From there they can be popped until the </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/2008871399679006373/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/implement-queue-using-two-stacks.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/2008871399679006373'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/2008871399679006373'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/implement-queue-using-two-stacks.html' title='Implement a Queue using two Stacks'/><author><name>avid gardener</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>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-6619424036556484441</id><published>2008-12-24T18:37:00.000-08:00</published><updated>2009-02-20T16:13:55.060-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tree'/><category scheme='http://www.blogger.com/atom/ns#' term='Data Structures'/><title type='text'>Tree: Breadth First Search</title><summary type='text'>Problem: Write code for doing a breadth first search in a Tree data structure.

Solution: Breadth first search inspects items one level at a time starting with the root node. This is unlike the Depth First Search where the nodes in the left most branch are visited until there are no more nodes and then backtracks.

The problem with implementing a breadth first search is that we have to remember </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/6619424036556484441/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/tree-breadth-first-search.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/6619424036556484441'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/6619424036556484441'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/tree-breadth-first-search.html' title='Tree: Breadth First Search'/><author><name>avid gardener</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></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-3438446755617466438</id><published>2008-12-24T18:16:00.000-08:00</published><updated>2009-02-20T16:18:46.208-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Data Structures'/><title type='text'>Implement a Queue using an Array</title><summary type='text'>Problem: Implement a queue using an Array. Make efficient use of the space in the array.

Solution: Queue is a data structure that supports Enqueue and Dequeue methods. The Enqueue method adds an item to the end of the list and Dequeue method removes an item from the beginning of the list. This means that the Queue is a FIFO (First In First Out) data structure. Theoretically speaking a Queue </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/3438446755617466438/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/implement-queue-using-array.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/3438446755617466438'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/3438446755617466438'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/implement-queue-using-array.html' title='Implement a Queue using an Array'/><author><name>avid gardener</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></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-9102329230906916423</id><published>2008-12-18T16:47:00.000-08:00</published><updated>2008-12-18T17:16:18.959-08:00</updated><title type='text'>Interview Preparation Books</title><summary type='text'>1. Programming Interviews Exposed
2. Programming Pearls
3. C#
4. ASP.NET
5. T-SQL Recipes 
6. Operating Systems
7. Networking TCP/IP
8. Compilers
9. More Programming Pearls
10. Algorithms
11. Head First Patterns
12. Object Oriented Analysis and Design
13. Writing Secure Code
14. Code Complete</summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/9102329230906916423/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/interview-preparation-books.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/9102329230906916423'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/9102329230906916423'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/interview-preparation-books.html' title='Interview Preparation Books'/><author><name>avid gardener</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></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-2809909670908428547</id><published>2008-12-16T21:59:00.000-08:00</published><updated>2008-12-16T22:03:14.088-08:00</updated><title type='text'>Microsoft Technical Phone Screen Interview Questions</title><summary type='text'>General Questions
- What do you work on and what is your preferred area?
- What do you not like to work on?

Patterns &amp; Design
- What patterns have you used?
- Whats a pattern that implements event driven programming model?
- When would you use inheritance vs encapsulation?

Xml Questions
- How do you validate an Xml document? Whats the difference between XSD and DTD?
- When do you use an </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/2809909670908428547/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/microsoft-technical-phone-screen.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/2809909670908428547'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/2809909670908428547'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/microsoft-technical-phone-screen.html' title='Microsoft Technical Phone Screen Interview Questions'/><author><name>avid gardener</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></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-4874294693899040893</id><published>2008-12-12T01:39:00.000-08:00</published><updated>2009-02-20T16:07:37.117-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='String Manipulation'/><title type='text'>String: Palindrome Check</title><summary type='text'>Problem: Find if a given string is a palindrome. Palindrome is a word or a phrase that reads the same in either direction. Ex: A man, a plan, a canal, panama!
Punctuation and spaces can be ignored.

Solution: The solution is pretty straight forward and involves comparing the characters at both ends, incrementally moving towards the center of the string. This is similar logic we used for reversing</summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/4874294693899040893/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/string-palindrome-check.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/4874294693899040893'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/4874294693899040893'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/string-palindrome-check.html' title='String: Palindrome Check'/><author><name>avid gardener</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></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-2920102475098800625</id><published>2008-12-11T23:24:00.000-08:00</published><updated>2009-02-20T16:08:03.656-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='String Manipulation'/><title type='text'>String: Reverse Words</title><summary type='text'>Problem: Reverse the words in a sentence. For example "Hello World" should become "World Hello".
Comment: This is one of most frequently asked interview questions on string manipulation.

Solution: First we reverse the entire string and then reverse each word of this reversed string.

"Hello World"
      |
   reverse
      |
      v
"dlroW olleH"
  |      |
reverse reverse
  |      |
  v      v
"</summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/2920102475098800625/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/string-reverse-words.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/2920102475098800625'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/2920102475098800625'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/string-reverse-words.html' title='String: Reverse Words'/><author><name>avid gardener</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></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-6634669854571728003</id><published>2008-12-11T07:33:00.000-08:00</published><updated>2009-02-20T16:08:53.505-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='String Manipulation'/><title type='text'>String: Reverse in place</title><summary type='text'>Problem: Given a string of unknown length reverse it in place.

Solution: Lets take a sample string "hello". When reversed it should read as "olleh". For those who are new to C/C++, a string has null terminator at the end. This null terminator denotes the end of the string. So, when you say declare a string in C language like:
char *str = "hello";

How many bytes of memory does it take to store </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/6634669854571728003/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/string-reverse-in-place.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/6634669854571728003'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/6634669854571728003'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/string-reverse-in-place.html' title='String: Reverse in place'/><author><name>avid gardener</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><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_MaVk85uAEFM/SUE3G-gHnJI/AAAAAAAADUs/jKqx-R8eeEQ/s72-c/string-representation-in-memory.PNG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-5110644770020009899</id><published>2008-12-10T01:16:00.000-08:00</published><updated>2009-02-18T10:36:52.399-08:00</updated><title type='text'>Linked List Loop/Cycle Detection</title><summary type='text'>Problem: Given the head pointer to a singly linked list with a loop or cycle in it. If you were to walk this list you never arrive at the end or the tail of the linked list. Find whether the list contains a loop in O(n) time and space complexity.

Observation:  A linked list with a loop will have a node that is being pointed from 2 different node.

Solution 1: This problem was solved in the late </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/5110644770020009899/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/linked-list-cycle-loop-detection.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/5110644770020009899'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/5110644770020009899'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/linked-list-cycle-loop-detection.html' title='Linked List Loop/Cycle Detection'/><author><name>avid gardener</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><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_MaVk85uAEFM/ST-NLLweOpI/AAAAAAAADUM/sBY9SDUgWG4/s72-c/linked-list-cycle-loop-detection.PNG' height='72' width='72'/><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-3821547768295347086</id><published>2008-12-09T02:42:00.000-08:00</published><updated>2009-03-23T11:35:32.095-07:00</updated><title type='text'>Links</title><summary type='text'>http://www.tekpool.com/
http://maxnoy.com/interviews.html
http://www.sellsbrothers.com/fun/msiview/default.aspx?content=question.htm
http://www.geekinterview.com/Interview-Questions/Programming
http://halcyon.usc.edu/~kiran/msqs.html
http://www.softwareinterview.com/
http://savenseek.com/page/Microsoft_Google_Algorithm_Interview_Questions__brainDead
http://savenseek.com/page/</summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/3821547768295347086/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/links.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/3821547768295347086'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/3821547768295347086'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/links.html' title='Links'/><author><name>avid gardener</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></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-4813617672377981554</id><published>2008-12-09T01:51:00.000-08:00</published><updated>2009-04-03T19:11:36.720-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MySpace'/><category scheme='http://www.blogger.com/atom/ns#' term='Linked List'/><category scheme='http://www.blogger.com/atom/ns#' term='Microsoft'/><title type='text'>Linked List: Merged List Problem</title><summary type='text'>Problem: There are 2 singly linked lists (list1 and list2) that merge at one of the nodes and share the nodes there onwards. The goal is to find the node where these linked lists merge or join.
Solution 1: 
Find length of both linked lists, say len1 and len2.Make current pointers for both lists equidistant from the common node. If one of the lists is longer we need to advance its current pointer </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/4813617672377981554/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/linked-list-joined-list-common-nodes.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/4813617672377981554'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/4813617672377981554'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/linked-list-joined-list-common-nodes.html' title='Linked List: Merged List Problem'/><author><name>avid gardener</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><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_MaVk85uAEFM/ST5FeelpdwI/AAAAAAAADTk/0M75pAGvQt0/s72-c/joint-linked-list.PNG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-873763428360193452</id><published>2008-12-09T00:21:00.000-08:00</published><updated>2009-02-20T16:14:54.573-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linked List'/><category scheme='http://www.blogger.com/atom/ns#' term='Microsoft'/><title type='text'>Linked List: Reverse</title><summary type='text'>Question: Given the head pointer to a singly linked list reverse the list.

Solution 1: Recursive Approach - We can recursively traverse the linked list till we arrive at the last but one node.  We then set the next pointer of the last node to point to the current node. We keep reversing the links as we unwind the recursive calls.

Code:// Takes a pointer to the head node of a singly linked list
</summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/873763428360193452/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/linked-list-reverse.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/873763428360193452'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/873763428360193452'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/linked-list-reverse.html' title='Linked List: Reverse'/><author><name>avid gardener</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>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-3244634460703258976</id><published>2008-12-08T02:31:00.000-08:00</published><updated>2009-02-20T16:15:30.974-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linked List'/><category scheme='http://www.blogger.com/atom/ns#' term='Microsoft'/><title type='text'>Linked List: Delete Node</title><summary type='text'>Question: You are given a pointer to a node in a singly linked list. The head pointer is not available. Your task is to delete the specified node.

Solution: Typically, deleting a node from a singly linked list requires us to have the pointer to the node before the node to be deleted. We need this previous pointer so we can set it's Next pointer to the node after the specified node to be deleted.</summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/3244634460703258976/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/linked-list-delete-node.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/3244634460703258976'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/3244634460703258976'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/linked-list-delete-node.html' title='Linked List: Delete Node'/><author><name>avid gardener</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>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-4179139529769697946</id><published>2008-12-08T01:09:00.000-08:00</published><updated>2009-02-20T16:15:58.449-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linked List'/><category scheme='http://www.blogger.com/atom/ns#' term='Microsoft'/><title type='text'>Linked List: Find the middle element</title><summary type='text'>Question: Given a singly linked list, find the node in the middle.

Solution 1: Walk the linked list to find the length of the list. Lets say n is the length of the list. Walk the list again upto ⌊ n/2 ⌋.

Solution 2: Use two pointers. Move one pointer at twice the speed of the second. When the 1st pointer reaches the end of the list, the 2nd pointer will be pointing to the middle node.
Note: If </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/4179139529769697946/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/linked-list-find-middle-element.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/4179139529769697946'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/4179139529769697946'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/linked-list-find-middle-element.html' title='Linked List: Find the middle element'/><author><name>avid gardener</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>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2682781734368178743.post-6908196596324574510</id><published>2008-12-08T01:01:00.000-08:00</published><updated>2009-02-20T16:16:44.571-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linked List'/><category scheme='http://www.blogger.com/atom/ns#' term='Microsoft'/><title type='text'>Linked List: Find n-th element from the tail</title><summary type='text'>Question: Given a singly linked list find the n-th node from the back.

Solution 1: Reverse the linked list and select the n-th node from the head of the linked list.

Solution 2: Maintain 2 pointers n nodes apart. When the 1st pointer reaches the tail, the second pointer will be pointing to the desired node.


Notes: Both solutions take O(n) time but Solution 2 is more elegant.

Code:

//define </summary><link rel='replies' type='application/atom+xml' href='http://www.technicalinterviewquestions.net/feeds/6908196596324574510/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/linked-list-find-n-th-element-from-tail.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/6908196596324574510'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2682781734368178743/posts/default/6908196596324574510'/><link rel='alternate' type='text/html' href='http://www.technicalinterviewquestions.net/2008/12/linked-list-find-n-th-element-from-tail.html' title='Linked List: Find n-th element from the tail'/><author><name>avid gardener</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>2</thr:total></entry></feed>
