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

Lecture Data structures and other objects using C++ - Chapter 7: Using a stack - Trường Đại học Công nghiệp Thực phẩm Tp. Hồ Chí Minh

10 1 0

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

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 10
Dung lượng 688,74 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Each time the  Each time the  program decides  program decides  to place a queen  to place a queen  on the board,        on the board,        the position of  the position of  the new qu[r]

Trang 1

Chapter 7 introduces the  stack data type

Several example  applications of stacks are  given in that chapter. 

This presentation shows  another use called 

backtracking to solve the  N­Queens problem

Data Structures

and Other Objects

Using C++

Trang 2

chess queens

and a chess board

Trang 3

placed on the board so 

that no two queens are 

attacking each other  

?

Trang 4

allowed in the same 

row

Trang 5

allowed in the same  

row, or in the same 

column

Trang 6

allowed in the same  

row, or in the same 

column, or along the 

same diagonal

Trang 7

and the size of the board 

can vary

ws

N columns

Trang 8

which tries to find a way 

to place N queens on an 

N x N chess board

Trang 9

uses a stack to 

keep track of 

where each 

queen is placed

Trang 10

program decides 

to place a queen 

on the board,       

the position of 

the new queen is 

stored in a 

record which is 

placed in the 

stack

ROW 1, COL 1

Ngày đăng: 01/04/2021, 18:34

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

TÀI LIỆU LIÊN QUAN

w