hw8-soln - ECE 209 Homework 8 Fall 2007 Homework 8 Due:...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
ECE 209 Fall 2007 Homework 8 Homework 8 Due: November 27, 2007 NAME: __________________________________________________________ UNITY ID: _______________________ @ncsu.edu SECTION: _______________ (001/002) Print this file and answer in the space provided. Staple in the top left corner. Do not fold. 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ECE 209 Fall 2007 Homework 8 NOTE: In all of the exercises below, assume that the following struct and typedef definitions have been processed prior to your code. Assume that there is NO DUMMY NODE at the head or tail of the list. struct node { int data; struct node *next; }; typedef struct node Node; 1. (20 points) Write a definition for the following function, which creates a new node, containing the specified data value, and adds it to the beginning of the list pointed to by the head parameter. The return value is the new head of the list. (Note: The initial list might be empty, which means that head == 0.) Node *push(int num, Node *head); Node *push(int num, Node *head) { Node *n = malloc(sizeof Node); n->data = num; n->next = head; return n; } 2
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/24/2008 for the course ECE 209 taught by Professor Tuck during the Spring '08 term at N.C. State.

Page1 / 6

hw8-soln - ECE 209 Homework 8 Fall 2007 Homework 8 Due:...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online