Name: ____________________________________________________ Alpha: _____________ Section: ________

Describe help received: _________________________________________________________________

See the bottom for how to submit your work.

Due: Before 0800 on next class day

  1. (10 pts) Read today's lecture notes. Honestly declare how you read the notes.
    1. (10 pts) I read the notes carefully. I have a good understanding of the topics therein.
    2. (10 pts) I read the notes carefully, but I don't really understand the following points well:
      
      
      
    3. (0 pts) I didn't read the notes carefully.
  2. [15pts] We have a variable LIST of type Node* with the values depicted in the figure below:

    
    struct Node
    {
      int data;
      Node* next;
    };
    

    The definition of struct Node is given above too. Write statements (mostly manipulating pointers) that perform the following.

    • Each problem is independent, meaning that changes in one part are not carried forward into the next part.
    • Do not use any function. Write code directly.
    • You can introduce temporary variables if necessary.
    1. Print all the values in order. Use a for loop.
       
    2. Delete 42 from the list.
       
    3. Move 42 to the front of the list. That is, the list should be 42, 87, 53, 4. You should not create or delete any node.
       
  3. [75pts] Write a program hw.cpp that works as follows:
    1. It reads in lower-case words, ending with the word "END"
    2. It stores them in a linked list.
    3. Then, it reads in a single letter.
    4. Then, it prints out all words that start with that letter, in reverse order from how they were read in.
    Hint: Store the words in your linked list in reverse order from how there were read in by calling add2front repeatedly as you read each word in.
    Example runs:
    ~/$ ./hw
    Enter words followed by END:
    one two three four five six seven eight END
    What letter? t
    three
    two
    
    ~/$ ./hw
    Enter words followed by END:
    aa ab ac ac END
    What letter? a
    ad
    ac
    ab
    aa
    
    ~/$ ./hw
    Enter words followed by END:
    aa ab ac ad END
    What letter? b
    

Submit to the submission server (due: 0800 on the next class day)

~/bin/submit -c=IC210 -p=hw32 hw.cpp

Bring to class