Data Structures Interview Questions
- 0of 0 votes
AnswersA parent array P is given where P[i] denotes the parent of the ith node in the tree(the tree is generic). Parent of root is indicated with -1. I need to find the height/depth of tree. (Best sol in O(n))
- gopi.komanduri October 30, 2014 in India| Report Duplicate | Flag | PURGE
ADP Analyst Algorithm Arrays C# Data Structures Trees and Graphs - 0of 0 votes
AnswersGiven ~300k words with an average length of 7 in a file.
- JSDUDE October 27, 2014 in United States
All words are dictionary correct words.
Print all the anagrams that are present in this list of words without repeating them.
E.g. if the list has:
ACT
BAT
CAT
TAB
TAC
print:
ACT, CAT, TAC
BAT, TAB| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Data Structures - 0of 0 votes
AnswersWrite a function that takes a list of positive integers as an input, and returns all of the pairs of integers it contains that sum to 100. You can assume that all inputs are between 1 and 99.
- cguru171 October 22, 2014 in Canada| Report Duplicate | Flag | PURGE
Software Engineer / Developer Data Structures - 9of 9 votes
AnswersGiven a string (1-d array) , find if there is any sub-sequence that repeats itself.
- for.anonymous.usa October 22, 2014 in United States
Here, sub-sequence can be a non-contiguous pattern, with the same relative order.
Eg:
1. abab <------yes, ab is repeated
2. abba <---- No, a and b follow different order
3. acbdaghfb <-------- yes there is a followed by b at two places
4. abcdacb <----- yes a followed by b twice
The above should be applicable to ANY TWO (or every two) characters in the string and optimum over time.
In the sense, it should be checked for every pair of characters in the string.| Report Duplicate | Flag | PURGE
Google Software Engineer Intern Algorithm Brain Teasers C C++ Coding Data Structures Dynamic Programming Problem Solving String Manipulation - 4of 6 votes
AnswersWrite a program to implement Double Linked List from Stack with min. complexity.
- Purushotham Kumar October 20, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Intern Data Structures Java Linked Lists Stacks - 2of 2 votes
AnswersThe stepping number:
- Anon October 13, 2014 in United States
A number is called as a stepping number if the adjacent digits are having a difference of 1. For eg. 8,343,545 are stepping numbers. While 890, 098 are not. The difference between a ‘9’ and ‘0’ should not be considered as 1.
Given start number(s) and an end number(e) your function should list out all the stepping numbers in the range including both the numbers s & e.| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer Algorithm Data Structures Dynamic Programming Java Online Test - 3of 5 votes
AnswersYou're given an array of integers(eg [3,4,7,1,2,9,8]) Find the index of values that satisfy A+B = C + D, where A,B,C & D are integers values in the array.
- omair.ahmed08 October 09, 2014 in United States
Eg: Given [3,4,7,1,2,9,8] array
The following
3+7 = 1+ 9 satisfies A+B=C+D
so print (0,2,3,5)| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm Arrays Data Structures - 1of 1 vote
AnswersWe have 'n' patients and 'm' problems. The problems are of boolean type. Eg diabetes problem would be 'T' if a patient has it or 'F' otherwise. Suggest the data structure you would store this scenario on?
- Anon October 01, 2014 in United States
Q: We have a set of problems {diabetes, liver disease, kidney disease} find all the patients who have at least the 3 problems from the set.
The number of patients can be huge (n).
The number of problems not comparatively huge (m).
Which would be the best data structure to store these kind of records, so that we have a better search time.| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer Data Structures - -1of 1 vote
AnswersA Load Balancer has the following functions:
getHost() addHost(String) removeHost(String)
Implement these functions using any data structure you wish. Also indicate the average performance for each function and what you expect to be its call count in a typical system with respect to each other of the three functions. In other words, how often do you expect getHost() to be called compared to addHost(...)?
- Chris September 23, 2014 in United States
Constraints:
Hosts are unique.
getHost() returns a random host from the host group| Report Duplicate | Flag | PURGE
Amazon SDE-2 Data Structures - 0of 2 votes
AnswersDifference between a crash and exception.
- avinash September 20, 2014 in India for GTSC
Difference between macros and inline functions.
Mfc: message maps and virtual functions.
Different calling convention.
Late n early binding...
Garbage collector algorithm. When gc will fail to clean the memory.
How to know heap size, crash dump analysis, What is a stack n how to know stack memory size.
Commands in windbg.
Questions on Critical section, mutex, semaphores. Can we use mutex in single process and how?
Working of MSIL and JIT COMPILER.
Can a C# code, use c++ code and call kernel functions like createfile.
Areas: dot net, oops, operating systems, thread synchronization.
Difference in execution steps of c++ and c# code| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Assembly C++ Data Structures Debugging Object Oriented Design Operating System Threads - 1of 1 vote
AnswersHow to impliment Google map
- surendersinghpawar September 20, 2014 in India
Data Structure and algorithm.
1. Zoom in/out
2. horizontal/ vertical.
Assumtion - all the image of earth with pixel\Any other assumption is allowed| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm Application / UI Design Data Structures - 1of 1 vote
AnswersHow google map implemented ? zoom in , zoom out, moving horizontal and moving vertically.
- surendersinghpawar September 20, 2014 in India
Give data Structure and algorithm.
Given all the data from satellite which revolve around earth in spiral way.| Report Duplicate | Flag | PURGE
Amazon Member Technical Staff Algorithm Application / UI Design Data Structures - 5of 5 votes
AnswersGiven a Sorted integer array which is rotated N number of times. You have no idea what that N is. An element in the array can occur more for any number of time. Write a method to search the position of a given element. If there are more than one of the same element, return the position of the first element.
- jeevanus September 04, 2014 in India for Microsoft CRM| Report Duplicate | Flag | PURGE
Microsoft SDE1 Algorithm Data Structures Sorting - 1of 3 votes
AnswersJAVA:
- abcabc August 29, 2014 in United States
Given an array say of length 1000; Pick up every value from every 20th index and store it in a separate array. Make sure to loop through all the elements in the array. Example: newArray1 = {0, 20, 40, 60, ..};
newArray2 = {1, 21,41, 61, ..};| Report Duplicate | Flag | PURGE
Amazon Software Engineer Intern Data Structures - 0of 0 votes
AnswersGiven an array say of length 1000; Pick up every value from every 20th index and store it in a separate array. Make sure to loop through all the elements in the array. Example: newArray1 = {0, 20, 40, 60, ..};
- abcabc August 29, 2014 in United States
newArray2 = {1, 21,41, 61, ..};| Report Duplicate | Flag | PURGE
Software Engineer Intern Data Structures - -1of 1 vote
Answerpackage jp.co.worksap.global;
- samarth.se August 25, 2014 in India
import java.util.NoSuchElementException;
/**
* The Queue class represents an immutable first-in-first-out (FIFO) queue of objects.
* @param <E>
*/
public class ImmutableQueue<E> {
/**
* requires default constructor.
*/
public ImmutableQueue() {
// modify this constructor if necessary, but do not remove default constructor
}
// add other constructors if necessary
/**
* Returns the queue that adds an item into the tail of this queue without modifying this queue.
* <pre>
* e.g.
* When this queue represents the queue (2, 1, 2, 2, 6) and we enqueue the value 4 into this queue,
* this method returns a new queue (2, 1, 2, 2, 6, 4)
* and this object still represents the queue (2, 1, 2, 2, 6) .
* </pre>
* If the element e is null, throws IllegalArgumentException.
* @param e
* @return
* @throws IllegalArgumentException
*/
public ImmutableQueue<E> enqueue(E e) {
return null;
}
/**
* Returns the queue that removes the object at the head of this queue without modifying this queue.
* <pre>
* e.g.
* When this queue represents the queue (7, 1, 3, 3, 5, 1) ,
* this method returns a new queue (1, 3, 3, 5, 1)
* and this object still represents the queue (7, 1, 3, 3, 5, 1) .
* </pre>
* If this queue is empty, throws java.util.NoSuchElementException.
* @return
* @throws java.util.NoSuchElementException
*/
public ImmutableQueue<E> dequeue() {
return null;
}
/**
* Looks at the object which is the head of this queue without removing it from the queue.
* <pre>
* e.g.
* When this queue represents the queue (7, 1, 3, 3, 5, 1),
* this method returns 7 and this object still represents the queue (7, 1, 3, 3, 5, 1)
* </pre>
* If the queue is empty, throws java.util.NoSuchElementException.
* @return
* @throws java.util.NoSuchElementException
*/
public E peek() {
return null;
}
/**
* Returns the number of objects in this queue.
* @return
*/
public int size() {
return -1;
}
}| Report Duplicate | Flag | PURGE
Data Structures - 1of 1 vote
AnswersHow will you design, and what data structure will you use for a contact list in a cell Phone. It should support insert/modify/delete/search functionality like that provided in a cell phone.
- anurag6989 August 21, 2014 in India
Suppose some of the entries are
Aman
Amazon
Neha Aman
and we type 'ama'
then the result should show all the above three enteries.
Also it should be possible to search using phone numbers.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Data Structures - 0of 0 votes
AnswersGiven an array[0, n-1], each number of the array is positive int. Your task is adding the operators,"+","*", "(",")" (add, multiply, parenthesis) to maximize the result . The position in the array is Fixed.
- justtest August 19, 2014 in United States
For example, "2,1,1,2", you can get (2+1)*(2+1)=9.
Follow up, if the number may be negative , how to solve it ?| Report Duplicate | Flag | PURGE
Algorithm Brain Teasers Coding Data Structures Dynamic Programming - 0of 2 votes
AnswersDesign a system like friend's functionality in facebook. should have all features of facebook's friends functionality. like for each person , he can have any number of friends , he will get suggestions for new firends , showing common friends if we visits any other profile . algo should be scalable , robust .
- gopi.komanduri August 02, 2014 in United States| Report Duplicate | Flag | PURGE
Computer Scientist Algorithm Android Application / UI Design Arrays Bit Manipulation C# C++ Cache Coding Computer Architecture & Low Level Data Mining Data Structures Database Distributed Computing Dynamic Programming Hash Table Java Large Scale Computing Linked Lists Math & Computation Object Oriented Design Problem Solving Sorting SQL Stacks System Design Trees and Graphs XML - 0of 0 votes
AnswersDesign a phone book such that fields are searchable with name , with number. Later enhanced teh question asking searchable with address as well.
- gopi.komanduri July 22, 2014 in India| Report Duplicate | Flag | PURGE
Analyst Algorithm Arrays Bit Manipulation Brain Teasers C# C++ Cache Coding Computer Architecture & Low Level Data Mining Data Structures - 0of 2 votes
AnswersHow to design a multi key hash map ( key count can be dynamic. if there are two keys , initiallly which can be used to find the value , keys can be increased to three as well ex: consider school structure. Intially , consider , student id is key , later , should be searchable even with key name , later with grade.
- gopi.komanduri July 05, 2014 in India| Report Duplicate | Flag | PURGE
Analyst Algorithm Arrays C# C++ Coding Data Structures Dynamic Programming Experience Hash Table Large Scale Computing Linked Lists Problem Solving Sorting Trees and Graphs - 1of 3 votes
AnswersDesign a telephone directory for large ppl (he gave example like design for India). fields will be , first name , last name , number . this should be searchable with first name , last name , number as welll.
- gopi.komanduri July 04, 2014 in India
later added more complexity like do the same for organisation where even it contains designations. so this should be searchable with designations.| Report Duplicate | Flag | PURGE
Analyst Algorithm Arrays C C++ Cache Coding Computer Architecture & Low Level Data Mining Data Structures Dynamic Programming Hash Table Ideas Large Scale Computing Linked Lists Object Oriented Design Problem Solving Trees and Graphs - 0of 0 votes
AnswersCan anyone provide implementation of Suffix tree and trie?
- suresh June 21, 2014 in India| Report Duplicate | Flag | PURGE
Data Structures - 2of 4 votes
AnswersGiven a complete binary tree, Find a Max element
- sLion June 18, 2014 in United States| Report Duplicate | Flag | PURGE
Google SDE1 Data Structures - -1of 1 vote
AnswersWrite code to read from a file and build datastructure that helps you query products based on their category, title, author etc.
- LV May 22, 2014 in United States
ItemNo , Product No (unique), Title, Author, Category
1 , 00000001, Cracking Coding Interview, Gayle Laakmann McDowell , Books > Business, Finance & Law > Careers > Job Hunting
2 , 000002, The Art of Captaincy, Robert James, Books > Biography > Sport > Cricket| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Data Structures - 1of 1 vote
AnswersWrite a program to return minimum number of swaps required to convert this binary tree into a BST.
- mvk May 19, 2014 in India| Report Duplicate | Flag | PURGE
Flipkart Software Engineer / Developer Data Structures - -3of 3 votes
AnswersDraw a graph as a graph. Assume there is graphics library to draw lines and all. Just tell how will you order the vertices such that the edges don't intersect and they seem ordered.
- kenadams.awesome May 18, 2014 in India| Report Duplicate | Flag | PURGE
Google SDE1 Data Structures - -1of 1 vote
Answersstruct st{
- croox_shil May 18, 2014 in India
int a;
char *ptr;
}obj;
assign : a=10;
ptr="Hello world";| Report Duplicate | Flag | PURGE
Alcatel Lucent Software Engineer / Developer Data Structures