Last active
August 29, 2015 13:57
-
-
Save LuisRBarreras/9361221 to your computer and use it in GitHub Desktop.
Making a queue using two stack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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