mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2025-07-28 04:33:42 +08:00
contents: rearrange algo layout structure
This commit is contained in:
@ -12,6 +12,13 @@ This behavior is commonly called FIFO (first in, first out). The name "queue" fo
|
||||
|
||||
Breadth-first search is commonly implemented using queues.
|
||||
|
||||
## Learning resources
|
||||
|
||||
- Readings
|
||||
- [To Queue Or Not To Queue](https://medium.com/basecs/to-queue-or-not-to-queue-2653bcde5b04), basecs
|
||||
- Videos
|
||||
- [Queues](https://www.coursera.org/lecture/data-structures/queues-EShpq), University of California San Diego
|
||||
|
||||
## Implementations
|
||||
|
||||
| Language | API |
|
||||
@ -31,12 +38,9 @@ Breadth-first search is commonly implemented using queues.
|
||||
| Back | O(1) |
|
||||
| isEmpty | O(1) |
|
||||
|
||||
## Learning resources
|
||||
## Things to look out for during interviews
|
||||
|
||||
- Readings
|
||||
- [To Queue Or Not To Queue](https://medium.com/basecs/to-queue-or-not-to-queue-2653bcde5b04), basecs
|
||||
- Videos
|
||||
- [Queues](https://www.coursera.org/lecture/data-structures/queues-EShpq), University of California San Diego
|
||||
Most languages don't have a built in Queue class which to be used, and candidates often use arrays (JavaScript) or lists (Python) as a queue. However, note that the enqueue operation in such a scenario will be O(n) because it requires shifting of all other elements by one. In such cases, you can flag this to the interviewer and say that you assume that there's a queue data structure to use which has an efficient enqueue operation.
|
||||
|
||||
## Corner cases
|
||||
|
||||
@ -44,10 +48,6 @@ Breadth-first search is commonly implemented using queues.
|
||||
- Queue with one item
|
||||
- Queue with two items
|
||||
|
||||
## Things to look out for during interviews
|
||||
|
||||
Most languages don't have a built in Queue class which to be used, and candidates often use arrays (JavaScript) or lists (Python) as a queue. However, note that the enqueue operation in such a scenario will be O(n) because it requires shifting of all other elements by one. In such cases, you can flag this to the interviewer and say that you assume that there's a queue data structure to use which has an efficient enqueue operation.
|
||||
|
||||
## Recommended questions
|
||||
|
||||
- [Implement Queue using Stacks](https://leetcode.com/problems/implement-queue-using-stacks)
|
||||
|
Reference in New Issue
Block a user