interview-questions

N-ary trees - is it symmetric or not

Given an N-ary tree, find out if it is symmetric about the line drawn through the root node of the tree. It is easy to do it in case of a binary tree. However for N-ary trees it seems to be difficult ...

How many total gifts in the twelve days of christmas if we extend 12 to any number?

I got this question today in an interview: write a function to calculate the total number of gifts received for any day in the 12 days of christmas song. I wrote a simple function using a for() loop in c#'ish code that worked. Then the interviewer asked me to extend it to any number of days. The conversation then turned to how to opt...

Good (non-code) interview questions for college intern candidates

Next week I'm beginning several rounds of interviews for a company wide technical intern program. Many of these candidates are only sophomores or juniors and have little programming experience. They can do basic data structures, regurgitate algorithms and the like, but they have little or no professional coding experience in an enterpri...

How can I print out all possible letter combinations a given phone number can represent?

I just tried for my first programming interview and one of the questions was to write a program that given a 7 digit telephone number, could print all possible combinations of letters that each number could represent. A second part of the question was, what about if this was a 12 digit international number? How would that effect you de...

Confusion in finding the order of the data structure

Hi, Today I attended a written test conducted by a company. The overall test was focussed on data structures. I got a problem which I thought I solved. But I had a tough time in calculating the Big O function for the data structure. I will provide the question and the answer I came up with. Given a document you need to store and the...

Merging two sorted lists

Hi, This is one of the programming questions asked during written test from Microsoft. I am giving the question and the answer that I came up with. Thing is my answer although looks comprehensive (at least to me), I feel that the number of lines can be reduced. It was asked in C and I am a Java person but I managed to code it (my answer...

java questions - solutions

I was reading a J2EE interview question thread and saw these. I realize that i cant answer these. If anyone wants to stab at this, i will generously reward points =) What is the flaw with the Stack class? Explain the Java Class loader mechanism. How would you prevent someone from overriding the java.lang.Object class? Can interfaces co...

R interview questions..

Hi, What are some common R interview questions? I'm not sure what are the must-know for someone who claims to have working knowledge of R so I'd like to test myself. Also, if you were an interviewer and looking for an R person, what would you ask? Thanks.. -k ...

How to master in-place array modification algorithms?

I am preparing for a software job interview, and I have trouble with in-place array modifications. For example, in the out-shuffle problem you interleave two halves of an array, so that 1 2 3 4 5 6 7 8 would become 1 5 2 6 3 7 4 8. This question asks for a constant-memory solution (and linear-time, although I'm not sure that's even possi...

What technique do I use for when I want to check all possible combinations of a set?

I'm working through an interview question that goes like: Given an array of integers and sum, check whether any combination adds up to the sum. What programming technique does one use when they want to try all possible combinations of a set? Even if that isn't the best solution to this problem, I come across problems where I...

Interview question; what is the main theme of Effective C++?

I was asked the following question at a recent job interview: What do you think is the main theme / single word that sums up the Effective C++ series from Scott Meyers? What would be your answer to this question? ...

Answer to a practice interview question

I'm just going through a bunch of C++ interview questions just to make sure there's nothing obvious that I don't know. So far I haven't found anything that I didn't know already, except this: long value; //some stuff value &= 0xFFFF; The question is "what's wrong with this code?" And hints that it's something to do with target archite...

Design for ConnectionPool

When some one asks you to write (do / depict) design for Connection Pool in a Java interview what would you typically write. Do you write code for connection pool or do you depict the Class diagrams. Can somebody please explain the design of Connection pool. ...

How Clear is this Interview Question?

We are interviewing for a Senior Java Development Role and all three people that we have asked to complete this question gave us the same incorrect answer. The question was done before the interview so they had a lot of time. Their solutions seemed to sort the input by parentId and then childId instead of creating a tree and from the inp...

Alternative of struct tm

Does there exist any other alternative data structure instead of struct tm (having same memory allocated as this structure) ? So that I could use strftime without declaring <time.h> I am aware of the fact that relying on implicit declaration is not good,but I faced this question in an interview. EDIT: To be precise I was asked to print...

string conversion between UTF-8 representation and unicode representation

How to design an algorithm to convert a UTF-8 string to a unicode string? ...

what is Dotnet Module, dynamic keyword and ....

Last day I have been interviewed and the interviewer asked me a) what is dotnet Modules? b) What is the new dynamic keyword and what is it's use(dot net 4.0) c) what is the difference between dynamic keyword and var(dotnet 3.5+) d) What is the difference between Var & Object? Why should we use one over another? Could anyone be kind...

How can we find second maximum from array efficiently?

Is it possible to find the second maximum number from an array of integers by traversing the array only once? As an example, I have a array of five integers from which I want to find second maximum number. Here is an attempt I gave in the interview: #define MIN -1 int main() { int max=MIN,second_max=MIN; int arr[6]={0,1,2,3,4,...

Given N points in a 3D space, how to find the smallest sphere that contains these N points?

Given N points in a 3D space, how to find the smallest sphere that contains these N points? ...

The intersection of two sorted arrays.

Given two sorted arrays: A and B. The size of array A is La and the size of array B is Lb. How to find the intersection of A and B? If La is much bigger than Lb, then will there be any difference for the intersection finding algorithm? ...