Learn how to write the code to recursively attempt to place an additional queen on a board.
- [Instructor] And now for the part that's…almost always obvious when you're finished…but typically tough to arrive at in the first place.…We're going to use recursion, so a method…that calls itself, to solve this particular problem.…Going back into the ChessBoard source code file,…scroll down to PlaceQueens,…and I'm going to replace line 39.…But just before I do, notice the method signature.…So it says PlaceQueens given a starting point,…a board and initial layout of queens,…and int column zero tell me…which column to start working from.…
And so this is important because the way…I want to do this is to say if you don't give me anything,…I'll work with an empty board.…If you don't tell me where to start,…I'll start on the leftmost column.…But for testing purposes, it was important for me…to be able to manually enter a board and say,…well given this layout, can you find…a solution from this point onwards?…And so I wanted that level of control.…So, let's start.…If someone gives us a board, great, we'll keep it.…
Question mark, question mark, so if that's null,…
Skill Level Intermediate
1. Problem 1: Pond Oreille
2. Problem 2: Where Am I?
3. Problem 3: Eight Queens
4. Problem 4: Accessing Peripherals
5. Problem 5: Facial Recognition
6. Problem 6: Real-Time Information Dashboard
Next steps2m 46s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.