Class Activities CS2440

July 14
Final Report Due by Noon today. I will not grade any report that arrives after the deadline.

July 13
Finsishing Program 4 and Lab (6).

July 12
Exam (4)
Program (4) is due by midnight.

July 8
Ethics Presentations:
Michael: Computer Security and Computer Crimes
Ryan: The Acquisition of Information, Information Access and Stewardship
Ben: Software Ownership and Intellectual Property Issues
Jason: The Social Impact of Computer Technology

Preparing a good talk: Recommendations
I will provide you handouts on how to prepare your reports.

July 7
Recursion - To better understand this, let's go through the following small lab.
We talked about Trees Trees

Here are the files for a program that illustrates the usef of a binary tree.
animal.C ,
useful.C ,
useful.h ,
bintree.template , and
To compile use g++ animal.C useful.C

We talked about Sorting Sorting


Select Sort select.C ,
Heap Sort heapsort.C ,
Merge Sort merge.C ,
Quick Sort quick.C ,

July 6
Lab (6) - Process Scheduling Simulation

July 5

July 1
Exam (3) - Template and Stacks

June 30
Chapter (8) - Queues
We talked about queues and discussed its differences with stacks.

Here is what I want you to do. Suppose we want to write a program that uses a queue and a stack to find out whether a statement that is entered on one line from the keyboard is palindrome. For simplicity, do not consider the blank spaces between words or characters and assume that the entire statement will be converted to uppercase.

Input: Racecar
It is palindrome.
Here is the pal.C file pal.C

Ok, we got this part. How about changing this program to do word-by-word palindrome. What is that? Look at this example:
You can cage a swallow, can't you, but, you can't swallow a cage, can you?

If you write this backward word-by-word, you get the original one back.
Next we talked about a carwash simulation.
1) the amount of time needed to wash one car in total seconds
2) the probability that a new customer arrives during any given second. We assume that, at most one customer arrives in a second, and
3) the total length of time to be simulated in seconds.
The program produces two pieces of output information:
1) the number of customers serviced in the simulated time, and
2) the average time that a customer spent in line during the simulation (in seconds)
Let.s discuss the design among ourselves.
We want to use the queue class.
How do you want to represent each customer?
Maybe the customer time stamp.
The waiting time can be computed easily . current time . time stamp
See Figure 8.5 for pseudocode.

June 29
Program 3 Program 3. (Due Midnight Wed June 30)

June 28
Chapter(7) - Cool stuff now :-). We start talking about stacks. We want to write a program that used a stack to reverse a word.
Let's start with a simple program that evaluates a fully paranthesized arithmetic expression.
Here is the calc.C file calc.C
Run this program for: ( (2+4) + (2*(3+5)) ) what is the result?

now run it for:
(2+4) + (2*(3+5)) what is the result?
Can you explain why the results are different?

Here is the stack1.h file stack1.h
Here is the stack1.template file stack1.template

The above files with danamic array:
Here is the stack2.h file stack2.h
Here is the stack2.template file stack2.template

June 24
Lab (5) Due, Continue with Lab (5). Start working on Program 3. (Due Midnight Sat June 26)

June 23
Chapter (6) - Templates
Lab (5) - Sequence program with Templates

June 22
Chapter (6) - Templates
The bag program with templates.

The initial bag programs with constructors are listed below.
Here is the bag2.h file bag2.h
Here is the bag2.C file bag2.C
Here is the bag2_demo.C file bag2_demo.C

The initial bag programs are listed below. Here is the bag1.h file bag1.h
Here is the bag1.C file bag1.C
Here is the bag1_demo.C file bag1_demo.C
Let's write the bag program with temlate.

The header file for the bag with template is:
Here is the bag1.h file bag4.h
Here is the bag4.template file bag4.template
Here is the bag4demo.C file bag4demo.C

June 21
Chapter (6) - Templates
An introductory template Lab Intro to Template , just for practice during the class time.

June 18
Exam (2) - Extra time toward programming part.

June 17
Exam (2) - Chapter 4 and 5.

June 16
Lab (4)

June 15
Chapter (5) continued - finished

June 14
Program 2

June 10
Chapter(5) - Linked List.
In our last class, we created a linked list using a struct. We did several things with a linked list that we had created. Today, we create a linked list using a class. As you can imagine, using a class requires defining several accessors and mutators.
But we want to work some more on that program first. Include functions:

int length_list(const NodePtr head);
//computes the length of the linked list. This is the number of nodes

NodePtr search(NodePtr head, string target);
//Search for a target (item) in the list. Return the node when you find it

NodePtr search_position(NodePtr head, int position);
//Searches for a particlar pointer. For instance the 3rd node

void list_head_remove(NodePtr& head);
//Removes the head node, the linked list will remain the same except
//the head node is removed.

void list_clear(NodePtr& head);
//Removes all nodes and free the space on the heap

void list_copy(NodePtr source, NodePtr& head, Node_ptr& tail);
//Copy one list to another. Sourse is the original list.

Now we can look at the Linked List with a class.
Here is the node1.h file: node1.h
This file a the header file for a Linked List Toolkit. You have written most of the functions, but used a struct. All the functions for this toolkit are stored in the following file.
Here is the node1.C file: node1.C
We will look at this file and the class definition very closely.

Next you will re-write the bag program using a linked list. You can use the Linked list Toolkit. Also,
Here is the bag3.h file: bag3.h
Here is the bag3.C file: bag3.C
Here is demo program for bag3: bag3demo.C

June 9
Chapter (5) - Linked List. Slides for this chapter is here.
The Pointer and Linked List Lab (Lab 15)
Program (2) - Due Sunday June 13

June 8
Lab (3) - Sequence Lab with Pointers

June 7
Chapter (4)
Grades Exam (1)
Work on Quiz(8) program, then start working on the bag program with pointers.
The bag class with pointers.
Here is the bag2.h file: bag2.h
Here is the bag2.C file: bag2.C
Here is the bag2demo.C file: bag2demo.C

June 3
Exam (1) - Chapters (1-3)

June 2
Chapter (4) - Pointers
Here is the pointer demo program we wrote together in class: mypointer.C file mypointer.C
Here is the dynademo.C file you need for Quiz (8) dynademo.C

June 1
Chapter (3) Lab (2) - Sequence

May 31
Lab (1) - Statistician, Chapter (3) - Container Class, The Bag class

May 28
Chapter (2), We worked on the point program but used a couple of overloaded operators. Here are the new files:
Here is the point2_new.h file point2_new.h
Here is the point2_new.C file point2_new.C
Here is simple test program pointmain2_new.C

Next we start working on the bag program. Given the bag1.h file, you are to first write the bag1.C file.
Here is the bag1.h file bag1.h
Here is the bag1.C file bag1.C
Here is the bag1_demo.C file bag1_demo.C

May 27
Here is the point.h file point.h
Here is the point.C file point.C
Here is simple test program pointmain.C
New programs with the EQUAL and ADD functions:
Here is the point.h file point2.h
Here is the point.C file point2.C
Here is simple test program pointmain2.C

May 26
Chapter (2), Throttle Class. Point Class, Point Program. After discussion of Point.h file. Given Point.h file, write the Point.C and main.C program.
Here is the main for this program

Let's look at this differently. Here are the two files I wanted to use this time. Let's look at the class definition first:
and the new main: newthrottlemain.C
With the following file, all three files would be new.

May 25
Syllabus , Chapter (1), Review and Lab0 - Counting Characters in a file
Then gave out Assignment (1), Due: Midnight Saturday May 29.