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
Give a recursive definition for the set POWERS-OF-TWO = {1 2 4 8 16 ....} and use your definition to prove that the product of two POWERS-OF-TWO is also a POWER-OF-TWO
DO BOTH WITH EXPLATION
10 Is A-(BU C) = (A-B) (A-C)? Prove it or disprove it.
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