Teach Dynamic Memory Structures: Linked Lists

Posted by:

The “generic” approach to programming provides code that is “safer” because it passes data types into class “templates” that are built to manipulate data of most or all data types. This approach allows programmers reuse of methods that are optimized and rigorously debugged, cialis thus saving a programmer precious development time. However, the disadvantage from a pedagogical perspective is that fundamental operations get abstracted (placed in methods) and thus pushed yet one more step deeper into the implementation of code. This has the net effect of hiding fundamental operations that student learning benefits from understanding. The recommended

teaching strategy here is to teach dynamic memory allocation at three levels of increasing abstraction: (1) actual memory allocation; (2) changing values of instance variables; (3) accessor and mutator methods. This is exemplified by when we compare the practice code from the Practice-It web site, we discover that their linked lists (LL) and Binary Search Trees (BST) deal with specific data types such as their “IntTree” practice class, whereas the Deitel JHTP8 text, chapter 22 manipulates generic classes that can handle almost any data type. The “problem” (which in my opinion is really a virtue in disguise) with this inconsistency is that students will learn from Deitel how to use generic classes and methods but must then apply the logic that they learned to data specific methods and classes. Students will thus practice the “old-fashioned” approach of implementation by using instance variables of raw data as seen in the Practice-It site but will see how code can be generalized in the Deitel JHTP8 materials. This will take some extra effort in adapting to the historically different approaches. KEY TEACHING TECHNIQUE: Remind students that everything happens at the electronic level in the memory of the computer. Illustrate this by constantly mapping every Java operation with


About the Author:

Gerry Donaldson was Calgary’s first high school teacher to use a lab of personal computers. Gerry taught CSE, including CTS, AP and IB Computer Science, for 30 years before teaching and consulting to the Department of Computer Science at the University of Calgary.
  Related Posts
  • No related posts found.

Add a Comment