Last active
September 2, 2015 18:10
Revisions
-
hoitomt revised this gist
Sep 2, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -23,4 +23,4 @@ Now pop return the value from node5 update @data to reference node4 -
hoitomt revised this gist
Sep 2, 2015 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -16,3 +16,11 @@ Now Stack @data = node5 POP Now node5 -> node4 -> node3 -> node2 -> node1 pop return the value from node5 update the reference of node5 to nil -
hoitomt created this gist
Sep 2, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ Stack - [a, b, c, d] Start: node4 -> node3 -> node2 -> node1 Stack - no idea how many items are in it, only knows the top item @data = node4 Next - Add a new node to the stack - "push" push(value) Use that value to create a new node (New Node) Take our new node and add a reference to the last existing node - represented by @data @data = New Node, which essentially becomes node5 Now Stack @data = node5