Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
17 views
Tree Questions
Data Structures using C
Uploaded by
govopi6584
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Tree Questions For Later
Download
Save
Save Tree Questions For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
17 views
Tree Questions
Data Structures using C
Uploaded by
govopi6584
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Tree Questions For Later
Carousel Previous
Carousel Next
Save
Save Tree Questions For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 14
Search
Fullscreen
{7:7 BINARY SEARCH TRE Binary tree T is said to be binary search tree if each node N of T has the following properties : 1. The value of N is greater than every value in the left subtree of N. 2, The value of Nis less than every value in the right subtree of N. In other words, a binary tree in which the left child, if any, of each contains a smaller value and the right child, if any, contains a large value than the parent node.. For example, Fig. 7.24 shows a binary search tree. : Fig. 7.24: A binary search tree with 10 nodes. Notice that, for any given node, the node to its left contains smaller value and its right contains larger value. nodet?rees ADVANTAGES cs Thegreat advantage of this Search tree athe root will either find the element grin ure ay ne oranelement,acomparison icate whi pROPERTIES OF BINARY SEARCH tee Which one subtree to search. Following are the properties of bin, s lary search tree ‘he inorder tr: i Bee creadingerae oat Search tree shows that values stored in this tree inFig 724% For example, the inorder traversal of binary search tree 1, 2, 3, 4, 5, 6, 7,8 9, 10 ie, element comes in an increasing order. 2. Smallest element in binary search tree is the left most element and largest element of binary search tree is the right most element in the binary search tree. 18: OPERATION ON BINARY SEARCH TREE _ —~Cenarally follouine nw Generally, following operations are performed on binary search tree. 1 Insertion 2. Deletion 3. Searching LINSERTION To insert a node in binary search tree, we must first check whether the tree already ‘ntains any nodes. If tree is empty, the node is placed in the root node. If the tree is not ‘npty, then the proper location is found and new node becomes either a left or a right child ofan existing node. . Consider the following binary search tree T and suppose 33 is added to the tree T. 5 pinary Search Tree Before Insertion, 25: Fig. 7306 Eagle’s Data Structure Using ¢ First, compare the 33 with root ie. 60. Since 33 < 60, move to the left chilg of oo, which is 30., Compare 33 with 30. Since 33 > 30, move to the right child of 30 ie. s¢ Compare 33 with 55, Since 33 <55, move tothe left child of 55, whichis 35, Now, compar 33 and 35, Since, 33 <35 and 35 has no left child, so we add 33 as left child of node 35 So, new binary search tree is : Fig. 7.26 : Binary Search Tree after insertion. -- ALGORITHM : INS_BST (ROOT, ITEM) Here, ROOT is a pointer variable that contains address of root node and ITEMis value to be inserted in binary search tree. This is a recursive algorithm. Step! If(ROOT== Step2 Set PTR:= ROOT Step3 -If(TEM
Data Step 4. Preorder (PTR —> child) Step5. Preorder (PTR —> Rchild) Step6. End. Q.5, Construct a binary tree whose nodes are as under : Preorder: ABCD FHJMKEGILN Postorder: AD JMHKFCINLGEB Ans, Recheck Result : Preorder: AB CD FHJMKEGILN Ostorder : AD JMHKF CINLGEB316 Eagle’s Data Structure Using Q. 6. Construct a binary tree whose nodes are as under : Preorder: ABDGHCEFIKJ Inorder: BGHDAECIKFJ Ans. os \ io Age NS De Recheck Result : Preorder: ABD GHCEFIKJ Inorder: BGHDAECIKFJ ======m OBJECTIVE TYPE QUESTIONS Be=———= data structure. tree can have at the most two children. 3. ‘Two nodes are known as .. ... if they have the same parents. ou Ancemunctancde mparenenedegea node. 5. Terminal node is the node that has .. degree. 6. Binary tree is.............. in nature. ... is the maximum level of any node in a tree. 8. Siblings are the children of .. parent. 9. A tree is composed of a collection of .. 10. BST stands for ... 1. Ab . Tefers to the process of visiting each node in a tree data structure. 12. , the contents of a root node are printed first. 13. The maximum leyel of any leaf in the tree is known as the .......... of the tree. 14, Ina complete binary tree, the out degree of every node is exactly equal to 2 or 0-(" crf) 15. Two nodes are .. . if they are left and Tight children of the same node. 16. The height of a iar tree is the maximum level of its tree. cy 17. A binary tree consists of nodes which have exactly two nodes. ee | 18. ee number of nodes at each level in complete binary tree is 1 less than som? oa) ol 19. The preorder traversal of binary tree begins with processing of the ...ac / grees 317 Answers 1. ae 2. Binary 3. siblings 4. Depth 5. zero 6. hierarchical eee 8. same 9. nodes 10. st earch Tree 11. Traverse 12. preorder 13. dept! 14. True 15. siblings 16. False 17. False 18. True 19. root SHORT ANSWER TYPE QUESTIONS Why trees structure is known as non-linear data structure ? What do you mean by similar binary tree and copies of binary tree ? Define the following terms : ere (i) Root (ii) Siblings (ii) Ancestor (iy) Descendents (») Level (vi) Path (vii) Branch (viii) Height (ix) Leaf node. Write short notes on the following : (a) Full binary tree (b) Complete binary tree (¢) Extended binary tree. = LONG ANSWER TYPE QUESTIONS g==——=—= 1. What do you mean by a binary tree ? How they are represented and implemented in memory ? Explain with suitable examples. 2. Explain the three standard ways of traversing a binary tree in detail with suitable examples. 4. Write and explain the preorder tree traversal algorithm. 4 Write and explain the inorder tree traversal algorithm. © White and explain postorder tree traversal algorithm. i ‘ f do you mean by binary search tree ? Explain the operations associated with binary >, tarch tree, | What distinguish a binary tree from other dynamic data structure such as linked stack, 4, iked queue and linked list ? ; ; i 4 . do you mean by sequential representation and linked representation of binary , “Sesin memory ? Explain. =
You might also like
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Mark Manson
4/5 (6129)
Principles: Life and Work
From Everand
Principles: Life and Work
Ray Dalio
4/5 (627)
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Brene Brown
4/5 (1148)
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
Chris Voss
4.5/5 (934)
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Jeannette Walls
4/5 (8215)
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Angela Duckworth
4/5 (631)
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
Jesmyn Ward
4/5 (1253)
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Stephen Chbosky
4/5 (8365)
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Phil Knight
4.5/5 (860)
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
Carmen Maria Machado
4/5 (877)
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Ben Horowitz
4.5/5 (361)
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
Margot Lee Shetterly
4/5 (954)
Steve Jobs
From Everand
Steve Jobs
Walter Isaacson
4/5 (2923)
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
Ashlee Vance
4.5/5 (484)
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
Siddhartha Mukherjee
4.5/5 (277)
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Fredrik Backman
4.5/5 (4972)
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Frank McCourt
4.5/5 (444)
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
Colm Toibin
3.5/5 (2061)
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
Garth Stein
4/5 (4281)
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
Sarah M. Broom
4/5 (100)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
Meik Wiking
3.5/5 (447)
Yes Please
From Everand
Yes Please
Amy Poehler
4/5 (1987)
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
Gilbert King
4.5/5 (278)
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Thomas L. Friedman
3.5/5 (2283)
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
Roxane Gay
4/5 (1068)
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
Ruth Ware
3.5/5 (2641)
The Outsider: A Novel
From Everand
The Outsider: A Novel
Stephen King
4/5 (1993)
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
Betty Smith
4.5/5 (1936)
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
Viet Thanh Nguyen
4.5/5 (125)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Dave Eggers
3.5/5 (692)
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Doris Kearns Goodwin
4.5/5 (1912)
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
Hilary Mantel
4/5 (4074)
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Naomi Klein
4/5 (75)
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Bob Woodward
3.5/5 (830)
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
Jennifer Egan
3.5/5 (901)
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Jay Sekulow
3.5/5 (143)
John Adams
From Everand
John Adams
David McCullough
4.5/5 (2544)
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
M L Stedman
4.5/5 (790)
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
George Packer
4/5 (45)
Little Women
From Everand
Little Women
Louisa May Alcott
4/5 (105)
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel
John le Carré
3.5/5 (109)
Related titles
Click to expand Related Titles
Carousel Previous
Carousel Next
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Principles: Life and Work
From Everand
Principles: Life and Work
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
Steve Jobs
From Everand
Steve Jobs
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
Yes Please
From Everand
Yes Please
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
The Outsider: A Novel
From Everand
The Outsider: A Novel
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
John Adams
From Everand
John Adams
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
Little Women
From Everand
Little Women
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel