Dense List - PowerPoint PPT Presentation

Loading...

PPT – Dense List PowerPoint presentation | free to download - id: 6fcdef-NzNmM



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

Dense List

Description:

9. Dense List Linked List Applications * Doubly Linked List ... – PowerPoint PPT presentation

Number of Views:155
Avg rating:3.0/5.0
Slides: 37
Provided by: ying104
Category:
Tags: dense | doubly | link | linked | list

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: Dense List


1
9. ????????????????????????
  • Dense List
  • Linked List
  • Applications

2
?????????????????
  • ??????????
  • ??????????????????????? (Data Structure)
    ??????????
  • ???????????????????? (Algorithm)
    ??????????????????
  • Program Data Structure Algorithm

3
Data Structure
  • Linear
  • Array
  • Link List
  • Stack
  • Queue
  • Non-Linear
  • Tree
  • Graph

4
List
  • ??????????????????????????????????????????????????
    ??????????????????????????????????????????????????
    ??????????????????

5
List
  • ?????????????????????????? 2 ????
  • Array
  • Link List

2
count
1
3
4
25 31 42 58
4

25
31
42
58
6
????????????????? Array
  • ?????????????????????

Ex. newdata d
void insert (datatype newdata) position
search(newdata) ptr cur while (ptr gt
position) listptr1 listptr
ptr-- listposition newdata cur

a
b
position
d
e
e
g
t
cur
g
t
cur
7
????????????????? Array
  • ??????????????????

Ex. olddata e
void delete(datatype olddata) position
search(olddata) ptr position while
(ptr lt cur) listptr listptr1
ptr cur --
a
b
position
g
e
g
cur
t
t
cur
8
????????????????? Array
  1. ????????? Array ??????????????????????????????????
    ???????????????????? ???? ????????????????????????
    ???? 10,000 ??? ??????????????????? 2 byte
    ?????????????????????????????? 20,000 byte
    ??????????????????????????????????????????????????
    ???????????????????? 20,000 byte
    ?????????????????????????????
  2. ????????????????????????????????????? 10,000 ???
    ?????????????????????????????????????????
    ?????????????????? ??????????????? 2,000 ???
    ?????????????????????????????????
    ?????????????????????????????

9
????????????????? Array (???)
  1. ?????????????????????????????????? 10,000 ???
    ?????????????????????????????????????????? 10,000
    ??? ????????????????????????????????????
    ????????????????????? ???????????????

Address
100 data1
102 data2
104 data3
106 data4

10
????????? Linked list
  • ???????????????????????????????????????
    ????????????????????????????????
    ?????????????????? ????????????????????????
  • ???????????????????????????????????????????????

Address
100 data5
102
104 data1
106

11
Linked List
  • ??????????????????????????????????????????????????
    ????????????????????????????? 2 ???????
    ????????????????? (Data) ??? ?????????????????
    (Pointer)

1 ????
12
Linked List
  • ????????????????? (Data) ???????????????????? 1
    ?????? ??????????????
  • ????????????????? (pointer) ?????????????????
    (Address) ????????????????????????
  • ???????????????????
  • Singly Linked List
  • Doubly Linked List

13
Linked List
  • Singly Linked List ???????????????????????????????
    ?????????????????? ????????????????????
  • ???????????????????????? ?????????????????????????
    ????? NULL ????????????????

data pointer
data pointer
data pointer
14
Linked List
  • Doubly Linked List ????????????????? Data ???
    ?????????????????? 2 ?????? ??? ?????????????????
    ??????????????????????? ??????????????????????????
    ??????????? 2 ???? ??? ?????????????????
    ????????????????????

15
Linked List
  • Operation ??? Linked list
  • ??????????? (Insert) ?? list ?? 2 ???
  • ??????????????? list (Append)
  • ??????????????????? node
  • ?? (Delete) ???????????? list

16
Singly Linked List
  • ??????????????
  • head ???? address ????????????? list
  • last ???? address ????????????????? list
  • newnode ???? address ??????????????????????
  • data ??????????
  • next ???? address ????????????
  • ?????????? list ?????? ????
  • newnode -gt data ???????????????????????????
    newnode
  • newnode -gt next ?????????????? address
    ????????????? newnode

17
Singly Linked List
  • ????????????????

struct node int data
struct node next
newnode
18
Singly Linked List
  • ????????????????????? list (Append)
  • ????????
  • 1. ???????????? Insert 25


1.1 create newnode 1.2 newnode -gt data
25 1.3 newnode -gt next NULL 1.4 head
newnode last (?)
25
19
Singly Linked List
  • ????????????????????? list (Append)
  • ????????
  • 2. ???????????? 2 Insert 30


2.1 create newnode 2.2 newnode -gt data
30 2.3 newnode -gt next NULL 2.4 last- gt
next newnode 2.5 last newnode (?)
30
20
Singly Linked List
  • ????????????????????? list (Append)
  • ????????
  • 2. ???????????? 2 Insert 30

2.1 create newnode 2.2 newnode -gt data
30 2.3 newnode -gt next NULL 2.4 last- gt
next newnode 2.5 last newnode
21
Singly Linked List
  • ????????????????????? list (Append)
  • ????????
  • 3. ???????????? 3 Insert 42

3.1 create newnode 3.2 newnode -gt data
42 3.3 newnode -gt next NULL 3.4 last- gt
next newnode 3.5 last newnode ( ?)
30
42
22
Singly Linked List
  • ????????????????????? list (Append)
  • ????????
  • 3. ???????????? 3 Insert 12

2.1 create newnode 2.2 newnode -gt data
12 2.3 newnode -gt next NULL 2.4 last- gt
next newnode 2.5 last newnode ( ?)
30
12
23
Singly Linked List
  • ???????????????????????????????? (Insert)
  • ????????
  • 4. Insert 38 ?????????????? 2 ?????????? 3

4.1 create newnode 4.2 newnode -gt data 38
38
24
Singly Linked List
  • ???????????????????????????????? (Insert)
  • ????????
  • 4. Insert 38 ?????????????? 2 ?????????? 3 (???)

4.3 ??? ptr ???? address ?????????? 2 4.4
newnode -gt next ptr -gt next 4.5 ptr -gt next
newnode
38
25
Singly Linked List
  • ????????????? list (Delete)
  • ???????? Delete 25 ?????? list
  • ??????? head -gt data 25 ??????? ?
  • 2. ?????? ??? head head -gt next ( ?)

26
Singly Linked List
  • ????????????? list (Delete)
  • ???????? Delete 38 ?????? list
  • ??? ptr head
  • ptr -gt next -gt data 38?
  • ?????? ??? ptr -gt next ptr -gt next -gt next
  • ????????? ??? ptr ptr -gt next ????????????? 2.
    ????

27
Doubly Linked List
  • ??????????????
  • head ???? address ????????????? list
  • last ???? address ????????????????? list
  • newnode ???? address ??????????????????????
  • data ??????????
  • previous ???? address ???????????????
  • next ???? address ????????????

28
Doubly Linked List
  • ?????????? list ?????? ????
  • newnode -gt data ???????????????????????????
    newnode
  • newnode -gt previous ?????????????? address
    ??????????????? newnode
  • newnode -gt next ?????????????? address
    ????????????? newnode

29
Doubly Linked List
  • ????????????????

struct node int data
struct node next, previous
newnode
30
Doubly Linked List
  • ????????????????????? list (Append)
  • ????????
  • 1. ???????????? Insert 25

1.1 create newnode 1.2 newnode -gt data
25 1.3 newnode -gt previous NULL 1.4 newnode
-gt next NULL 1.5 head newnode last ( 100)
31
Doubly Linked List
  • ????????????????????? list (Append)
  • ????????
  • 2. ???????????? 2 Insert 30

2.1 create newnode 2.2 newnode -gt data
30 2.3 newnode -gt next NULL 2.4 newnode -gt
previous last 2.5 last- gt next
newnode 2.6 last newnode (200)
32
Doubly Linked List
  • ????????????????????? list (Append)
  • ????????
  • 3. ???????????? 3 Insert 42


25
3.1 create newnode 3.2 newnode -gt data
42 3.3 newnode -gt next NULL 3.4 newnode -gt
previous last 3.5 last- gt next
newnode 3.6 last newnode (300)
30
42
33
Doubly Linked List
  • ???????????????????????????????? (Insert)
  • ????????
  • 4. Insert 38 ?????????????? 2 ?????????? 3

4.1 create newnode 4.2 newnode -gt data 38
38
34
Doubly Linked List
  • ???????????????????????????????? (Insert)
  • ???????? 4. Insert 38 ?????????????? 2
    ?????????? 3 (???)


4.3 ??? ptr ???? address ?????????? 2 4.4
newnode -gt next ptr-gt next 4.5 newnode -gt
previous ptr-gt next -gt previous 4.6 ptr -gt
next newnode
38
42
35
Doubly Linked List
  • ????????????? list (Delete)
  • ???????? Delete 25 ?????? list
  • ??????? head -gt data 25 ??????? ?
  • 2. ?????? ??? head head -gt next ( ?)

42
38
36
Singly Linked List
  • ????????????? list (Delete)
  • ???????? Delete 38 ?????? list
  • ??? ptr head
  • ptr -gt next -gt data 38?
  • ?????? ??? ptr -gt next ptr -gt next -gt next
  • ????????? ??? ptr ptr -gt pointer ?????????????
    2. ????

42
38
37
Array vs Linked List
  • Array
  • ???????????
  • ??????????????????
  • Linked List
  • ??????????????
  • ???????????????

38
Motto Today ??????????????????????????
?????????????????????? ?????????????????????????
Practice makes Perfect !
About PowerShow.com