From 1d5030c74f1f57e2a61595aef1fbaabb85f11d0c Mon Sep 17 00:00:00 2001 From: sayebabu Date: Wed, 6 Dec 2023 15:32:22 +0100 Subject: [PATCH] tp dev --- .../Arbre/ABR/src/ArbreBinaireRecherche.class | Bin 0 -> 1723 bytes .../Arbre/ABR/src/ArbreBinaireRecherche.java | 48 ++++++++++++++++++ DEV3.2/Arbre/ABR/src/Main.class | Bin 0 -> 1201 bytes DEV3.2/Arbre/ABR/src/Main.java | 14 +++++ DEV3.2/Arbre/ABR/src/Noeud.class | Bin 0 -> 439 bytes DEV3.2/Arbre/ABR/src/Noeud.java | 13 +++++ 6 files changed, 75 insertions(+) create mode 100644 DEV3.2/Arbre/ABR/src/ArbreBinaireRecherche.class create mode 100644 DEV3.2/Arbre/ABR/src/ArbreBinaireRecherche.java create mode 100644 DEV3.2/Arbre/ABR/src/Main.class create mode 100644 DEV3.2/Arbre/ABR/src/Main.java create mode 100644 DEV3.2/Arbre/ABR/src/Noeud.class create mode 100644 DEV3.2/Arbre/ABR/src/Noeud.java diff --git a/DEV3.2/Arbre/ABR/src/ArbreBinaireRecherche.class b/DEV3.2/Arbre/ABR/src/ArbreBinaireRecherche.class new file mode 100644 index 0000000000000000000000000000000000000000..dabbd70b9e1a00d4d81a55dbfb282c9263fa2814 GIT binary patch literal 1723 zcmaJ>TXWk)7(E+bWV_1E&ZTXV)`^qG7l;d#TU^>EE};e|DRt^n%FEhb+iDcaBdr5@ z=ST3&Fw@t-6qhM8Ji-h=is4&HA@(%GgI2qrzCGVLXFu)V|GfSKz&(7Ez!*Xr!a5>| zGE6<^$Gm8At5e)>JQq#L5WQ_!hP=ZN%I4}CVhoWzTl8BABydTCu45b%4AbX3E0z=; z;V@{&-0X|}Hp5)DlB>RvQA$9=lqx-~QZ7iy)#FHEM#HR*Im|Q6ZaED{Y#SCg9Pvmr zyTYM|A?(;Tk=3dmHv&%KijJ#TV7SCvEz0aWu0c$uvq1_GI?L6tq~jW{GsHVW*10MA z#Gdq4;zV#+$BHT)Hbq;iz^aZl6^J-Sr%RD_WHsb;qG)di4(s3J~Fw7tELs7P^CYMhP*`=8)xg}jyZRFI0dJ5&PPR&PrBObFDwi!SU zQ+}OZWxGX3I$1R=vDZIp2DCVt}9#(Uoot`q3t5d8op+@_W!ALfB5>aOieaM zZ9^xmeq|apnnzHk@jk6?A?$sh$-e^2{|@cx!f%Mb!sM?={_O4hl*S2!XpB&9l<<6n zXn?RpZ-pLF2xE2 za~qNb54z=IxK2gV1iegK>7NgP9@9#RUM>8I6;Fi^qJ+K1CNRJq70ystq59P4=qzXt zVXu*0H^``UWRUadhQKleUcu)<3FV^V8cJ>{@yrwNAI}Ea`h|yD#V);L^mUJ(1Jr4i MpxF~V#WP&_7em{6SpWb4 literal 0 HcmV?d00001 diff --git a/DEV3.2/Arbre/ABR/src/ArbreBinaireRecherche.java b/DEV3.2/Arbre/ABR/src/ArbreBinaireRecherche.java new file mode 100644 index 0000000..0732fbe --- /dev/null +++ b/DEV3.2/Arbre/ABR/src/ArbreBinaireRecherche.java @@ -0,0 +1,48 @@ +public class ArbreBinaireRecherche { + + Noeud root; + + public ArbreBinaireRecherche(int valeur) { + this.root = new Noeud(valeur); + } + + public ArbreBinaireRecherche() {} + + public void add(int val) { + root = addRecursif(root, val); + } + + public Noeud addRecursif(Noeud current, int val) { + if (current == null) { + return new Noeud(val); + } + if (val < current.getValeur()) { + current.left = addRecursif(current.left, val); + } else if (val > current.getValeur()) { + current.right = addRecursif(current.right, val); + } else { + return current; + } + return current; + } + + public void show() { + System.out.println("Affichage de l'arbre binaire de recherche (ordre infixe) :"); + afficherInfixe(root); + System.out.println(); + } + + private void afficherInfixe(Noeud current) { + if (current != null) { + afficherInfixe(current.left); + System.out.print(current.getValeur() + " "); + afficherInfixe(current.right); + } + } + + public String toString() + { + + return ""; + } +} \ No newline at end of file diff --git a/DEV3.2/Arbre/ABR/src/Main.class b/DEV3.2/Arbre/ABR/src/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..223c5d155ba2b9d3a316f086c7847007e7ea99c9 GIT binary patch literal 1201 zcmaJ>-A)rh6#j;8Sy&hOvlLKZLD05fE9FO|iVA^9(yFnDFKCt67_`KC5PE{R0+*DWw&GRfZ z>ndM)yj~D$+pYMWt(Z2D#f*;GV0v>5;}>O1XV0yQOk+@ufv)kga=m?qFPB?<4s1Am z$(@QV{PDc&R(I=7=6k8SD~22Uby2;AsI1?kKJIXg5TZ5sjvf!M+j0aG%yd9q{c)AW1ZU zeuYMIU@dhTJwW_B^i(8E?+H49BXl1k{S)yI#~8?`3R9;`k$Ekq4IQ9=DyC%@qmu*C z9~eA>^;u(wXTO73En%!-=)_0Jw}wIbFN{&tc^G&`bd`LkNIQba;29m6sE$b;aatKA hct&_ed}#h4beKklXd9*ckiK~=(9R(4F>-i{fxpDhE-nB7 literal 0 HcmV?d00001 diff --git a/DEV3.2/Arbre/ABR/src/Main.java b/DEV3.2/Arbre/ABR/src/Main.java new file mode 100644 index 0000000..73de375 --- /dev/null +++ b/DEV3.2/Arbre/ABR/src/Main.java @@ -0,0 +1,14 @@ +public class Main { + public static void main(String[] args) { + if (args.length < 2) { + System.out.println("Utilisation incorecte: "+args[0]+" arg1 arg2 ...\nExemple: "+args[0]+" 1 4 5 3 8"); + } + else + { + ArbreBinaireRecherche arbre = new ArbreBinaireRecherche(); + for (String string : args) { + arbre.add(Integer.parseInt(string)); + } + } + } +} diff --git a/DEV3.2/Arbre/ABR/src/Noeud.class b/DEV3.2/Arbre/ABR/src/Noeud.class new file mode 100644 index 0000000000000000000000000000000000000000..fe6bf1200270fda8f1400331255747d7a0f952c6 GIT binary patch literal 439 zcmZut%Syvg5Ir|(^J?1kq4h1gYa`f&%ZdnsP$+ewWS_Lxn3ARtl75vN!78}$1Ne&qoQDyu1|~QIHq-lf1~ozKM~l1T}Ix_sDKA!o4CX5jCrAV+*b%!tf9Ln wYt)}e3G5Qvs1U0}6(%$^ptG`v?)QKrMnQ$)KBNAE*5gm7R`NCCJ~;&kU(}LKBLDyZ literal 0 HcmV?d00001 diff --git a/DEV3.2/Arbre/ABR/src/Noeud.java b/DEV3.2/Arbre/ABR/src/Noeud.java new file mode 100644 index 0000000..a615290 --- /dev/null +++ b/DEV3.2/Arbre/ABR/src/Noeud.java @@ -0,0 +1,13 @@ +public class Noeud { + Integer valeur; + Noeud left, right = null; + + public Noeud(Integer etiquette) { + this.valeur = etiquette; + } + + public int getValeur() + { + return valeur; + } +}