• 沒有找到結果。

基本的なデータ構造& 検索

N/A
N/A
Protected

Academic year: 2023

Share "基本的なデータ構造& 検索"

Copied!
5
0
0

加載中.... (立即查看全文)

全文

(1)

快樂營- 3 基本的なデータ構造 & 検索

基本的なデータ構造 & 検索

fujizzray August 6, 2013

1 Data Structure

1.1 Stack

stack( )

LIFO( )

stack pop

push pop

push stack

(top) (size)

stack STL

Algorithm 1STL stack

1: # include<stack>

2: using namespace std;

3:

4: stack<int> stk;

5:

6: (int) stk.size() 回傳 stack 內的個數

7: (void) stk.push(int j) 把 j 放到最上層

8: (void) stk.pop() 把 stack 最上層的東西拿走

9: (int) stk.top() 回傳 stack 的最上層

I

(2)

1.2 Queue 基本的なデータ構造 & 検索

1.2 Queue

queue( )

( ) ( )

stack queue FIFO( )

queue push pop

stack

(front) (back)

queue STL

> .∼

Algorithm 2STL queue

1: #include<queue>

2: using namespace std;

3:

4: queue<int> que;

5:

6: (int) que.size() 回傳 queue 內的個數

7: (void) que.push(int j) 把 j 放到最後面

8: (void) que.pop() 把 queue 最前面的東西拿走

9: (int) que.front() 回傳 queue 的最前面

1.3 Exercises

1. <TIOJ 1176 Cows>

n

O(n)

2. <TIOJ 1063 >

n×m 01 1 O(nm)

3. <TIOJ 1368 Get High>

=

×

jizz O(n) 4. <TIOJ 1320 >

II

(3)

2. Search 基本的なデータ構造 & 検索

d O(nlogn)

5. <TIOJ 1489 >

a∼z O(n)

<TIOJ 1225> <TIOJ 1721> <TIOJ 1378> <POJ 2559>

stack queue

stack

stack queue

BFS queue

2 Search

Introduction

• (No-Lifting)(Enumerate)

jizz XD

• (State Space Search) (Shinda Sekai Sensen) (rebels against the god)

(State Transition) (Graph)

(State) (Edge)

III

(4)

2.1 DFS 基本的なデータ構造 & 検索

2.1 DFS

DFS(Depth First Search)

O(d(

)) GG

2.2 BFS

BFS(Breath First Search) DFS

queue jizz

DFS : 1 → 2 → 5 → 9 → 10 → 6 → 3 → 4 → 7 → 11 → 12 → 8

BFS : 1 → 2 → 3 → 4 → 5 → 6 → 7

→ 8 → 9 → 10 → 11 → 12

2.3 Exercises

1. <TIOJ 1061 >

OOXX

O X

2. <TIOJ 1046 >

OOXX

OX O

3. <TIOJ 1235 >

4. <TIOJ 1376 >

(ex: ■ )

IV

(5)

2.3 Exercises 基本的なデータ構造 & 検索

5. <TIOJ 1008 >

K(K <6) L

6. <TIOJ 1085 >

<POJ 3411> <TIOJ 1213> <SGU125> <TIOJ 1050> <STEP5 74>

jizz

( 101 pC) Judge

POJ

V

參考文獻

相關文件

More importantly, dielectric relaxation features associated with the polar- like behavior in the CO2 state is identified, suggesting that this CO2 state is dynamic without a clear

This can be done by identifying the required function by symbol and name in theIndex of Special Functions and Notation on page xxxvii, and by then referring to the defining formula or