{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

COP3502_33_Backtracking

# COP3502_33_Backtracking - Backtracking Computer Science...

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

Computer Science Department University of Central Florida Backtracking COP 3502 – Computer Science I

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

View Full Document
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
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

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

View Full Document
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.
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 .

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

View Full Document
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:
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### 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
Ask a homework question - tutors are online