Chapter 2.2 Questions

Nodes

We are going to be building linked lists, graphs, and dictionaries. Becuase both linked lists and graphs have nodes, we are going to start with nodes. We are going to need to create a couple types so first we will make linked lists nodes with a next, previous, and value. Next and previous should point to nodes, not the values in those nodes.

Okay, now that we have done that, we need to make nodes which point to children and parents. This is more for trees than graphs. If you want to build a graph, replace children with connections. For more bonus, you can make connections with weights.

Linked Lists

Linked lists should have a head and a tail. I should be able to delete a node, a value, or al of the same value. Under the hood all you need to do is have next and previous point to a different node. I will also be implementing a way to turn an array in into a linked list.

It would also be useful to have a reverse method, which reverses the linked list. Rather than storing all the values and using a built in reverse method, can you do it by just iterating through your linked list, once?

Queue

A queue is a dynamic array, where you can only pop off the front, view the item in front, and add to the back. AS YOU SHOULD KNOW. Build a queue. It should have pop, view (you can also call it peek), and push. But it should follow queue rules.

Stack

A stack is a dynamic array, where you can only pop off the front, view the item in front, and add to the front....you get it. Build a stack. It should have the same funcations as a queue.