From d308724726664a9aee52bfcb6e52c15d6a904a66 Mon Sep 17 00:00:00 2001 From: zero4994 Date: Fri, 11 Jan 2019 10:36:07 +0900 Subject: [PATCH 1/3] Added simple 'Snake Game' example --- src/data-structures/linked-list/README.md | 41 +++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/data-structures/linked-list/README.md b/src/data-structures/linked-list/README.md index d4eb6ef4..3cc16938 100644 --- a/src/data-structures/linked-list/README.md +++ b/src/data-structures/linked-list/README.md @@ -154,6 +154,47 @@ end ReverseTraversal O(n) + +### Examples +Some of real live usages are liste below: + + - Snake Game + You start the game with one node on the list which in thime and place is both the head and tail + + [] <- (single node) + + As the snake keeps eating those items are being added to the tail, and as such, becoming the tail for the list + + (food)-> * [] <-(snake) + / \ + head tail + + [][] (snake has eaten and it grew by one) + / \ + head tail + + And so on and so forth + (food)-> * [][] <-(snake) + / \ + head tail + + [][][] (snake has eaten and it grew by one) + / \ + head tail + + + + (food)-> * [][][] <-(snake) + / \ + head tail + + [][][][] (snake has eaten and it grew by one) + / \ + head tail + + + + ## References - [Wikipedia](https://en.wikipedia.org/wiki/Linked_list) From 969f906a8e23a9e4cf3063834cb6c900d0abfac1 Mon Sep 17 00:00:00 2001 From: zero4994 Date: Fri, 18 Jan 2019 09:45:47 +0900 Subject: [PATCH 2/3] Added examples for linked list README --- src/data-structures/linked-list/README.md | 32 +++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/data-structures/linked-list/README.md b/src/data-structures/linked-list/README.md index 3cc16938..2c02df61 100644 --- a/src/data-structures/linked-list/README.md +++ b/src/data-structures/linked-list/README.md @@ -192,8 +192,36 @@ Some of real live usages are liste below: / \ head tail - - + + - Web Browser History + Let's say you are confortably browsing the web on your computer, you are using your favorite browser, when you visit your first page your browser creates a single node list with the website you are looking at. + + The value for the node would then be the link for that site, for example, Github + + [ Github/javascript-algorithms ]. <- current website (tail and also head) + + But then you decide to go to facebook on that tab, but your browser instead of forgetting where you've been keeps track of the last page by adding nodes to that list + + [ Github/javascript-algorithms ]. <- (head) + | + [ Facebook/your-profile ] <- current website (tail) + + As you keep visiting new websites on that tab the browser keeps track of it and will append it to the tail of the list + until you have something like this + + [ Github/javascript-algorithms ]. <- (head) + | + [ Facebook/your-profile ] <- node + | + [ Wikipedia/Pomodoro_Technique ] <- node + | + [ Wikipedia/Life_hack ] <- node + | + [ Whatsapp ] <- current website (tail) + + This is a very good example of a double link list + + ## References From 0a018953be27621033abb2451c82ebdf0c95e941 Mon Sep 17 00:00:00 2001 From: zero4994 Date: Fri, 25 Jan 2019 09:22:08 +0900 Subject: [PATCH 3/3] Fixed typo --- src/data-structures/linked-list/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data-structures/linked-list/README.md b/src/data-structures/linked-list/README.md index 2c02df61..02545e77 100644 --- a/src/data-structures/linked-list/README.md +++ b/src/data-structures/linked-list/README.md @@ -156,7 +156,7 @@ O(n) ### Examples -Some of real live usages are liste below: +Some of real live usages are listed below: - Snake Game You start the game with one node on the list which in thime and place is both the head and tail