Search code examples
nodes

Why do people use Nodes in certain situations?


Recently I learned about creating nodes and using them in LinkedLists, but I'm not sure what you can use nodes for. How are they useful in certain situations, and why not just use a LinkedList of Integers or Strings for data storage instead? What kind of problems would you use a node data structure to solve and how efficient are these structures?


Solution

  • Nodes are building blocks for some data structures like the linkedlist, skiplist, graphs (implemented with adjacency lists), trees etc.

    The node data structure is very simple. In most cases, it contains some data and a pointer.

    Nodes are used because it allows for expanding a data structure without having to copy the data over to a newly expanded and then delete the old version from memory.