???? - ?? C ?? 2 - PowerPoint PPT Presentation

1 / 83
About This Presentation
Title:

???? - ?? C ?? 2

Description:

Chapter 4 4.1 4.2 4.3 4.4 linked list ... – PowerPoint PPT presentation

Number of Views:52
Avg rating:3.0/5.0
Slides: 84
Provided by: v574
Category:
Tags: doubly | link | linked | list

less

Transcript and Presenter's Notes

Title: ???? - ?? C ?? 2


1
Chapter 4 ????
  • 4.1 ??????
  • 4.2 ????
  • 4.3 ??????
  • 4.4 ???????

2
  • ????
  • ????(linked list)??????????,?????????????????
  • ?????????????(single linked list)?????(circular
    linked list)???????(doubly linked
    list),?????????????????????????,???????????,??????
    ?????????????????

3
4.1 ??????
  • ??????????,????(insert)???(delete)????(node)??????
    ,???????a,b,d,e????,??c?????,????????,????d,e????,
    ???c????????,??????????????,?????????????????????
    ??????(linked list)?

4
4.1 ??????
  • ????????????????????,????????(pointer)???????
  • ???????????(node)????????,?????(data)????(next)?
    ,?????????struct node ??,?????

5
4.1 ??????
  • ??? Aa, b, c, d,???????
  • head?????????,????????data??????????,????????????
    ??

6
4.1 ??????
  • 4.1.1 ????
  • 1.????????????????

7
4.1 ??????
  • ????x?????????,?????
  • x(struct node) malloc(sizeof(struct node))

8
4.1 ??????
  • (x-gtnexthead-gtnext / /

?
9
4.1 ??????
  • head-gtnextx / /

?
10
4.1 ??????
  • 2.????????????????

11
4.1 ??????
  • ????x????????,?????
  • x(struct node )malloc(sizeof(struct node))
  • x-gtnextNULL

12
4.1 ??????
  • ???????????????,???????????????????

13
4.1 ??????
  • p-gtnextx

14
4.1 ??????
  • ????????????????????????,?data??????????

15
4.1 ??????
  • ?????ptr?data????75,????????????????????????,????7
    5????80?70??,??????????????

16
4.1 ??????
  • ??prev?current???????,prev????current????

17
4.1 ??????
  • ?????????ptr??????prev??? ptr-gtnextcurrent
    / ? / prev-gtnextptr / ? /

?
?
18
4.1 ??????
  • 4.1.2 ????
  • ?????????????????

19
4.1 ??????
  • ????????????
  • phead-gtnext
  • head-gtnextp-gtnext

20
4.1 ??????
  • free(p) ??free(p)???p?????

21
4.1 ??????
  • ?????????????????

22
4.1 ??????
  • ???????????????? ?????,????
  • phead-gtnext

23
4.1 ??????
  • prev-gtnextNULL
  • free(p)

24
4.1 ??????
  • ?????????????????????????
    ??current?prev,??????? ????(current)?????
    (prev),??prev????current?
  • ????????????

25
4.1 ??????
  • ????Mary???del_data?????Mary,??????????????cur
    rent????Mary???,?prev??John??,??current???????
    ?

26
4.1 ??????
?
27
4.1 ??????
  • 4.1.3 ?????????????
  • ?????????

28
4.1 ??????
  • ?x?y?????z??,?????
  • if(x-gtnextNULL)zy
  • if(y-gtnext NULL)zx
  • zxcx-gtnext

29
4.1 ??????
30
4.1 ??????
  • 4.1.4 ??????
  • ????,?????(invert)?????????????,??,???????????????
    ???????,??????????,??????????

31
4.1 ??????
  • ????????

32
4.1 ??????
  • ?????????????????
  • phead-gtnext
  • currentNULL

33
4.1 ??????
  • while(p ! NULL) prevcurrent currentp
    pp-gtnext current-gtnextprev

34
4.1 ??????
  • ??????????p??,current???prev????????????????,????

35
4.1 ??????
  • ?????p NULL?,????

36
4.1 ??????
  • ??,??head-gtnextcurrent
  • ??????????????????????????????

37
4.1 ??????
  • 4.1.5 ???????
  • ???????????????,???????????????

38
4.1 ??????
  • ???????????????? (p ! NULL)
  • ????count?????????head?????????,????????

39
4.2 ????
  • ??????????????????head???,?????????(circular
    list),?????
  • ?????????????????????????????x1?

40
4.2 ????
  • 4.2.1 ????
  • ?????????????????????????
  • ??malloc?????????

41
4.2 ????
  • ?????????x????????????????

42
4.2 ????
  • ??(1)(2)???????????????????

43
4.2 ????
  • ?????????????

44
4.2 ????
  • ??????????????????,???????????

45
4.2 ????
  • 4.2.2 ?????
  • ??????????????????

46
4.2 ????
  • ???????????????
  • ??p??????,?????????????

47
4.2 ????
  • ?????????????????

48
4.2 ????
  • ?????????????????

49
4.2 ????
  • ????????????????????,???????

50
4.2 ????
  • 4.2.3 ??????????
  • ???????????????????,?????????,??????????

51
4.2 ????
  • ???????????
  • ?????????????????????

52
4.2 ????
  • ?????????????????????,??????????,???Big-O?O(n),???
    ?????????,??????????Big-O?O(1),???????,????????,??
    ???????????????

53
4.2 ????
  • ???free(q)???????????AV????

54
4.2 ????
  • 4.2.4 ?????????
  • ?????????,????????????????????

55
4.3 ??????
  • ??????(doubly linked list)?????????????,
  • ?????(LLINK)
  • ????(DATA)
  • ?????(RLINK)
  • ???????

56
4.3 ??????
  • ??LLINK??????,?RLINK????????
  • ????????????????,???????????????????

57
4.3 ??????
  • ??????????????
  • ??ptr??????????,?ptr ptr-gtllink-gtrlink
    ptr-gtrlink-gtllink
  • ?????????????,?????????

58
4.3 ??????
  • 4.3.1 ????
  • ?????????????????????????

59
4.3 ??????
  • ???????????????x??????

60
4.3 ??????
61
4.3 ??????
  • ????????????????????????

62
4.3 ??????
  • ???????????????x???????

63
4.3 ??????
64
4.3 ??????
  • ????(2), (3)????????

65
4.3 ??????
  • ???????????????????????,????????????,???????????
    ??????(??????)

66
4.3 ??????
67
4.3 ??????
68
4.3 ??????
  • 4.3.2 ????
  • ???????????,????

69
4.3 ??????
70
4.3 ??????
  • ???????????,?????????????

71
4.3 ??????
72
4.3 ??????
  • ????????????????
  • ???del_dat?cd,???????

73
4.3 ??????
  • ??current????????,?prev???current??????

74
4.3 ??????
75
4.4 ???????
  • 4.4.1 ?????????
  • ?????????????????,??,?????????????????????,???????
    ????????????????????

76
4.4 ???????
  • 4.4.2 ?????????
  • ???????????????,????????????????????,?????????????

77
4.4 ???????
  • 4.4.3 ?????
  • ??????????????????????????????,???????
  • COEF???????,EXP???????,?LINK???????????

78
4.4 ???????
  • ??????? A3x142x81,???????

79
4.4 ???????
  • ???????????????
  • A3x142x81 B8x14-3x1010x6

80
4.4 ???????
  • ??A?B??????????EXP???(EXP(p) EXP(q)),???????C??,
    ??p?q???????????

81
4.4 ???????
  • EXP(p)8ltEXP(q)10????B???????????C???,??q????????
    ??

82
4.4 ???????
  • ??EXP(p)8gtEXP(q)6,???A???????????C???,p?????????
    ?

83
4.4 ???????
  • ??????C????
  • C11x14-3x102x810x61
Write a Comment
User Comments (0)
About PowerShow.com