data-structures

Data Structures: 5. Binary Tree

Apr 10, 2022
programming, go, data-structures, generics

Introduction # A binary tree is a tree where each node has up to two leaves, and each of those leaves has up to two leaves. So you start with a root node and then fan out, like a genealogical tree. The way the insertion works is that you look at the root node and decided whether the value you are trying to insert is less than or greater than the root node node value. ...

Data Structures: 4. Doubly Linked List

Mar 26, 2022
programming, go, data-structures

Introduction # A doubly linked list is the same as a linked list, execept that now each item is linked to both the next one and the previous one. So if you have a linked list with the following items (1, 2, 3, 4) it would look like this: flowchart LR; H(["HEAD"]) --> A([1]); A([1]) <--> B([2]); B([2]) <--> C([3]); C([3]) <--> D([4]); D([4]) --> E(["NIL"]) The operations available on a doubly linked list can vary - in this case we provide a function to check to see if the doubly linked list is empty or not, a function to get the length of the list, a function to get the items without removing them, a function to list the items without removing them, a function to search the doubly linked list, as well as functions to add or remove items from the front of the list, the back of the list, as well as a specified position in the list. ...

Data Structures: 3. Linked List

Mar 26, 2022
programming, go, data-structures

Introduction # A linked list is literally that, a list where each item is linked to the next one. So if you have a linked list with the following items (1, 2, 3, 4) it would look like this: flowchart LR; H(["HEAD"]) --> A([1]); A([1]) --> B([2]); B([2]) --> C([3]); C([3]) --> D([4]); D([4]) --> E(["NIL"]) The operations available on a linked list can vary - in this case we provide a function to check to see if the linked list is empty or not, a function to get the length of the list, a function to get the items without removing them, a function to list the items without removing them, a function to search the linked list, as well as functions to add or remove items from the front of the list, the back of the list, as well as a specified position in the list. ...

Data Structures: 2. Queues

Mar 20, 2022
programming, go, data-structures

Introduction # Queues, in there simplest form, are like stacks, except that the first element in is the first element out, or FIFO (First In First Out). It’s a bit like a stack of plates were you alway put on the top of the stack but if you remove a plate you take it from the bottom. As noted for stacks, we are using any type instead of a specific type like string or int. ...

Data Structures: 1. Stack

Mar 20, 2022
programming, go, data-structures

Introduction # The stack is one of the simplest data structures and one that is easy to image from every day life. If you have a stack of dishes, you normally add to the top of the stack and when you want to take one off you also take it from the top. This is known as First In First Out, or FIFO. The act of adding a plate is called pushing a new plate onto the stack, removing one is called popping the plate from the stack. ...