[comp.lang.c++] Data Structures course in C++

dougm@titan.rice.edu (08/03/89)

It shall be my privilege to teach a second semester programming course to
bright undergraduates in C++.  The topics covered are (roughly) queues,
stacks, trees, recursion, searching, sorting, hashing, graphs.  Previous
instructors, teaching the course in Pascal, have used _Programming with
Data Structures_ by Robert L. Kruse, with apparent satisfaction.

I seek your advice.  Do you know of good texts that use C++ for examples?
Do you advise a book other than _The C++ Programming Language_ by Stroustrap
as an introduction to the language?  Any advice to help this C programmer
and C++ neophyte would be appreciated.

Respond by mail;  I'll summarize if warrented.

Doug Moore (dougm@rice.edu)

dougm@titan.rice.edu (Doug Moore) (08/08/89)

As promised, here are the comments I solicited on the question "What books
should I consider for a Data Structures course in C++?"  I have decided
to use "C++ Primer" by Lippman and "Data Structures and C programs" by
Van Wyk.  Thanks for your help.

Doug Moore (dougm@rice.edu)

************
From: pattis@june.cs.washington.edu (Richard Pattis)

Well, not exactly what you wanted, but close.  See Chris Van Wyck's book,
published by Prentice-Hall (in the ATT series).  (The book is "Data Structures
and C Programs", dm.)  It covers standard data structure topics in C, plus
Chris writes very well and knows his material cold.  I think it is premature
to expect an real (means academically correct) data structure book in C++ for
a while.

Rich Pattis

************
From: Rene' Seindal <seindal@diku.dk>

There is ``An Introduction to Object-Oriented Programming and C++'' by Richard
S. Wiener and  Lewis J. Pinson,  Addison-Wesley, ISBN 0-201-15413-7.

I cannot recommend it, though.  It is lousy, to be honest.  Lousy topography
and lousy examples (some of the faulty).

Sorry to be so negative, but it is the only other C++ book I have seen.

Rene' Seindal (seindal@diku.dk).

************
From: smb@ulysses.att.com

I'd very strongly suggest Lippmann instead of Stoustrup as the C++ intro.

************
From: jon@hanauma.stanford.edu (Jon Claerbout)

Book reviews on object oriented programming and C++ by Jon Claerbout
-------------------------------------------------------------------

Sessions, Roger "Reusable data structures for C" (Prentice Hall 88)
	I especially recommend the first 60 pages.
	A good read.  Clear code, clearly motivated.
	C only, not C++ so it is a good introduction to this general area.
	grade A.

Stroustrup, "The C++ Programming Language,"
	Stroustrup is the author of C++.
	This book is of uneven difficulty
	partly because he decides to explain C the same time as C++,
	and he isn't as good a writer as the classic Kernighan and Ritchie.
	Better for the bookshelf than for me.
	grade C.

Berry, John: "The Waite Group's C++ Programming,"
	First 70 pages were OK.  Then it got vague.  I don't recommend.
	grade C.

Wiener and Pinson "An Introduction to Object Oriented Programming and C++"
	On first sight, I didn't like the extensive code,
	but on reading the book, I changed my mind.
	I found the code easy to read and very helpful.
	It is much nicer to have complete runnable code than mere fragments.
	They chose their examples very well.
	I especially recommend pages 1-77 and then p 124-134.
	grade A.

Lippman, Stanley B., "C++ Primer"
	Not as well motivated as Sessions or Wiener and Pinson,
	but has the same definitive documentary flavor as Stroustrup
	and he is writing about the current 1989 release.
	Unfortunately the book has 460 pages and teaches C too.
	Highly regarded by C++ professionals.
	grade B for learners.

To students considering learning C++ I recommend they first learn C from K&R.
(Thus they aren't assaulted by too many new ideas at once as with BS or SL).
Then grasp the goals of C++ by reading
"Reusable data structures for C" by Roger Sessions,
and then read the first half of Weiner and Pinson.
After that they can take advice from comp.lang.c++.

************
From: vaughan%cadillac.cad.mcc.com@mcc.com (Paul Vaughan)
	
	Whatever you do, don't use Stroustrup's book.  It's totally
inappropriate for beginning or early programmers.  Lippman's book (C++
Primer, Stanley Lippman, Addison Wesley) is much more up-to-date on
C++ and is much easier to understand.  I expect you would need to
supplement it with a book on the topics you mentioned also.  You might
consider using g++ as your compiler and using g++-lib.  You will find
state of the art implementations of hash tables, queues, and several
other useful classes.  Studying their interfaces and the way that a
programmer creates the objects for use is a good way to understand the
strengths and weaknesses of C++.

************
From: wlp@calmasd.prime.com (Walter Peterson)

Congratulations on your opportunity to teach data structures in C++!
I'm certain that you are aware of the privilege; I hope that you are 
equally aware of the responsibility (since you are asking for advice,
I believe that you are aware). 	As a researcher and developer of
object-oriented systems, I am often worried when I see classes such as
"Data Structures in C++" being offered.

The data structures class is one of the most important in the entire
computer science curriculum; perhaps *the* most important.  If a
student can not grasp the fundamentals of stacks, queues, linked lists
and the like, he/she will only get further lost in more advanced
courses where a through understanding of these structures is assumed
and required. For this reason, clarity of useage and familiarity with
the implementation language (for both the student and the instructor)
are essential.  I am concerned that the use of languages like C++ for
a data structures class not follow introductory programming classes
that are conducted in Pascal. If properly taught, data structures is
demanding enough without trying to shift mental gears from Pascal to C
or C++ !

Of more immediate concern to me however, is the concept of using an
object-oriented language for an introduction to data structures.  I
have very mixed feelings about this idea.  One the one hand, as a
proponent of the object paradigm, I like to see it being taught and
used. One the other hand, I am concerned that if it is mis-taught and
mis-used it will have the effect of "turning off" some of these
students, who will later resist using object-oriented systems after
they graduate.

Part of the problem stems from the fact that much of what is done by
and with an object-oriented language presupposes a knowledge of the
fundamentals of data structures.  For example, the DSM language with
which I work, has tables, lists, trees, dynamic arrays, sets and n-ary
relations as *built-in* types in the language.  Any and all of these
can be re-implemented if need be using more traditional types
(ints, pointers, etc.) but the power of the object paradigm is lost;
DSM (or C++, Objective-C, whatever) just becomes a more cumbersome
version of C.  

I wish I could help with your search for a good "Data Structures in
C++" text, but I know of none; and I *have* looked. If one of the
purposes of the course is to teach object-oriented data structures and
design and not "just" data structre fundamentals, then I can suggest
some supplementary texts.

Cox, Brad, "Object-oriented Programming : an Evolutionary Approach"
Addison-Wesley, Reading, MA 1986 ISBN 0-201-10393-1

Meyer, Bertrand, "Object-Oriented Software Construction"
Prentice Hall, Englewood Cliffs, NJ ISBN 0-13-629049-3 or
ISBN 0-13-629031-0 PBK

Kim, Won and Frederick H. Lochovsky, eds., "Object-Oriented Concepts,
Databases, and Applications"
ACM Press, Addison-Wesley, Reading, MA, 1989 ISBN 0-201-14410-7

These are about the best introductions to the object paradigm that
currently exist in book form. There are and have been, better
articles focusing on narrower topics, but they are probably too spread
out and too advanced for an introductory undergrad class. The
unfortunate thing is that both Cox and Meyer are not only trying to
teach the object paradigm, they are also trying to "sell" their
respective languages (Objective-C and Eiffel).

Please, please, avoid ANY and ALL "Ada" books like they were the
plague! (Ada : the B-2 of computer science !)

If your students are fortunate enough to already be familiar with C,
then I can heartily recommend one book.

Pohl, Ira, "C++ for C Programmers"
Benjamin/Cummings, Redwood City, CA, 1989 ISBN 0-8053-0910-1

Bjarne Stroustrup's book is the standard, the K&R of C++, but I would
not want to have it as my only source for learning C++.  

I hope this helps.  In any case, good luck. Please, feel free to contact
me with any further questions.

************
From: jeh@hr2top.att.com (James E Humelsine)

I wouldn't use Stroustrup's book as the main text. He assumes the reader
knows the concepts of OOP, and he just shows how C++ implements it. It
would probably be good as an optional book. His book is not up to date
with the new C++2.0.

I learned the most about OOP, but not necessarily about C++, from
An Introduction to Object-Oriented Programming and C++. I thought
this book did a good job of explaining the concepts of OOP and
it used C++ in most of its examples, but it really didn't teach
C++. I know of at least one possibly two mistakes in the examples.
There could be more. This book however does go into some data structures.

A new book C++ Primer by Stanely B. Lippman is supposed to be a good
C++ 2.0 book. I started reading it, but I am only about a quarter of the
way through it.

I don't know of any books that give you exactly what you are looking
for. 

One point that most books don't stress is style. When someone adds an
object he/she must make the interface to that object consistent
especially when using overloading. In a way, adding an object is 
like adding to the language, but without having to rewrite the compiler.

Some overloaded interfaces make sense. Like a matrix object

matrix A(4,4), B(4,4), C(4,4);

A = B + C;

C = B * A;
...

But some aren't so straight forward since symbols have never been used
for them before. For example:

queue Q;
stack S;
int x;

S.push(x) // or should it be S << x
S.pop(x)  // or should it be S >> x

Q.tail(x) // or should it be Q << x as in a stack notation
Q.head(x) // or should it be Q >> x as in a stack notation


tree T;
hashtable H;
linkedlist L;

All can have the exact same methods, insert, delete, search.




My personal feeling is that a data structure course should stress why
these structures are necessary, the problems they solve, and then then
the means of implementing them. This is true for a procedure language
but even more important for an object language since the implementation
is hidden from the user.


Sorry. I gave you more than you asked for.

Jim Humelsine

************
From: Dag Bruck <dag@control.lth.se>

Lippman, Stanley B. (1989): ``C++ Primer,'' Addison-Wesley.

Very good text on C++.  Requires programming experience and knowledge
of some high-level language (not neccesarily C).  Describes C++ in
great detail; good chapters on OOP.  Many examples, quite readable for
non-language designers.  Covers C++ 2.0.  Over 450 pages!

Dag Michael Bruck