??(Heap Tree) - PowerPoint PPT Presentation

1 / 67
About This Presentation
Title:

??(Heap Tree)

Description:

(Heap Tree) (Heap) Heap Max ... – PowerPoint PPT presentation

Number of Views:68
Avg rating:3.0/5.0
Slides: 68
Provided by: CMH90
Category:
Tags: heap | sort | tree

less

Transcript and Presenter's Notes

Title: ??(Heap Tree)


1
??(Heap Tree)
???????
2
????
  1. ??(Heap)???????????,????????
  2. Heap?????????Max-heap, Min-heap, Min-max
    heap?Deap?
  3. Heap???????,???Heap sort(????)?

3
Definition
  1. ??? ( max  tree ) ????,????????????????? ( ??????
    ) ????
  2. ???? ( max heap ) ???????????????
  3. ??? ( min  tree ) ????,????????????????? ( ??????
    ) ???? ???? ( min heap ) ???????????????

4
????

5
????
6
????
  • ????Heap,?????????????????????
  • ??????,????????????,?????????
  • ,??,????????????????

7
????
8
????
  • ?????????????,????????????,???????????????,???2
    3?30?30??,??15?30???????????,??????????,??????????

9
????
  • ??Heap????,????????????????????????,???????????
    ,????????,?????????????

10
?????????
  • ?????????????
  • ???
  • ???
  • ??????????????,???????
  • ?????,??????????????
  • Heap???????,???Heap sort(????)?

11
?????????
  • ???????????,??????????
  • ??????
  • ???????

12
?????? (ReheapUp)
  1. ????????????N???,??N-1?????????????,????????????
  2. ????,???????????,?????????????
  3. ?????? (ReheapUp),???????????,??????????,?????????
  4. ?9-4???????,????????????,??????????????????,??????
    ???,??????????????

13
?????? (ReheapUp)
  • ?????????
  • ?????????????,????????????1?(???)??,??9-4???
  • ?????????????,???????????,?????????
  • ????????-?????????,??????????????
  • ?????? (ReheapUp) ?????????????,??????????,???????
    ???

14
? 9-4 ????????
15
?????? (ReheapUp)
  • ?9-5??ReheapUp???
  • ???25????12???????????????25?12???
  • ????25????????21,????????
  • ????????25???????42,?????????,???????

16
? 9-5 ????????
17
?????? (ReheapDown)
  • ?????? (ReheapDown)
  • ??????????,???????,???????????
  • ???????????,????????
  • ????????,???????????????????,???????????
  • ?????? (ReheapDown) ????????,?????????????
  • ??????,??????????,?????????????????
  • ????????????(ReHeapDown),??9-6???

18
? 9-6 ?????????
19
?????? (ReheapDown)
  1. ?9-7??????????????
  2. ???,???10?????,?????????,?????????32,????? ???
  3. ?9-7(b) ?????????,?????????????????,??10?????,????
    10???????30????
  4. ??,??????,?????????

20
? 9-7 ??????
21
Heap???
22
Heap???
??30?50? ?????????????30???, ???
23
Heap???
  • ????50?????Heap,?????????
  • ????????Heap,??,??????????????????

24
Heap???
  • Heap????????????????????????,?????????Heap,??,?
    ?????????????

25
Heap???
26
Heap???
27
Heap???
  • ???40,??10????

28
????
  • ????,???Heap??

29
????
  • ???40??,??15??40(??15??????????????)

30
????
  • ???15????????????,??15?35(?????30)??,???15?35??
    ?

31
??min-heap
  • ?????Heap,?????max-heap,?max-heap?????,???????,
    ?????????????????min-heap???????,????????????,??ma
    x-heap??,???????min-heap????

32
??min-heap
  • ????????????max-heap????,??????????

33
min-max heap
  • min-max heap???min-heap?max-heap??Heap???

34
min-max heap
35
min-max heap
  • ??min-max heap
  • ??????,??????????,???min-max heap,??????????
  • 1.min-max heap????min-heap,??max-heap??????
  • 2.???min-heap???,????min-heap????
  • 3.???max-heap???,???? max-heap????

36
min-max heap???
min-max heap????max-heap??????,?????,????????min-
max heap????
37
min-max heap???
38
min-max heap???
  • ???5,????

39
min-max heap???
  • ???18gt5,????????,?5?18???

40
min-max heap???
  • ???,??10gt5,????????,?5?10???

?????min-max heap???,???????
41
min-max heap???
  • ???min-max heap???????,?????????,???????????????
    ?????,??????,????????????????????????min-max
    heap??

42
min-max heap???
43
min-max heap???
44
min-max heap???
  • ???45,??????

45
min-max heap???
  • ???40,????????????18??40?

46
min-max heap???
  • ???18lt19,????????,?18?19???

47
min-max heap???
  • ???,??19??32?28?34?31,????????,???19??????34???

??min-max heap???,???????
48
Deap
  • Deap?????max-heap?min-heap???,?????
  • 1.Deap??????????,??????
  • 2.??????,???min-heap?????max-heap?
  • 3.min-heap?max-heap?????,???????????i,????????????
    j?i??,?i??????j?

49
Deap
50
Deap
51
Deap???
Deap????????Heap??,??????????????,?????Deap????
52
Deap???
  • ??????deap??

53
Deap???
  • ???25,??????????max-heap,????????15????????????
    ??25,??deap???,???????

54
Deap???
  • ??17,??????????

55
Deap???
  • ???????max-heap,?17???????????20,??17?20???

56
Deap???
  • ??40,????

57
Deap???
  • ????????min-heap,?40???????25(???40????????????
    ),???deap???,??40?25??,????

58
Deap???
  • ?????????????max-heap,???????max-heap???

59
Deap???
  • Deap????????Heap??,???????????????,????????????
    ?????,??????deap????

60
Deap???
61
Deap???
62
Deap???
  • ???29,???????,???????

63
Deap???
  • ??21,?????????22???,??????????,?????????min-hea
    p,?????22???????32,??????????????

64
Deap???
65
Deap???
  • ??12,???????27???

66
Deap???
  • ??????min-heap???,?27?????????16???

67
Deap???
  • ??16?????30??16??30,??27???????max-heap???30,?
    ???????
Write a Comment
User Comments (0)
About PowerShow.com