SI 204 Spring 2017 / HWs


Homework 33: Linked list traversal

Name: _____________________________________________ Alpha: ___________________

Describe help received: ________________________________________________________

  • Due before class on Monday, April 17
  • This homework contains code to be submitted electronically. Put your code in a folder called hw33 and submit using the 204sub command.
  • This is an electronic homework and you do not need to print out anything to turn in during class.

Assignment

  1. Required reading: Sections 3 (Linked list loops) and 3 (linked list recursion) from the Unit 9 notes.
  2. Write a program called wordstart.c that reads in lower-case words, ending with the word "END", and stores them in a linked list. Then you should read in a single letter and print out all words that start with that letter, in reverse order from how they were read in.

    Try writing it with a loop and then with recursion. (But just submit one version that works!)

    Example runs:

    roche@ubuntu$ ./wordstart
    Enter words followed by END:
    one two three four five six seven eight END
    What letter? t
    three
    two
    roche@ubuntu$ ./wordstart
    Enter words followed by END:
    aa ab ac ad END
    What letter? a
    ad
    ac
    ab
    aa
    roche@ubuntu$ ./wordstart
    Enter words followed by END:
    aa ab ac ad END
    What letter? b