Data Structures Interview Questions
- 2of 2 votes
AnswersData structure which supports both map operations and array operations without time complexity penalty.
- Ray November 14, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer in Test Data Structures - 0of 0 votes
AnswersWrite func repeat(e, n).
- ab123 November 12, 2015 in United States
Args:
e: any object
n: a number of times
Returns:
an iterator producing the element e n times| Report Duplicate | Flag | PURGE
Google Software Engineer Intern Data Structures - 0of 0 votes
AnswersGiven an array of integers. Modify the array by moving all the zeros to the end (right side). The order of the other elements doesn't matter.
- m.mirzamo October 28, 2015 in United States| Report Duplicate | Flag | PURGE
Facebook Intern Algorithm Data Structures - 1of 1 vote
AnswersHow to find if a given expression is a valid arithmetic expression?
- testsync012345 October 23, 2015 in United States
Eg:(())()) - Invalid expression, (()()) - Valid expression| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Data Structures - 4of 4 votes
AnswersGiven a linkedlist, write an algorithm to divide the linkedlist into two linkedlists, the first contains the Fibonacci numbers in the list and the second contains the non-Fibonacci numbers.
- a.ahmed.shalabey October 23, 2015 in United States for Software Development
Test the algorithm after developing the code| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm C Data Structures - 3of 3 votes
AnswersSuppose you have a incoming stream of numbers and a method like T* readNextNumber() to read them, and each time there is only limited amont of them coming in and readNextNumber would return null if no more available. implement a method to calculate the median of all numbers you have read.
- lucifer1986 August 28, 2015 in United States
The key point to the question is figure out the data structure to store those numbers you have read and I stopped at a balance tree, the interviewer told me it should be 2 heaps, one ascending and one descending, plus a median value between them. The final algorithm I figure out based on it is each time compare the new number with median, if bigger than it insert to the descending heap at the right side of the median else to the left, recalculate the median by checking heap sizes, the new median would be either current median, max of the left heap or min of the right heap.| Report Duplicate | Flag | PURGE
Google Data Structures - 1of 1 vote
AnswersDesign a data structure which should have following operation. Insert, Delete, Random access
- hm August 21, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Data Structures - 0of 0 votes
AnswersDesign a system java same as relational database.
For example,
You Have employee table as bellow:ID | Name | Manager | Salary
Now you can execute queries like :
select * from Employee where ID= ' something' select * from Employee where Name= ' something' select * from Employee where salary = ' something'
In same way you have a class Emplyee as bellow:
class Employee { String ID; String Name; String Salary; String Manager; }
Now I want to query on this class as same as the sql queries above,
- Ghosh August 17, 2015 in India
How can I do it efficiently?
The code should be optimized on time complexity and space complexity.| Report Duplicate | Flag | PURGE
Oracle Software Architect Algorithm Data Structures Java Object Oriented Design - 0of 0 votes
AnswerImplement a class to provide in real-time the list of the top 100 most viewed
- chestnut304 August 14, 2015 in United States
properties in the last hour. For the purposes of this exercise, you should think of
"the last hour" as the 3600 seconds ending now. Properties are represented by a
"zpid" or Zillow property ID, which we will treat as a unique string.
Example, if the current time is 2:20:
| 1 | 2 | 3 | 4 |
|-------| <- we want this time range
One possible interface:
interface MostViewed
{
// Every user view of a property calls this:
void propertyViewed(String zpid);
//Anytime we want the top 'count' properties, we can call this:
//which returns a list of zpids
List<String> getCurrentMostPopular(int count);
}| Report Duplicate | Flag | PURGE
Zillow Data Structures - 1of 1 vote
AnswersDesign a data structure in which we can do all CRUD operations in O(1) ?
- Aman Mittal August 07, 2015 in India
CRUD- Create, Retrieve, Update, Delete| Report Duplicate | Flag | PURGE
Flipkart SDE1 Data Structures - 0of 0 votes
AnswersWrite a function which will sort a linked list efficiently. I explain merge sort, However interviewer was not agree with my answer.
- Sach July 20, 2015 in India
Interviewer was expecting answer bubble sort along with backtracking. Not convinced or agreed with his opinion though.| Report Duplicate | Flag | PURGE
GSLab Technical Architect C Data Structures - 2of 2 votes
AnswersA single-elimination tournament with 64 teams. Before the tournament, fans construct fantasy brackets for their tournament predications. Design a data structure for storing fan brackets and algorithm to score their brackets against a winning bracket. Assume we will then need to quickly score a player’s predictions (1 point per successful round prediction) and your solution should be optimal enough to handle millions of fan brackets with minimal data.
- DVD July 15, 2015 in United States| Report Duplicate | Flag | PURGE
Amazon Software Developer Data Structures - 4of 4 votes
AnswersDesign a data structure that supports kind of full text search but in numbers.
- coredo July 14, 2015 in United States
We are given file with lot of 10-digits numbers, for example:
1234 567 890
4124 123 123
3123 123 322
On a given number X we should return all numbers that contain X.
For example, if the number 123 was given, we should return all numbers (from the list above) because 123 is in all of them.
If the number 41 was given we should return only the middle number - because the number 41 is only in it.| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Data Structures - 0of 0 votes
AnswersA client wants to build a software phone book that contains everyone in the world (7 billion people). Every person has only the first name and the name is unique. What data structure would you use to store the data?
- rv July 14, 2015 in United States| Report Duplicate | Flag | PURGE
Bloomberg LP Financial Software Developer Algorithm Data Structures - 0of 0 votes
AnswersGiven a BST write a function that looks for a value.
- rv July 14, 2015 in United States| Report Duplicate | Flag | PURGE
Bloomberg LP Financial Software Developer Algorithm C++ Data Structures - -1of 1 vote
AnswersRound 5
- sonesh July 12, 2015 in United States
Question 4 : Now lets say you have 1 PB(1000 TB) of numbers, what kind of system you would prefer, not that you can't store this data in one box. How will you sort these many numbers, what is the time complexity in seconds ?. does increasing core per machine help here ?| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm Arrays Data Structures Distributed Computing Sorting - -1of 1 vote
AnswersRound 4
- sonesh July 12, 2015 in United States
Question 3 : this question was similar to Round 2 Question No 3, which is basically convert row type of data to column type of data| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm Arrays Data Structures - -1of 1 vote
AnswersRound 3
- sonesh July 12, 2015 in United States
Question 2 : You are given a array of integers, array may have duplicates, you have to find out the rank k number, and then print out the k highest numbers ?
Required complexity is O(N) + O(1) space, duplicates may be an issue, on which she wanted me to put more focus.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm Arrays Data Structures - 0of 0 votes
AnswersRound 2
- sonesh July 12, 2015 in United States
Question 3 : You have to implement an external iterator which iterate the binary tree InOrder. You have to figure out what kind of iterator one should use, and implement each of those function. required complexity is O(N) time + O(log(N)) space| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Coding Data Structures Trees and Graphs - -3of 3 votes
AnswersRound 1(taken by DATA SCIENTIST 2)
- sonesh July 12, 2015 in United States
Question 1 : You are given a street map of a city, Every day you travel from your home to work. some day you take bus or someday your our car. Bus fare is also not constant, it may change in future, may increase or decrease ?
you have to find shortest path from your home to your work ?.
Note that : you have to expose this as library, so no custom assumptions. need to find out how you incorporate variable bus fare ?, also it is up-to the user to choose between bus and his car ?, in case of bus, you have to minimise the total money, and in case of care, you have to minimise the distance.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm Data Structures Trees and Graphs - 0of 0 votes
AnswersGiven huge database of songs design search data structure and algorithm to search all songs with words starting with the letters entered and words matching the sequence of words entered.
- emptycup July 06, 2015 in India
Suppose the songs are:
1. Every night in my dreams
2. Listen to my heart
3. Show me the meaning
4. Night in London
5. Night changes
Entering "m" should list 1,2 and 3. "my" should list 1 and 2. "Night" should list 1,4 and 5. "Night in" should list 1 and 4.| Report Duplicate | Flag | PURGE
Flipkart SDE-3 Data Structures - 0of 0 votes
AnswersInput Parser and Processor
- rameshelworthy July 04, 2015 in India
Problem
Implement a java program for querying data from a java object. Java object need to be constructed based on text data provided to program.
The parser should be generic to parse any input confirming to the hierarchical format similar to the one mentioned in sample
The Content of the file
[employee]
name=john
age=30
salary=100
[address]
houseno=221b
street=bakerstreet
[location]
place=xyz
state=abc
country=123
[/location]
[/address]
designation = srDeveloper
[/employee]
Sample Input and Output
employee.name Output John
employee.address.houseno Output 221b
employee.address.location.state Output abc
employee.manager Output NOT_FOUND
The program should work any object data specified as input file.| Report Duplicate | Flag | PURGE
Oracle Java Developer Data Structures - 2of 2 votes
AnswersTech Screening
- sonesh July 02, 2015 in United States
Question 1 : You will be given a stream of integers, and a integer k for window size, you will only receive the streams integers one by one. whenever you receive an integer, you have to return the maximum number among last k integers inclusive of current entry.
Interviewer was expecting O(N) solution for N asks.
Edits: Interviewer was expecting O(N) Time + O(1) avg case space complexity solution for N asks.
and integers are not given in a array, every time only one integer will be passed as input to your method.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm Arrays Data Structures - 0of 0 votes
AnswersRound 3
Question 1, you are given a puzzle, You can check the image herehttps://drive.google.com/file/d/0B6-TjTC-KfTqQThBamxPa0NwNGM/view?usp=sharing
You have to write a program to provide a solution for this.
- sonesh July 02, 2015 in United States| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Coding Data Structures Puzzle - 0of 0 votes
AnswersRound 2
- sonesh July 02, 2015 in United States
Question 1: Design a traffic signalling system for a city.
1.a : think as you were asked this question in a high level meeting with leadership teams, what would you do at that time ?
1.b : what are the check-list/to-do you will do before start of your project.
1.c : how will you go over each and every check-list/to-do
1.d : Once you have done all this, what are the design principle you will follow.
1.e : what kind of system you would choose(I gave distributed/centralized)
1.f : Tell me the pros and cons of these type which you have listed
1.g : how do you go over your goal.
1.h : how will you make the cons go away from one system which out changing it to another type(like possible modification).
1.i : How will to achieve your goal which was given to you by LT team.
1.f : Now lets write the code for a road intersection, make it generic enough both in terms of colors, and ordering, so what it can be used anywhere.
Note that : a road intersection may have many traffic lights one for each side of the roads| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Coding Data Structures Software Design System Design - 0of 0 votes
AnswersImplemented a bounded queue:
- JSDUDE June 23, 2015 in United States for Customer experience
Read:
If queue is empty, wait till it can return a value with time out
If another thread is reading from the queue then wait till that thread is done
Remove the first element from the queue and return it
Do not block if a thread is writing into the queue
Write:
If queue is full, wait till one value is read with time out
If another thread is writing to the queue, wait till that thread is done
Write the element at the end of the queue
Do not block if a thread is reading from the queue| Report Duplicate | Flag | PURGE
Walmart Labs Software Developer Data Structures Threads - 0of 0 votes
AnswersFind all paths in binary tree that add up to a given sum.
Given a tree like this:2 3 5 4 8 6 -2 2
return {3,4}, {2,5}, {2, 5, -2, 2}
- steez June 22, 2015 in United States for android amazon app, social shopping| Report Duplicate | Flag | PURGE
Amazon SDE-2 Data Structures - 0of 0 votes
AnswersIn java, how will you implement hashset in which the insertion order of elements is preserved?
- Vpn June 09, 2015 in India| Report Duplicate | Flag | PURGE
abc Data Structures