1
h12
CS16 S17
Name:
(as it would appear on official course roster)
Umail address: @umail.ucsb.edu section
Optional: name you wish to be called
if different from name above.
Optional: name of "homework buddy"
(leaving this blank signifies "I worked alone"

h12: Chapter 13 Linked-lists contd.

ready? assigned due points
true Mon 05/15 02:00PM Wed 05/31 02:00PM

You may collaborate on this homework with AT MOST one person, an optional "homework buddy".

MAY ONLY BE TURNED IN IN THE LECTURE/LAB LISTED ABOVE AS THE DUE DATE,
OR IF APPLICABLE, SUBMITTED ON GRADESCOPE. There is NO MAKEUP for missed assignments;
in place of that, we drop the three lowest scores (if you have zeros, those are the three lowest scores.)


Please:

  • No Staples.
  • No Paperclips.
  • No folded down corners.

Re-read Chapter 13, section 13.1 (If you do not have a copy of the textbook yet, there is one on reserve at the library under “COMP000-STAFF - Permanent Reserve”).

PLEASE MARK YOUR HOMEWORK CLEARLY, REGARDLESS OF IF YOU WRITE IT OUT IN INK OR PENCIL! ILLEGIBLE WORK WILL NOT BE GRADED.
FOR BEST RESULTS, PRINT THIS PAGE AS A PDF, THEN PRINT THE PDF

For all the following questions, use the definitions of the struct Node and struct LinkedList from lab 06.

1.(10 pts) Implement a function that returns the number of even elements in a linked list. Test your code before writing it out. Illegible code will receive 0 credit.

int countEven(LinkedList* list){
	
















}

2.(2 pts) In the implementation of a linked list, why does struct Node contain a pointer member variable of type Node *?

3.(10 pts) You are given the following memory map, where the numbers on the left column are memory locations and the numbers on the right are 4 byte values stored at each location. Suppose that a linked-list is stored in the given memory segment. In the memory map there exists a pointer (named ‘list’) to a LinkedList object. You are given the location of list to be 0x8008. Draw the pointer diagram for the linked list showing all the nodes in the linked-list, the data stored in each node and all pointers, starting with the variable ‘list’. The LinkedList and Node types are the same as those defined in lab06

Memory 
Address  Value
0x8000	0x8008
0x8004	0x8020
0x8008	0x803C
0x800C	0x000A
0x8010	0x8018
0x8014	0x0002
0x8018	0x8030
0x801C	0x0004
0x8020	0x0005
0x8024	0x8014
0x8028	0x0020
0x802C	0x0000
0x8030	0x0003
0x8034	0x8028
0x8038	0x8008
0x803C	0x8000
0x8040	0x8028

4.(10 pts) Implement a function that takes a linked list as an input and returns a dynamic array containing the data elements of the linked list. Test your code before writing it out. Illegible code will receive 0 credit.

int* linkedListToArray(LinkedList * list);