Data Structures Interview Questions
- 3of 3 votes
AnswersI need to store countries, its states and cities in a data structure.
- krupaljpatel July 24, 2013 in United States for Risk
The following queries might be used to fetch details
1) find list of states for a country.
2) find list of cities for a state.
3) find the name of the country and state for a city.
eg:
1) India -> Gujarat, UP, MP
MP -> bhopal,indore
Gujarat-> Surat,Ahmedabad, Baroda
2) USA -> Texas, California.. and so on.
Which is the best data structure that can be used to store these details.| Report Duplicate | Flag | PURGE
Morgan Stanley Java Developer Data Structures - 0of 0 votes
AnswersWrite data structure for query such as given user it returns all pages he visited with frequency.
- PT July 21, 2013 in United States
If users clicks pages its (page) frequency count increases by 1.| Report Duplicate | Flag | PURGE
Yahoo Software Engineer / Developer Data Structures - 1of 1 vote
AnswersImplement Object Pool for database connections in the following interface
interface Pool{ public Connection get() public void put(Connection c) }
It should have object pool characteristics.
- SoMiE July 11, 2013 in India
Hint - The emphasis is on which data structure you will use to achieve this.| Report Duplicate | Flag | PURGE
Goldman Sachs Java Developer Data Structures - 1of 1 vote
AnswersWhat is the difference between a tree and a map ?
- snowpa July 08, 2013 in Canada| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Data Structures - 2of 2 votes
AnswersHow can we implement spell checker.
- rapirapp July 04, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm Data Structures - 1of 1 vote
AnswersImplement T9 dictionary for mobile phone
- anim June 29, 2013 in India| Report Duplicate | Flag | PURGE
Microsoft Algorithm Application / UI Design Data Structures Object Oriented Design Problem Solving - 0of 0 votes
AnswersYou are given a 2D array that is your sea. It has more than one ships which don't overlap each other. All ships are not necessarily of the same size.
- JSDUDE June 27, 2013 in United States
You are to improve on performance and space is no concern.
Write a program that takes in two co-ordinates:
If the attack co-ordinates did not have a ship, print "Missed"
If the attack co-ordinates have a ship, print "Attacked Ship <Name>"
If the attack co-ordinates have a the same part of the attacked ship, print "Already Attacked"
If the last piece of the un-attacked ship was attacked print: "Ship sunk".| Report Duplicate | Flag | PURGE
Ebay SDE1 Coding Data Structures - 1of 1 vote
AnswersTwo files containing large number, one in each. You have only fopen(), int read(fp), fclose(), fwrite(). Add these two numbers and write in third file with the help of given functions only.
- grave June 23, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm C# C++ Coding Data Structures - 4of 6 votes
AnswersGiven a server that has requests coming in. Design a data structure such that you can fetch the count of the number requests in the last second, minute and hour.
- AVK June 15, 2013 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Data Structures - 0of 0 votes
AnswersDesign an API that will support constant time add, remove, search and random find operations. Random find will get a random number and return that element. Note: Only hash map will not be sufficient since it cannot support random read.
- hsantosh71 June 15, 2013 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Data Structures - 0of 0 votes
AnswersOnce upon a time the following puzzle was suggested to pupils on a regional middle school olympiad on mathematics:
- oglA June 14, 2013 in India
A set of coins consists of 15 coins: 14 coins are valid while a remaining 15-th coin is a false one. All valid coins have one and the same weight while the false coin has a different weight. One valid coin is marked. Is it possible to identify a false coin balancing coins 3 times at most?
A jury member was a trainer of a team of undergraduates for programming contests. So a question on how to put the puzzle for programming arose naturally. Fin ally the problem was formulated as follows:
A set of coins consists of N coins: (N - 1) coins are valid while a remaining N-th coin is a false one. All valid coins have one and the same weight while the false coin has a different weight. One valid coin is marked. Write a program which for every input pair
a number N of coins under question,
a limit K of balancing
outputs either ``POSSIBLE" or ``IMPOSSIBLE" with respect to existence of a strategy to identify the false coin balancing coins K times at most.
Input
The first line of input contains a single integer T that represents a total amount of different pairs (N, K) to process.
Output
The output file should contain T lines with ``POSSIBLE" or ``IMPOSSIBLE" per line.
Sample Input
3
6 2
10 2
15 3
Sample Output
POSSIBLE
IMPOSSIBLE
POSSIBLE| Report Duplicate | Flag | PURGE
IIT-D Algorithm Data Structures - 2of 2 votes
AnswersCheck if the given binary tree is BST or not.
- aopencv June 14, 2013 in United States| Report Duplicate | Flag | PURGE
Ebay Software Engineer / Developer Algorithm Data Structures Java - 0of 0 votes
AnswersGiven an integer array, find pairs in an array which sum up to a given number.
- aopencv June 14, 2013 in United States
For example: Array{4,5,1,3,2} and required sum=6 then output should be [1,5] and [2,4].| Report Duplicate | Flag | PURGE
Ebay Software Engineer / Developer Data Structures Java - 0of 0 votes
AnswerGiven:
- JSDUDE June 07, 2013 in United States
Array of n objects of type Object
///<summary>
/// Given two objects, this function returns a value between 0-100 depending on the relation of the two objects
/// <param1: objToBeCompared>Any object instance which has to be compared to the objReference</param1: objToBeCompared>
/// <param2: objReference>Instance of an object against which the other instance of the Object is to be compared</param2: objReference>
/// <return>A value between 0-100</return>
///</summary>
int Compare(Object objToBeCompared, Object objReference)
Now implement a function:
///<summary>
/// Given an object array of length n, a reference object this function returns the top numberOfMatches matches based on Compare(obj, obj) function's return value
/// Start with the object(s) that return 99 and go up till you find numberOfMatches element
/// The return array doesn't have to be sorted by the Compare value
/// <param1: objects>Array of n Object from which numberOfMatches have to be selected</param1: objects >
/// <param2: ObjectToBeCompared>Object against which the other objects need to be compared to</param2: ObjectToBeCompared>
/// <param3: numberOfMatches>number of matches to be returned</param3: numberOfMatches>
/// <return>Array of numberOfMatches objects</return>
///</summary>
Object[] FindTopMatch(Object[] objects, Object ObjectToBeCompared, int numberOfMatches)| Report Duplicate | Flag | PURGE
Data Structures - 2of 2 votes
AnswersHow to find in a binary tree, whether all leaves are at same level or not, and return a boolean value after identifying this.
- seth June 04, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 1of 3 votes
AnswersGiven a binary tree, a complete path is defined as a path from root to a leaf. The sum of all nodes on that path is defined as the sum of that path. Given a number K, you have to remove (prune the tree) nodes from the tree which lie on a path having sum less than K.
- seth June 04, 2013 in India
Note: A node can be part of multiple paths. So we have to delete it only in case when all paths from it have sum less than K.| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 2of 4 votes
AnswersGiven two sorted arrays, find the median of each array. The length of the arrays are m and n and we should not use extra buffer. We should find the median and time complexity should be less than 0(M+N);
- alregith June 02, 2013 in India for Chennai| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Data Structures - 1of 1 vote
AnswersPrint the sum of all nodes of a binary tree, excluding leaf node values.
- muks June 01, 2013 in India| Report Duplicate | Flag | PURGE
VMWare Inc Member Technical Staff Data Structures - -5of 7 votes
Answersneed to implement a weather report functionality. user will provide the city name , need to return the weather report.
- gopi.komanduri May 29, 2013 in India
if weather station exists n functioning properly , will return the weather report of that station .
else ,
will return the nearest available weather station report.
interviewer looking for optimized manner.
looking for datastructures to stores the cities n algo to return the report.| Report Duplicate | Flag | PURGE
Mentor Graphics Analyst Algorithm Arrays Bit Manipulation Brain Teasers C C# C++ Cache Coding Computer Architecture & Low Level Data Mining Data Structures Dynamic Programming General Questions and Comments Graphics Hash Table Ideas Linked Lists Math & Computation Object Oriented Design Problem Solving Sets Sorting Stacks String Manipulation Terminology & Trivia Threads Trees and Graphs XML - 0of 0 votes
AnswersFor a given BST, connect each of its right child to its inorder successor.
- Razz May 27, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 0of 0 votes
AnswersMax distance between two nodes of binary tree. Distance is # of branches.
- Huwanda May 10, 2013 in United States| Report Duplicate | Flag | PURGE
VMWare Inc Member Technical Staff Algorithm Data Structures Trees and Graphs - 0of 0 votes
Answerswrite a program to serialize and deserialize a Binary tree
- VJ May 06, 2013 in India| Report Duplicate | Flag | PURGE
VMWare Inc Member Technical Staff Algorithm Arrays Data Structures Trees and Graphs - 0of 0 votes
Answerswrite a program to return the highest value from a binary tree (note: not BST)
- VJ May 06, 2013 in India| Report Duplicate | Flag | PURGE
VMWare Inc Member Technical Staff Algorithm Data Structures Trees and Graphs - 0of 0 votes
Answerswrite a program to validate a BST and state the complexity (assume payload is integer values)
- VJ May 06, 2013 in India| Report Duplicate | Flag | PURGE
VMWare Inc Member Technical Staff Algorithm Data Structures Trees and Graphs - 0of 2 votes
Answerswrite a code to print the second largest element in a list
- Anonymous May 04, 2013 in United States
Shortest possible complexity.| Report Duplicate | Flag | PURGE
Amazon Software Engineer Intern Algorithm Data Structures - 3of 3 votes
AnswersWrite a class that will have following functions:
- JSDUDE May 04, 2013 in United States
long CheckOut()
CheckIn(long)
Range of values is 1 to LONG_MAX
At any given point in time checkout should return the minimum available LONG number
Checkin can return the value back
No need to check for border conditions (e.g. check out when all values are exhausted)
Implement:
1. long checkout()
2. void checkIn(long input)| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 0of 0 votes
AnswersFind the 3rd closest element in a bst.You will be given a pointer to root and a value within the tree against which the closest has to be figured out. (closeness is in terms of value, not by distance ) and then follow up qn: for finding the kth closest in a bst.
- seth May 02, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 0of 0 votes
AnswersA video streaming server is generating the following data. Find the potential customers facing buffering issues.
A person is said to face buffering issues when he hits the play button multiple times on the same video
You are given a huge file (say 1GB) that contains the following data:
CustomerId-TimeStamp-Event-VideoId-Videolength
0040 -01.00pm -Play -Video1 -02:30:00
Write code for this. What data structure will you use
He also said, lets say all the parsing is taken care of and you are given a collection of classes that contain the above data:
- JSDUDE April 30, 2013 in United StatesClass { CustomerId TimeStamp Event VideoId }
| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Data Structures - 0of 0 votes
AnswersFinding border of a binary tree.Given a Binary tree print all the nodes that form the boundary.
- mrunalishah.cool April 20, 2013 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures