Red de conocimiento informático - Aprendizaje de código fuente - Preguntas sobre programación de estructuras de datos: construir un árbol binario

Preguntas sobre programación de estructuras de datos: construir un árbol binario

#include?lt;stdio.hgt;

#include?lt;stdlib.hgt;

typedef?struct?node?{ char?item; struct?node?*l,?*r;

}BinNode;

BinNode?*create_tree()

{ BinNode?*t; ; ch?=?getchar(); if(ch?==?'#') t?=?NULL; else { t?=?(BinNode?*)malloc(sizeof?*t); ?=?ch; t-gt; l?=?create_tree(); t-gt; r?=?create_tree(); } retorno?t;

}

nulo ?pre_ord(BinNode?*t)

{ if(t) { printf("c",?t-gt; elemento); pre_ord(t-gt; l); r); }

}

void?in_ord(BinNode?*t)

{ if(t) { in_ord(t-gt;l); printf("c",?t-gt;item); in_ord(t-gt;r); }

}

void?post_ord(BinNode?*t) p>

{ if(t) { post_ord(t-gt; l); post_ord(t-gt; r);? printf("c",?t-gt; elemento }

}

int?BinTreeDepth(BinNode?*t)

{ if(t==NULL)?return?0; return?BinTreeDepth(t-gt;l )? gt;?BinTreeDepth(t-gt;r)BinTreeDepth(t-gt;l) 1: BinTreeDepth(t-gt;r) 1;

}

int? main( void)

{ BinNode?*root?=?NULL; root?=?create_tree(); pre_ord(root);?printf("\n"); (" \n"); post_ord(raíz);?printf("\n");? printf("Profundidad?=?d\n",?BinTreeDepth(raíz)); p> }

Reemplace los nodos vacíos con # al ingresar e ingrese ABK##D##CEG###FH##I##