amzngoogaapl
BAN USER- 0of 0 votes
AnswersCreate a number pool 1...infinity which has 2 methods..
- amzngoogaapl in United States
CheckIn(someNumber) and checkout()
Checkout should give the min number checked in.
Checkin should add to numberPool if number doesnt exist.
Intially all numbers 1..infinity are available.
eg:
1. checkout() gives 1
2. checkout() gives 2
3. Checkin(1)
4. checkout() gives 1 now.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersYou have a binary tree (not BST), serialize it in a stream and reconstruct the tree maintaining the format of the tree.
- amzngoogaapl in United States
sending 2 streams InOrder+PreOrder or InOrder+PostOrder is not an option.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Data Structures
@Hari
How would you create a heap for infinite numbers ?? Also every time you do a heapsort to maintain min number at root is way too expensive. How would you check if a number exists in heap?
I dont see any option to edit the question
- amzngoogaapl August 03, 2012Guys, any algo where we store nums 1...infinity for initialization was rejected right away... and the frequency of checkout and checkin is not defined...
- amzngoogaapl August 03, 2012checkin ignores any number which is already present
- amzngoogaapl August 03, 2012
@yemrus_ankara
- amzngoogaapl August 03, 2012Can you walk through an eg?