Coding Interview Questions
- 0of 0 votes
AnswersGiven a deck of nCards unique cards, cut the deck iCut cards from top and perform a perfect shuffle. A perfect shuffle begins by putting down the bottom card from the top portion of the deck followed by the bottom card from the bottom portion of the deck followed by the next card from the top portion, etc., alternating cards until one portion is used up. The remaining cards go on top. The problem is to find the number of perfect shuffles required to return the deck to its original order. Your function should be declared as:
- sweety May 02, 2006
static long shuffles(int nCards,int iCut);| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Coding - 1of 0 votes
AnswersImagine you have an unbalanced binary search tree. Design an algorithm which creates a linked list of all the nodes at each depth (eg, if you have a tree with depth D, you'll have D linked lists).
- Sach (Sachin) April 22, 2006
Each node in the linked list should have previous/next pointers (for the linked list) and left/right pointers (from the tree). Code this algorithm and then test it.| Report Duplicate | Flag | PURGE
Microsoft Coding Algorithm - 0of 0 votes
AnswersWrite a program to detect if a number is a palindrome
- Sach (Sachin) April 22, 2006| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer Coding - 0of 0 votes
AnswersGave me a piece of code...which is as follows...
- Sach (Sachin) April 22, 2006
Class A
{
int x;
}
Class B
{
int y;
}
Class C : public A, B
{
int z;
}
A *aa;
B *bb;
C cc;
aa = &c;
bb = &c;
Tell me do aa and bb point to the same address? If yes or no....why?| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer Coding - 0of 0 votes
Answervoid type pointer, pointer arithmetic
- cd April 20, 2006| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer Coding - 0of 0 votes
AnswersHow would you implement C++ in C?
- cd April 20, 2006| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer Object Oriented Design Coding - 0of 0 votes
Answersgiven char arr[100]. what is strlen(arr) and what would printf("%s", arr) do?
- cd April 20, 2006| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer Coding - 0of 0 votes
AnswersInterviewer>Assume that we have a string being passed to a function with a char pointer, write a pgm to reverse the string?
- Karthik Srinivasan April 17, 2006
My Answere> blah...blah..| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer Coding Algorithm - 0of 0 votes
AnswersInterviewer>How do u copy the reversed string into another variable i.e. if we have 'hello' the other variable should have
- Karthik Srinivasan April 17, 2006
'olleh'?
My Answere>Well I just gave an idea on how to get it woking and he bombared me with questions such as "how can determine the
size of the pointer...give a C implementation not C++!!"| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer Coding Terminology & Trivia - 0of 0 votes
AnswersDesign an algorithm and write code to serialize and deserialize a binary tree/graph
- AP April 16, 2006| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Trees and Graphs Coding Algorithm - 0of 0 votes
Answerslots of questions straight from programming interviews exposed
- Sach April 04, 2006
a) detecting loops in a linked list
b) Different ways to find the no. of set bits in an integer(bitwise operators).| Report Duplicate | Flag | PURGE
Qualcomm Software Engineer / Developer Coding - 0of 0 votes
AnswersWrite a function which uses malloc and returns a starting memory location which is a multiple of 32.
- Sach April 04, 2006| Report Duplicate | Flag | PURGE
Qualcomm Software Engineer / Developer Coding - 0of 0 votes
AnswersDescribe how to ensure quality of a function.
- Jack April 04, 2006| Report Duplicate | Flag | PURGE
Chicago Mercantile Exchange Software Engineer / Developer Coding - 0of 0 votes
AnswersGiven a dictionary of millions of words, write a program to find the largest possible rectangle of letters such that every row forms a word (reading left to right) and every column forms a word (reading top to bottom).
- tryit April 02, 2006
Anyone got any ideas?| Report Duplicate | Flag | PURGE
Yahoo Software Engineer / Developer Coding - 0of 0 votes
Answersreverse double link (improve the algorithm with no additional memory, no redundant computation)
- JustGot2Offers March 31, 2006| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Coding - 0of 0 votes
AnswersWrite a method to compute all permutations of a string. You can do this either recursively or non-recursive
- JustGot2Offers March 31, 2006| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Coding - 0of 0 votes
Answersfind dup number for n+1 numbers from 1...n
- abc March 28, 2006| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Coding - 0of 0 votes
Answersno.of 1 bits in a number ---program
- sweety March 24, 2006| Report Duplicate | Flag | PURGE
Amazon Development Support Engineer Coding - 0of 0 votes
AnswersWrite code to reverse the words of a sentence and not the sentence itself eg:
- Payal Chakravarty March 23, 2006
Input: a quick brown fox
Output:a kciuq nworb xof
Test the code
Now what if there is a punctuation mark like a quick, brown fox ...we still want the output to be a kciuq, nworb xof and not a ,kciuq nworb xof
What if the developer did not want to fix this bug since it is not there in the specs...what would you do?| Report Duplicate | Flag | PURGE
Microsoft Coding - 0of 0 votes
AnswerWrite code to delete a node from a linked list. Write test cases for the code you have written
- Payal Chakravarty March 23, 2006| Report Duplicate | Flag | PURGE
Microsoft Testing Coding - 0of 0 votes
AnswersInsert a node in a doubly linked list
- Anonymous March 23, 2006| Report Duplicate | Flag | PURGE
Microsoft Program Manager Coding - 0of 0 votes
AnswersConstruct a singly linked list head to tail
- Anonymous March 23, 2006| Report Duplicate | Flag | PURGE
Microsoft Program Manager Coding - 0of 0 votes
AnswersWrite code to reverse a singly linked list
- Anonymous March 23, 2006| Report Duplicate | Flag | PURGE
Microsoft Program Manager Coding - 0of 0 votes
AnswersConstruct a Binary tree in which each node has n children
- Anonymous March 23, 2006| Report Duplicate | Flag | PURGE
Microsoft Program Manager Coding - 0of 0 votes
AnswersQ9.Write code to implement a class for wrapping text stored in a file. You should add enough functionality to the class to demonstrate your ability to design classes with either the C++ or C# language.
- Jack March 17, 2006
The class should at least meet the following requirements:
1.The class should be named CPersistentString
2.A class instance should flush its string to a file before it dies.
3.The class should support at least the following operators: "=", "==", and "[ ]".
4.The class should include the following operations: GetLength(), IsPalindrome(),Load(), Persist().| Report Duplicate | Flag | PURGE
Sage Software Software Engineer / Developer Coding