CS 14 - Lab 1
CS 14
Homepage
Simple Linked Lists
This lab is designed to give you a refresher on pointers and
experience with a very simplified linked list of integers.
Most importantly, this lab is designed to teach you how to
conform with a given specification for a design. In this
lab, I am giving you a skeleton of the code and the function
prototypes. I am also giving you a main function that will
test the functionality of you code. It is very important that
the code that you write works with the main function that I
provide you with. The majority of future lab assignments
and home programming assignments will follow the same format.
This does not mean that you should not write your own main
function and test cases to test your code. You should try
to test your code on your own and then make sure that it
works with the main function provided.
The Assignment
You will implement a simple linked list of integers and four
operations on the list: size, push_front, push_back, and print.
You will begin with the skeleton code provided. DO NOT
make any changes to the code given to you. You will only add
code to the skeleton code.
-
node.h - Class declaration for you
node class.
-
list.h - Class declaration for your
list class.
-
list.cc - This file will contain all
of the functions for the list class.
-
main.cc - This file contains the
main function for you program with your list class declaration.
This file is used to test your program and your code must
work correctly with this main function to receive credit
for the assigment.
List Functions
You will implement the following list functions. The specifications
for each list function is listed below. Please
use the function declarations exactly as they are listed because
if you change them, your code will not interface correctly with the
main test function.
-
int size ( ) - Returns the size of the list
-
void push_front ( int value ) - This function will insert the integer
at the head of the list.
-
void push_back ( int value ) - This function will insert the integer
at the tail of the list.
-
void print ( ) - Prints the list in a nice, readable format.
Procedure
1. Sign up for the class mailing list
here.
2. Carefully read and sign the 2 academic dishonesty handouts in lab. Please
completely fill out the information at the bottom of each handout and
return them to your TA.
3. Download the code provided above.
4. Compile the code using "g++ -Wall -W -Werror -pedantic main.cc list.cc"
5. Insert the code for the functions that you will need to implement. Test
your program.
6. When your program is working correctly with the main.cc file provided,
raise your hand to be checked out. If it is getting towards the end of the lab
period, make sure you get checked out for what you currently have working.
Partial credit is much better than no credit at all.
7. You MUST turn in your code electronically to receive credit
for the lab. Make sure your name and partners name is on the code and
turn it in. Please only have one turnin
for each group (only turn the code in from one account). The code is due
1 hour after the end of the lab period (as it will be every week).
Make sure to turn it in to the correct
section.
Point Breakdown
-
2 points - Attendance - Lab attendance will be 20% of the grade for each
lab. You will receive 1 point when the lab begins and 1 point when the lab
ends. Attendance will be taken during the first and last 5 minutes of the
lab period
-
8 points - Functionality
- 1 point - Correct destructor
-
2 points - size()
-
2 points - print()
-
3 points - push_front()
-
.5 points extra credit for push_back()
-
Deductions -
- -1 point - Program seg faults at any time
- -1 point - Doesn't compile with complete flags: -Wall -W -Werror
-pedantic
- -5 points - Turned into the wrong lab section (if you screw up you are
allowed to turn the lab in again to the correct section, just make sure that
your final turnin does go to the correct section).
- -1 point - No name on turned in work
- -5 points - Code not turned in at all. This deduction also applies to
turnins that do not contain a the partners name (only the name that is not
on the turnin will have 5 points deducted. The person that actually turned
the code in will only have 1 point deducted if their name is not on the
turnin).
© 2003 UC Riverside Department of Computer Science &
Engineering. All rights reserved.