I had an interesting conversation with Prof. Tom Rebold of Monterey Peninsula College (www.mpc.edu) about generics in Java. Prompted by that exchange, I thought of three ways to implement a class of bags using a generic data type. I describe them in this article. One important point is that generics applies to compilation, not execution. Feel free to post other suggestions for working with generics!
Small group instruction
Small group instruction, especially within the context of a large lecture class, can be an effective teaching tool. But what do you think of this article? http://www.npr.org/2012/01/01/144550920/physicists-seek-to-lose-the-lecture-as-teaching-tool
Plans for the 6th edition of Data Abstractions & Problem Solving with C++, Walls and Mirrors
I am happy to announce my collaboration with my colleague, Tim Henry, in developing the next edition of Walls & Mirrors C++. We have exciting plans for this edition, and you can read about them here. Comments about our plans are most welcome. Look for the new edition in bookstores by September 2012.
Computer Science Education Week (CSEdWeek) December 4 – 10, 2011
For details, visit http://www.csedweek.org/
The following note is from Dr. Ann W. Drobnis, Albert Einstein Distinguished Educator Fellow, at the National Science Foundation:
In celebration of CS Ed Week, The National Science Foundation will rollout CS Bits & Bytes, a one-page biweekly newsletter highlighting innovative computer science research, on December 5 and continue publication through the end of the 2011/2012 academic year.
The NSF CS Bits & Bytes series will emphasize how computer science permeates and improves our lives and supports progress in many other disciplines. CS Bits & Bytes issues will also include profiles of the individuals who do this exciting work. It is our hope that educators and parents will use CS Bits & Bytes to inspire students to engage in the multi-faceted world of computer science, to become not just users but creators of technology, and to develop the skills to bend computation to their own ends, no matter their interests.
To receive CS Bits & Bytes, please visit: http://www.nsf.gov/cise/csbytes/
Happy Thanksgiving!
It’s time for a holiday break. Although I follow an algorithm’s steps closely when I implement it, I tend to use recipes as inspiration when I cook. I planned to bring a dessert to a dinner party last weekend. Bavarian Apple Tort, a recipe given me by a good friend a while ago, was my choice. But then I saw a recipe for Pumpkin-Apple Cake that sounded tasty. My indecision was solved by combining the recipes into my Pumpkin-Apple Surprise Cake. Quite good, but so is the tort. Try them and have a happy, thankful holiday!
A New Order: Making Linked Data Structures More Accessible to Students
Learning about linked data structures in Java can be challenging for students. Typical introductions to data abstraction begin with the ADT list. After examining how to use an array in the definition of a class of lists, I and many other instructors proceeded by introducing the idea of linked nodes as a way to represent a list. Unfortunately, this approach requires that we consider additions to and deletions from the list at its beginning, end, and interior. This is a lot for a student to assimilate.
Knowing that I would rather start out with the much simpler data organization, the bag, I set out to learn the impact of this new topic order. I found that I could talk about data abstraction in terms of a bag in the same way that I had using a list. Moreover, when defining a class of bags using an array to contain the bags entries, resizing the array was just as natural here as it had been before with a list. But it was the linked implementation of a bag that exhibited an elegant new way to introduce linked nodes. Since a bag does not organize its entries, additions and deletions can be made anywhere within the data structure containing the entries. With a chain of linked nodes, the easiest place to perform these operations is at the beginning of the chain–that is, assuming we have a head reference.
By starting out with a bag instead of a list, we can talk about serious design and implementation issues without overwhelming our students. But what is next? It turns out that many students become familiar with stacks, and even queues, in high school. The linked implementation of the ADT stack uses the same additions and deletions at the beginning of a chain of linked nodes as does the bag. And the stack is a more useful data organization that has many interesting applications, yet we have familiar material to use in its implementations.
Moving on, queue implementations that use linked nodes provide the opportunity to discuss adding and removing the last node in the chain and tail references. The related ADT deque lets us talk about a circular arrangement of nodes. Finally, the treatment of lists looks at the more involved operations of adding and removing a node that lies between existing nodes.
I think you will find that this reorganization makes the difficult topic of linked data more accessible to your students. I have used this approach in the recently published third edition of Data Structures and Abstractions with Java.
Coding
I have been busy completing the supplementary material for the third edition of Data Structures and Abstractions with Java. I’ve spent the last few weeks writing Java code for the solutions to the programming projects. I really like coding, and it gives me the opportunity to use all the programming tips I give my readers and students.
When creating a data structure, I like to define an interface. Doing so affords the opportunity to focus on what the methods will do. Actually writing javadoc comments forces me to consider what should happen under various circumstances. An interface makes the separation between specification and implementation clear. (The same is true of a header file in C++.) But even if a Java interface is not appropriate for your situation, spending time on specifying methods before defining them is worthwhile.
I make coding mistakes: Big ones, little ones, subtle ones, and stupid ones. I get to practice my debugging skills. Learning to debug can be hard, and teaching another to debug is even harder. That’s why I wrote and included Debugging Interludes in my book Imagine! Java. Readers are introduced to various techniques while examining several examples of coding errors. And instructors have a framework for including debugging as a topic in their courses. And remember, as long as you blame something or someone other than yourself for your mistake, you delay finding the bug!
Happy coding and have a great day!
Problem Solving
I posted a question to my LinkedIn group, URI Computer Science, about the importance of taking a physics course as a part of an undergraduate degree in computer science. The responses ranged from very important to not important. Feel free to add your own opinion either here or on LinkedIn.
The argument for the physics requirement is to develop one’s problem-solving ability. Many moons ago, I was an undergraduate physics major. At the time, I certainly had trouble solving first-year physics problems! Whatever courses are meant to foster problem solving are successful not by their subject matter alone, but to a great degree by the focus of the instructor on developing these skills.
It seems to me that introductory courses in computer science, such as CS1 (Programming) and CS2 (Data Structures) have material that is rich enough to develop a student’s skills in problem solving. I’m thinking of abstraction, the idea that we separate the “what” from the “how.” We first specify the purpose and expectations of a class, a method, or an abstract data type (ADT). We then test those specifications by trying to use that class, method, or ADT in a pseudocode solution. This task might lead us to clarify or alter our specifications. After we fully understand and approve what our planned components are to do, we implement them in a programming language.
As computer science instructors, we can begin to form our students’ problem solving abilities. Later, courses such as physics, chemistry, theoretical mathematics, or logic can help to develop these abilities. Simply requiring these courses is not enough.
Steve Jobs
Programming Tip
When calling a method, you should rely on its specification, but not its implementation. Here is an example.


