重建二叉树

body { font-family: 微软雅黑, “Microsoft YaHei”, Georgia, Helvetica, Arial, sans-serif, 宋体, PMingLiU, serif; font-size: 10.5pt; line-height: 1.5 }
html, body { }
h1 { font-size: 1.5em; font-weight: bold }
h2 { font-size: 1.4em; font-weight: bold }
h3 { font-size: 1.3em; font-weight: bold }
h4 { font-size: 1.2em; font-weight: bold }
h5 { font-size: 1.1em; font-weight: bold }
h6 { font-size: 1em; font-weight: bold }
img { border: 0; max- 100%; height: auto !important }
blockquote { margin-top: 0; margin-bottom: 0 }
table { border-collapse: collapse; border: 1px solid rgba(187, 187, 187, 1) }
td { border-collapse: collapse; border: 1px solid rgba(187, 187, 187, 1) }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
.wizimgdragresize { position: absolute; z-index: 1000; border: 1px solid rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1) }
.wizimgdragresize-lt { cursor: nw-resize }
.wizimgdragresize-tm { cursor: n-resize }
.wizimgdragresize-rt { cursor: ne-resize }
.wizimgdragresize-lm { cursor: w-resize }
.wizimgdragresize-rm { cursor: e-resize }
.wizimgdragresize-lb { cursor: sw-resize }
.wizimgdragresize-bm { cursor: s-resize }
.wizimgdragresize-rb { cursor: se-resize }
.wiz-todo, .wiz-todo-img { 16px; height: 16px; cursor: default; padding: 0 10px 0 2px; vertical-align: -10%; -webkit-user-select: none }
.wiz-todo-label { display: inline-block; padding-top: 7px; padding-bottom: 6px; line-height: 1.5 }
.wiz-todo-label-checked { color: rgba(102, 102, 102, 1) }
.wiz-todo-label-unchecked { }
.wiz-todo-completed-info { padding-left: 44px; display: inline-block }
.wiz-todo-avatar { 20px; height: 20px; vertical-align: -20%; margin-right: 10px; border-radius: 2px }
.wiz-todo-account, .wiz-todo-dt { color: rgba(102, 102, 102, 1) }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
.wizimgdragresize { position: absolute; z-index: 1000; border: 1px solid rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1) }
.wizimgdragresize-lt { cursor: nw-resize }
.wizimgdragresize-tm { cursor: n-resize }
.wizimgdragresize-rt { cursor: ne-resize }
.wizimgdragresize-lm { cursor: w-resize }
.wizimgdragresize-rm { cursor: e-resize }
.wizimgdragresize-lb { cursor: sw-resize }
.wizimgdragresize-bm { cursor: s-resize }
.wizimgdragresize-rb { cursor: se-resize }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
body { font-family: 微软雅黑, “Microsoft YaHei”, Georgia, Helvetica, Arial, sans-serif, 宋体, PMingLiU, serif; font-size: 10.5pt; line-height: 1.5 }
html, body { }
h1 { font-size: 1.5em; font-weight: bold }
h2 { font-size: 1.4em; font-weight: bold }
h3 { font-size: 1.3em; font-weight: bold }
h4 { font-size: 1.2em; font-weight: bold }
h5 { font-size: 1.1em; font-weight: bold }
h6 { font-size: 1em; font-weight: bold }
img { border: 0; max- 100%; height: auto !important }
blockquote { margin-top: 0; margin-bottom: 0 }
table { border-collapse: collapse; border: 1px solid rgba(187, 187, 187, 1) }
td { border-collapse: collapse; border: 1px solid rgba(187, 187, 187, 1) }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
.wizimgdragresize { position: absolute; z-index: 1000; border: 1px solid rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1) }
.wizimgdragresize-lt { cursor: nw-resize }
.wizimgdragresize-tm { cursor: n-resize }
.wizimgdragresize-rt { cursor: ne-resize }
.wizimgdragresize-lm { cursor: w-resize }
.wizimgdragresize-rm { cursor: e-resize }
.wizimgdragresize-lb { cursor: sw-resize }
.wizimgdragresize-bm { cursor: s-resize }
.wizimgdragresize-rb { cursor: se-resize }
.wiz-todo, .wiz-todo-img { 16px; height: 16px; cursor: default; padding: 0 10px 0 2px; vertical-align: -10%; -webkit-user-select: none }
.wiz-todo-label { display: inline-block; padding-top: 7px; padding-bottom: 6px; line-height: 1.5 }
.wiz-todo-label-checked { color: rgba(102, 102, 102, 1) }
.wiz-todo-label-unchecked { }
.wiz-todo-completed-info { padding-left: 44px; display: inline-block }
.wiz-todo-avatar { 20px; height: 20px; vertical-align: -20%; margin-right: 10px; border-radius: 2px }
.wiz-todo-account, .wiz-todo-dt { color: rgba(102, 102, 102, 1) }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
.wizimgdragresize { position: absolute; z-index: 1000; border: 1px solid rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1) }
.wizimgdragresize-lt { cursor: nw-resize }
.wizimgdragresize-tm { cursor: n-resize }
.wizimgdragresize-rt { cursor: ne-resize }
.wizimgdragresize-lm { cursor: w-resize }
.wizimgdragresize-rm { cursor: e-resize }
.wizimgdragresize-lb { cursor: sw-resize }
.wizimgdragresize-bm { cursor: s-resize }
.wizimgdragresize-rb { cursor: se-resize }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
body { font-family: 微软雅黑, “Microsoft YaHei”, Georgia, Helvetica, Arial, sans-serif, 宋体, PMingLiU, serif; font-size: 10.5pt; line-height: 1.5 }
html, body { }
h1 { font-size: 1.5em; font-weight: bold }
h2 { font-size: 1.4em; font-weight: bold }
h3 { font-size: 1.3em; font-weight: bold }
h4 { font-size: 1.2em; font-weight: bold }
h5 { font-size: 1.1em; font-weight: bold }
h6 { font-size: 1em; font-weight: bold }
img { border: 0; max- 100%; height: auto !important }
blockquote { margin-top: 0; margin-bottom: 0 }
table { border-collapse: collapse; border: 1px solid rgba(187, 187, 187, 1) }
td { border-collapse: collapse; border: 1px solid rgba(187, 187, 187, 1) }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
.wizimgdragresize { position: absolute; z-index: 1000; border: 1px solid rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1) }
.wizimgdragresize-lt { cursor: nw-resize }
.wizimgdragresize-tm { cursor: n-resize }
.wizimgdragresize-rt { cursor: ne-resize }
.wizimgdragresize-lm { cursor: w-resize }
.wizimgdragresize-rm { cursor: e-resize }
.wizimgdragresize-lb { cursor: sw-resize }
.wizimgdragresize-bm { cursor: s-resize }
.wizimgdragresize-rb { cursor: se-resize }
.wiz-todo, .wiz-todo-img { 16px; height: 16px; cursor: default; padding: 0 10px 0 2px; vertical-align: -10%; -webkit-user-select: none }
.wiz-todo-label { display: inline-block; padding-top: 7px; padding-bottom: 6px; line-height: 1.5 }
.wiz-todo-label-checked { color: rgba(102, 102, 102, 1) }
.wiz-todo-label-unchecked { }
.wiz-todo-completed-info { padding-left: 44px; display: inline-block }
.wiz-todo-avatar { 20px; height: 20px; vertical-align: -20%; margin-right: 10px; border-radius: 2px }
.wiz-todo-account, .wiz-todo-dt { color: rgba(102, 102, 102, 1) }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
body { font-family: 微软雅黑, “Microsoft YaHei”, Georgia, Helvetica, Arial, sans-serif, 宋体, PMingLiU, serif; font-size: 10.5pt; line-height: 1.5 }
html, body { }
h1 { font-size: 1.5em; font-weight: bold }
h2 { font-size: 1.4em; font-weight: bold }
h3 { font-size: 1.3em; font-weight: bold }
h4 { font-size: 1.2em; font-weight: bold }
h5 { font-size: 1.1em; font-weight: bold }
h6 { font-size: 1em; font-weight: bold }
img { border: 0; max- 100%; height: auto !important }
blockquote { margin-top: 0; margin-bottom: 0 }
table { border-collapse: collapse; border: 1px solid rgba(187, 187, 187, 1) }
td { border-collapse: collapse; border: 1px solid rgba(187, 187, 187, 1) }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
.wizimgdragresize { position: absolute; z-index: 1000; border: 1px solid rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1) }
.wizimgdragresize-lt { cursor: nw-resize }
.wizimgdragresize-tm { cursor: n-resize }
.wizimgdragresize-rt { cursor: ne-resize }
.wizimgdragresize-lm { cursor: w-resize }
.wizimgdragresize-rm { cursor: e-resize }
.wizimgdragresize-lb { cursor: sw-resize }
.wizimgdragresize-bm { cursor: s-resize }
.wizimgdragresize-rb { cursor: se-resize }
.wiz-todo, .wiz-todo-img { 16px; height: 16px; cursor: default; padding: 0 10px 0 2px; vertical-align: -10%; -webkit-user-select: none }
.wiz-todo-label { display: inline-block; padding-top: 7px; padding-bottom: 6px; line-height: 1.5 }
.wiz-todo-label-checked { color: rgba(102, 102, 102, 1) }
.wiz-todo-label-unchecked { }
.wiz-todo-completed-info { padding-left: 44px; display: inline-block }
.wiz-todo-avatar { 20px; height: 20px; vertical-align: -20%; margin-right: 10px; border-radius: 2px }
.wiz-todo-account, .wiz-todo-dt { color: rgba(102, 102, 102, 1) }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
.wizimgdragresize { position: absolute; z-index: 1000; border: 1px solid rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1) }
.wizimgdragresize-lt { cursor: nw-resize }
.wizimgdragresize-tm { cursor: n-resize }
.wizimgdragresize-rt { cursor: ne-resize }
.wizimgdragresize-lm { cursor: w-resize }
.wizimgdragresize-rm { cursor: e-resize }
.wizimgdragresize-lb { cursor: sw-resize }
.wizimgdragresize-bm { cursor: s-resize }
.wizimgdragresize-rb { cursor: se-resize }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
body { font-family: 微软雅黑, “Microsoft YaHei”, Georgia, Helvetica, Arial, sans-serif, 宋体, PMingLiU, serif; font-size: 10.5pt; line-height: 1.5 }
html, body { }
h1 { font-size: 1.5em; font-weight: bold }
h2 { font-size: 1.4em; font-weight: bold }
h3 { font-size: 1.3em; font-weight: bold }
h4 { font-size: 1.2em; font-weight: bold }
h5 { font-size: 1.1em; font-weight: bold }
h6 { font-size: 1em; font-weight: bold }
img { border: 0; max- 100%; height: auto !important }
blockquote { margin-top: 0; margin-bottom: 0 }
table { border-collapse: collapse; border: 1px solid rgba(187, 187, 187, 1) }
td { border-collapse: collapse; border: 1px solid rgba(187, 187, 187, 1) }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
.wizimgdragresize { position: absolute; z-index: 1000; border: 1px solid rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1) }
.wizimgdragresize-lt { cursor: nw-resize }
.wizimgdragresize-tm { cursor: n-resize }
.wizimgdragresize-rt { cursor: ne-resize }
.wizimgdragresize-lm { cursor: w-resize }
.wizimgdragresize-rm { cursor: e-resize }
.wizimgdragresize-lb { cursor: sw-resize }
.wizimgdragresize-bm { cursor: s-resize }
.wizimgdragresize-rb { cursor: se-resize }
.wiz-todo, .wiz-todo-img { 16px; height: 16px; cursor: default; padding: 0 10px 0 2px; vertical-align: -10%; -webkit-user-select: none }
.wiz-todo-label { display: inline-block; padding-top: 7px; padding-bottom: 6px; line-height: 1.5 }
.wiz-todo-label-checked { color: rgba(102, 102, 102, 1) }
.wiz-todo-label-unchecked { }
.wiz-todo-completed-info { padding-left: 44px; display: inline-block }
.wiz-todo-avatar { 20px; height: 20px; vertical-align: -20%; margin-right: 10px; border-radius: 2px }
.wiz-todo-account, .wiz-todo-dt { color: rgba(102, 102, 102, 1) }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }.wizimgdragresize { position: absolute; z-index: 1000; border: 1px solid rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1) }
.wizimgdragresize-lt { cursor: nw-resize }
.wizimgdragresize-tm { cursor: n-resize }
.wizimgdragresize-rt { cursor: ne-resize }
.wizimgdragresize-lm { cursor: w-resize }
.wizimgdragresize-rm { cursor: e-resize }
.wizimgdragresize-lb { cursor: sw-resize }
.wizimgdragresize-bm { cursor: s-resize }
.wizimgdragresize-rb { cursor: se-resize }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
body { font-family: 微软雅黑, “Microsoft YaHei”, Georgia, Helvetica, Arial, sans-serif, 宋体, PMingLiU, serif; font-size: 10.5pt; line-height: 1.5 }
html, body { }
h1 { font-size: 1.5em; font-weight: bold }
h2 { font-size: 1.4em; font-weight: bold }
h3 { font-size: 1.3em; font-weight: bold }
h4 { font-size: 1.2em; font-weight: bold }
h5 { font-size: 1.1em; font-weight: bold }
h6 { font-size: 1em; font-weight: bold }
img { border: 0; max- 100%; height: auto !important }
blockquote { margin-top: 0; margin-bottom: 0 }
table { border-collapse: collapse; border: 1px solid rgba(187, 187, 187, 1) }
td { border-collapse: collapse; border: 1px solid rgba(187, 187, 187, 1) }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
.wizimgdragresize { position: absolute; z-index: 1000; border: 1px solid rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1) }
.wizimgdragresize-lt { cursor: nw-resize }
.wizimgdragresize-tm { cursor: n-resize }
.wizimgdragresize-rt { cursor: ne-resize }
.wizimgdragresize-lm { cursor: w-resize }
.wizimgdragresize-rm { cursor: e-resize }
.wizimgdragresize-lb { cursor: sw-resize }
.wizimgdragresize-bm { cursor: s-resize }
.wizimgdragresize-rb { cursor: se-resize }
.wiz-todo, .wiz-todo-img { 16px; height: 16px; cursor: default; padding: 0 10px 0 2px; vertical-align: -10%; -webkit-user-select: none }
.wiz-todo-label { display: inline-block; padding-top: 7px; padding-bottom: 6px; line-height: 1.5 }
.wiz-todo-label-checked { color: rgba(102, 102, 102, 1) }
.wiz-todo-label-unchecked { }
.wiz-todo-completed-info { padding-left: 44px; display: inline-block }
.wiz-todo-avatar { 20px; height: 20px; vertical-align: -20%; margin-right: 10px; border-radius: 2px }
.wiz-todo-account, .wiz-todo-dt { color: rgba(102, 102, 102, 1) }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
body { font-family: 微软雅黑, “Microsoft YaHei”, Georgia, Helvetica, Arial, sans-serif, 宋体, PMingLiU, serif; font-size: 10.5pt; line-height: 1.5 }
html, body { }
h1 { font-size: 1.5em; font-weight: bold }
h2 { font-size: 1.4em; font-weight: bold }
h3 { font-size: 1.3em; font-weight: bold }
h4 { font-size: 1.2em; font-weight: bold }
h5 { font-size: 1.1em; font-weight: bold }
h6 { font-size: 1em; font-weight: bold }
img { border: 0; max- 100%; height: auto !important }
blockquote { margin-top: 0; margin-bottom: 0 }
table { border-collapse: collapse; border: 1px solid rgba(187, 187, 187, 1) }
td { border-collapse: collapse; border: 1px solid rgba(187, 187, 187, 1) }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
.wizimgdragresize { position: absolute; z-index: 1000; border: 1px solid rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1) }
.wizimgdragresize-lt { cursor: nw-resize }
.wizimgdragresize-tm { cursor: n-resize }
.wizimgdragresize-rt { cursor: ne-resize }
.wizimgdragresize-lm { cursor: w-resize }
.wizimgdragresize-rm { cursor: e-resize }
.wizimgdragresize-lb { cursor: sw-resize }
.wizimgdragresize-bm { cursor: s-resize }
.wizimgdragresize-rb { cursor: se-resize }
.wiz-todo, .wiz-todo-img { 16px; height: 16px; cursor: default; padding: 0 10px 0 2px; vertical-align: -10%; -webkit-user-select: none }
.wiz-todo-label { display: inline-block; padding-top: 7px; padding-bottom: 6px; line-height: 1.5 }
.wiz-todo-label-checked { color: rgba(102, 102, 102, 1) }
.wiz-todo-label-unchecked { }
.wiz-todo-completed-info { padding-left: 44px; display: inline-block }
.wiz-todo-avatar { 20px; height: 20px; vertical-align: -20%; margin-right: 10px; border-radius: 2px }
.wiz-todo-account, .wiz-todo-dt { color: rgba(102, 102, 102, 1) }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
.wizimgdragresize { position: absolute; z-index: 1000; border: 1px solid rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1) }
.wizimgdragresize-lt { cursor: nw-resize }
.wizimgdragresize-tm { cursor: n-resize }
.wizimgdragresize-rt { cursor: ne-resize }
.wizimgdragresize-lm { cursor: w-resize }
.wizimgdragresize-rm { cursor: e-resize }
.wizimgdragresize-lb { cursor: sw-resize }
.wizimgdragresize-bm { cursor: s-resize }
.wizimgdragresize-rb { cursor: se-resize }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
body { font-family: 微软雅黑, “Microsoft YaHei”, Georgia, Helvetica, Arial, sans-serif, 宋体, PMingLiU, serif; font-size: 10.5pt; line-height: 1.5 }
html, body { }
h1 { font-size: 1.5em; font-weight: bold }
h2 { font-size: 1.4em; font-weight: bold }
h3 { font-size: 1.3em; font-weight: bold }
h4 { font-size: 1.2em; font-weight: bold }
h5 { font-size: 1.1em; font-weight: bold }
h6 { font-size: 1em; font-weight: bold }
img { border: 0; max- 100%; height: auto !important }
blockquote { margin-top: 0; margin-bottom: 0 }
table { border-collapse: collapse; border: 1px solid rgba(187, 187, 187, 1) }
td { border-collapse: collapse; border: 1px solid rgba(187, 187, 187, 1) }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
.wizimgdragresize { position: absolute; z-index: 1000; border: 1px solid rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1) }
.wizimgdragresize-lt { cursor: nw-resize }
.wizimgdragresize-tm { cursor: n-resize }
.wizimgdragresize-rt { cursor: ne-resize }
.wizimgdragresize-lm { cursor: w-resize }
.wizimgdragresize-rm { cursor: e-resize }
.wizimgdragresize-lb { cursor: sw-resize }
.wizimgdragresize-bm { cursor: s-resize }
.wizimgdragresize-rb { cursor: se-resize }
.wiz-todo, .wiz-todo-img { 16px; height: 16px; cursor: default; padding: 0 10px 0 2px; vertical-align: -10%; -webkit-user-select: none }
.wiz-todo-label { display: inline-block; padding-top: 7px; padding-bottom: 6px; line-height: 1.5 }
.wiz-todo-label-checked { color: rgba(102, 102, 102, 1) }
.wiz-todo-label-unchecked { }
.wiz-todo-completed-info { padding-left: 44px; display: inline-block }
.wiz-todo-avatar { 20px; height: 20px; vertical-align: -20%; margin-right: 10px; border-radius: 2px }
.wiz-todo-account, .wiz-todo-dt { color: rgba(102, 102, 102, 1) }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
body { font-family: 微软雅黑, “Microsoft YaHei”, Georgia, Helvetica, Arial, sans-serif, 宋体, PMingLiU, serif; font-size: 10.5pt; line-height: 1.5 }
html, body { }
h1 { font-size: 1.5em; font-weight: bold }
h2 { font-size: 1.4em; font-weight: bold }
h3 { font-size: 1.3em; font-weight: bold }
h4 { font-size: 1.2em; font-weight: bold }
h5 { font-size: 1.1em; font-weight: bold }
h6 { font-size: 1em; font-weight: bold }
img { border: 0; max- 100%; height: auto !important }
blockquote { margin-top: 0; margin-bottom: 0 }
table { border-collapse: collapse; border: 1px solid rgba(187, 187, 187, 1) }
td { border-collapse: collapse; border: 1px solid rgba(187, 187, 187, 1) }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
.wizimgdragresize { position: absolute; z-index: 1000; border: 1px solid rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1) }
.wizimgdragresize-lt { cursor: nw-resize }
.wizimgdragresize-tm { cursor: n-resize }
.wizimgdragresize-rt { cursor: ne-resize }
.wizimgdragresize-lm { cursor: w-resize }
.wizimgdragresize-rm { cursor: e-resize }
.wizimgdragresize-lb { cursor: sw-resize }
.wizimgdragresize-bm { cursor: s-resize }
.wizimgdragresize-rb { cursor: se-resize }
.wiz-todo, .wiz-todo-img { 16px; height: 16px; cursor: default; padding: 0 10px 0 2px; vertical-align: -10%; -webkit-user-select: none }
.wiz-todo-label { display: inline-block; padding-top: 7px; padding-bottom: 6px; line-height: 1.5 }
.wiz-todo-label-checked { color: rgba(102, 102, 102, 1) }
.wiz-todo-label-unchecked { }
.wiz-todo-completed-info { padding-left: 44px; display: inline-block }
.wiz-todo-avatar { 20px; height: 20px; vertical-align: -20%; margin-right: 10px; border-radius: 2px }
.wiz-todo-account, .wiz-todo-dt { color: rgba(102, 102, 102, 1) }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
.wizimgdragresize { position: absolute; z-index: 1000; border: 1px solid rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1) }
.wizimgdragresize-lt { cursor: nw-resize }
.wizimgdragresize-tm { cursor: n-resize }
.wizimgdragresize-rt { cursor: ne-resize }
.wizimgdragresize-lm { cursor: w-resize }
.wizimgdragresize-rm { cursor: e-resize }
.wizimgdragresize-lb { cursor: sw-resize }
.wizimgdragresize-bm { cursor: s-resize }
.wizimgdragresize-rb { cursor: se-resize }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
body { font-family: 微软雅黑, “Microsoft YaHei”, Georgia, Helvetica, Arial, sans-serif, 宋体, PMingLiU, serif; font-size: 10.5pt; line-height: 1.5 }
html, body { }
h1 { font-size: 1.5em; font-weight: bold }
h2 { font-size: 1.4em; font-weight: bold }
h3 { font-size: 1.3em; font-weight: bold }
h4 { font-size: 1.2em; font-weight: bold }
h5 { font-size: 1.1em; font-weight: bold }
h6 { font-size: 1em; font-weight: bold }
img { border: 0; max- 100%; height: auto !important }
blockquote { margin-top: 0; margin-bottom: 0 }
table { border-collapse: collapse; border: 1px solid rgba(187, 187, 187, 1) }
td { border-collapse: collapse; border: 1px solid rgba(187, 187, 187, 1) }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
.wizimgdragresize { position: absolute; z-index: 1000; border: 1px solid rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1) }
.wizimgdragresize-lt { cursor: nw-resize }
.wizimgdragresize-tm { cursor: n-resize }
.wizimgdragresize-rt { cursor: ne-resize }
.wizimgdragresize-lm { cursor: w-resize }
.wizimgdragresize-rm { cursor: e-resize }
.wizimgdragresize-lb { cursor: sw-resize }
.wizimgdragresize-bm { cursor: s-resize }
.wizimgdragresize-rb { cursor: se-resize }
.wiz-todo, .wiz-todo-img { 16px; height: 16px; cursor: default; padding: 0 10px 0 2px; vertical-align: -10%; -webkit-user-select: none }
.wiz-todo-label { display: inline-block; padding-top: 7px; padding-bottom: 6px; line-height: 1.5 }
.wiz-todo-label-checked { color: rgba(102, 102, 102, 1) }
.wiz-todo-label-unchecked { }
.wiz-todo-completed-info { padding-left: 44px; display: inline-block }
.wiz-todo-avatar { 20px; height: 20px; vertical-align: -20%; margin-right: 10px; border-radius: 2px }
.wiz-todo-account, .wiz-todo-dt { color: rgba(102, 102, 102, 1) }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
.wizimgdragresize { position: absolute; z-index: 1000; border: 1px solid rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1) }
.wizimgdragresize-lt { cursor: nw-resize }
.wizimgdragresize-tm { cursor: n-resize }
.wizimgdragresize-rt { cursor: ne-resize }
.wizimgdragresize-lm { cursor: w-resize }
.wizimgdragresize-rm { cursor: e-resize }
.wizimgdragresize-lb { cursor: sw-resize }
.wizimgdragresize-bm { cursor: s-resize }
.wizimgdragresize-rb { cursor: se-resize }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
body { font-family: 微软雅黑, “Microsoft YaHei”, Georgia, Helvetica, Arial, sans-serif, 宋体, PMingLiU, serif; font-size: 10.5pt; line-height: 1.5 }
html, body { }
h1 { font-size: 1.5em; font-weight: bold }
h2 { font-size: 1.4em; font-weight: bold }
h3 { font-size: 1.3em; font-weight: bold }
h4 { font-size: 1.2em; font-weight: bold }
h5 { font-size: 1.1em; font-weight: bold }
h6 { font-size: 1em; font-weight: bold }
img { border: 0; max- 100%; height: auto !important }
blockquote { margin-top: 0; margin-bottom: 0 }
table { border-collapse: collapse; border: 1px solid rgba(187, 187, 187, 1) }
td { border-collapse: collapse; border: 1px solid rgba(187, 187, 187, 1) }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
.wizimgdragresize { position: absolute; z-index: 1000; border: 1px solid rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1) }
.wizimgdragresize-lt { cursor: nw-resize }
.wizimgdragresize-tm { cursor: n-resize }
.wizimgdragresize-rt { cursor: ne-resize }
.wizimgdragresize-lm { cursor: w-resize }
.wizimgdragresize-rm { cursor: e-resize }
.wizimgdragresize-lb { cursor: sw-resize }
.wizimgdragresize-bm { cursor: s-resize }
.wizimgdragresize-rb { cursor: se-resize }
.wiz-todo, .wiz-todo-img { 16px; height: 16px; cursor: default; padding: 0 10px 0 2px; vertical-align: -10%; -webkit-user-select: none }
.wiz-todo-label { display: inline-block; padding-top: 7px; padding-bottom: 6px; line-height: 1.5 }
.wiz-todo-label-checked { color: rgba(102, 102, 102, 1) }
.wiz-todo-label-unchecked { }
.wiz-todo-completed-info { padding-left: 44px; display: inline-block }
.wiz-todo-avatar { 20px; height: 20px; vertical-align: -20%; margin-right: 10px; border-radius: 2px }
.wiz-todo-account, .wiz-todo-dt { color: rgba(102, 102, 102, 1) }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
body { font-family: 微软雅黑, “Microsoft YaHei”, Georgia, Helvetica, Arial, sans-serif, 宋体, PMingLiU, serif; font-size: 10.5pt; line-height: 1.5 }
html, body { }
h1 { font-size: 1.5em; font-weight: bold }
h2 { font-size: 1.4em; font-weight: bold }
h3 { font-size: 1.3em; font-weight: bold }
h4 { font-size: 1.2em; font-weight: bold }
h5 { font-size: 1.1em; font-weight: bold }
h6 { font-size: 1em; font-weight: bold }
img { border: 0; max- 100%; height: auto !important }
blockquote { margin-top: 0; margin-bottom: 0 }
table { border-collapse: collapse; border: 1px solid rgba(187, 187, 187, 1) }
td { border-collapse: collapse; border: 1px solid rgba(187, 187, 187, 1) }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
.wizimgdragresize { position: absolute; z-index: 1000; border: 1px solid rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1) }
.wizimgdragresize-lt { cursor: nw-resize }
.wizimgdragresize-tm { cursor: n-resize }
.wizimgdragresize-rt { cursor: ne-resize }
.wizimgdragresize-lm { cursor: w-resize }
.wizimgdragresize-rm { cursor: e-resize }
.wizimgdragresize-lb { cursor: sw-resize }
.wizimgdragresize-bm { cursor: s-resize }
.wizimgdragresize-rb { cursor: se-resize }
.wiz-todo, .wiz-todo-img { 16px; height: 16px; cursor: default; padding: 0 10px 0 2px; vertical-align: -10%; -webkit-user-select: none }
.wiz-todo-label { display: inline-block; padding-top: 7px; padding-bottom: 6px; line-height: 1.5 }
.wiz-todo-label-checked { color: rgba(102, 102, 102, 1) }
.wiz-todo-label-unchecked { }
.wiz-todo-completed-info { padding-left: 44px; display: inline-block }
.wiz-todo-avatar { 20px; height: 20px; vertical-align: -20%; margin-right: 10px; border-radius: 2px }
.wiz-todo-account, .wiz-todo-dt { color: rgba(102, 102, 102, 1) }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
.wizimgdragresize { position: absolute; z-index: 1000; border: 1px solid rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1) }
.wizimgdragresize-lt { cursor: nw-resize }
.wizimgdragresize-tm { cursor: n-resize }
.wizimgdragresize-rt { cursor: ne-resize }
.wizimgdragresize-lm { cursor: w-resize }
.wizimgdragresize-rm { cursor: e-resize }
.wizimgdragresize-lb { cursor: sw-resize }
.wizimgdragresize-bm { cursor: s-resize }
.wizimgdragresize-rb { cursor: se-resize }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
body { font-family: 微软雅黑, “Microsoft YaHei”, Georgia, Helvetica, Arial, sans-serif, 宋体, PMingLiU, serif; font-size: 10.5pt; line-height: 1.5 }
html, body { }
h1 { font-size: 1.5em; font-weight: bold }
h2 { font-size: 1.4em; font-weight: bold }
h3 { font-size: 1.3em; font-weight: bold }
h4 { font-size: 1.2em; font-weight: bold }
h5 { font-size: 1.1em; font-weight: bold }
h6 { font-size: 1em; font-weight: bold }
img { border: 0; max- 100%; height: auto !important }
blockquote { margin-top: 0; margin-bottom: 0 }
table { border-collapse: collapse; border: 1px solid rgba(187, 187, 187, 1) }
td { border-collapse: collapse; border: 1px solid rgba(187, 187, 187, 1) }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }
.wizimgdragresize { position: absolute; z-index: 1000; border: 1px solid rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1) }
.wizimgdragresize-lt { cursor: nw-resize }
.wizimgdragresize-tm { cursor: n-resize }
.wizimgdragresize-rt { cursor: ne-resize }
.wizimgdragresize-lm { cursor: w-resize }
.wizimgdragresize-rm { cursor: e-resize }
.wizimgdragresize-lb { cursor: sw-resize }
.wizimgdragresize-bm { cursor: s-resize }
.wizimgdragresize-rb { cursor: se-resize }
.wiz-todo, .wiz-todo-img { 16px; height: 16px; cursor: default; padding: 0 10px 0 2px; vertical-align: -10%; -webkit-user-select: none }
.wiz-todo-label { display: inline-block; padding-top: 7px; padding-bottom: 6px; line-height: 1.5 }
.wiz-todo-label-checked { color: rgba(102, 102, 102, 1) }
.wiz-todo-label-unchecked { }
.wiz-todo-completed-info { padding-left: 44px; display: inline-block }
.wiz-todo-avatar { 20px; height: 20px; vertical-align: -20%; margin-right: 10px; border-radius: 2px }
.wiz-todo-account, .wiz-todo-dt { color: rgba(102, 102, 102, 1) }
{ 17px; height: 17px; background-color: rgba(240, 240, 240, 1); border: none }
{ background-color: rgba(220, 220, 220, 1) }
{ background-color: rgba(192, 192, 192, 1) }
{ background-color: rgba(150, 150, 150, 1) }
{ background-color: rgba(249, 249, 249, 1) }
{ background-color: rgba(240, 240, 240, 1) }
{ }
{ 12px; height: 12px }

二叉树的建立:

对于二叉树,如果单纯通过前序遍历或后序遍历以及中序遍历是无法唯一确定一棵二叉树的前序+中序后序+中序才可以唯一确定一棵二叉树。
因此我们可以通过前序+中序或者后序+中序的结果对二叉树进行确定。

假设一棵二叉树为如下:
则前序和中序遍历的结果是:
我们首先要对前序遍历和中序遍历的特点进行了解。如上图数组中,明显可以看到。在前序遍历中,数组第一个元素就是这棵树的Root,而中序遍历,则Root位于中间位置啦 ,但是在中序中Root(图中中序遍历数组 的“1”)左边是其左子树,而其右边是其右子树的节点值,于是我们大概可以确定这棵树了。
那么左子树又如何确定呢?前序遍历结果:                   中序遍历结果:
于是我们又可以确定如下:

那么又子树呢?同样的嘛:
一直这样迭代下去,肯定就可以了搞定了。

#ifndef RECONSTRUCT_BINARY_TREE_H#define RECONSTRUCT_BINARY_TREE_H#include<iostream>struct TreeNode{	int val; 	struct TreeNode *left; 	struct TreeNode *right; }; struct TreeNode *reconstructBinaryTree(int *preorder,int *midorder,int length); struct TreeNode *reconstructCore(int *startPreorder,int *endPreorder,int *startMidorder,int *endMidorder); 
struct TreeNode *reconstructBinaryTree(int *preorder,int *midorder,int length){ return reconstructCore(preorder,preorder+length-1,midorder,midorder+length-1); }struct TreeNode *reconstructCore( int *startPreorder,int *endPreorder, int *startMidorder,int *endMidorder){ //这里是关键,传入的参数是当前前序、中序的起始位置
int rootValue=*startPreorder; struct TreeNode *root=new TreeNode; //核心部分,构建一个节点 root->val=rootValue; root->left=root->right=NULL; if(startPreorder==endPreorder){ if(startMidorder==endMidorder&&*startPreorder==*startMidorder){ return root; //边界值的处理 }else{ throw("invalid input "); } } int *iter; int leftCount=0; for(iter=startMidorder; iter!=endMidorder; iter++){ if(*iter==rootValue){ break; } leftCount++; } if(iter!=startMidorder&&iter!=endMidorder){ //如果左右子树不为空 root->left=reconstructCore(startPreorder+1,startPreorder+leftCount,startMidorder,iter-1); root->right=reconstructCore(startPreorder+leftCount+1,endPreorder,iter+1,endMidorder); } if(iter==startMidorder&&iter!=endMidorder){ //如果左子树为空 root->left=NULL; root->right=reconstructCore(startPreorder+leftCount+1,endPreorder,iter+1,endMidorder); } if(iter!=startMidorder&&iter==endMidorder){ //如果右子树为空 root->left=reconstructCore(startPreorder+1,startPreorder+leftCount,startMidorder,iter-1); root->right=NULL; } return root; }void preorderPrint(struct TreeNode *root){ if(root==NULL){ return; } std::cout<<root->val<<std::endl; preorderPrint(root->left); preorderPrint(root->right); }void midorderPrint(struct TreeNode *root){ if(root==NULL){ return; } preorderPrint(root->left); std::cout<<root->val<<std::endl; preorderPrint(root->right);}#endif

int main(){	int pre[8]={1,2,4,7,3,5,6,8}; 	int mid[8]={4,7,2,1,5,3,8,6};	struct TreeNode *root=reconstructBinaryTree(pre,mid,8); 	/*std::cout<<root->left->val<<std::endl; 	std::cout<<root->left->left->right->val<<std::endl; 	std::cout<<root->left->left->val<<std::endl; 	std::cout<<root->right->left->val<<std::endl; 	std::cout<<root->right->right->val<<std::endl; 	std::cout<<root->right->right->left->val<<std::endl; */		preorderPrint(root); 	midorderPrint(root); }

来自为知笔记(Wiz)

Published by

风君子

独自遨游何稽首 揭天掀地慰生平

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注