diff --git a/gsa01.md b/_gsa01.md similarity index 100% rename from gsa01.md rename to _gsa01.md diff --git a/gsa02.md b/_gsa02.md similarity index 100% rename from gsa02.md rename to _gsa02.md diff --git a/gsa03.md b/_gsa03.md similarity index 100% rename from gsa03.md rename to _gsa03.md diff --git a/gsa04.md b/_gsa04.md similarity index 100% rename from gsa04.md rename to _gsa04.md diff --git a/gsa05.md b/_gsa05.md similarity index 100% rename from gsa05.md rename to _gsa05.md diff --git a/gsa06.md b/_gsa06.md similarity index 100% rename from gsa06.md rename to _gsa06.md diff --git a/_gsa07.md b/_gsa07.md index 133b898..3089b68 100644 --- a/_gsa07.md +++ b/_gsa07.md @@ -74,7 +74,7 @@ Please note that all of these functions **must** be written recursively. You wil There are 8 functions you will need to write for this assignment, one of which is a bonus: In strFuncs.cpp: -- **isPalindrome()** +- **[10 points] isPalindrome()** - Recursively check if a string is a palindrome - A palindrome is a word or phrase that reads the same backwards & forwards - Palindromes **are not** case-sensitive - disregard spaces as well @@ -83,21 +83,21 @@ In strFuncs.cpp: - *HelloN* reads *olleH* and is not a palindrome In linkedListFuncs.cpp: -- **recursiveSum()** +- **[10 points] recursiveSum()** - Recursively calculate the sum of a linked list - Given a head node, return the sum of the linked list - Example - list: 2 → 3 → 4           - recursiveSum(list) = 9 -- **recursiveLargestValue()** +- **[10 points] recursiveLargestValue()** - Recursively find the largest value in a linked list - Given a head node, return the largest value in the linked list - Example - list: 2 → 3 → 4           - recursiveLargestValue(list) = 4 -- **recursiveFindKthNode()** +- **[10 points] recursiveFindKthNode()** - Recursively find the kth Node of a linked list - Given a head node and integer k, return the address of the kth node - You do not know whether the linked-list contains k or more nodes; if k is greater than the length of the linked-list, return NULL @@ -107,7 +107,7 @@ In linkedListFuncs.cpp: - recursiveFindKthNode(list, 3) = 4 - recursiveFindKthNode(list, 4) = NULL -- **recursiveDeleteKthNode()** +- **[10 points] recursiveDeleteKthNode()** - Recursively delete the kth node from a linked list - Given the head of a linked list, delete the kth node from the linked list - k will always be less than or equal to the length of the linked list @@ -116,9 +116,9 @@ In linkedListFuncs.cpp: - list: 2 → 3 → 4           - recursiveDeleteKthNode(list, 2) = 2 → 4 - recursiveDeleteKthNode(list, 1) = 3 → 4 - - recursiveDeleteKthNode(list, 4) = 2 → 3 + - recursiveDeleteKthNode(list, 3) = 2 → 3 -- **recursiveRemoveKFromFront()** +- **[10 points] recursiveRemoveKFromFront()** - Recursively delete k nodes from a linked list - Given the head of a linked list, delete the first k nodes from the linked list - k will always be less than or equal to the length of the linked list @@ -128,7 +128,7 @@ In linkedListFuncs.cpp: - recursiveRemoveKFromFront(list, 2) = 4 - recursiveRemoveKFromFront(list, 1) = 3 → 4 -- **recursiveElementwiseSum()** +- **[10 points] recursiveElementwiseSum()** - Recursively find the elementwise sum of two linked lists - Given two head nodes, return the head of a **new** linked-list where each element is the sum of the corresponding element of the other two - if one linked-list is shorter, fill the rest of the result with elements from the other (i.e., treat the non-existent nodes as a value of zero) @@ -180,7 +180,7 @@ Submit the `strFuncs.cpp` and `linkedListFuncs.cpp` files on gradescope. 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. - + ## Academic Honesty diff --git a/gsa08.md b/_gsa08.md similarity index 100% rename from gsa08.md rename to _gsa08.md diff --git a/gsa07.md b/gsa07.md deleted file mode 100644 index 3089b68..0000000 --- a/gsa07.md +++ /dev/null @@ -1,216 +0,0 @@ ---- -layout: page -title: GSA 07 -num: gsa07 -nav_order: 8 -desc: "Recursion" -assigned: 2023-03-01 13:00 -due: 2023-03-17 23:59 ---- - -# {{page.title}} - {{page.desc}} - -## Goals of this assignment - -The goal of this assignment is get more practice with recursion, linked-lists, and string functions. - -To prepare you for the final exam, this assignment will ask you to implement functions that may appear difficult. Do not panic! - -# Step by Step Instructions! - -## Step 1: Getting Started - -1. Go to github and find a repo for this assignment assigned to your GitHub id. -2. Log on to your CSIL account. -3. Change into your `~/cs16` directory -4. Clone your empty {{page.num}} 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:{{site.github_org}}/STARTER-{{page.num}}.git - -Previous assignments contain instruction for the process of: -* Adding a `starter` remote for this repo -* Pulling the code from that `starter` remote into your own repo. - -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: -* First consult previous assignments for more detailed instructions. -* Then, if you are still having trouble, ask the staff for help during discussion section or office hours. - -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 assignment: - -### 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 assignment may be more difficult than the previous assignments 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 assignment, one of which is a bonus: - -In strFuncs.cpp: -- **[10 points] isPalindrome()** - - Recursively check if a string is a palindrome - - A palindrome is a word or phrase that reads the same backwards & forwards - - Palindromes **are not** case-sensitive - disregard spaces as well - - Examples - - *Noel sees Leon* reads *noeL sees leoN* backwards, and as we disregard spaces and capitalization, it is a palindrome - - *HelloN* reads *olleH* and is not a palindrome - -In linkedListFuncs.cpp: -- **[10 points] recursiveSum()** - - Recursively calculate the sum of a linked list - - Given a head node, return the sum of the linked list - - Example - - list: 2 → 3 → 4           - - recursiveSum(list) = 9 - -- **[10 points] recursiveLargestValue()** - - Recursively find the largest value in a linked list - - Given a head node, return the largest value in the linked list - - Example - - list: 2 → 3 → 4           - - recursiveLargestValue(list) = 4 - -- **[10 points] recursiveFindKthNode()** - - Recursively find the kth Node of a linked list - - Given a head node and integer k, return the address of the kth node - - You do not know whether the linked-list contains k or more nodes; if k is greater than the length of the linked-list, return NULL - - Example: - - list: 2 → 3 → 4           - - recursiveFindKthNode(list, 1) = 2 - - recursiveFindKthNode(list, 3) = 4 - - recursiveFindKthNode(list, 4) = NULL - -- **[10 points] recursiveDeleteKthNode()** - - Recursively delete the kth node from a linked list - - Given the head of a linked list, delete the kth node from the linked list - - k will always be less than or equal to the length of the linked list - - Return NULL if there are no nodes left after deleting. - - Example: - - list: 2 → 3 → 4           - - recursiveDeleteKthNode(list, 2) = 2 → 4 - - recursiveDeleteKthNode(list, 1) = 3 → 4 - - recursiveDeleteKthNode(list, 3) = 2 → 3 - -- **[10 points] recursiveRemoveKFromFront()** - - Recursively delete k nodes from a linked list - - Given the head of a linked list, delete the first k nodes from the linked list - - k will always be less than or equal to the length of the linked list - - Return NULL if there are no nodes left after deleting. - - Example: - - list: 2 → 3 → 4           - - recursiveRemoveKFromFront(list, 2) = 4 - - recursiveRemoveKFromFront(list, 1) = 3 → 4 - -- **[10 points] recursiveElementwiseSum()** - - Recursively find the elementwise sum of two linked lists - - Given two head nodes, return the head of a **new** linked-list where each element is the sum of the corresponding element of the other two - - if one linked-list is shorter, fill the rest of the result with elements from the other (i.e., treat the non-existent nodes as a value of zero) - - Do **NOT** change the values of the original linked list - you must make a new one - - Examples - - Linked List 1: 1 → 2 → 3 → 4           Linked List 2: 5 → 6 → 7 - - Output: 6 → 8 → 10 → 4 - -- **recursiveSplice()** - - Doing this problem is optional - - Recursively splice together two linked lists - - Given two linked lists, splice the two linked lists together - - Splice two linked lists by interweaving the nodes - the second linked list's nodes should be inserted at alternating positions into the first linked list - - If the size of the two linked lists differ, after successfully splicing, finish the combined linked list with the remaining elements of the larger linked list - - Examples - - Linked List 1: 1 → 2 → 3 → 4           Linked List 2: 5 → 6 → 7 → 8 - - Output: 1 → 5 → 2 → 6 → 3 → 7 → 4 → 8 - - - Linked List 1: 1 → 2                         Linked List 2: 3 → 4 → 5 → 6 - - Output: 1 → 3 → 2 → 4 → 5 → 6 - - - You CANNOT create another linked list - doing so will fail both the local tests and Gradescope tests. Instead, splice the lists together by rearranging the *next* pointers of each linked list. You are allowed to declare additional nodes, but the returned linked list should only contain nodes from each linked list, in some order. - -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 assignment 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. - -## Gradescope Autograder - - - - - - - - - - - - - -
Test NameValue

isPalindrome()

[10 pts]

recursiveSum()

[10 pts]

recursiveLargestValue()

[10 pts]

recursiveFindKthNode()

[10 pts]

recursiveDeleteKthNode()

[10 pts]

recursiveRemoveKFromFront()

[10 pts]

recursiveElementwiseSum()

[10 pts]

recursiveSplice()

[10 pts]

Git Etiquette

[10 pts]

Make

[10 pts]
- - -## 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 -```