CS
14 - Lab
CS 14
Homepage
First Task - Lab Practical
Complete the lab practical as assigned by the TAs.
You will have 2 hours to complete the practical. You will
turn in your lab using the electronic turnin. WATCH THE TIME! The electronic
turnin will be gone 2 hours after the scheduled start time of
your lab section and ASBOLUTELY NO LATE LAB PRACTICALS WILL BE ACCEPTED NO
MATTER WHAT THE REASON EVEN IF YOU ARE ONLY 1 SECOND LATE. DO NOT TRUST THE
CLOCK ON YOUR COMPUTER!!! IT IS NOT THE SAME AS THE CLOCK ON THE TURNIN
SERVER. MAKE SURE YOU OPEN A TURNIN PAGE AND REFRESH IT IF YOU WOULD LIKE
TO KNOW THE CURRENT TIME. REMEMBER THAT LAB PRACTICALS ARE 8% OF YOUR GRADE.
DO NOT PUSH THE TURNIN TIME BECAUSE IF YOU MISS THE TURNIN, YOU ARE OUT OF
LUCK. I suggest that you implement the functions in the order specified
above and turn in a copy of your code each time you get a new function
working so that you can maximize your points.
You may not use ANY reference material at all and, should I even need to
specify that this includes man/info pages,
web, IM, chat, email, book, previous code written
by you, code written by anyone, etc. You may not look at ANY reference while
doing this lab practical. You may only look at this web page containing the
lab practical, electrontic turnin, your code that you are currently writing
for the practical, and gdb or ddd.
Second Task - Array Implementation of a Binary Heap (and experience with pointers)
In this lab you will be implementing a max heap (the highest number will be the
root). You will be simulating a print queue and each print job will be
represented as a class called PrintJob.
You must implement the enqueue, dequeue, print,
and highest functions for your heap class and various functions for the
PrintJobs class. Your heap will be implemented as a dynamically allocated
array of print job pointers (this will perhaps give you an experience
with pointers that you have not yet had).
Provided files
- heap.h - The class for your heap. Notice that
the heap is represented as a dynamically allocated array of pointers. You
must implement AT LEAST the following functions to interface with
main.cc. (NOTE: these may not be the only heap functions
you will need to write for the heap to function correctly).
- void enqueue ( PrintJob* ) - Enqueue the PrintJob into the heap
- void dequeue ( ) - Dequeue the highest priority job
- PrintJob highest ( ) - Return a pointer to the highest priority job.
Returns null if the heap is empty
- void print ( ) - Prints all of the jobs in the heap in the order that
they appear in the array. Overload the insertion operator to print each print
job. You must adhere to the following print
specifications. Each print job will be printed like this (just what is
in the quotes, do not print the quotes): "(priority, numPages, jobNumber)".
All print jobs are printed on a single line with no spaces between them
and a return at the end of the line.
Here is an example of three print jobs: (3, 4, 5)(1, 2, 3)(2, 3, 4)
- printjob.h - The class for your print jobs.
It has three variables: priority (the priority of the print job), numPages
(the number of pages to print), and jobNumber (the job number assigned to
the print job). You must implement AT LEAST the following functions to
interface with main.cc. (NOTE: these may not be the
only PrintJob functions
you will need to write for the heap to function correctly).
- int getPriority ( ) - return the priority of the print job
- int getPages ( ) - return the number of pages for the print job
- int getJobNumber ( ) - return the job number of the print job
- Furthermore, you must overload the insertion operator to print the
printjob to the screen (more details are above on printing) and the
> operator so you can compare the priorities of the printjobs.
- main.cc - the main test file that you will be using
to test your program
Point Breakdown For Lab Assignment
You will be working alone for this lab
You may demo your program in lab or it will be
graded from your electronic submission (due 24 hours after the end of your
lab section). Please show the output
from main.cc to the TA if you complete the lab.
Remember, to
receive credit for this lab, you MUST turn the code in online.
If you do not turn in your code online,
you will lose points for your lab. All code must be turned in online for
archival purposes.
- 2 points - Attendance is, as always, worth 20% of your lab grade.
- 1 point - Passes test 1
- 1 point - Passes test 2
- 1 point - Passes test 3
- 1 point - Passes test 4
- 2.1 points - Passes test 5 (.3 for each dequeue operation passed)
- .9 points - Print looks exactly as I specified
- 1 point - Overloaded the > and insertion operator for the print job
class
- Deductions -
- -1 point - If both partners turn in the code. There should
only one turnin per group
- -1 point - if your program seg faults at any point during
execution.
- -1 point - not using a makefile
- -1 point - program does not compile with the standard flags: -Wall
-Werror -W -pedantic
- -4 points - Changing the array in the heap to anything else (you must
use the PrintJob** arr as it is declared in the heap class).
- -10 points - Not implementing a binary heap but rather simulating a binary
heap using a different data structure
- -1 point - not logically seperating your code into seperate files
- -5 points - Turned into the wrong lab section.
- -1 point - No name on work turned in
- -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).
- -5 points - If your currently assigned partner is in lab and you do not
work together.
© 2003 UC Riverside Department of Computer Science &
Engineering. All rights reserved.