Amazon Interview Question
Software Engineer / DevelopersCountry: United States
FILO data structure.
Think of it as a stack of plates, the last plate you put on top of the stack if the first plate you're going to get when you need to get something from the stack. And of course it comes with all the advantages and disadvantages that come with that. For example the last element might be in the stack for a long time before it can be accessed since you need to get all the elements that were put in the stack after if first before getting to it.
Also getting an element from the middle of the stack (random access) would naturally not be possible without having to make ugly hacks to get around the natural behavior like creating temporary structures to get an element, and then re-adding all the elements back to the original stack.
we can keep track the last entry in O(1) time
- Anonymous March 19, 2012Searching will be O(n) to get the first element time O(n)