CS Behind the Curtain (CS195 2003S)

Class 37: Linked Lists (1)

Back to Reading Gries. On to A List Wrapper (1).

Held: Monday, 7 April 2003

Summary: Today we begin our consideration of how to implement Scheme-like lists, which are generally called linked lists.

Related Pages:

Assignments:

Notes:

Overview:

What is a List?

Linked List Operations

Implementing Linked Lists

Implementing Linked List Operations

node *empty_list() {
  return null;
} /* empty_list() */

/* Note: cons returns NULL if it fails. */
node *cons(int val, node *next) {
  node *new_node = (node *) malloc(sizeof(node));
  if (new_node == (node *) NULL)
    return new_node;
  new_node->datum = val;
  new_node->next = next;
  return new_node;
} /* cons(int, node *) */

/* The rest left for discussion. */

Homogenous Linked Lists

 

History

Tuesday, 7 January 2003 [Samuel A. Rebelsky]

Sunday, 6 April 2003 [Samuel A. Rebelsky]

 

Back to Reading Gries. On to A List Wrapper (1).

Disclaimer: I usually create these pages on the fly, which means that I rarely proofread them and they may contain bad grammar and incorrect details. It also means that I tend to update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.

This document was generated by Siteweaver on Fri May 2 14:20:57 2003.
The source to the document was last modified on Sun Apr 6 23:20:13 2003.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS195/2003S/Outlines/outline.37.html.

You may wish to validate this document's HTML ; Valid CSS! ; Check with Bobby

Samuel A. Rebelsky, rebelsky@grinnell.edu