lab09 : Recursion

num ready? description assigned due
lab09 true Recursion Mon 11/28 08:00AM Tue 12/06 02:00PM

Complete survey to help plan for the logistics of the final exam

All students are required to complete this survey by Fri Dec 2 at noon to get their assigned seat for the final: https://forms.gle/wHupQCCPZ4UVxoWu8

Goals of this lab

The goal of this lab is get more practice with recursion, linked-lists, and string functions.

To prepare you for the final exam, this lab will ask you to implement functions that may appear difficult. Do not panic! First, refer to this following problem solving guide and follow the guidelines to help you solve complex problems: https://sites.cs.ucsb.edu/~alexmei/documents/cs16/week7.pdf. If you need more assistance, the course staff is happy to provide you additional support on Piazza, in section, and during office hours.

Continue to practice code tracing to reason about your code. We request that you DO NOT ask the staff to debug your code. They have been specifically instructed not to debug for you, rather to guide in the process.

Do not refer the starter code from previous offerings of this course as this version is new. Remember that code that is not written by you (even if it from starter code from a previous offering) is in violation of the academic honesty for this class.

Step by Step Instructions!

Step 1: Getting Started

  1. Go to github and find a repo for this lab assigned to your GitHub id.
  2. Log on to your CSIL account.
  3. Change into your ~/cs16 directory
  4. Clone your empty lab06 repo into your ~/cs16 directory.
  5. In your empty repo, do git checkout -b main to establish that you are on the main branch as your default branch.

Note: Remember to push your work to github at the end of EVERY work session. That way, you will not accidentally lose your code.

Step 2: Starter Code

The URL for cloning this repo is this: git@github.com:ucsb-cs16-f22/STARTER-lab09.git

Previous labs contain instruction for the process of:

Please do those steps now, and then do a git push origin main to populate your own repo with the starter code.

If you need help with these steps:

Once you’ve populated your repo, typing the ls command should show you the following files in your current directory.

$ ls
deleteKthNodeTest.cpp   linkedListFuncs.cpp  removeKFromFrontTest.cpp  strTest.cpp
elementwiseSumTest.cpp  linkedListFuncs.h    spliceTest.cpp            sumTest.cpp
findKthNodeTest.cpp     Makefile             strFuncs.cpp              tddFuncs.cpp
largestValueTest.cpp    README.md            strFuncs.h                tddFuncs.h

Step 3: Review the Files

Here is a list of your tasks for this lab:

Step 3a: Look at the Big Picture

Type “make tests” and you will see some tests pass, but some fail.

You are finished when all the tests pass. You will need to edit two files: linkedListFuncs.cpp and strFuncs.cpp

Please note that this lab may be more difficult than the previous labs you have worked on. We encourage you to ask questions publicly on Piazza (so your classmates can be of assistance) and attend office hours for 1:1 assistance.

Step 3b: String and Linked List and Functions

Please note that all of these functions must be written recursively. You will not get credit if you implement them iteratively. There are 8 functions you will need to write for this lab, one of which is a bonus:

In strFuncs.cpp:

In linkedListFuncs.cpp:

Each one has a set of tests which can be found under its corresponding heading when you type make tests. For example, the recursiveRemoveKNodesFromFront tests look like this to start:

./llTests 1
--------------REMOVE_K_NODES_FROM_THE_FRONT_OF_THE_LIST--------------
   FAILED: Remove 3 from front of 1->2->3->4->5
     Expected: 4 5  Actual:

You should replace each function stub with the correct code for the function until all of the tests for each one pass. It is recommended that you work on the functions one at a time in the order that they are presented above. That is, get all the tests to pass for isPalindrome then recursiveSum and so on. When all the tests pass, move on to the next step. Note that the test cases provided to you in the lab are not comprehensive. Think about possible edge cases that is breaking your code.

Step 4: Check Your Work

When you are finished, you should be able to type make clean and then make tests and see all of the tests pass.

At that point, you are ready to try submitting on gradescope.

Step 5: Submitting on Gradescope

Submit the strFuncs.cpp and linkedListFuncs.cpp files on gradescope.

If your code does not pass the Gradescope tests, think about possible edge cases that is breaking your code.

Grading Rubric

Most of the points will be awarded based on gradescope automatic grading. Other points will be assigned after visual code inspection by TAs - if a function is not implemented recursively, you will receive NOT receive any credit for that function at all.

The recursiveSplice function is a bonus question - note that it is intended to be difficult. Although Gradescope will be display a score out of 110, your lab is only worth 100 points - should you successfully complete the bonus and the rest of the lab, you will receive 100/100 on the lab and 1% extra credit in the course. We will manually adjust the grades afterwards.

Gradescope Autograder

Test NameValue

isPalindrome()

[10 pts]

recursiveSum()

[10 pts]

recursiveLargestValue()

[10 pts]

recursiveFindKthNode()

[10 pts]

recursiveDeleteKthNode()

[10 pts]

recursiveRemoveKFromFront()

[10 pts]

recursiveElementwiseSum()

[20 pts]

recursiveSplice()

[1% Course Extra Credit]

Manual Grading

These points will be awarded on a binary basis. If your comments or coding style is exceptionally underwhelming, you will not receive any of these points.

Refer to the following style guide to learn more about good coding style: link to style guide. If you are unsure about the quality of your code and comments, please ask a member of the course staff during section or office hours.

Academic Honesty

We will test your code against other data files too—not just these. So while you might be able to pass the tests on gradescope now by just doing a hard-coded “cout” of the expected output, that will NOT receive credit.

To be very clear, code like this will pass on gradescope, but represents a form of academic dishonesty since it is an attempt to just “game the system”, i.e. to get the tests to pass without really solving the problem.

I would hope this would be obvious, but I have to say it so that there is no ambiguity: hard coding your output is a form of cheating, i.e. a form of “academic dishonesty”. Submitting a program of this kind would be subject not only to a reduced grade, but to possible disciplinary penalties. If there is any doubt about this fact, please ask your TA and/or your instructor for clarification.

And, as usual, all code you submit must be written and thought of by you. Referring to online homework answer services is definitely a form of academic dishonesty and will be reported. Do not jeopardize your academic career over one assignment. Please reach out on Piazza and come to section or office hours if you need help.

Logging Out

If you are logged in remotely, you can log out using the exit command:

$ exit