From 731020a934d9353f528f1bba1ee24dd9083e901d Mon Sep 17 00:00:00 2001 From: Felix-Vimalaratnam Date: Wed, 4 Dec 2024 15:49:35 +0100 Subject: [PATCH] fin de arbre suite --- DEV3.2/Files/chaine/LinkedQueue$Node.class | Bin 0 -> 544 bytes DEV3.2/Files/tableau/Arithmetique.class | Bin 0 -> 2278 bytes DEV3.2/Files/tableau/Arithmetique.java | 56 +++++++ DEV3.2/Files/tableau/File.class | Bin 0 -> 315 bytes DEV3.2/Files/tableau/File.java | 6 + DEV3.2/Files/tableau/FileTableau.class | Bin 0 -> 1087 bytes DEV3.2/Files/tableau/FileTableau.java | 41 +++++ .../auth_API/Authentification.class | Bin 0 -> 2957 bytes .../auth_API/Authentification.java | 87 +++++++++++ .../auth_sans_API/Authentification.class | Bin 0 -> 3525 bytes .../auth_sans_API/Authentification.java | 140 ++++++++++++++++++ .../Authentification/auth_sans_API/Node.class | Bin 0 -> 365 bytes .../Authentification/auth_sans_API/Node.java | 11 ++ DEV3.2/arbre_suite/Tri/BinarySearchTree.class | Bin 0 -> 2394 bytes DEV3.2/arbre_suite/Tri/BinarySearchTree.java | 67 +++++++++ DEV3.2/arbre_suite/Tri/Node.class | Bin 0 -> 272 bytes DEV3.2/arbre_suite/Tri/Node.java | 9 ++ 17 files changed, 417 insertions(+) create mode 100644 DEV3.2/Files/chaine/LinkedQueue$Node.class create mode 100644 DEV3.2/Files/tableau/Arithmetique.class create mode 100644 DEV3.2/Files/tableau/Arithmetique.java create mode 100644 DEV3.2/Files/tableau/File.class create mode 100644 DEV3.2/Files/tableau/File.java create mode 100644 DEV3.2/Files/tableau/FileTableau.class create mode 100644 DEV3.2/Files/tableau/FileTableau.java create mode 100644 DEV3.2/arbre_suite/Authentification/auth_API/Authentification.class create mode 100644 DEV3.2/arbre_suite/Authentification/auth_API/Authentification.java create mode 100644 DEV3.2/arbre_suite/Authentification/auth_sans_API/Authentification.class create mode 100644 DEV3.2/arbre_suite/Authentification/auth_sans_API/Authentification.java create mode 100644 DEV3.2/arbre_suite/Authentification/auth_sans_API/Node.class create mode 100644 DEV3.2/arbre_suite/Authentification/auth_sans_API/Node.java create mode 100644 DEV3.2/arbre_suite/Tri/BinarySearchTree.class create mode 100644 DEV3.2/arbre_suite/Tri/BinarySearchTree.java create mode 100644 DEV3.2/arbre_suite/Tri/Node.class create mode 100644 DEV3.2/arbre_suite/Tri/Node.java diff --git a/DEV3.2/Files/chaine/LinkedQueue$Node.class b/DEV3.2/Files/chaine/LinkedQueue$Node.class new file mode 100644 index 0000000000000000000000000000000000000000..0c53952b6aa3cc662d50b2b0260eb4d31945b8c9 GIT binary patch literal 544 zcmX^0Z`VEs1_mbv1uh0A24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00SP6iGJPId+^9tLg(9!3TMpUk}M)Re%|)Y4QHzxlsEGaEYWn^FuakXY-5cfe>W)tFS zZD-BMAgY0Bk7gJn1B)}*J^VhId8vM-xk;%-A&E&jsf-M48X>OMAQc)mu2z_O?J$KH z8MuP;ON)|I-7-N2Ap2Sm z{94-?7`3#wGO%kgZe`%z$iTqB$RNhRz#zoH!oa}5!@$D8%fQLN$H2$H4>ekxfd$Hv eV2}h`CdD8Prezr97#JA17#JBi7-Sga8Mpv3Z*Ktr literal 0 HcmV?d00001 diff --git a/DEV3.2/Files/tableau/Arithmetique.class b/DEV3.2/Files/tableau/Arithmetique.class new file mode 100644 index 0000000000000000000000000000000000000000..425fcb84ab7dfeea61ca9a5a3998d07e651a871b GIT binary patch literal 2278 zcmX^0Z`VEs1_mdFGA;%t24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00SP6iGJPId+^9tLg(9u(!lmBl5gxr_|V`K2X{45B_@gEI5=1Bx>9N`gy@ zQWJBnIT-jD863h=OEYtFQmYiw@=J^IGK&;S^HLR3D+-EIi;FY!^Au9^6!P**5=%hr zg8ZEPyu{4nRE5mEvecsD!z)wuxEKT&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!elYO~XcVcG<=4W7LNM>MQU}8vNNM&GP;A3E7 c$YNk*NCT4@3 queue = new FileTableau<>(); + + try { + for (String token : args) { + switch (token) { + case "+": + // Addition + queue.ajouter(queue.retirer() + queue.retirer()); + break; + case "-": + // Soustraction (attention à l'ordre) + int b = queue.retirer(); + int a = queue.retirer(); + queue.ajouter(a - b); + break; + case "x": + // Multiplication + queue.ajouter(queue.retirer() * queue.retirer()); + break; + case "/": + // Division (attention à l'ordre) + b = queue.retirer(); + a = queue.retirer(); + if (b == 0) { + throw new ArithmeticException("Division par zéro"); + } + queue.ajouter(a / b); + break; + default: + // Si ce n'est pas un opérateur, alors c'est un nombre + queue.ajouter(Integer.parseInt(token)); + break; + } + } + + // Le résultat final doit être le seul élément restant dans la file + if (queue.taille() == 1) { + System.out.println("= " + queue.retirer()); + } else { + System.out.println("Erreur : Expression incorrecte."); + } + + } catch (Exception e) { + System.out.println("Erreur lors de l'évaluation de l'expression : " + e.getMessage()); + } + } +} \ No newline at end of file diff --git a/DEV3.2/Files/tableau/File.class b/DEV3.2/Files/tableau/File.class new file mode 100644 index 0000000000000000000000000000000000000000..42ef4dde2fc5e5f71dde74412cf4456c348f9a81 GIT binary patch literal 315 zcmX^0Z`VEs1_mbvVRi;4Mg|tQ%$!tq1{OvJfvm)`ME#t^ymWp4q^#8B5=I90#H{?% zlGGwb22l+kbZKkNFh&N>;LP;A#FEmYR7M6ijSyF`AbU}2NoEm9n}~)crandnRt?P% zS8GNFwvxomoSalf24)RSPeumz)Z&t`%oGSeijhIX#?=Z_yB($wBLi1(erZv1D#$a8 z44fcJ59D4pMg~R(W(E*oVPRxoWng1qWMF4tU|?e4U}0q7WZ;7Hxmg$)co=vYKtaLB QzzV!Z literal 0 HcmV?d00001 diff --git a/DEV3.2/Files/tableau/File.java b/DEV3.2/Files/tableau/File.java new file mode 100644 index 0000000..f0452b1 --- /dev/null +++ b/DEV3.2/Files/tableau/File.java @@ -0,0 +1,6 @@ +public interface File { + void ajouter(E element); // Ajoute un élément en fin de la file + E retirer(); // Retire et retourne l'élément en tête de la file + int taille(); // Retourne la taille de la file + boolean estVide(); // Vérifie si la file est vide +} \ No newline at end of file diff --git a/DEV3.2/Files/tableau/FileTableau.class b/DEV3.2/Files/tableau/FileTableau.class new file mode 100644 index 0000000000000000000000000000000000000000..7b9c119033f020dbf9f792c1be7b5c56b2b038f9 GIT binary patch literal 1087 zcmX^0Z`VEs1_mbvGcE=u24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00SP6iGJPId+^9tLg(9!3Ukx6GW>ki?{%)WlLo2DXyK%$%H5Mg~StkUBmd z27Ztt)|Aww(h`t}AP<8ONQ5~pGY`ZU;b9PE5MyNENX<#jP0cGQW@HeK_Ca@oH5UU1 zg9HzQB!d(q1AA(5Nmyn|D%d$u>4`bPC5a`et`*6t1tppJc^nLK zj0^%ki3(|%IjIV%#U%=5nJKAU4AKk=AYUsoGKgv*SsGkYl$n=qtr^D7pv=g?0`egv zgP^lxfTOc#h--~}3ULNS1`Y-$21W)Y237_s1{DS#21W)| z1_lNu1~mpIP{cAYGN^<38VpRJ^a5t{Gw^_EAu!F#zz9ls42%q#3=9mOVDlIlWVN<4 zFlsSxWnc#pydXkAOF(2V1JhOp;f)Lo42%p~3=9lX3~USx44e!s3@i+s46F=%3~UU- z3|tH{4BQNi4B8Aj3`}5Sof()Jm>3usKkYMd0j%b}9{>OV literal 0 HcmV?d00001 diff --git a/DEV3.2/Files/tableau/FileTableau.java b/DEV3.2/Files/tableau/FileTableau.java new file mode 100644 index 0000000..ff237f8 --- /dev/null +++ b/DEV3.2/Files/tableau/FileTableau.java @@ -0,0 +1,41 @@ +public class FileTableau implements File { + private static final int CAPACITE_INITIALE = 20; + private E[] elements; + private int taille = 0; + private int debut = 0; + private int fin = 0; + + @SuppressWarnings("unchecked") + public FileTableau() { + elements = (E[]) new Object[CAPACITE_INITIALE]; // Création du tableau initial + } + + @Override + public void ajouter(E element) { + elements[fin] = element; + fin = (fin + 1); + taille++; + } + + @Override + public E retirer() { + if (estVide()) { + throw new IllegalStateException("La file est vide"); + } + E element = elements[debut]; + elements[debut] = null; // Supprime la référence pour éviter les fuites de mémoire + debut = (debut + 1); + taille--; + return element; + } + + @Override + public int taille() { + return taille; + } + + @Override + public boolean estVide() { + return taille == 0; + } +} \ No newline at end of file diff --git a/DEV3.2/arbre_suite/Authentification/auth_API/Authentification.class b/DEV3.2/arbre_suite/Authentification/auth_API/Authentification.class new file mode 100644 index 0000000000000000000000000000000000000000..702cc0b587cd3091c33d5846a19f4d37c5e3a331 GIT binary patch literal 2957 zcmX^0Z`VEs1_mdFIa~}(49x5dEIbUX3~Y=H0$GV=iTXK-dFlH8Nm;4MC5#MgHko;u zC3cJq%o>_u>vW@O+_&d)1J%*-qHPOW5Q z5Y>PvM{JmDp&B(x!ms(NclbM&w$RMJD>~&~F za4`5XGB7HDeB{r=5Wo<~$iP}$kds-$$e<3j89C}TqahAP76a)G=3xi{S;t+H?~`Ai zTI8HqoC*>T<6#JAh+t&k$Ve>CaL!Lj1!pTy4u&X32Ij<+6b^(^D0! z6cSTX6l_4*F)uMU)lR{tAhEc(JijQ#4rECN4?`v>__!eH24oKhLpCFW7)*CcY7UZa zkd|B?hCGnFctB1D<@)5rl2i_c0!9WUm?n@6k}f1WIT(r<88{tF6^c^J@-vG-@m0dZ zPzoxLSd(+|i&Hrm${88Nobz*Y6Z2A174q`)6pB)l^YijbQ}q}bID<3O^Abx+i&7aG zEFoS;E}U#2Lda2sDPm{M$iM=L5Pned@GH$tN-YXWOv*`RWZ(@hNlec6O)P-&S#lFW ziB(JkOYDQn$Oc9RVJuRN3|ztarA5i9ZkZrcMbQgLJy5~H$ROa9pI=g3Qj}QWn_7~Q zpHj@h(8|al7g~~;lUbZtl3H4%pv0)8kXn&hT#~Aga(HFd;RSje4DE~z;^=A;v+_$z z4zJ{3=)@vflv{jkEt8p7mYetvdo0dlDbF$h@%MPo>1K`OE&R5@~FVJQ}&MmQ(t@45}D@!sb+VhFOdZa`=@pGO$7X#h}Q*&A`OKz`)4B1gcXR7#S)U z7#NrsDj8TA7(o>_10zEf0|SEr12Y370|SGA)^-L)t=$alk=q$Kw=!^T1naG4U|`^5 zU}j)o;9y{3;AG%u;9_6|l_F5x$qdY3SwpQY3|!jV7zAcA2yJ2z(cZ-%#lWzQL2fyN zBv?jg8-q$XL_z~B0WzM60c5-w11s1PZU%k^DF#6X6$T*&0|pU>8U_Xi76v9MQ3gg( zi2}7Slz|ECEp@Q5+ZZ&D!7S7To4cHWA7YIjn2WFmRH-m9NHB0SNHRz`#0}Mtw+ZasXzBC8h0=Lux%tg0UkwKP0i9v@! zg~5VB4Q8nhHv=a_Ekhl|QpOJqEDY=n42<@>8Mq_2Gg$iUX0VFf#9*_X!NGSEgNTsx zHU?LnZ44fMxeLyaWM zKDGr6LfVonEJl(ntVY`y5|=Y1g1nLnP8VU4Ec;j&Fz|sDY-31Y&fo%)%mPbVV(QLW z&Y%oZkPlWM0b&+zW02F?#!$Qw#3=)b|GN%O users; + + public Authentification() { + users = new HashMap<>(); + } + + // Ajout d'un utilisateur + public void addUser(String username, String password) { + if (users.containsKey(username)) { + System.out.println("Utilisateur \"" + username + "\" existe déjà."); + } else { + users.put(username, password); + System.out.println("Utilisateur \"" + username + "\" ajouté"); + } + } + + // Suppression d'un utilisateur + public void removeUser(String username) { + if (users.remove(username) != null) { + System.out.println("Utilisateur \"" + username + "\" retiré"); + } else { + System.out.println("Utilisateur \"" + username + "\" non trouvé."); + } + } + + // Authentification d'un utilisateur + public void authenticate(String username, String password) { + if (users.containsKey(username) && users.get(username).equals(password)) { + System.out.println("Utilisateur \"" + username + "\" reconnu"); + } else { + System.out.println("Utilisateur \"" + username + "\" non reconnu"); + } + } + + // Main pour interagir avec le programme + public static void main(String[] args) { + Authentification auth = new Authentification(); + Scanner scanner = new Scanner(System.in); + + while (true) { + System.out.print("> "); + String command = scanner.nextLine(); + String[] parts = command.split(" "); + + if (parts.length == 0) continue; + + switch (parts[0].toLowerCase()) { + case "add": + if (parts.length == 3) { + auth.addUser(parts[1], parts[2]); + } else { + System.out.println("Usage : add "); + } + break; + + case "del": + if (parts.length == 2) { + auth.removeUser(parts[1]); + } else { + System.out.println("Usage : del "); + } + break; + + case "auth": + if (parts.length == 3) { + auth.authenticate(parts[1], parts[2]); + } else { + System.out.println("Usage : auth "); + } + break; + + case "quit": + System.out.println("Au revoir"); + scanner.close(); + return; + + default: + System.out.println("Commande non reconnue."); + } + } + } +} diff --git a/DEV3.2/arbre_suite/Authentification/auth_sans_API/Authentification.class b/DEV3.2/arbre_suite/Authentification/auth_sans_API/Authentification.class new file mode 100644 index 0000000000000000000000000000000000000000..98e09d8d30a688dcb1dcb9e095bc19fb15a7f003 GIT binary patch literal 3525 zcmX^0Z`VEs1_mdFRa^{A49x5dEIbUX3~Y=H0$GV=iTXK-dFlH8Nm;4MC5#MgHko;u zC3cJq%o>_uoD3Wcoa_u-JPh0nJd6wij-@3Tsd*)tX_?81C7Jnoj0`MA`S~DSK7RQr zsn%Q!91MIs4EziNj0{|fDJh}FsYOAl$&3s}8W06O2n&NtiZb)ktuaM3Axb$JgcyX` z8ANy(L>a_ToEltNT#}m0$iSRmTEfU63NaxwUq7HIGp{7Lq$o8p*II~yfkA?YL6Sj= zkwH8+F+0^cKQB44Bs{Yu!#O{%xFj*Jq?nOGO#`AC90E`WX<`a-F~~5;vNOo>Fvv3~ zFfs^(J%MT=BLjN@$oiZ-Mg~!AriQUIC^0gyfP#sOL6JcP6a%V^4C+|aVmbg66N(J# zJPaBPnv4t_rNya5d5O8Hj0{4UYPlG+8Fbhgba@!`81zxY4IJW(44ldNxdn+usUi6| z-0I26pvYjz!(ar8be5ddv=Wej2@iuQNPx8{Gd%+=V$Q>00d`P9VsUYKeo+c2{;hZz ztQl+=8F-6QbMwnm;YmONXA*!$xDW#)gM<(R6N3cE7zZ8(M+PTG2KKbfycFNeJVpjS zr~y#rAVn@b46Y!%I6#U(Hi10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1Bk#BH`o9QFyn0u_I}#BTNu=~ zGN^%QGf=>QWk7-uvr$Y$1eza%FaraFA_EJ95`zGPGJ_C<8iOo@I)g5Q2B@-T@LB&Zmy!D*3!K@jA{V+`CN%4hliFGw*6Njwe=>T=^kT{)!o8irn8N~Z6<>dBx!nqLvJ|)KZNTI=7ORWl3c_X zSQ!`?JQ%nbJQ*YzycjeXd>Bj^{J@rSGBEvN&|qg!1SMcs1{)F20GgqoFTCTX2Dab90NN814AGK3queC8$$?#AVVmFFhe+l976LSkt7SN(Kd#X%6Aal5=NWPs?lI&sJYy(ec*#)A@PVO(;WtAWBQrw 0) { + node.right = addUserRec(node.right, username, password); + } else { + node.password = password; // Mise à jour du mot de passe si utilisateur existe + } + return node; + } + + // Supprimer un utilisateur + public void removeUser(String username) { + root = removeUserRec(root, username); + } + + private Node removeUserRec(Node node, String username) { + if (node == null) { + System.out.println("Utilisateur \"" + username + "\" non trouvé."); + return null; + } + + if (username.compareTo(node.username) < 0) { + node.left = removeUserRec(node.left, username); + } else if (username.compareTo(node.username) > 0) { + node.right = removeUserRec(node.right, username); + } else { + // Cas où l'utilisateur est trouvé + if (node.left == null){ + System.out.println("Utilisateur \"" + username + "\" retiré"); + return node.right; + } + if (node.right == null){ + System.out.println("Utilisateur \"" + username + "\" retiré"); + return node.left; + } + + // Remplacer par le successeur in-order + Node minNode = findMin(node.right); + node.username = minNode.username; + node.password = minNode.password; + node.right = removeUserRec(node.right, minNode.username); + } + System.out.println("Utilisateur \"" + username + "\" retiré"); + return node; + } + + private Node findMin(Node node) { + while (node.left != null) { + node = node.left; + } + return node; + } + + // Authentification d’un utilisateur + public void authenticate(String username, String password) { + Node user = findUser(root, username); + if (user != null && user.password.equals(password)) { + System.out.println("Utilisateur \"" + username + "\" reconnu"); + } else { + System.out.println("Utilisateur \"" + username + "\" non reconnu"); + } + } + + private Node findUser(Node node, String username) { + if (node == null){ + return null; + } + if (username.equals(node.username)){ + return node; + } + if (username.compareTo(node.username) < 0) { + return findUser(node.left, username); + } + return findUser(node.right, username); + } + + // Main pour le test + public static void main(String[] args) { + Authentification auth = new Authentification(); + Scanner scanner = new Scanner(System.in); + + while (true) { + System.out.print("> "); + String command = scanner.nextLine(); + String[] parts = command.split(" "); + + if (parts.length == 0) continue; + + switch (parts[0].toLowerCase()) { + case "add": + if (parts.length == 3) { + auth.addUser(parts[1], parts[2]); + } else { + System.out.println("Usage : add "); + } + break; + + case "del": + if (parts.length == 2) { + auth.removeUser(parts[1]); + } else { + System.out.println("Usage : del "); + } + break; + + case "auth": + if (parts.length == 3) { + auth.authenticate(parts[1], parts[2]); + } else { + System.out.println("Usage : auth "); + } + break; + + case "quit": + System.out.println("Au revoir"); + scanner.close(); + return; + + default: + System.out.println("Commande non reconnue."); + } + } + } +} diff --git a/DEV3.2/arbre_suite/Authentification/auth_sans_API/Node.class b/DEV3.2/arbre_suite/Authentification/auth_sans_API/Node.class new file mode 100644 index 0000000000000000000000000000000000000000..1fef2be7b38d7178033be51712a9ffe398292bc8 GIT binary patch literal 365 zcmX^0Z`VEs1_mbv2`&aE24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00SP6iGJPId+^9tLg(9!3ThzxQ6GcVPzG&d==C?qi{CzX+bD>%QjC^^+F6U5;JnXd{>co8F)7` lFfcGOh%zuR2!V}cXJ7#Z4+AFy9|IQyBZC+N0|OI-H~{6}M3?{o literal 0 HcmV?d00001 diff --git a/DEV3.2/arbre_suite/Authentification/auth_sans_API/Node.java b/DEV3.2/arbre_suite/Authentification/auth_sans_API/Node.java new file mode 100644 index 0000000..767ba41 --- /dev/null +++ b/DEV3.2/arbre_suite/Authentification/auth_sans_API/Node.java @@ -0,0 +1,11 @@ +// Classe interne pour représenter un nœud de l'arbre +public class Node { + String username; + String password; + Node left, right; + + Node(String username, String password) { + this.username = username; + this.password = password; + } +} \ No newline at end of file diff --git a/DEV3.2/arbre_suite/Tri/BinarySearchTree.class b/DEV3.2/arbre_suite/Tri/BinarySearchTree.class new file mode 100644 index 0000000000000000000000000000000000000000..45f48fc60b12d21000d3200e0d0902b22b8b0941 GIT binary patch literal 2394 zcmX^0Z`VEs1_mdFDlP^l24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00SP6iGJPId+^9tLg(9!3TMr_8*>qRQaZ#G>SkkfPL7Mh2Fm{CtouAHV#R zRBJ8<4hB9R27U$sMh4EzyyDcNlAzRNMh1Qjh`fs?gl1PGYf)x; zMhQEEA|rz^*h8fynK}B7MMa5~KAFWOTnq{f%pjMk@Gz({s4+5dW#;)8rKA>tohAu& znh!!JNRzc@7#D*EgC;wJ77v3qgAPhqx#X87<)kt)u!G&_pT@`_s^OvuF##Ny5CzuU z40;Uu>|&5@7Ca1=3|5Q`93}a|B}JKe>5L2_FqL4JK}4-N8EhDA*%|D3 z80;AwQ2Z8LSzMBu%gDf-Us}S*APR9>X1;zvQD$CAa7j^WVy-m@gA*fzRak0iW=>9O zl|ov6X;EHgkwR%+szOd?aY?E|N~%K9;gzX5#R{o;3OSkSd0?UB{M_8cyp&WuE(R9{ zS9S(B9tL*?4_Kt3+QG=cUI4N&Cl4)vpdJ844+kh(H5j~k75{rscAwiEr zlM5(R{dpJy7(^Kv*dPg%ogs*kK|Twf5&TMXlTwS^@{4j4OI$0GQwvHm^Yerl7#Ko$ z7(yAs7#YNK6SGsD^YfAuOTsftGMw}Cic1pnN{Sg7)HEQ$g&fk*XhIg^Vu)afWM_y1 zC9G)Fz=y^eib1d>foZl710zESBLj=^{BYRxc42A15!%sfU0F^y;>^Wd?@ z&XC5)AdE$dk%22XzqBYh)h!d0wM5a28a+@9fr_B~{F365qQnB<)RK(+lwuBsY(@r| zu*96y(jtY-yt2fc%#>7x%=El`PzqGAQefm@$Yo>@J=~ddcx7&CUP-Y+Nm1tEmBk<_ zel~`DE`|bzLUx8CQ0x{nGN^#;ffR|Ed1d+8srnGNLn7QQF}WnasFIOk269wG6+&F( zk(if~lUl6elb@emT40SC2uLC*8bc}zQn4sU4l6840cwPEVopwQW=X0wBLk0TUS4XE zb53G$acVI;Lm4B3Du$o1IhCEEf{{TEzfwj9Hi*9%6d5=em>3us7#WyAl>-9<13LpF zs8(TMWQb*8V31{CWME`qU|`kS&cL`4tT2v&fq@My$ilz~%7aj)S`4fV%nS?+d|Fys zTNv2Yw=wW;Wnf3>0aaQI3|tJn4BQM%pvncRuabe4frWvA!A|=)1J7;-!AOnm48j{U zw6`#b&6vX=tgWTJg+WRKY?{<^21&5Q^mz;dUgsk=k1_lNu29Vq27}!CsU|?b3 zXW(TJWDsKzVo+lcX3%F4VX$EkV~7WNhk=<_LX?3KR4_9zfqiPszzhxv;oS@hk=q%R ze89fY-o~H|Hk%P_HXqoB(hM97G7N$YvJ44eTN4?WKvfddpfCnzuqsvUV+_h*$Lnlk zP}TwYX9t7&P6k~jhH#LuEJzp>JP>D#F|aZ)FeoyxFeowbGAJ`hGpI1AFsOl@%gn&2 z0<|lNfe}@GMFth6n~mc80)T417PpDKQ-! jHyI3>;MBmxkjKEtkOd}l7)lsGDUp$(l%brVl0gyx$sIF_ literal 0 HcmV?d00001 diff --git a/DEV3.2/arbre_suite/Tri/BinarySearchTree.java b/DEV3.2/arbre_suite/Tri/BinarySearchTree.java new file mode 100644 index 0000000..15eae35 --- /dev/null +++ b/DEV3.2/arbre_suite/Tri/BinarySearchTree.java @@ -0,0 +1,67 @@ +import java.util.ArrayList; +import java.util.List; + +public class BinarySearchTree { + + private Node root; // Racine de l'arbre + + // Méthode d'insertion + public void insert(double value) { + root = insertRec(root, value); + } + + private Node insertRec(Node node, double value) { + if (node == null) { + return new Node(value); + } + if (value < node.value) { + node.left = insertRec(node.left, value); + } else if (value > node.value) { + node.right = insertRec(node.right, value); + } + return node; + } + + // Parcours en ordre croissant + public List inOrderTraversal() { + List sortedList = new ArrayList<>(); + inOrderRec(root, sortedList); + return sortedList; + } + + private void inOrderRec(Node node, List sortedList) { + if (node != null) { + inOrderRec(node.left, sortedList); + sortedList.add(node.value); + inOrderRec(node.right, sortedList); + } + } + + // Redéfinir la méthode toString pour afficher les éléments triés + @Override + public String toString() { + return inOrderTraversal().toString(); + } + + // Main pour le test + public static void main(String[] args) { + if (args.length == 0) { + System.out.println("Veuillez fournir une liste de réels en ligne de commande."); + return; + } + + // Créer un arbre binaire de recherche et y insérer les éléments + BinarySearchTree bst = new BinarySearchTree(); + for (String arg : args) { + try { + double value = Double.parseDouble(arg); + bst.insert(value); + } catch (NumberFormatException e) { + System.out.println("Valeur invalide ignorée : " + arg); + } + } + + // Afficher les éléments triés + System.out.println("Éléments triés : " + bst); + } +} diff --git a/DEV3.2/arbre_suite/Tri/Node.class b/DEV3.2/arbre_suite/Tri/Node.class new file mode 100644 index 0000000000000000000000000000000000000000..1a1e7ea84edc5b5b9608d1d7f566c1227f10537a GIT binary patch literal 272 zcmX^0Z`VEs1_mbvQ7#5124;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00SP6iGJPId+^9tLg(9!3ThzxDkB3|aDHh~a;jSDD0KS_lfdBvi literal 0 HcmV?d00001 diff --git a/DEV3.2/arbre_suite/Tri/Node.java b/DEV3.2/arbre_suite/Tri/Node.java new file mode 100644 index 0000000..e768c83 --- /dev/null +++ b/DEV3.2/arbre_suite/Tri/Node.java @@ -0,0 +1,9 @@ +// Classe interne représentant un nœud +public class Node { + double value; + Node left, right; + + Node(double value) { + this.value = value; + } +} \ No newline at end of file