1. Trang chủ
  2. » Cao đẳng - Đại học

Slide phân tích và thiết kế giải thuật chap6 backtracking algorithms

43 7 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Cấu trúc

  • Chapter 6 Backtracking Algorithms

  • Backtracking Algorithm

  • The Knight’s Tour Problem

  • Data representation

  • Given the current coordinate pair <x, y>, there are 8 potential candidates for coordinates <u, v> of the destination. They are

  • The final refinement

  • The recursive procedure is initiated by a call with the coordinates x0, y0 , from which the tour is to start. h[x0,y0]:= 1;

  • The general pattern of backtracking algorithm

  • The eight queens problem

  • Rule of chess: A queen can attacks all other queens in either the same column, row or diagonal on the board

  • Extension: Finding all solutions

  • In the extended algorithm, to simplify the stopping condition of the selection process, the repeat statement is replaced by a

  • State space tree

  • Complexity of backtracking algorithm

  • Branch-and-bound algorithm

  • Exhaustive search: Modified DFS to generate all the simple paths

  • An instance of TSP

  • Exhaustive search to find all simple paths

  • From the algorithm generating all simple paths to the algorithm solving TSP

  • The idea of branch-and-bound

  • The idea of branch-and-bound (cont.)

  • Example: Given a Traveling Salesman Problem as in the figure:

  • References

Nội dung

j ) are constant cu u du o ng th an Given these data, the statement setqueen is refined as: x[i]:=j; a[j]:=false; b[i+j]:=false;c[i-j]:=false; The statement removequeen is refined as: a[j] = true; b[i+j] = true ; c[i-j] := true The condition safe is represented as: a[j] ∧ b[i+j] ∧ c[i-j] 18 CuuDuongThanCong.com https://fb.com/tailieudientucntt u=x+y 16 c om y ng an co th ng du o cu u x -7 CuuDuongThanCong.com -3 v=x-y https://fb.com/tailieudientucntt 19 cu u du o an co ng c om begin x[i]:=j; a[j]:=false; b[i+j]:=false; c[i-j]:=false; if i

Ngày đăng: 06/12/2021, 14:34

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN