IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Mathématiques Discussion :

Algorithme conversion postfixée vers infixée


Sujet :

Mathématiques

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé Avatar de Onimaru
    Homme Profil pro
    Étudiant
    Inscrit en
    Mars 2010
    Messages
    283
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : Turquie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Mars 2010
    Messages : 283
    Par défaut Algorithme conversion postfixée vers infixée
    Salut, je cherche l’algorithme qui permet de convertir une expression arithmétique postfixée vers une expression infixée.

  2. #2
    Membre Expert
    Avatar de Franck Dernoncourt
    Homme Profil pro
    PhD student in AI @ MIT
    Inscrit en
    Avril 2010
    Messages
    894
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : PhD student in AI @ MIT
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2010
    Messages : 894
    Par défaut
    As-tu cherché sur Google quelque chose du genre "convert postfix to infix" ? Il semble y avoir beaucoup de résultats.

  3. #3
    Membre éclairé Avatar de Onimaru
    Homme Profil pro
    Étudiant
    Inscrit en
    Mars 2010
    Messages
    283
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : Turquie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Mars 2010
    Messages : 283
    Par défaut
    Citation Envoyé par Franck Dernoncourt Voir le message
    As-tu cherché sur Google quelque chose du genre "convert postfix to infix" ? Il semble y avoir beaucoup de résultats.
    Salut, en effet j'ai cherché sur Google, mais il donne toujours "infix to postfix".
    En tout cas moi je cherche les étapes à suivre pour faire la conversion en utilisant une pile.

  4. #4
    Membre Expert
    Avatar de Franck Dernoncourt
    Homme Profil pro
    PhD student in AI @ MIT
    Inscrit en
    Avril 2010
    Messages
    894
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : PhD student in AI @ MIT
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2010
    Messages : 894
    Par défaut
    http://www.cs.man.ac.uk/~pjj/cs212/fix.html :
    Converting between these notations
    
    The most straightforward method is to start by inserting all the implicit brackets that show the order of evaluation e.g.:
    Infix	                    Postfix	         Prefix
    ( (A * B) + (C / D) )	( (A B *) (C D /) +)	(+ (* A B) (/ C D) )
    ((A * (B + C) ) / D)	( (A (B C +) *) D /)	(/ (* A (+ B C) ) D)
    (A * (B + (C / D) ) )	(A (B (C D /) +) *)	(* A (+ B (/ C D) ) )
    You can convert directly between these bracketed forms simply by moving the operator within the brackets e.g. (X + Y) or (X Y +) or (+ X Y). Repeat this for all the operators in an expression, and finally remove any superfluous brackets.
    You can use a similar trick to convert to and from parse trees - each bracketed triplet of an operator and its two operands (or sub-expressions) corresponds to a node of the tree. The corresponding parse trees are:
    
    			      /			   *
          +			     / \		  / \
         / \		    *   D		 A   +
        /   \		   / \			    / \
       *     /		  A   +			   B   /
      / \   / \		     / \		      / \
     A   B C   D		    B   C		     C   D
    
    ((A*B)+(C/D))		((A*(B+C))/D) 		(A*(B+(C/D)))
    

  5. #5
    Membre éclairé Avatar de Onimaru
    Homme Profil pro
    Étudiant
    Inscrit en
    Mars 2010
    Messages
    283
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : Turquie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Mars 2010
    Messages : 283
    Par défaut
    Citation Envoyé par Franck Dernoncourt Voir le message
    http://www.cs.man.ac.uk/~pjj/cs212/fix.html :
    Converting between these notations
    
    The most straightforward method is to start by inserting all the implicit brackets that show the order of evaluation e.g.:
    Infix	                    Postfix	         Prefix
    ( (A * B) + (C / D) )	( (A B *) (C D /) +)	(+ (* A B) (/ C D) )
    ((A * (B + C) ) / D)	( (A (B C +) *) D /)	(/ (* A (+ B C) ) D)
    (A * (B + (C / D) ) )	(A (B (C D /) +) *)	(* A (+ B (/ C D) ) )
    You can convert directly between these bracketed forms simply by moving the operator within the brackets e.g. (X + Y) or (X Y +) or (+ X Y). Repeat this for all the operators in an expression, and finally remove any superfluous brackets.
    You can use a similar trick to convert to and from parse trees - each bracketed triplet of an operator and its two operands (or sub-expressions) corresponds to a node of the tree. The corresponding parse trees are:
    
    			      /			   *
          +			     / \		  / \
         / \		    *   D		 A   +
        /   \		   / \			    / \
       *     /		  A   +			   B   /
      / \   / \		     / \		      / \
     A   B C   D		    B   C		     C   D
    
    ((A*B)+(C/D))		((A*(B+C))/D) 		(A*(B+(C/D)))
    
    Merci pour l'aide.
    D’après ce que je comprends ce procédé est récursif. Je cherche la version itérative qui utilise une pile, le processus inverse de "infix->postfix".

  6. #6
    Membre Expert
    Avatar de Franck Dernoncourt
    Homme Profil pro
    PhD student in AI @ MIT
    Inscrit en
    Avril 2010
    Messages
    894
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : PhD student in AI @ MIT
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2010
    Messages : 894

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Algorithme conversion PDU vers Texte
    Par begyves dans le forum Algorithmes et structures de données
    Réponses: 1
    Dernier message: 16/02/2009, 15h10
  2. Conversion Unix vers DOS...
    Par nicosfly dans le forum Langage
    Réponses: 4
    Dernier message: 23/06/2008, 17h53
  3. conversion Access vers SQL
    Par Bjuice2 dans le forum MS SQL Server
    Réponses: 6
    Dernier message: 23/03/2004, 13h57
  4. [langage] conversion décimal vers hexa
    Par chipster dans le forum Langage
    Réponses: 2
    Dernier message: 23/02/2004, 16h05
  5. Conversion Timestamp vers varchar
    Par stejutt dans le forum SQL
    Réponses: 4
    Dernier message: 08/01/2004, 08h46

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo