#include <stdio.h> #include <stdlib.h> #include <string.h> #define __max_ length__ 20typedef struct sqstack{//Call Stack int data[__MAX_LENGTH__]; int top;} sqstack;typedef struct sqbitree{//Sequential Storage binary Tree elemType data[__MAX_LENGTH__]; int len;} sqbitree;//a two-tree Int tratree (sqbitree *t) { sqstack *stack) that traverses a one-dimensional array as a storage structure by first order = calloc (sizeof (Sqstack), 1); stack->top = 0;//Stack Empty; int root; root = 0;//points to the root node; while ( Stack->top) >-1) {//when the stack is not empty, enter the loop while (root<__max_length_ _&&t->data[root]>= ' a ') {// printf ("%c,", T->data[root]);//Access Node &NBSP;&NBSP;&Nbsp; stack->data[stack->top] = root;// Node into the stack stack->top ++; root = (root+1) * 2-1;// Check the next Zuozi; } if ( STACK->TOP&NBSP;>-1) {//stack non-null access, traverse right subtree; stack->top --; root = (stack->data[stack->top]+1) *2; } }}int main (int argc, char *argv[]) { sqbitree *p = calloc (sizeof (Sqbitree), 1); strcpy (P->data, "Abcdefghij"); tratree (p); return 0;}
650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M02/06/67/wKiom1m3pGyhHY08AABTcaKN8oE984.png-wh_500x0-wm_ 3-wmp_4-s_3637921156.png "title=" icon "alt=" Wkiom1m3pgyhhy08aabtcakn8oe984.png-wh_50 "/>
This article is from the "Android_home" blog, make sure to keep this source http://yangzheng0809.blog.51cto.com/6024606/1964688
Ordinal traversal algorithm for C-language binary tree sequential storage structure