TP 3 - Manipulations sur les arbres >> Abre null << Arbre null : . Arbre null : _ Arbre null est vide ! Arbre null comporte 0 elements ! Arbre null a une hauteur de 0 ! b = a->sad->sad->sad->sad->sag s'il existe, et l'arbre vide sinon : => b n'est pas un sous arbre de a Arbre null est un ABR ! Arbre null est l'arbre vide donc un ABR ! Arbre null detruit : 0 noeuds liberes ! >> Arbre de Syracuse jusqu'a la profondeur 7 << Arbre de Syracuse : 1 . 2 . 4 . 8 . 16 5 . 10 3 . . 20 . . 32 . 64 21 . . 128 . . Arbre de Syracuse : 1(_, 2(_, 4(_, 8(_, 16(5(_, 10(3, 20)), 32(_, 64(21, 128))))))) Arbre de Syracuse n'est pas vide ! width_walker_printer : 1 2 4 8 16 5 32 10 64 3 20 21 128 depth_walker_printer : 1 2 4 8 16 5 10 3 20 32 64 21 128 infix_walker_printer : 1 2 4 8 5 3 10 20 16 32 21 64 128 Arbre de Syracuse comporte 13 elements ! Arbre de Syracuse a une hauteur de 8 ! b = a->sad->sad->sad->sad->sag s'il existe, et l'arbre vide sinon : => b est un sous arbre de a La branche [a, b] est : [a, b] : .->[1]->[2]->[4]->[8]->[16]->[5] | Arbre de Syracuse n'est pas un ABR ! Arbre de Syracuse n'est pas un ABR ! Arbre de Syracuse detruit : 13 noeuds liberes ! >> ABR parfait de profondeur 5 << ABR parfait : 1 2 4 8 16 32 . . 33 . . 17 34 . . 35 . . 9 18 36 . . 37 . . 19 38 . . 39 . . 5 10 20 40 . . 41 . . 21 42 . . 43 . . 11 22 44 . . 45 . . 23 46 . . 47 . . 3 6 12 24 48 . . 49 . . 25 50 . . 51 . . 13 26 52 . . 53 . . 27 54 . . 55 . . 7 14 28 56 . . 57 . . 29 58 . . 59 . . 15 30 60 . . 61 . . 31 62 . . 63 . . ABR parfait : 1(2(4(8(16(32, 33), 17(34, 35)), 9(18(36, 37), 19(38, 39))), 5(10(20(40, 41), 21(42, 43)), 11(22(44, 45), 23(46, 47)))), 3(6(12(24(48, 49), 25(50, 51)), 13(26(52, 53), 27(54, 55))), 7(14(28(56, 57), 29(58, 59)), 15(30(60, 61), 31(62, 63))))) ABR parfait n'est pas vide ! width_walker_printer : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 depth_walker_printer : 1 2 4 8 16 32 33 17 34 35 9 18 36 37 19 38 39 5 10 20 40 41 21 42 43 11 22 44 45 23 46 47 3 6 12 24 48 49 25 50 51 13 26 52 53 27 54 55 7 14 28 56 57 29 58 59 15 30 60 61 31 62 63 infix_walker_printer : 32 16 33 8 34 17 35 4 36 18 37 9 38 19 39 2 40 20 41 10 42 21 43 5 44 22 45 11 46 23 47 1 48 24 49 12 50 25 51 6 52 26 53 13 54 27 55 3 56 28 57 14 58 29 59 7 60 30 61 15 62 31 63 ABR parfait comporte 63 elements ! ABR parfait a une hauteur de 6 ! b = a->sad->sad->sad->sad->sag s'il existe, et l'arbre vide sinon : => b est un sous arbre de a La branche [a, b] est : [a, b] : .->[1]->[3]->[7]->[15]->[31]->[62] | ABR parfait n'est pas un ABR ! ABR parfait n'est pas un ABR ! ABR parfait detruit : 63 noeuds liberes !