Skip to content

Instantly share code, notes, and snippets.

@LuisRBarreras
Last active August 29, 2015 13:57
Show Gist options
  • Save LuisRBarreras/9361221 to your computer and use it in GitHub Desktop.
Save LuisRBarreras/9361221 to your computer and use it in GitHub Desktop.
Making a queue using two stack
public void function queue(Node node) {
stackToStore.push(node);
}
public Node function dequeue() {
if(stackToRetrive.top==null) {
while(stackToStore.top!=null) {
Node tmp = stackToStore.pop();
stackToRetrive.push(tmp);
}
}
return stackToRetrive.pop();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment