Due Wednesday, July 28 at 11:59 pm Pacific
- Submissions received by the due date receive a small on-time bonus.
- All students are granted a pre-approved extension or "grace period" of 24 hours after the due date. Late submissions are accepted during the grace period with no penalty.
- The grace period expires Thu, Jul 29 at 11:59 pm Pacific, after which we cannot accept further late submissions.
- In this course, we express all date/times in Pacific time GMT -7. Our Paperless submission system also displays/records due dates and submission times in Pacific time.
Last week's assignment introduced you to the intriguing world of recursion and built your solid base of recursive fundamentals. This week we pivot towards applying the powerful nature of recursive backtracking to solve real-world problems. As is typical in recursive problem-solving, you'll likely spend the bulk of your time wrapping your head around the "thinking recursively" part, but once writing the actual code, you'll find that a rather concise algorithm is all that's needed to solve the task. That sparse elegance can sometimes seem incongruous with how hard you had to work for it. Start early to give yourself enough time to let these deep and powerful ideas percolate to full understanding. When you put the finishing touches on these problems, you will have earned your rightful place as a master in the way of recursive problem-solving.
After completing this assignment, you will be able to…
- Appreciate the elegance and power of recursive problem-solving and identify problems that are well-suited to be solved recursively
- Implement more advanced recursive algorithms to solve problems that cannot be easily solved using an iterative approach
This assignment consists of a warmup exercise and three separate problems to solve using recursive backtracking.
Practice with testing and debugging recursive functions.
Predict a user's intended word when typed on old-style phone keypad.
Find all words on a given Boggle board and tally the maximum possible score.
An embedded ethics and coding exercise that investigates the practice of Gerrymandering through the lens of data analysis and recursive backtracking algorithms.
As always, we have provided a ZIP of the starter project. However, this time around, accessing the starter code files will require a little bit of additional work.
As we are always working to make the learning experience in CS106B as good as it can be, feedback from students is one of the most important things that we consider as we design the class going forward and reflect on the things that we have tried so far. To that end, before getting started on Assignment 4, we would appreciate it if you all took about 15-20 minutes of your time to fill out a Mid-Quarter Evaluation regarding your experience in CS106B so far. All responses are anonymous. We would love to get your input, especially considering all the changes and new aspects of the class that we've experimented with in the time of virtual learning. Thank you in advance for taking the time to share your thoughts with us!
Once you have completed the feedback survey, you will be redirected to a page containing the link to the starter code zip. From there, download the zip, extract the files, and open the project in Qt Creator.
The source files you will edit are,
gerrymandering.cpp. Additionally, you will answer questions in
Here are some resources that you might find helpful for this assignment:
- The Assignment 4 YEAH Session is scheduled for Thursday, July 21 from 11:30am-12:30pm. Zoom information can be found on the Zoom Information page. Come join the party!
- The CS106B Style Guide
- A Guide to Testing Code in CS106B
- Common Build/Run Errors Guide, put together by one of our wonderful section leaders, Jillian Tang.
- Lectures: Wednesday Why We Use Recursion, Friday Recursive Backtracking and Enumeration, Monday Backtracking Revisited
- Section: Backtracking
- Textbook Chapter 9 Recursive Backtracking
We have several channels where you can reach out to the course staff: post on Ed, email your section leader, join in at office hours, or sign up for one-one-one help at the LaIR. For questions specific to your code, coming to Lair is your best bet. If you cannot attend LaIR due to timezone issues, you may post your question on Ed. However, you must use a private post if you are including code so that you are not posting your solutions for the whole class to see.
Before you call it done, run through our submit checklist to be sure all your
t's are crossed and
i's dotted. Then upload your completed files to Paperless for grading.
Please submit only the files you edited; for this assignment, these files will be:
Note: On Paperless, all due dates and submission times are expressed in Pacific time.