Skip to main content

Backtracking

  • Chapter
  • First Online:
First Course in Algorithms Through Puzzles

Abstract

In this chapter, we learn the technique called backtracking . Backtracking is a systematic method of trial and error. In short, it is an approach that tests all possible choices, looking for the desired solution. Up to this point, it is similar to the DFS and BFS algorithms discussed in Chap. 4 and, like these algorithms, checks in the search tree systematically in order. The main feature of backtracking is that, if it finds at some point that there is no possibility of finding a solution, it halts the search, returns to the last branch, and turns to the next choice that has not yet been tested. This trick—return and turn to the next choice—is the reason why this method is called “backtracking.” If we can halt the redundant searching, even if the search tree is huge, we may find a solution efficiently.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Hardcover Book
USD 49.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    Application of sentinel: We can omit this check of “outside the board” using the technique called sentinel. If you have enough energy, consider how you can realize this.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Ryuhei Uehara .

Rights and permissions

Reprints and permissions

Copyright information

© 2019 Springer Nature Singapore Pte Ltd.

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Uehara, R. (2019). Backtracking. In: First Course in Algorithms Through Puzzles. Springer, Singapore. https://doi.org/10.1007/978-981-13-3188-6_5

Download citation

  • DOI: https://doi.org/10.1007/978-981-13-3188-6_5

  • Published:

  • Publisher Name: Springer, Singapore

  • Print ISBN: 978-981-13-3187-9

  • Online ISBN: 978-981-13-3188-6

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics