In algorithms, you create a queue (more efficiently than a single linked list) from two stacks, by always adding items to a Insert stack, and removeing items from a Remove stack, how?
Answer
Remove from top of remove stack (list.pop()). If remove stack is empty, add all items from insert stack to it one at a time (since items will be added in reverse order, remove order is kept in tact!), then do the pop()
Question
In algorithms, you create a queue (more efficiently than a single linked list) from two stacks, by always adding items to a Insert stack, and removeing items from a Remove stack, how?
Answer
?
Question
In algorithms, you create a queue (more efficiently than a single linked list) from two stacks, by always adding items to a Insert stack, and removeing items from a Remove stack, how?
Answer
Remove from top of remove stack (list.pop()). If remove stack is empty, add all items from insert stack to it one at a time (since items will be added in reverse order, remove order is kept in tact!), then do the pop()
If you want to change selection, open document below and click on "Move attachment"
pdf
owner: kkhosravi - (no access) - PYTHON_DATA_STRUCTURES_AND_ALGORITHMS.pdf, p137
Summary
status
not learned
measured difficulty
37% [default]
last interval [days]
repetition number in this series
0
memorised on
scheduled repetition
scheduled repetition interval
last repetition or drill
Details
No repetitions
Discussion
Do you want to join discussion? Click here to log in or create user.