interview-questions

data structure problems

hey guys, please help me in finding the optimized solutions to these interesting data structure questions: given a file containing approx 10 million words, design a data structure for finding the anagrams Write a program to display the ten most frequent words in a file such that your program be efficient in all complexity measures. yo...

How to write a recursive function that returns a linked list of nodes, when given a binary tree of nodes?

I was once asked of this in an interview: How to write a recursive function that returns a linked list of nodes, when given a binary tree of nodes? (flattening the data) (Update: how about, don't just traverse the tree and add the nodes to a global structure. Make the function totally recursive, and modifying the binary tree...

Interview Question in C#

A Technical Lead asked me the following: He created a class, declared an object and initialized it. But in some circumstance we may get "null reference" exception. He commented that there are 1000 possible reasons for such exception and asked me to guess a single reason. I am unable to figure it out. What is (are) the reason(s) ,we may g...

test cases for testing a strtok-alike function [C++]

Consider the following class definition: class StrToTokens { StrToTokens(const char* str, const char* delimiters = "\t\r\n"); //constructor string getNextToken(); void reset(); bool empty(); } Can someone list some good testcases to test the above class. A few I could think of are: empty string, empty delimiters, repeated del...

WCF Operation contract availability

This question was asked at interview. Say I have a contract. [ServiceContract] public interface IMyService { [OperationContract] void methodForClientA(); [OperationContract] void AnothermethodForClientA(); [OperationContract] void methodForClientB(); [OperationContract] void AnothermethodForClientB(); } When a...

What Ruby and Rails Developers Ought To Know?

What should know the Entry Level, Mid-level, Senior Developer? Theoretical knowledge, development tools, gems and more. What issues are usually at the interview? ...

How to answer this interview question?

As i am in between 1-2 years experience what should i say to this interview question.... What are the types of Normalization? Should i say all the normal forms or what? ...

median of a billion numbers

If you have one billion numbers and one hundred computers, what is the best way to locate the median of the numbers? one solution which i have is: split the set equally among the 100 computers - sort them - find medians for each set. sort the sets on medians. merge two sets at a time starting from the lowest median to highest. if we h...

Given a 1TB data set on disk with around 1KB per data record, how can I find duplicates using 512MB RAM and infinite disk space?

There is 1TB data on a disk with around 1KB per data record. How to find duplicates using 512MB RAM and infinite disk space? ...

Data structure behind T9 type of dictionary

How does a T9 dictionary work? What is the data structure behind it. If we type '4663' we get 'good' when we press down button we get 'gone' then 'home' etc... EDIT: If the user types in 46 then it should show 'go' and when pressed down arrow should show 'gone' etc... ...

Are there any widely-agreed upon guidelines for rating your language knowledge on a scale?

The question was imagined after a co-worker was complaining for an hour about some guy who could not answer basic Java questions on an interview after self-identifying himself as "8 out of 10" on Java. While that was an obvious fib, I personally always had major trouble defining my specific language skills on a sliding scale unless I'm ...

interface as a method parameter in Java

Hi all, I had an interview days ago and was thrown a question like this. Q: Reverse a linked list. Following code is given: public class ReverseList { interface NodeList { int getItem(); NodeList nextNode(); } void reverse(NodeList node) { } public static void main(String[] args) { } } I wa...

What is a jagged array in c#?

What is a jagged array in c#? Any examples and when should one use it.... ...

How to convert a binary tree to binary search tree in-place, i.e., we cannot use any extra space.

How to convert a binary tree to binary search tree in-place, i.e., we cannot use any extra space. ...

Number of elements in static array and dynamic array

What is the quickest way to find the number of elements in a static array and dynamic array? ...

Do session use cookies?

This is an interview question asked a month ago.... Do session use cookies? If so,how do they do so? Assume Session["UserId"]=1 how does this session variable uses cookies internally? If so, what will be the name of the cookie and what is the value of that cookie.... ...

Puzzle: find the minimum number of weights

I came across this question: say given two weights 1 and 3, u can weigh 1,2 (by 3-1),3,4 (by 3+1) (using both sides of balance). Now find the minimum number of weights so that you can measure 1 to 1000. So the answer was 1,3,9,27... I want to know how do you arrive at such a solution means powers of 3. What is the thought process? Sou...

Finding missing numbers in an array

Given an array of size n, which contains numbers in the range 1 to n, and in which each number is present at least once, but some numbers may be missing, how can I find the missing numbers? ...

LINQ and Storedprocedure

The interview i faced was "What is the difference between LINQ and Stored procedure?". I don't know whether it is a vague question or proper one. I answered "In Linq there is a support for Closure so you can refer the value of outer parameter inside the anonymous body,you can't do the same with Stored procedure". Just i am requesting ...

Dependency Injection -Colloquial explanation

Recently I was asked to express the DI in colloquial explanation. I answered : 1) I am going to a hotel.I ordered food.The hotel management asks me to clean the plates and clean the tables.So here i am a client,I am responsible for managing the service (Instantiating,executing,disposing).But DI decouples such tasks so the service cons...