204 */ InitiateStack s ; /* s */ i = n; t = p = new node; /* */ p->data = postorder[i]; while i > q = new node; if parent[i - ] == postorder[i] S,T S

Similar documents
1

Microsoft Word - 专论综述1.doc

标题

标题

ZS.indd


Microsoft Word - A doc

Vol. 22 No. 4 JOURNAL OF HARBIN UNIVERSITY OF SCIENCE AND TECHNOLOGY Aug GPS,,, : km, 2. 51, , ; ; ; ; DOI: 10.

m m m ~ mm

4 115,,. : p { ( x ( t), y ( t) ) x R m, y R n, t = 1,2,, p} (1),, x ( t), y ( t),,: F : R m R n.,m, n, u.,, Sigmoid. :,f Sigmoid,f ( x) = ^y k ( t) =

CHINA SCIENCE AND TECHNOLOGY DEVELOPMENT REPORT

2011年上海市高校精品课程申报表(本科)

~ ~ ~ ~ ~ ~ ~ % % ~ 20% 50% ~ 60%

Sep (SCI) 10. Jiann-Ming Wu, Annealing by two sets of interactive dynamics, IEEE Trans. on Systems Man and Cybernetics Part B-Cybernetics 34 (3)

SVM OA 1 SVM MLP Tab 1 1 Drug feature data quantization table

罗 森 平 1989 年 1 月 2007 年 9 月 2011 年 7 月 无 无 就 读 于 清 华 大 学 数 学 科 学 系 罗 森 平, 男, 汉 族,1989 年 1 月 生, 江 西 永 丰 人, 数 学 在 读 博 士,2010 年 6 月 加 入 中 国 共 产 党 2007 年

第16卷 第2期 邯郸学院学报 年6月

威 福 髮 藝 店 桃 園 市 蘆 竹 區 中 山 里 福 祿 一 街 48 號 地 下 一 樓 50,000 獨 資 李 依 純 105/04/06 府 經 登 字 第 號 宏 品 餐 飲 桃 園 市 桃 園 區 信 光 里 民

mm ~

1.2 资 金 的 管 理 1.1 权 利 义 务 来 源 MOU 1.3 数 据 的 使 用 和 保 护 2 国 际 空 间 站 资 源 分 配 方 案 54

<4D F736F F D F B0E6B8DFB1BBD2FDD6B8CAFDC7B0D1D42E646F63>

untitled

《红楼梦》中茗烟与李贵的对比分析

9, : Java 19., [4 ]. 3 Apla2Java Apla PAR,Apla2Java Apla Java.,Apla,,, 1. 1 Apla Apla A[J ] Get elem (set A) A J A B Intersection(set A,set B) A B A B

龍華科技大學數位典藏論文

附件1:

Microsoft Word - 专论综述1.doc

封皮:

P.2 6:45 7:00 pm 7:00 7:10 pm 7:10 7:30 pm 7:30 8:00 pm 8:00 8:30 pm P.3 P.4 P.6 P.7 P.10 P.10 P.11 P.12 P.13 P.14 P.15 P.16 P.17 P.24 P.25 P.26 P.27

附3

,.,,.. :,, ,:, ( 1 ). Π,.,.,,,.,.,. 1 : Π Π,. 212,. : 1)..,. 2). :, ;,,,;,. 3

实 践 探 讨 高 丽 : 从 少 数 民 族 大 学 生 的 阅 读 需 求 看 民 族 院 校 图 书 馆 的 资 源 建 设 有 区 域 性 和 民 族 性 很 强 的 传 统 学 科 特 色 学 科 及 优 势 学 科, 因 此 图 书 馆 的 资 源 建 设 也 要 顺 应 这 一 特 性

专 技 能 1. 精 通 Matlab/Simulink 平 台 下 的 海 洋 运 载 器 运 动 控 制 系 统 与 仿 真 建 模 设 计 ; 2. 精 通 51 单 片 机 AVR 单 片 机 Arduino 开 源 板 的 开 发 和 设 计 ; 3. 精 通 基 于 Arduino 板

元培科技大學 年度「傑出校友」推薦表

北 京 大 学

标题

p

Mechanical Science and Technology for Aerospace Engineering October Vol No. 10 Web SaaS B /S Web2. 0 Web2. 0 TP315 A

济南信息工程学校章程

Microsoft Word - ED-774.docx

F3

标题


PowerPoint Presentation

Improving the Effectiveness of the Training of Civil Service by Applying Learning Science and Technology: The Case Study of the National Academy of Ci

CHINA SCIENCE AND TECHNOLOGY DEVELOPMENT REPORT ()

68 ( ) 2006,,,,,,,,,, (narrative history),,, [1 ] (P ),,,,,,, [ 2 ] ( P ), ;,,,,,,,,,,,,,, (1917),, 30,,,, :,, ;,,,,, ( ) ( ), :,,,,,,,,,,

(Pattern Recognition) 1 1. CCD

第十一届“21世纪杯”全国中小学生英语演讲比赛

簡章內容

[1] Liu Hongwei,2013, Study on Comprehensive Evaluation of Iron and Steel Enterprises Production System s Basic Capacities, International Asia Confere

高等学校教师职务申报表(高级职务)

<4D F736F F D20C9CFBAA3BFC6BCBCB4F3D1A7D0C5CFA2D1A7D4BA C4EAC7EFBCBEC8EBD1A7B2A9CABFD7CAB8F1BFBCCAD4CAB5CAA9CFB8D4F22D C8B7B6A8B8E5>

( ) [11 13 ] 2 211,,, : (1),, 1990 ( ) ( ),, ; OD, ( ) ( ) ; , ( ), (2) 50 %,, 1999 ( ) ( ) ; (3),,

标题

13-4-Cover-1

I041 JOURNAL OF ZHEJIANG UNIVERSITY SCIENCE A I159 JOURNAL OF ZHEJIANG UNIVERSITY SCIENCE B I184 MINING SCIENCE AND TECHNOLOGY F019 MOLECULAR PLANT I2

, , 10, , %, % %; %, % %,2030,, 2., ,90%,

中北大学常规事项财务报销操作指南

27 :OPC 45 [4] (Automation Interface Standard), (Costom Interface Standard), OPC 2,,, VB Delphi OPC, OPC C++, OPC OPC OPC, [1] 1 OPC 1.1 OPC OPC(OLE f

第十一届“21世纪杯”全国中小学生英语演讲比赛

定稿

Transcription:

28 4 Vol.28 No.4 4 204 2 JOURNAL OF NANTONG VOCATIONAL UNIVERSITY Dec. 204!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! doi:0.3969/j.issn.008-5327.204.04.024 唐自立 ( 苏州大学计算机科学与技术学院, 江苏苏州 25006) : 提出一种新的由一棵严格二叉树的后序序列和结点的双亲情况构造该严格二叉树的非递 归算法通过实例说明该算法的执行过程, 假设 n 是严格二叉树的结点的个数, 该算法的时间复杂度 和最差情况空间复杂度都是 O(n) : 非递归算法 ; 严格二叉树 ; 后序序列 ; 结点的双亲 ; 严格二叉树构造 : TP30.6 : A : 008-5327(204)04-0093-06 A Non-recursive Algorithm for Constructing a Strictly Binary Tree from Its Post-order Traversal and the Parent of Each Node TANG Zi-li School of Computer Science and Technology, Soochow University, Suzhou 25006, China Abstract: A new non-recursive algorithm is presented for constructing a strictly binary tree from its post-order traversal and the parent of each node. The execution of the algorithm is illustrated by an example. Let n be the number of nodes of a strictly binary tree. The time complexity and the worst case space complexity of the algorithm are both O n. Key words: non-recursive algorithm; strictly binary tree; postorder traversal; parent of node; strictly binary tree construction [2] [] [2] [3-8] : 204-09-8 : (6075040); (0KJA52004); (BK202645); (BY2024) : 965-93

204 */ InitiateStack s ; /* s */ i = n; t = p = new node; /* */ p->data = postorder[i]; while i > q = new node; if parent[i - ] == postorder[i] S,T S Push s p ;,U T p->rightchild = q;, else U NULL; p->leftchild = q; p = q; p->data = postorder[--i]; p->leftchild = p->rightchild = NULL; DestroyStack s ; U 2 # n 7 U postorder[..7] parent[..7] v t a s v v b t c postorder[..7] parent[6] A =postorder A d preorder[..7] parent[5] C =postorder[6] ConstructSBT7 &t postorder[ ] parent[ ] n C C /* t postorder[..n] parent[..n] p ->leftchild = p ->rightchild = Pop s p ; BFGDECA ADDCCA# postorder [7] A [7] A A postorder[6] C C 94

4 parent[4] C postorder[5] E E postorder[2] F NULL C h preorder C [..7] parent[] postorder[4] D A postorder[2] F F f postorder[..7] NULL A parent [3] D =postorder parent [2] D pos- postorder[5] E e torder[3] G G postorder [..7] NULL D [4] D D postorder[] D B i preorder[..7] B postorder [3] G g preorder[..7] NULL j D A s k a b c d 95

204 e f g h 96

第4期 唐自立 由后序序列和结点的双亲情况构造严格二叉树的非递归算法 i j k 图 3 实例执行过程 算法分析 假设 n n 是一棵严格二叉树的结点的 个数 那么 n 一定是正奇数[ 8 ] 在时间开销上 由于执行算法 时要循环 n - 次 而每循环一次都要花费 O 时间 则执 行算法 总共要花费 O n 时间因此 算法 的 时间复杂度是 O n 在空间开销上 当所构造的严格二叉树有以 97

204 988,28(6):297-299. tree from its traversals n- / 2 O n 992,42(2):7-9. O n 4 989,29(3):572-575. O n [2] BIT,989,29(2):36-363. Systems,996,7(2):28-224. : [] Knuth D E. The art of computer programming,vol.,fundamental algorithms [M]. 3rd ed. Reading,MA:Addison-Wesley, 997. [2] 唐自立. 基于遍历序列的唯一确定树或二叉树的方法 [J]. 小型 微型计算机系统,200,22(8):985-988. [3] Andersson A,Carlsson S. Construction of a tree from its traversals in optimal time and space[j]. Information Processing Letters, 990,34():2-25. [4] Burgdorff H A,Jajodia S,Springsteel F N,et al. Alternative methods for the reconstruction of trees from their traversals [J]. BIT,987,27(2):34-40. [5] Chen G H,Yu M S,Liu L T. Two algorithms for constructing a binary tree from its traversals [J]. Information Processing Letters, [6] Gabrani N,Shankar P. A note on the reconstruction of a binary [J]. Information Processing Letters, [7] Kamakoti V,Rangan C P. An optimal algorithm for reconstructing a binary tree[j]. Information Processing Letters,992,42(2): 3-5. [8] M 覿 kinen E. Constructing a binary tree from its traversals[j]. BIT, [9] M 覿 kinen E. Constructing a binary tree efficiently from its traversals [J]. International Journal of Computer Mathematics,2000,75 (2):43-47. [0] Olariu S,Overstreet M,Wen Z F. Reconstructing a binary tree from its traversals in doubly logarithmic CREW time[j]. Journal of Parallel and Distributed Computing,995,27():00-05. [] Slough W,Efe K. Efficient algorithms for tree reconstruction[j]. [2] Stojmenovic I. Constant time BSR solutions to parenthesis matching, tree decoding, and tree reconstruction from its traversals [J]. IEEE Transactions on Parallel and Distributed [3] Wen Z F. New algorithms for the LCA problem and the binary tree reconstruction problem [J]. Information Processing Letters, 994,5():-6. [4] Xiang L M,Lawi A,Ushijima K. On constructing a binary tree from its traversals [J]. Research Reports on Information Science and Electrical Engineering of Kyushu University,2000,5(): 3-8. [5] 唐自立. 基于遍历序列的构造二叉树的算法 [C]// 全国计算机技术应用与高等学校计算机教育论文集 ( 第 卷 ), 成都 : 西 南交通大学出版社,2009:394-397. [6] 唐自立. 基于遍历序列的构造严格二叉树的算法 [J]. 苏州大学学报 : 自然科学版,200,26(3):40-43. [7] 唐自立. 基于遍历序列的构造树的算法 [J]. 苏州大学学报 : 自 然科学版,20,27(3):26-29. [8] 唐自立. 由先序序列和结点的左孩子情况构造严格二叉树的高效算法 [J]. 南通大学学报 : 自然科学版,203,2():9-3. 98