CS120 Labs

Labs - All work is to be completed independently!

LAB1 - Command Line Compilation, the XCode IDE and XCode Debugging

Purpose: This lab will familiarize you with compiling C++ programs from the command line, using the C++ XCode IDE environment, and using the XCode debugger tool. Please note, this is the only lab that requires you to use XCode and the T200 or Mac machines. For all other labs you may use either the Xcode or Clion IDEs.

To login to the T200 machines the username is labuser and the password is empty - this grants you permission to use XCode. Do not login with your Wooster credentials.


PART1 : Create and compile your first C++ program using the command line compiler.

Ask questions if you run into problems.


Ask questions if you run into problems.


PART2: Using the XCode IDE

Ask questions if you run into problems.


PART3: Using the XCode Debugger. Download and print this answer sheet for PART3 and PART4 of the lab

 


PART4: Debugging logic errors in the Pascal's triangle program

Print and answer all questions on the Debugger.doc handout and turn in before leaving the lab.

The program's purpose is to display Pascal's Triangle, a sequence of integers that arises in numerous areas of math and computer science, especially combinatorics and probability. When completed, the program's output should be:

Enter the number of rows (<= 13) in Pascal's Triangle. 

     THE FIRST 5 ROWS OF PASCAL's TRIANGLE:

                        1
                      1   1
                    1   2   1
                  1   3   3   1
                1   4   6   4   1
                

Entries in Pascal's triangle are indexed by integers. n is the number of the row and k is the position from the leftmost member of the row. The indices in both directions start at zero (0), so in the fifth row listed above, C(4,0) = 1, C(4,1) = 4, and so on.

The values themselves are computed by the formula C(n, k) = n! / ( k! (n-k)!), which is called a combination. n! denotes a factorial, that is, the product n(n-1)(n-2)...(2)(1). The combinations can be interpreted as the number of ways to choose k elements from a collection containing n elements. When described, it is customary to say "n choose k", for instance '4 choose 3 is 4' ".

Answer question 1 on Debugger.doc handout.

As you will discover with the help of your debugger, the program to compute Pascal's triangle has some mistakes. Each provides an opportunity to learn a debugging concept in context of it's use.

Answer question 2 on Debugger.doc handout.

Step over / inspect

Answer question 3 on Debugger.doc handout.

Answer question 4 on Debugger.doc handout.

More stepping

Answer question 5 on Debugger.doc handout.

That is strange. The program is supposed to print three newlines, then the title. Let's find out why the title doesn't appear.

Answer question 6 on Debugger.doc handout.

Answer question 7 on Debugger.doc handout.

Variables Window

Answer question 8 on Debugger.doc handout.

Answer question 9 on Debugger.doc handout.

Answer question 10 on Debugger.doc handout.

Answer question 11 on Debugger.doc handout.

Answer question 12 on Debugger.doc handout.

Step into

Answer question 13 on Debugger.doc handout. Note that k is undefined in the variables window since k is not active in the function factorial.

Answer question 14 on Debugger.doc handout.

Setting breakpoints

It is tedious to have to keep stepping to get inside a function. A more efficient way is to set a breakpoint at a line of interest. Then the program runs at full speed until a breakpoint is reached.

Answer question 15 on Debugger.doc handout.

Answer question 16 on Debugger.doc handout.

Finally

Answer question 17 on Debugger.doc handout.

Submit a Folder: You should upload a "CS120Lab1YourName" zipped folder created for this lab to moodle. It must contain the Lab1.cpp program from Part1 and your corrected Pascal's Triangle program from Part4.


Graded on: Correct answers on Debugger.doc provided to TA, correct Lab1.cpp program from PART1, correct Pascal's Triangle program from PART4, and correct electronic drop. BE SURE TO ADD YOUR NAME TO ALL source files you create or modify!!!


LAB2 - Black Box and White Box program testing

Purpose: This lab will familiarize you with basic debugging techniques that work in all development environments and are independent of specific testing and debugging tools.  Make sure you have completed the reading for lab 2, http://softwaretestingfundamentals.com/white-box-testing/


PART1 : Create and compile the C++ program for this lab.


PART2 : Work with white-box and black-box testing

In the lab manual pages, complete the activities for Lab 1.1

  1. In the traces of items 6 and 7, think of each row of the trace as describing the status of the program before the corresponding line of code executes.
  2. In item 10, the author wants you to decide what code change is appropriate and make it in your actual code and then explain why it is more efficient in the sense that it has the potential to execute more quickly.

PART3 : Submit your completed lab

  1. Submit your zipped project folder via moodle and annotated with CS120Lab2YourName.

  2. Hand in the lab manual pages for Lab1.1 to the TA.

Graded on : Correct answers in lab manual, correct search.cpp program file, and correct moodle submission.


LAB3 - The Text ADT

Purpose: The purpose of this lab is to explore the implementation and applications of a Text ADT, a simplified version of the STL’s string class.


Please download the starting packet, Lab3.zip, for this lab. This folder contains

Refer to the lab manual pages provided as a handout  and Text_ADT.doc for directions on completing the lab.

  1. Submit your source code and input files via moodle in a zipped folder annotated with CS120Lab3YourName.
  2. Hand in your lab worksheets and grade sheet to the TA.

Graded on : Correct answers in lab worksheets provided to TA, grading sheet provided to TA, correct source files (all prelab and inlab files with input files provided) submitted to moodle.


LAB4 - The BlogEntry ADT

Purpose: The purpose of this lab is to explore the implementation and applications of a BlogEntryADT, which is built on the Date class and the Text ADT class of Lab3.


Please download the starting packet, Lab4.zip, for this lab. This folder contains

Refer to the lab manual pages provided as a handout and BlogEntry ADT.doc for directions on completing the lab.

  1. Submit your source code and input files via moodle in a zipped folder annotated with CS120Lab4YourName.
  2. Hand in your lab worksheets and grade sheet to the TA.

Graded on : Correct answers in lab worksheets provided to TA, grading sheet provided to TA, correct source files (all prelab and inlab files with input files provided) submitted to moodle.


LAB5 - Array List ADT

Purpose: The purpose of this lab is to explore the implementation and applications of an array-based List ADT, using C++'s template mechanism.


 Please download the starting packet, Lab5.zip, for this lab. This folder contains

Refer to the lab manual pages (Lab3) provided as a handout and Array List_ADT.doc for directions on completing the lab.

  1. Submit your source code and input files via moodle in a zipped folder annotated with CS120Lab6YourName.
  2. Hand in your lab worksheets and grade sheet to the TA.

Graded on : Correct answers in lab worksheets provided to TA, grading sheet provided to TA, correct source files (ALL prelab and inlab files with input files provided) submitted to moodle.


LAB6 - Ordered List ADT

Purpose: The purpose of this lab is to explore the implementation and applications of an ordered array-based List ADT, using C++'s inheritance and template mechanism.


Please download the starting packet, Lab6.zip, for this lab. This folder contains

Refer to the provided lab manual pages (Lab4) and Array List ADT.doc for directions on completing the lab.

  1. Submit your source code and input files via moodle in a zipped folder annotated with CS120Lab6YourName.
  2. Hand in your lab worksheets and grade sheet to the TA.

Graded on : Correct answers in lab worksheets provided to TA, grading sheet provided to TA, correct source files (ALL prelab and inlab files with input files provided) submitted to moodle.


LAB7 - Linked List ADT

Purpose: The purpose of this lab is to explore the implementation and applications of an linked one-way List ADT, using C++'s encapsulation and template mechanism.

Please download the starting packet, Lab7.zip, for this lab. This folder contains

Refer to the provided lab manual pages (Lab5) and Linked List Impl ADT.doc for directions on completing the lab.

  1. Submit your source code and input files via moodle in a zipped folder annotated with CS120Lab7YourName.
  2. Hand in your lab worksheets and grade sheet to the TA.

Graded on : Correct answers in lab worksheets provided to TA, grading sheet provided to TA, correct source files (all prelab and inlab files with input files provided) submitted to moodle.


LAB8 - Stack ADT

Purpose: The purpose of this lab is to explore the implementation and applications of a Stack ADT, using C++'s encapsulation and template mechanism. Two implementations, stack as array and stack as a list, are required.

Please download the starting packet, Lab8.zip, for this lab. This folder contains

Refer to the provided lab manual pages (Lab6) and Stack ADT.doc for directions on completing the lab.

  1. Submit your source code and input files via moodle in a zipped folder annotated with CS120Lab8YourName.
  2. Hand in your lab worksheets and grade sheet to the TA.

Graded on : Correct answers in lab worksheets provided to TA, grading sheet provided to TA, correct source files (all prelab and inlab files with input files provided) submitted to moodle.


LAB9 -  Performance Evaluation

Purpose: The purpose of this lab is to perform a timing analysis of several provided algorithms using your implementation of a Timer ADT

Please download the starting packet, Lab9.zip, for this lab. This folder contains

Refer to the provided lab manual pages (Lab13) and Lab 9 Performance Evaluation.doc for directions on completing the lab.

  1. Submit your source code and input files via moodle in a zipped folder annotated with CS120Lab9YourName.
  2. Hand in your lab worksheets and grade sheet to the TA.

Graded on : Correct answers in lab worksheets provided to TA, grading sheet provided to TA, correct source files (all prelab and inlab files with input files provided) submitted to moodle.


LAB10 - Queue ADT

Purpose: The purpose of this lab is to explore the implementation and applications of a Queue ADT, using C++'s encapsulation and template mechanism. Two implementations, queue as array and queue as a list, are required.

Please download the starting packet, Lab10.zip, for this lab. This folder contains

Refer to the provided lab manual pages (Lab7) and 10-Queue ADT.doc for directions on completing the lab.

  1. Submit your source code and input files via moodle in a zipped folder annotated with CS120Lab10YourName.
  2. Hand in your lab worksheets and grade sheet to the TA.

Graded on : Correct answers in lab worksheets provided to TA, grading sheet provided to TA, correct source files (all prelab and inlab files with input files provided) submitted to moodle.


LAB11 - Chained Hash Table with STL vector and list

Implementing a Hash Table class, pages 87-89 in the provided lab manual pages. Download the Lab11 input file here.

  1. You may use the STL vector class or a statically allocated array for your Hash Table and chained collisions must be implemented using the STL list class.
  2. For Step A4: Instead of adding a Display method to the HashTable class, overload the operator<<() free function as a friend of the class.
  3. You must write your own header and class implementation files complete with pre and post condition documentation. The files must be named HashTable.h and HashTable.cpp
  4. You must write a simple main test driver, named main.cpp. Once that is working you should process the provided input file using your Hash Table and producing the output shown below,
enter a file name : inputTest11.txt
Here is your hashtable :
Index 0 : SINCERELY    THAT    AZORES    
Index 1 : BUT    CAMELS    
Index 2 : BIG    ABOUT    
Index 3 : AND    AND    AND    AND    AND    JIM    AND    MARLIN    
Index 4 : SMALL    THE    WERE    THE    AARDVARKS    THE    
Index 5 :
Index 6 : ANTS    ANTS    
Index 7 : BATS    BATA    PS    TO    SHIPPED    DEAR    
Index 8 : IN    ARE    CATS    ARE    ARE    ANIMALS    ARE    CATS    
Index 9 :
Index 10 : SORRY    
Index 11 : BETWEEN    BETWEEN    
Index 12 : COWS    COWS    MISTAKENLY
  1. Submit your source code files via moodle in a zipped folder annotated with CS120Lab11YourName.
  2. Hand in the Project grade sheet to the TA.
  3. FOR BONUS POINTS; implement additional methods such as isKeyInTable(key), retrieveKey(key), removeKey(key), printCollisons(int i), which would print a list of items in the table at index i. Be sure to add tests for these to your main.cpp.


Graded on : Correct answers in lab worksheets provided to TA, grading sheet provided to TA, correct source files (inlab files with input files provided) submitted to moodle.


LABs 12/13 - See Project4