EBK DATA STRUCTURES AND ALGORITHMS IN C
EBK DATA STRUCTURES AND ALGORITHMS IN C
4th Edition
ISBN: 9781285415017
Author: DROZDEK
Publisher: YUZU
bartleby

Concept explainers

Question
Book Icon
Chapter 5, Problem 24E
Program Plan Intro

Backtracking:

  • Back tracking is a form of recursion.
  • In this method it is possible to backtrack if traversal reaches a node which has no other way from that to find solution.
  • It can be used to solve problems like eight queens puzzle and maze problem.

Trace of “putQueen()”:

putQueen(0)

col = 0;

putQueen(1)

col = 0;

col = 1;

col = 2;

  putQueen(2)

col = 0;

col = 1;

col = 2;

col = 3;

  col = 3;

  putQueen(2)

col = 0;

col = 1;

  putQueen(3)

col = 0;

col = 1;

col = 2;

col = 3;

col = 2;

col = 3;

col = 1;

  putQueen(1)

col = 0;

col = 1;

col = 2;

col = 3;

  putQueen(2)

col = 0;

putQueen(3)

col = 0;

col = 1;

col = 2;

.Q..

...Q

Q...

..Q.

  col = 3;

col = 1;

col = 2;

col = 3;

col = 2;

  putQueen(1)

  col = 0;

  putQueen(2)

col = 0;

col = 1;

col = 2;

col = 3;

  putQueen(3)

col = 0;

col = 1;

..Q.

Q...

...Q

.Q..

col = 2;

col = 3;

col = 1;

col = 2;

col = 3;

  col = 3;

  putQueen(1)

  col = 0;

  putQueen(2)

col = 0;

col = 1;

col = 2;

  putQueen(3)

col = 0;

col = 1;

col = 2;

col = 3;

  col = 3;

  col = 1;

  putQueen(2)

col = 0;

col = 1;

col = 2;

col = 3;

col = 2;

col = 3;

2 solutions found

Blurred answer
Students have asked these similar questions
Write down a recursive definition of the set A that consists of all binary strings that satisfy all of the following properties: -> the string ends with 0, and -> the string has length at least two, and -> the length of the string is even.
Implement a method with signature transfer(S, T) that transfers all elements from stack S onto stack T, so that the element that starts at the top of S is the first to be inserted onto T, and the element at the bottom of S ends up at the top of T. Programming language:  java
program € an arraylist from user d iterate over this using iterator and print
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education