CS240 Final Exam Review

CS240 Final Exam Review - CS240 Final Exam Review Return...

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

View Full Document Right Arrow Icon
CS240 Final Exam Review Return the solutions to the following programs written by hand before the final exam. We will post the solutions the day before the final exam so you can compare your solutions. We strongly encourage you to solve this review before looking at the solutions. 1. Write the following functions for a single linked list data structure: SLList.h typedef struct SLListEntry { char * name; char * value; struct SLListEntry * next; } SLListEntry; typedef struct SLList { SLListEntry * head; } SLList; SLList.cpp #include "SLList.h" // Create a single-linked list SLList * sllist_create() { } // Insert an element in the linked list. If name already exists substitute value. Otherwise insert entry. Return 0 if name is not there. int sllist_insert(SLLIST *sllist, char * name, char * value) {
Background image of page 1

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

View Full DocumentRight Arrow Icon
// Remove entry in single linked list. int sllist_remove(SLLIST *sllist, char * name) { } // Return last entry in pname, pvalue. Return 0 if list is empty or 1 otherwise. int sllist_last(SLLIST *sllist, char ** pname, char **pvalue) { } // Print linked list in the format: // 0: name=name0 value=value0 // 1: name=name1 value=cvalue1 ... void sllist_print(SLLIST sllist) {
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 02/18/2012 for the course CS 240 taught by Professor Rego during the Fall '08 term at Purdue.

Page1 / 9

CS240 Final Exam Review - CS240 Final Exam Review Return...

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