Wednesday, August 15, 2007

Write a C program to find the depth or height of a tree.

Here is some C code to get the height of the three


tree_height(mynode *p)
{
if(p==NULL)return(0);
if(p->left){h1=tree_height(p->left);}
if(p=>right){h2=tree_height(p->right);}
return(max(h1,h2)+1);
}



The degree of the leaf is zero. The degree of a tree is the max of its element degrees. A binary tree of height n, h > 0, has at least h and at most (2^h -1) elements in it. The height of a binary tree that contains n, n>0, elements is at most n and atleast log(n+1) to the base 2.

Log(n+1) to the base 2 = h

n = (2^h - 1)

222 comments:

«Oldest   ‹Older   201 – 222 of 222
ツイッター said...

新時代突入!ツイッターで始まる出逢い…ここでしかできない出逢いが新しい風を巻き起こす!!素敵な巡りあわせを体験していこう!

SMチェッカー said...

あなたの秘められたSM度がわかるSMチェッカー!簡単な質問に答えるだけで自分の隠された部分が分かります!みんなで試してみよう

モバゲー said...

今やモバゲーは押しも押されもせぬ人気SNS!当然出 会いを求めてる人も多い!そこで男女が出 逢えるコミュニティーが誕生!ここなら友達、恋人が簡単にできちゃいますよ

モバゲー said...

もう夏休みも終わりに近づき、この夏最後の思い出を作りたいと焦ってる方が、モバゲーのコミュニティーに書かれてましたよ!!折角なんで夏の思い出作りに協力して自分も美味しい思いをしてみるのはどうですか?大手スポンサーサイトが付いてるので全部タダですよ

グリー said...

最近はどこのSNSサイトも規制ばっかりで、ちょっと出 合いに関して書き込みするとアク禁食らうけど、夏休み終盤に差し掛かり色々なサイトを調べた結果、グリーだけはどうも規制が緩んでるみたいです。今がチャンスの時期ですよ

ツイッター said...

ツイッターで出 合 いを求めるのです。気の合う異性と交流して楽しいひと時をお過ごしください。登録無料で使えるので気軽さは100点満点!

sandeep kumar said...

Thanks for the info. It is very helpful.
RegardsEducational site
Get jobs info at Educational site

Tyler Thursby said...

Hello there! Thanks for providing such an awesome resource with your site here. I was hoping you might be interested in swapping links.
I’m working on a little site that specializes in providing job interview tips. It’s a humble operation and we’re trying to build our exposure up now.
Keep up the great work! Your site looks fantastic  Cheers!

tom smith said...

It is nice to see this blog with full of interview questions with good order . It helped me a lot to prepare exams. Hadoop Interview Questions

anish mounish said...
This comment has been removed by the author.
Reginals Sanjay Pal said...

Myself reginald sanjay pal. Thanks for share beneficial information.

vivek vats said...

admit card 2015,
Exams Result
Answer Key
Question Papers
Syllabus
admit card
Naukri
government jobs

asitbangalorereviews said...

Good collection...
Core Java Interview Questions and Answers

Advanced Java Interview Questions and Answers

c++ interview questions and answers

Mysql Interview Questions and Answers

Testing Questions and Answers

Martin said...

Hello my friend! I would like to tell you that this write-up is awesome, great written and include almost all important info. I recently came to know about http:www.yesiamhired.com, their Interview Tips are very effective.
Interview Tips

akmal niazi khan said...

Programming is very interesting and creative thing if you do it with love. Your blog code helps a lot to beginners to learn programming from basic to advance level. I really love this blog because I learn a lot from here and this process is still continuing.
Love from Pro Programmer

Ramachandran Gopalan said...

Thank you for making this site very interesting! Keep going! You're doing very well
online interview guide

Bharath Gopalan said...

Wow, what a fantastic post. The best post around. Thumbs up
online interview guide

Anveshitha Anu said...

thnks for this sharing the lot of interview tips

interview tips
job interview tips
tips for job interviews
tips for an interview
tips interview
interview questions
interview questions and answers

Naresh Mallarapu said...

Thank you for sharing such a useful information. It was so useful. Please visit
Intrview

Naresh Mallarapu said...

Thank you for sharing such a useful information. It was so useful. Please visit
Intrview

Vamshi Krishna said...

Very Useful information that i have found. donot stopand Please keep updating us..... Thanks

Sujitkumar said...

Nice tutorial. Thanks for sharing the valuable info about c Training. it’s really helpful. Who want to learn c language this blog most helpful. Keep sharing on updated tutorials…..

«Oldest ‹Older   201 – 222 of 222   Newer› Newest»