Skip to main content

The N-Queens Problem

  • Chapter
Refinement Calculus

Part of the book series: Graduate Texts in Computer Science ((TCS))

  • 336 Accesses

Abstract

The n-queens problem is to place n queens (where n > 0) on an n -by-n chessboard so that no queen is threatened by another one. According to the rules of chess, this is equivalent to the requirement that no two queens be on the same row or the same column or on a common diagonal. For some values of n this is possible but for some values (for example, for n =2) there is no solution. In this chapter we show how one solution for a particular value of n is found with a depth-first search. The program derivation illustrates both recursion and loop introduction in a nontrivial setting. It also illustrates how to handle data structures like sequences in a program derivation.

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 84.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 109.99
Price excludes VAT (USA)
  • Compact, lightweight 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

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 1998 Springer Science+Business Media New York

About this chapter

Cite this chapter

Back, RJ., von Wright, J. (1998). The N-Queens Problem. In: Refinement Calculus. Graduate Texts in Computer Science. Springer, New York, NY. https://doi.org/10.1007/978-1-4612-1674-2_24

Download citation

  • DOI: https://doi.org/10.1007/978-1-4612-1674-2_24

  • Publisher Name: Springer, New York, NY

  • Print ISBN: 978-0-387-98417-9

  • Online ISBN: 978-1-4612-1674-2

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics