You are on page 1of 8

Data Structures

Unit 4 Part 3
BCA, NGMC
Backtracking
• Backtracking is an algorithmic-technique.
• Solving problems recursively by trying to build a
solution incrementally, one piece at a time.
• Removing those solutions that fail to satisfy the
constraints of the problem at any point of time.
• Definition: Backtracking can be defined as a
general algorithmic technique that considers
searching every possible combination in order to
solve a computational problem.
Types
• There are three types of problems in
backtracking –
• Decision Problem – In this, we search for a
feasible solution.
• Optimization Problem – In this, we search for
the best solution.
• Enumeration Problem – In this, we find all
feasible solutions.
• Backtracking algorithm determines the solution by
systematically searching the solution space for the
given problem. 
• Backtracking is a depth-first search with any
bounding function
• In a constraint satisfaction problem, which has clear
and well-defined constraints on any objective
solution, that incrementally builds candidate to the
solution and abandons a candidate (“backtracks”) as
soon as it determines that the candidate cannot
possibly be completed to a valid solution, can be
solved by Backtracking.
Divide & Conquer algorithm
• A divide-and-conquer algorithm works by
recursively breaking down a problem into two
or more sub-problems of the same or related
type, until these become simple enough to be
solved directly.
• The solutions to the sub-problems are then
combined to give a solution to the original
problem.
For example, to sort
a given list
of n natural
numbers, split it
into two lists of
about n/2 numbers
each, sort each of
them in turn, and
interleave both
results
appropriately to
obtain the sorted
version of the given
list.
Steps

• Divide/Break
• Conquer/Solve
• Merge/Combine
Advantages
• Solving difficult problems
• Algorithm efficiency
• Parallelism
• Memory access
• Roundoff control

You might also like