国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

二叉樹 已知 兩種遍歷序列 求第三種遍歷序列

2019-11-11 02:07:24
字體:
供稿:網(wǎng)友

已知 前序和中序遍歷 求后序遍歷序列

struct node *creat(char *a, char *b, int n) { struct node *ptr; char *p; int count = 0; if (n <= 0) return NULL; ptr = (struct node *)malloc(sizeof(struct node)); ptr -> data = *a; for (p = &b[0]; p <= b + n - 1;p ++) { if (*p == *a) break; } count = p - b; ptr -> l = creat(a + 1, b, count); ptr -> r = creat(a + 1 + count, p + 1, n - 1 - count); return ptr; }

已知中序和后序遍歷 求前序遍歷序列

struct node *creat(char *a, char *b, int n) { struct node *ptr; if (n <= 0) return NULL; ptr = (struct node *)malloc(sizeof(struct node)); ptr -> data = b[n - 1]; int q = strchr(a, b[n - 1]) - a; ptr -> l = creat(a, b, q); ptr -> r = creat(a + q + 1, b + q, n - q - 1); return ptr; }
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 娄烦县| 伊金霍洛旗| 开鲁县| 饶河县| 渭源县| 富宁县| 县级市| 盱眙县| 沙田区| 忻州市| 吉安县| 福泉市| 合阳县| 八宿县| 德阳市| 大足县| 宿州市| 井冈山市| 嘉善县| 谢通门县| 金湖县| 饶平县| 琼海市| 伊春市| 崇义县| 堆龙德庆县| 桂林市| 佳木斯市| 来凤县| 抚远县| 绥滨县| 南陵县| 读书| 阿拉善右旗| 高州市| 峡江县| 毕节市| 金华市| 东源县| 奇台县| 义乌市|