Lecture 8 Data Structure Stack SUDOKU STACK 1

  • Slides: 18
Download presentation
Lecture 8 Data Structure - Stack ØSUDOKU ØSTACK 軟體實作與計算實驗 1

Lecture 8 Data Structure - Stack ØSUDOKU ØSTACK 軟體實作與計算實驗 1

CHECK 軟體實作與計算實驗 Check row : 0 error Check column : 0 error Check block

CHECK 軟體實作與計算實驗 Check row : 0 error Check column : 0 error Check block : 0 error 5

Data Stack l Data structure: First in last out l Operations Initialize l Push

Data Stack l Data structure: First in last out l Operations Initialize l Push l Pop l empty 軟體實作與計算實驗 7

Structure l Stack l String 1 l Push push 1 2 2 3 3

Structure l Stack l String 1 l Push push 1 2 2 3 3 軟體實作與計算實驗 8

NEW l Activate PUSH and POP buttons 軟體實作與計算實驗 11

NEW l Activate PUSH and POP buttons 軟體實作與計算實驗 11

PUSH Key in a character to the input buffer l Press PUSH button to

PUSH Key in a character to the input buffer l Press PUSH button to store the character to the stack l Press PUSH 軟體實作與計算實驗 12

POP l Get the top element from the stack l Put to the output

POP l Get the top element from the stack l Put to the output buffer 軟體實作與計算實驗 13

Demo_stack demo_stack. rar 軟體實作與計算實驗 15

Demo_stack demo_stack. rar 軟體實作與計算實驗 15

Stack initialization % Initial a stack for characters l stack = '' l n=0

Stack initialization % Initial a stack for characters l stack = '' l n=0 軟體實作與計算實驗 16

Push l Let c denote an object l Append the object to the stack

Push l Let c denote an object l Append the object to the stack l stack=[stack c] l n=n+1 軟體實作與計算實驗 17

Pop % pop the top element of the stack to c n>0 T c

Pop % pop the top element of the stack to c n>0 T c = stack(n) n = n-1 軟體實作與計算實驗 18