Overview
This week we will continue our study of Chapter 6: Linked Lists.
Thursday, February 22nd
Classwork
During class today we will begin sharing our implementations of the circular
list functions assigned last class, starting with print_clist
and
clist_insert_in_order
. Since Nate's implementation of
clist_insert_in_order
creates a descending clist, let's
work in our same groups to change it to ascending (thus making Joseph's
0 -> 2 -> 4
work the way he wants it to ;-)
With the remaining time in class, work to finish the clist functions you were
assigned last class, using our now shared print_clist
to simply
writing your tests. Finish this for homework if you don't finish in class.
Homework
Read Section 6.4: Doubly Linked Lists on pages 188 to 199 in our textbook. Come to class on Monday ready to implement doubly linked list functions with a new partner during class.
Tuesday, February 20th
Classwork
We will begin class with a presentation of the work I did over the weekend
to complete implementations of insert_in_order
and
remove_from_list
. This discussion will also focus on the
refactoring of
both code and tests, and how using
TDD made
refactoring so much easier to do.
After that presentation, we will discuss what to do about
insert_in_order
, since it currently assumes a descending list.
Do we want to support both ascendind and descending lists? What about adding
functions insert_before
and/or insert_after
?
Also, are we happy with the way remove_from_list
is currently
implemented? It returns a pointer to the deleted node, leaving the caller the
responsibility of freeing memory if that is desired. Is this what we want?
Finally, we will summarize our homework reading on circular linked lists and decide on the names of the functions we want to implement them.
Homework
Working with your partner, use TDD to first design a test, then write code to make your test pass until you have robust implimentations of your assigned function. We will share our solutions and assembly them together in class on Thursday.
We will be creating three new files, test_clists.c
,
clist.h
and clist.c
, and then implementing the
following functions:
- Julissa and Edward will write
clist_length
andfind_in_clist
. - Joseph and Sheel will write
remove_from_clist
andclist_insert_at_index
. - Cyrus and Nate will write
print_clist
andclist_insert_in_order
.