intersection study - algorithm[list]

81
ALGORITHM

Upload: jea-hyeun-jung

Post on 17-Aug-2015

104 views

Category:

Software


3 download

TRANSCRIPT

Page 1: Intersection Study - Algorithm[List]

ALGORITHM

Page 2: Intersection Study - Algorithm[List]

ALGORITHM

Array

LIST

Circular

Etc..intro

Pointer

Doubly

Page 3: Intersection Study - Algorithm[List]

ALGORITHM

LIST INTRO

What is List?

Page 4: Intersection Study - Algorithm[List]

LIST INTRO

Sequential

ALGORITHM

Page 5: Intersection Study - Algorithm[List]

학교 게시판 공지사항 리스트

LIST INTRO

ALGORITHM

Page 6: Intersection Study - Algorithm[List]

15773

15772

15771

15770

15765

15764

List Model

LIST INTRO

ALGORITHM

Page 7: Intersection Study - Algorithm[List]

15773

제거

15771

15770

15765

15764

15773

15771

15770

15765

15764

비어 있음

Delete Issue

LIST INTRO

ALGORITHM

Page 8: Intersection Study - Algorithm[List]

Insert Issue

15773

15772

15771

15770

15765

15764

15774

15773

15772

15771

15765

15764

Insert front

15773

15772

15771

15770

15765

15764

15773

15772

15771

15770

15766

15765

Insert specific position

LIST INTRO

ALGORITHM

Page 9: Intersection Study - Algorithm[List]

createList

리스트 생성

deleteList

리스트 삭제

isFull

리스트의 여유 공간이 있는가?

addElement

리스트 내 특정 위치에 원소 추가

removeElement

리스트 내 특정 위치의 원소 제거

clearList

리스트 내 모든 원소 제거

getListLength

리스트 내 원소의 수

getElement

리스트 내 특정 위치의 원소

Total Issue

LIST INTRO

ALGORITHM

Page 10: Intersection Study - Algorithm[List]

1 2 3 4

Two Kinds of List

1 2 3 4 5

0 1 2 3 4

6

5

LIST INTRO

ALGORITHM

Page 11: Intersection Study - Algorithm[List]

Array List

1 2 3 4 5

0 1 2 3 4

6

5

LIST ARRAY LIST

ALGORITHM

Page 12: Intersection Study - Algorithm[List]

최대 원소 개수(maxElementCount)

현재 원소 개수(CurrentElementCount)

원소 배열 포인터(pElement)

ArrayList

data data data data …

0 1 2 3 …

data

(maxElementCount – 1)

원소(data)

ArrayListNode

Two Structures

LIST ARRAY LIST

ALGORITHM

Page 13: Intersection Study - Algorithm[List]

data data … data

0 1 …

curElementCount – 1

원소 추가 가능

Insert Range

LIST ARRAY LIST

ALGORITHM

Page 14: Intersection Study - Algorithm[List]

Push and Insert

LIST ARRAY LIST

data 1 2 3 4

curElementCount – 1

position position + 1

ALGORITHM

Page 15: Intersection Study - Algorithm[List]

Push and Insert

LIST ARRAY LIST

data 1 2 3 4 4

curElementCount – 1

position position + 1

ALGORITHM

Page 16: Intersection Study - Algorithm[List]

Push and Insert

LIST ARRAY LIST

data 1 2 3 3 4

curElementCount – 1

position position + 1

ALGORITHM

Page 17: Intersection Study - Algorithm[List]

Push and Insert

LIST ARRAY LIST

data 1 2 2 3 4

curElementCount – 1

position position + 1

ALGORITHM

Page 18: Intersection Study - Algorithm[List]

Push and Insert

LIST ARRAY LIST

data 1 1 2 3 4

curElementCount – 1

position position + 1

ALGORITHM

Page 19: Intersection Study - Algorithm[List]

Push and Insert

LIST ARRAY LIST

data 1 1 2 3 4

new

curElementCount – 1

ALGORITHM

Page 20: Intersection Study - Algorithm[List]

Delete and Pull

LIST ARRAY LIST

data 0 1 2 3 4

1 curElementCount – 1

position position + 1

ALGORITHM

Page 21: Intersection Study - Algorithm[List]

Delete and Pull

LIST ARRAY LIST

data 0 2 2 3 4

curElementCount – 1

position position + 1

ALGORITHM

1

Page 22: Intersection Study - Algorithm[List]

Delete and Pull

LIST ARRAY LIST

data 0 2 3 3 4

curElementCount – 1

position position + 1

ALGORITHM

1

Page 23: Intersection Study - Algorithm[List]

Delete and Pull

LIST ARRAY LIST

data 0 2 3 4 4

curElementCount – 1

position position + 1

ALGORITHM

1

Page 24: Intersection Study - Algorithm[List]

Delete and Pull

LIST ARRAY LIST

data 0 2 3 4

curElementCount – 1

position position + 1

ALGORITHM

1

Page 25: Intersection Study - Algorithm[List]

Delete and Pull

LIST ARRAY LIST

data 0 2 3 4

curElementCount – 1

position position + 1

ALGORITHM

1

return

Page 26: Intersection Study - Algorithm[List]

Linked List

1 2 3 4

LIST LINKED LIST

ALGORITHM

Page 27: Intersection Study - Algorithm[List]

LIST LINKED LIST

Linked List Node

자료(Data) 링크(Link)

ALGORITHM

Page 28: Intersection Study - Algorithm[List]

Various Linked List

LIST LINKED LIST

Linked List

Circular List

Doubly Linked List

ALGORITHM

Page 29: Intersection Study - Algorithm[List]

Linked List

LIST LINKED LIST

Linked List

ALGORITHM

Page 30: Intersection Study - Algorithm[List]

Two Structures

LIST LINKED LIST

현재 원소 개수(CurrentElementCount)

LinkedList

data

pLink

Header Nodedata

pLink

ListNode

ListNode

ALGORITHM

Page 31: Intersection Study - Algorithm[List]

LIST LINKED LIST

Insert Node

LinkedList

data

pLink

Header Node

data

pLink

position-1

data

pLink

position

data

pLink

newNode

ALGORITHM

Page 32: Intersection Study - Algorithm[List]

LIST LINKED LIST

Insert Node

LinkedList

data

pLink

Header Node

data

pLink

position-1

data

pLink

position

data

pLink

newNode

ALGORITHM

Page 33: Intersection Study - Algorithm[List]

LIST LINKED LIST

Insert Node

LinkedList

data

pLink

Header Node

data

pLink

position-1

data

pLink

position

data

pLink

newNode

ALGORITHM

Page 34: Intersection Study - Algorithm[List]

LIST LINKED LIST

Delete Node

LinkedList

data

pLink

Header Node

data

pLink

position-1

data

pLink

position+1

data

pLink

position

ALGORITHM

Page 35: Intersection Study - Algorithm[List]

LIST LINKED LIST

Delete Node

LinkedList

data

pLink

Header Node

data

pLink

position-1

data

pLink

position+1

data

pLink

position

ALGORITHM

Page 36: Intersection Study - Algorithm[List]

LIST LINKED LIST

Delete Node

LinkedList

data

pLink

Header Node

data

pLink

position-1

data

pLink

position+1

data

pLink

position

ALGORITHM

NULL

Page 37: Intersection Study - Algorithm[List]

LIST LINKED LIST

Delete Node

LinkedList

data

pLink

Header Node

data

pLink

position-1

data

pLink

position+1

data

pLink

position

ALGORITHM

NULL

return

Page 38: Intersection Study - Algorithm[List]

Circular List

LIST CIRCULAR LIST

Circular List

ALGORITHM

Page 39: Intersection Study - Algorithm[List]

Two Structures

LIST CIRCULAR LIST

현재 원소 개수(CurrentElementCount)

CircularList

pLink

data

pLink

ListNode

data

pLink

ListNode

ALGORITHM

Page 40: Intersection Study - Algorithm[List]

Insert Issue

LIST CIRCULAR LIST

Case 1-1 Case 1-2

curElementCount 0?

yes

No

Case 2

First Insert?

yes

No

ALGORITHM

Page 41: Intersection Study - Algorithm[List]

Insert case 1-1

LIST CIRCULAR LIST

CircularList

pLink

NULL

pLink

ListNode

ALGORITHM

Page 42: Intersection Study - Algorithm[List]

Insert case 1-1

LIST CIRCULAR LIST

CircularList

pLink

NULL

pLink

ListNode

ALGORITHM

Page 43: Intersection Study - Algorithm[List]

Insert case 1-1

LIST CIRCULAR LIST

CircularList

pLink

NULL

pLink

ListNode

ALGORITHM

Page 44: Intersection Study - Algorithm[List]

CircularList

pLink

pLink

newNode

pLink

first

pLink

last

Insert case 1-2

ALGORITHM

LIST CIRCULAR LIST

Page 45: Intersection Study - Algorithm[List]

CircularList

pLink

pLink

newNode

pLink

first

pLink

last

Insert case 1-2

ALGORITHM

LIST CIRCULAR LIST

Page 46: Intersection Study - Algorithm[List]

CircularList

pLink

pLink

newNode

pLink

first

pLink

last

Insert case 1-2

ALGORITHM

LIST CIRCULAR LIST

Page 47: Intersection Study - Algorithm[List]

CircularList

pLink

pLink

newNode

pLink

first

pLink

last

Insert case 1-2

ALGORITHM

LIST CIRCULAR LIST

Page 48: Intersection Study - Algorithm[List]

CircularList

pLink

pLink

newNode

pLink

first

pLink

last

Insert case 1-2

ALGORITHM

LIST CIRCULAR LIST

Page 49: Intersection Study - Algorithm[List]

CircularList

pLink pLink

first

pLink

position-1

pLink

position

Insert case 1-2

ALGORITHM

LIST CIRCULAR LIST

pLink

newNode

Page 50: Intersection Study - Algorithm[List]

CircularList

pLink pLink

first

pLink

position-1

pLink

position

Insert case 1-2

ALGORITHM

LIST CIRCULAR LIST

pLink

newNode

Page 51: Intersection Study - Algorithm[List]

CircularList

pLink pLink

first

pLink

position-1

pLink

position

Insert case 1-2

ALGORITHM

LIST CIRCULAR LIST

pLink

newNode

Page 52: Intersection Study - Algorithm[List]

CircularList

pLink pLink

first

pLink

position-1

pLink

position

Insert case 1-2

ALGORITHM

LIST CIRCULAR LIST

pLink

newNode

Page 53: Intersection Study - Algorithm[List]

Delete Issue

ALGORITHM

LIST CIRCULAR LIST

Case 1-1 Case 1-2 Case 2

First Node Delete?

curElementCount 1?

yes

yes

No

No

Page 54: Intersection Study - Algorithm[List]

CircularList

pLink

Delete case 1-1

ALGORITHM

LIST CIRCULAR LIST

pLink

ListNode

NULL

Page 55: Intersection Study - Algorithm[List]

CircularList

pLink

Delete case 1-1

ALGORITHM

LIST CIRCULAR LIST

pLink

ListNode

NULL

Page 56: Intersection Study - Algorithm[List]

CircularList

pLink

Delete case 1-1

ALGORITHM

LIST CIRCULAR LIST

pLink

ListNode

NULL

return

Page 57: Intersection Study - Algorithm[List]

ALGORITHM

LIST CIRCULAR LIST

Delete Case 1-2

CircularList

pLink pLink

first

pLink

second

pLink

last

Page 58: Intersection Study - Algorithm[List]

ALGORITHM

LIST CIRCULAR LIST

Delete Case 1-2

CircularList

pLink pLink

first

pLink

second

pLink

last

Page 59: Intersection Study - Algorithm[List]

ALGORITHM

LIST CIRCULAR LIST

Delete Case 1-2

CircularList

pLink pLink

first

pLink

second

pLink

last

Page 60: Intersection Study - Algorithm[List]

ALGORITHM

LIST CIRCULAR LIST

Delete Case 1-2

CircularList

pLink pLink

first

pLink

second

pLink

last

NULL

Page 61: Intersection Study - Algorithm[List]

ALGORITHM

LIST CIRCULAR LIST

Delete Case 1-2

CircularList

pLink pLink

first

pLink

second

pLink

last

NULL

return

Page 62: Intersection Study - Algorithm[List]

ALGORITHM

LIST CIRCULAR LIST

Delete Case 1-3

CircularList

pLink pLink

position-1

pLink

position

pLink

position+1

……

Page 63: Intersection Study - Algorithm[List]

ALGORITHM

LIST CIRCULAR LIST

Delete Case 1-3

CircularList

pLink pLink

position-1

pLink

position

pLink

position+1

……

Page 64: Intersection Study - Algorithm[List]

ALGORITHM

LIST CIRCULAR LIST

Delete Case 1-3

CircularList

pLink pLink

position-1

pLink

position

pLink

position+1

……

NULL

Page 65: Intersection Study - Algorithm[List]

ALGORITHM

LIST CIRCULAR LIST

Delete Case 1-3

CircularList

pLink pLink

position-1

pLink

position

pLink

position+1

……

NULL

return

Page 66: Intersection Study - Algorithm[List]

Doubly Linked List

ALGORITHM

LIST Doubly Linked List

Doubly Linked List

Page 67: Intersection Study - Algorithm[List]

Doubly Linked List Node

자료(Data)

오른쪽 링크(Right Link)

왼쪽 링크(Left Link)

ALGORITHM

LIST Doubly Linked List

Page 68: Intersection Study - Algorithm[List]

Doubly Linked List

DoublyList

data

pRLink

Header Node

pLLink

ALGORITHM

LIST Doubly Linked List

Page 69: Intersection Study - Algorithm[List]

LinkedList

data

pRLink

Header Node

pRLink

position-1

pRLink

newNode

Insert Node

pRLink

position

pLLinkpLLink pLLink

pLLink

ALGORITHM

LIST Doubly Linked List

pRLink

last

pLLink

Page 70: Intersection Study - Algorithm[List]

LinkedList

data

pRLink

Header Node

pRLink

position-1

pRLink

newNode

Insert Node

pRLink

position

pLLinkpLLink pLLink

pLLink

ALGORITHM

LIST Doubly Linked List

pRLink

last

pLLink

Page 71: Intersection Study - Algorithm[List]

LinkedList

data

pRLink

Header Node

pRLink

position-1

pRLink

newNode

Insert Node

pRLink

position

pLLinkpLLink pLLink

pLLink

ALGORITHM

LIST Doubly Linked List

pRLink

last

pLLink

Page 72: Intersection Study - Algorithm[List]

LinkedList

data

pRLink

Header Node

pRLink

position-1

pRLink

newNode

Insert Node

pRLink

position

pLLinkpLLink pLLink

pLLink

ALGORITHM

LIST Doubly Linked List

pRLink

last

pLLink

Page 73: Intersection Study - Algorithm[List]

LinkedList

data

pRLink

Header Node

pRLink

position-1

pRLink

newNode

Insert Node

pRLink

position

pLLinkpLLink pLLink

pLLink

ALGORITHM

LIST Doubly Linked List

pRLink

last

pLLink

Page 74: Intersection Study - Algorithm[List]

LinkedList

data

pRLink

Header Node

pRLink

position-1

pRLink

newNode

Insert Node

pRLink

position

pLLinkpLLink pLLink

pLLink

ALGORITHM

LIST Doubly Linked List

pRLink

last

pLLink

Page 75: Intersection Study - Algorithm[List]

LinkedList

data

pRLink

Header Node

pRLink

position-1

pRLink

position

pRLink

position+1

pLLinkpLLink pLLink

pLLink

ALGORITHM

LIST Doubly Linked List

pRLink

last

pLLink

Delete Node

Page 76: Intersection Study - Algorithm[List]

LinkedList

data

pRLink

Header Node

pRLink

position-1

pRLink

position

pRLink

position+1

pLLinkpLLink pLLink

pLLink

ALGORITHM

LIST Doubly Linked List

pRLink

last

pLLink

Delete Node

Page 77: Intersection Study - Algorithm[List]

LinkedList

data

pRLink

Header Node

pRLink

position-1

pRLink

position

pRLink

position+1

pLLinkpLLink pLLink

pLLink

ALGORITHM

LIST Doubly Linked List

pRLink

last

pLLink

Delete Node

Page 78: Intersection Study - Algorithm[List]

LinkedList

data

pRLink

Header Node

pRLink

position-1

pRLink

position

pRLink

position+1

pLLinkpLLink pLLink

pLLink

ALGORITHM

LIST Doubly Linked List

pRLink

last

pLLink

Delete Node

Page 79: Intersection Study - Algorithm[List]

LinkedList

data

pRLink

Header Node

pRLink

position-1

pRLink

position

pRLink

position+1

pLLinkpLLink pLLink

pLLink

ALGORITHM

LIST Doubly Linked List

pRLink

last

pLLink

Delete Node

NULL

Page 80: Intersection Study - Algorithm[List]

LinkedList

data

pRLink

Header Node

pRLink

position-1

pRLink

position

pRLink

position+1

pLLinkpLLink pLLink

pLLink

ALGORITHM

LIST Doubly Linked List

pRLink

last

pLLink

Delete Node

NULL

return

Page 81: Intersection Study - Algorithm[List]

ALGORITHM

LIST END

THANK YOU