Throughout the past two weeks, we
have been working with linked nodes, a common concept used for internal
implementations of objects and data structures. What surprises me most about
the use of linked nodes is the ease with which they can be used.
Consider, for example, the implementation of a Stack ADT using linked nodes. If one was to program the push() method of this class, the algorithm would involve linking the new top node to the rest of the stack and changing the "top" pointer. Simply enough, that's exactly how it would be coded in literally just one line of code per step (if not one in total with tuple unpacking).
The use of nodes is very basic,
since they all contain two simples pieces of information (that is, their value
and their link(s)). All operations on nodes involve working with just these two
things, and for those who like diagrams or may be visual learners, nodes are
easy to visualize and draw when trying to understand how they work or how to
code with them.
For myself, I realized how simple
node operations can be when working on the exercises of this week as well as in
the tutorial. Yes, as expected, coding does involve thinking, even if using
nodes can be basic; but, once you understand the way that you need to
manipulate the nodes, the way you manipulate them is only usually a matter of
changing values and changing reference pointers. The code for the exercises was
short once I understood how exactly I was supposed to work on the nodes, and in
tutorial, my partner and I had no difficulty translating the English of our
discussion to the Python of our program. Even when errors arrived, the
simplicity of node operations made it easy to understand what our code was
doing (and what our code was doing wrong!).
But, perhaps I speak too soon when I
say all this. Perhaps nodes only seem simple because all we've been taught are
the basics. Maybe there are more complexities than just these
"simple" manipulations of references and values. Well, there's only
one way to find out: Assignment 2.