UC BERKELEY

Berkeley CS61B Homework Help

Project walkthroughs from HW0 through Gitlet, BYOW, and the lab autograder with explicit JUnit @Timeout annotations matching the staff rubric. The number-one grading deduction on Project 2 Gitlet is a checkout-branch implementation that mutates the working directory before persisting the HEAD pointer, causing the file system to desync from the commit graph after a power-loss simulation, the exact failure mode our tutors annotate inline. Verified CS graduates with prior CS61B TA or lab assistant experience, starting at $20 per project, 12-hour average turnaround.

CS61B course identity card showing the course code, UC Berkeley, and pset coverage stats
8 Recurring Assignments Covered with autograder pass guarantees
3 Required Textbooks Mapped to assignment problems
2 Languages Covered Course-relevant language coverage
12h Avg Turnaround Standard delivery; rush 4-6h available

Course Overview

About CS61B at UC Berkeley

CS61B teaches data structures and Java software engineering across 14 weeks under Josh Hug (since 2017) and Justin Yokota (recent semesters). Lectures cover lists, sets, maps, trees, balanced search trees (LLRB, B-trees, B+ trees), hashing, heaps, graphs, BFS, DFS, Dijkstra, A-star, MSTs, sorting, comparison-based and radix sort, and software engineering topics including version control, testing, and asymptotic analysis. Weekly cadence: 2 lectures, 1 lab, 1 discussion, and either a homework set or a project milestone.

The course assesses through 11 lab autograded assignments (one per topic week), 3 homework sets (HW0 Java basics, HW2 conceptual asymptotic analysis, HW3 algorithm design), 4 projects (Project 0 NBody n-body gravity simulation, Project 1 Deque with linked-list and array-deque variants, Project 2 Gitlet a 4,000-line clone of git, Project 3 BYOW a procedurally-generated 2D tile world), a midterm at week 7, and a 3-hour final at the end of week 14. Project autograders use JUnit 4 with @Timeout annotations enforcing per-test budgets: Project 2 Gitlet must complete all 35 acceptance tests in under 60 seconds wall-clock; Project 3 BYOW world generation must seed-stably reproduce a world from a 9-digit seed in under 5 seconds. Grading splits 30 percent labs and homework, 50 percent projects (10-10-15-15), 10 percent midterm, 10 percent final.

UC Berkeley CS61B Instructor Josh Hug

Course Reading

Required Textbooks for CS61B

CS61B Course Notes (Hug 2024 edition)

Authored by Josh Hug, with contributions from Paul Hilfinger and the CS61B staff. Mapped to CS61B assignment problems by our tutors.

Algorithms (4th Edition)

Authored by Robert Sedgewick and Kevin Wayne. Mapped to CS61B assignment problems by our tutors.

Effective Java (3rd Edition)

Authored by Joshua Bloch. Mapped to CS61B assignment problems by our tutors.

Assignments

Recurring CS61B Assignment Types

HW0 (Java Basics and IntelliJ Setup)

Verifies the Java 17 toolchain (JDK, javac, java, junit-4.13.2.jar on the classpath), IntelliJ IDEA Community Edition project import, and git workflow with the staff skeleton repo. Includes a `Sort.java` that sorts an int array (any algorithm, autograded for correctness only) and `Pig.java` a Pig Latin translator. Sets the baseline development environment for the semester.

Project 0 (NBody)

A 2D n-body gravitational simulation reading planet data from a `.txt` file (e.g. `data/planets.txt` with 5 planets and 200 timesteps), computing pairwise force vectors, updating positions and velocities by Euler integration, and rendering each timestep via the staff-provided StdDraw library. Tests the float math, file I/O via In.java, and the `Planet` class API (constructor with position-velocity-mass-image-fields, calcForceExertedBy, calcNetForceExertedByAll, update).

Project 1A (LinkedListDeque)

A doubly-linked-list deque with a circular sentinel node, supporting addFirst, addLast, removeFirst, removeLast, get, size, isEmpty, and an iterator. The acceptance test calls 5,000 randomized operations and checks O(1) for addFirst, addLast, removeFirst, removeLast, and O(n) for get(i). The sentinel pattern (one always-present node where sentinel.next is the first real node and sentinel.prev is the last) avoids 8 special cases for empty-deque insertion and deletion.

Project 1B (ArrayDeque)

A circular-buffer deque with resizing (grow by 2x on overflow, shrink by 0.5x when usage drops below 25 percent and capacity exceeds 16). Maintains nextFirst and nextLast indices that wrap via modulo arithmetic. The hardest part: resize must preserve element order across the wraparound, which requires copying from nextFirst+1 through nextLast-1 with modulo indexing into the new array. Grading tests include a 1,000,000-element push-pop sequence verifying O(1) amortized cost and correct shrink behavior.

Project 2 (Gitlet)

A 4,000-line Java implementation of git with the commands init, add, commit, rm, log, global-log, find, status, checkout, branch, rm-branch, reset, and merge. Persists commit objects, blob objects, and the staging area as SHA-1-keyed files under `.gitlet/`. The acceptance test (35 integration tests via the ec module) must complete in under 60 seconds wall-clock; the merge command alone has 14 tests including criss-cross merges and conflict markers matching git's `<<<<<<< HEAD` syntax exactly. Project 2 is the largest single CS61B deliverable and the most autograder-sensitive.

Project 3 (BYOW: Build Your Own World)

A procedurally-generated 2D tile world rendered with the staff TileEngine and StdDraw. A 9-digit seed produces a deterministic dungeon (rooms of 3-by-3 to 8-by-8 connected by hallways of width 1 to 3), and the player controls an avatar with WASD navigation, save and load via colon-S, and a HUD showing the tile under the cursor. The autograder validates seed-stable world reproduction (same seed produces identical world across runs and across machines) and headless-mode behavior (TERenderer disabled, world state inspectable via getTiles).

Lab Autograder (11 weekly labs)

Labs run from Lab 1 (HelloNumbers Java I/O) through Lab 13 (Graph algorithms with Dijkstra and A-star on a Bay Area map). Each lab autogrades with JUnit 4 tests via the lab repo skeleton, runs in under 30 seconds per submission on the staff grading cluster, and accepts up to 5 submissions before locking. Specific labs: Lab 4 Asymptotic analysis (writes worst-case complexity proofs), Lab 6 Maps and Sets (implement BSTMap and HashMap), Lab 8 Heaps (ArrayHeapMinPQ for Dijkstra), Lab 11 Graphs (BFS and DFS with adjacency-list representation).

JUnit @Timeout Patterns Across All Projects

Every autograded test in the cs61b grader uses `@Test(timeout = N)` annotations to enforce per-test runtime budgets. Project 2 Gitlet has tests with 5,000 ms budgets for single commands and a 60,000 ms wall-clock for the full integration sequence. Project 1B ArrayDeque has a 100 ms budget for million-element addFirst loops to enforce O(1) amortization. Submissions that pass correctness but TLE on the timeout still fail the test.

Common Pitfalls

Where CS61B Students Get Stuck

Project 0 NBody float vs double precision

StdDraw uses double-precision coordinates, but Planet.java starter code stores xxPos, yyPos, xxVel, yyVel as double. Students who declare these as float lose precision over 200 timesteps and the planets drift visibly off their orbital paths in the autograder image-diff test. The fix: use double for all position, velocity, mass, and force calculations; cast to float only when calling StdDraw rendering methods.

Project 1B ArrayDeque resize wraparound bug

When the array is full and the elements wrap around (e.g. nextFirst is at index 14 of a 16-slot array with the data spanning indices 0 through 7 and 14 through 15), the naive resize that copies items[0..size] into the new array reorders the elements. The fix: copy from nextFirst+1 to the end of the old array first, then from index 0 to nextLast-1, then set nextFirst = newCapacity - 1 and nextLast = size. Hug's lecture notes have a 5-frame diagram for this exact case.

Project 2 Gitlet checkout-branch order of operations

The checkout-branch command must: (1) verify the branch exists, (2) verify the working directory has no untracked files that would be overwritten, (3) move HEAD to the new branch, (4) restore the working directory to the new HEAD commit, (5) clear the staging area. Students who restore the working directory before moving HEAD leave the repo inconsistent if a crash interrupts step 4: HEAD still points to the old branch but files match the new branch. The autograder simulates power-loss via the `crash` test in ec/CrashTest.java.

Project 2 Gitlet merge conflict marker format

Merge conflicts must produce conflict markers matching git's exact format: `<<<<<<< HEAD\n[current contents]=======\n[other branch contents]>>>>>>>\n` with `\n` after each marker, the current contents, the separator, the other branch contents, and the closing marker. Students who use Unix-style `<<<` or omit a trailing newline fail 7 of the 35 acceptance tests. The fix: read the staff test cases in the ec module and assert byte-equality of the conflict file via Utils.readContentsAsString.

Project 3 BYOW seed-dependent world divergence

BYOW world generation uses java.util.Random seeded by the 9-digit input. Students who use Math.random() (which has its own hidden global seed) or who call Random.nextInt() in a different order than the staff spec produce worlds that vary across machines. The autograder fails the seed-stability test by comparing tile-by-tile against a reference world generated on the staff machine. The fix: instantiate one Random instance from the seed, and call nextInt in a documented order (room count, then per-room x, y, width, height, then hallway endpoints).

JUnit timeout silent failure

A test with `@Test(timeout = 5000)` that runs at 4,999 ms passes, and at 5,001 ms fails with TestTimedOutException. Students who pass locally on a fast development machine (M1 Mac, M2 Pro) and submit to the grading cluster (older AWS instances) sometimes see tests that passed at 3 seconds locally fail at 7 seconds remotely. The fix: profile with java -agentlib:hprof or VisualVM, then redesign the hot loop to drop a level of nested iteration or replace a LinkedList with an ArrayDeque.

IntelliJ classpath misconfiguration

Lab 4 introduces JUnit 4 testing. Students who clone the skeleton repo without setting `library-cs61b-software.jar` as a project library see JUnit imports underline red in IntelliJ. The fix: Project Structure (cmd-semicolon on Mac), Libraries, add `library-su24/javalib/*.jar` as a new library, apply to all modules. The staff IntelliJ guide at cs61bl.org has screenshots for this exact step.

git push to skeleton overwrites previous submission

Project submission uses `git push skel su24-s123:proj2` against the skeleton remote. Students who push the wrong branch (e.g. `main:proj2` instead of `proj2:proj2`) overwrite a working submission with an in-progress feature branch. The fix: name the local proj2 branch `proj2` from the start, work in feature branches that merge into `proj2`, and verify the push target with `git remote -v` before each submission.

Sample Work

CS61B Code from Past Deliveries

Every CS61B deliverable ships with annotated code, an autograder transcript, and a line-by-line walkthrough. Browse anonymized samples to see what a delivered pset looks like before you submit.

See sample CS61B-style assignments we have delivered

Sample-work archive includes code, comments, autograder output, and the design-decision notes our tutors leave for each pset.

Browse sample work

Related Coverage

What Pairs With CS61B

Language

Java Homework Help

JUnit-passing solutions for OOP, multithreading, and Spring Boot assignments, with Big-O annotations on every method. The number-one cause of failed autograder submissions in undergraduate Data Structures II courses (Berkeley CS61B, U of T CSC263, U of Sydney INFO1113, NUS CS2030S, IIT Bombay CS213) is iterator invalidation after a mid-traversal HashMap put, the exact failure mode our tutors annotate inline. Verified CS graduates from Georgia Tech, U of Toronto, Manchester, NUS, EPFL Lausanne, and IIT, starting at $20 per task, 12-hour average turnaround.

Subject

Data Structures Homework Help

Implementation, Big-O analysis, and JUnit edge-case tests for every structure from arrays through graphs. The number-one cause of failed Gradescope submissions in CS61B is iterator invalidation after a mid-traversal mutation, the exact failure mode our tutors annotate inline. Verified CS graduates from BITS Pilani, EPFL Lausanne, and Georgia Tech, starting at $20 per task, 12-hour average turnaround.

Subject

Algorithms Homework Help

Sorting, dynamic programming, greedy, divide-and-conquer, and graph algorithms with formal complexity analysis. The hardest CS161 grading deduction is failing to prove the greedy-choice property for a problem that looks greedy but is not, the gap our tutors close with a worked exchange argument. Verified CS graduates from Georgia Tech, Purdue, and BITS Pilani, starting at $20 per task, 12-hour average turnaround.

FAQ

CS61B Tutoring, Frequently Asked Questions

Do you help with Project 2 Gitlet?
Yes. Gitlet is the largest CS61B deliverable at 4,000 lines and the most autograder-sensitive. Standard delivery includes all 13 commands (init, add, commit, rm, log, global-log, find, status, checkout, branch, rm-branch, reset, merge), the SHA-1 content-addressed storage layout under `.gitlet/`, conflict markers matching git's exact format, and a passing transcript of all 35 acceptance tests (ec module) completing in under 60 seconds wall-clock on the grading cluster. The merge command alone gets 14 tests including criss-cross merges with shared ancestors and conflict resolution.
Can you guarantee the Gitlet autograder under 60 seconds?
Standard Gitlet deliveries complete the 35-test acceptance suite in 35 to 50 seconds wall-clock on the staff grading cluster (AWS m5.large class). The implementation uses HashMap for branch and commit lookups (O(1) average), keeps the staging area in-memory between subcommand calls within a single JVM run (reducing disk I/O during the test sequence), and uses Utils.readContents (byte array) instead of Utils.readContentsAsString (UTF-8 decode) for blob serialization. The 60-second budget is enforced by @Test(timeout = 60000) in the ec test class.
How do you handle the Project 3 BYOW autograder?
BYOW grades on 3 axes: seed-stable world generation (same 9-digit seed produces identical tiles across machines), playable input handling (WASD navigation, save and load via colon-S), and headless-mode operation (TileEngine renderer disabled, world state inspectable via getTiles for grader assertions). Our implementations seed exactly one java.util.Random instance from the input, document the nextInt call order in WorldGenerator.java, and ship with a HeadlessMain.java entry point that runs the autograder commands without StdDraw initialization.
What about lab autograders?
All 11 weekly labs covered: Lab 1 Java I/O, Lab 2 git workflow, Lab 3 Debugging in IntelliJ, Lab 4 Asymptotic analysis, Lab 5 LinkedList, Lab 6 BSTMap and HashMap, Lab 7 Asymptotic and amortized analysis, Lab 8 Heaps (ArrayHeapMinPQ), Lab 9 Tries and Autocomplete, Lab 11 Graphs (BFS and DFS), Lab 13 Dijkstra and A-star on a Bay Area road network. Each submission runs through the staff JUnit test suite locally before delivery, with @Test(timeout) budgets matching the published rubric.
Is paying for CS61B help allowed under the academic honesty policy?
CS61B publishes its academic honesty policy at sp24.datastructur.es/about.html: cheating includes copying code from other students or paid services with intent to submit as your own work. CSHH operates as a study reference: every deliverable includes JavaDoc comments explaining the algorithm choice and complexity on every public method, a worked example trace for any project step over 50 lines, and a recommendation to retype the solution from scratch after reading rather than copy-paste. Whether a specific submission complies with your section's interpretation of the policy is your judgment to make against the published rules.
Do you help with the CS61B midterm and final?
Yes. Live tutoring at $40 per hour for midterm prep (week 7 coverage: lists, sets, maps, balanced BSTs, heaps, asymptotic analysis) and final prep (week 14 coverage: all of midterm plus hashing, graphs, MST, sorting, software engineering). Past exams from Spring 2019 through Fall 2024 are archived at hkn.eecs.berkeley.edu/exams and we work through every problem with the published solutions. The exam format is closed-book with one 2-sided cheat sheet for the midterm and two 2-sided cheat sheets for the final.
What turnaround do you offer on CS61B projects?
12-hour average for Project 0 NBody and Project 1A LinkedListDeque. 24 to 36 hours for Project 1B ArrayDeque and Project 3 BYOW. 5 to 7 days for Project 2 Gitlet given the 4,000-line scope and 35-test acceptance suite. Labs deliver in 4 to 8 hours. Pricing: $20 Debug and Explain per project, $30 Full Solution per project (Project 2 Gitlet priced at $150 given scope), $40 per hour Live Tutoring.
Can you help with the new BYOW (Spring 2024 vs prior semesters)?
Yes. The Spring 2024 BYOW reorganized the project around the TileEngine and TERenderer split, with explicit headless-mode hooks and the InputSource interface for replaying recorded inputs. Prior semester versions used a single TileEngine class with combined rendering and state, and the headless-mode behavior was less standardized. Our implementations target the semester your skeleton repo specifies (check pom.xml or build.gradle for the cs61b version pin) and pass the autograder for that semester.
Do you help with the Spring 2023 Lab 8 ArrayHeapMinPQ?
Yes. Lab 8 implements a min-heap priority queue with O(log n) insert, removeSmallest, and changePriority operations. The hardest part: changePriority must locate the item in the heap before sifting up or down, which requires a HashMap from item to heap index maintained in parallel with the array. Our implementation uses a single Node inner class holding the item, priority, and heap index, with the HashMap mapping item to Node for O(1) lookup. The JUnit autograder runs 5,000 randomized operations under @Test(timeout = 5000).
How do you handle the Hilfinger vs Hug semester differences?
CS61B has been taught by Paul Hilfinger and Josh Hug across alternating semesters since 2017, with Justin Yokota teaching recent semesters. The course content and project sequence are the same across instructors, but project deadlines, autograder versions, and the exact JUnit test files differ. Specify the semester (e.g. Spring 2024 Hug, Fall 2023 Hilfinger) when submitting so the deliverable targets the correct skeleton repo and autograder.

Reviewed By

Stuck on CS61B?

Submit your CS61B assignment and get a verified CS tutor on it within 12 hours. Every delivery passes the autograder, ships with line-by-line comments, and includes a design-decision walkthrough so you can defend the work in office hours.

Submit CS61B Assignment