height


Java Binary Tree Height


How would I go about solving this question? I'm pretty sure that the height of this tree is 3... Please correct me if I'm wrong! Thanks!
What the question asks is, How many combinations are there to insert elements to the binary tree in order to obtain the maximum height of the binary tree
Suppose if we insert elements to the tree in the reverse sorted manner. First 5, then 4 and finally 1. In this case, each element will be added to the right of the parent making a tree of height 5.
Suppose if we insert elements in sorted order. Then each element will be added to the left of it's parent which also make the tree of height 5.
In both of the above cases, child nodes were added only to left side or right side of a parent
In all the other combinations, since there can be at least one element with two children, the height of the tree will not exceed 4.
Therefore, the answer for the question is 2 since there is only two combinations to achieve the maximum height, 5. The height of the tree will be 3 only when the tree is balanced.
Hope you found the solution.

Related Links

Binary Tree find height of a specific Node
Re-size the Text and Button/Label in Livecode
Overlay a background image onto the web page
WooCommerce - change price based on product_id, width and height
Susy gallery breaks height for display table and table-cell
Flex Slider full height and width without stretching
mPDF set Height for SetHTMLHeader
How to Set Height of PdfPTable in iTextSharp
Margin not showing with 100% width & height
KO Grid Scrollbars not visible & Display issues
Increase scrollview's element height on clicking it
Using soft keyboard on libgdx for iOS and Android (hides textview)
Fine-uploader - Scaling picture by height
Zurb foundation framework - 100% height grid
Dynamically expanding CollectionView : Height of the CollectionView itself (not the items) changing when adding new items
IE 11 bug, div with height > 1,533,917px display negative computed height and doesnt render

Categories

HOME
caching
jdbc
cntk
reverse-engineering
mapping
label
survival-analysis
transparent
rocketmq
branch.io
avl-tree
proguard
eclipse-cdt
wysiwyg
onsen-ui2
glpk
lstm
reduction
dendrogram
redux-observable
off-canvas-menu
atlassian-plugin-sdk
jpeg2000
movies
propel2
multiple-columns
scalaz7
richfaces
restfb
rhandsontable
interrupt-handling
metadata-extractor
fetch-api
cell-array
referenceerror
strophe
exponential
fabric-digits
google-guava-cache
bigcartel
poco-libraries
initializer
mongoexport
topic-modeling
silverlight-3.0
jquery-multidatespicker
infusionsoft
flex4.5
wcf-security
onbackpressed
spring-bean
ttcn
scalafx
prototypejs
walmart-electrode
istorage
crystal-reports-8.5
laravel-query-builder
barcode-printing
inject
android-navigationview
push-diffusion
software-product-lines
wcf-ria-services
radians
group-concat
servlet-3.0
void
android-viewholder
futuretask
pyrocms
lines-of-code
virus
ejabberd-saas
sysctl
humanizer
wss
kraken.js
slick-2.0
help-viewer
lov
winrt-httpclient
chrome-for-android
baucis
jquery-tabs
sqljdbc
mstsc
mailcore
n-layer
jpf
hobo
flexicious
path-manipulation
throttling
curljs
paintcomponent
authenticode
libavformat
external-assemblies
multibyte-functions
opcodes
data-entry

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App