COP3502_33_Backtracking - Backtracking Computer Science...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Computer Science Department University of Central Florida Backtracking COP 3502 – Computer Science I
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Backtracking page 2 Preliminaries Exhaustive Search What is an exhaustive search? a trivial but very general problem-solving technique that consists of: 1) systematically enumerating all possible candidates for the solution, and 2) checking whether each candidate satisfies the problem's statement aka “brute-force” search Brute-force is simple to implement And given enough time, it will always find a solution
Background image of page 2
Backtracking page 3 Preliminaries Exhaustive Search Example: Let’s say you want to find all the possible divisors of some natural number, n. The exhaustive, brute-force approach would be to enumerate ALL integers from 1 to n and then check whether each of them divides n without any remainder Think of brute-force as searching without a brain Example 2: A brute-force search of a node in a BST would ignore the ordering property and, instead, would search EACH and every single node
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Backtracking page 4 Preliminaries Exhaustive Search Benefit of Brute-Force: You are guaranteed to find a solution Since your algorithm will ultimately try EACH AND EVERY possible candidate solution, you will find the real solution Negative of Brute-Force: It takes a LOOOOOOOONG time. Sure, your algorithm, in theory, will produce a solution But most likely not in your lifetime! Even for average size values of n, the running time is often computationally prohibitive.
Background image of page 4
Backtracking page 5 Backtracking What is backtracking? Often no more than a clever implementation of an exhaustive search BUT, the savings over a brute force algorithm can be significant Backtracking could degenerate, in a worst case, to a brute force, exhaustive search But in most cases, better cases, backtracking only checks a subset of possibilities within the search .
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Backtracking page 6 Backtracking Simple example: Arrange furniture in the house An exhaustive search: Would find ALL POSSIBLE furniture arrangements and check to see if one fits in the house This is WAAAAAAY crazy Computationally prohibitive!!! Backtracking:
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/21/2011 for the course COP 3330 taught by Professor Staff during the Spring '08 term at University of Central Florida.

Page1 / 42

COP3502_33_Backtracking - Backtracking Computer Science...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online