Starting Out With C++, Early Objects - With Access Package
Starting Out With C++, Early Objects - With Access Package
8th Edition
ISBN: 9780133441840
Author: GADDIS
Publisher: PEARSON
Question
Book Icon
Chapter 19, Problem 18RQE
Program Plan Intro

Binary tree:

  • It is a tree data structure which comes under hierarchical data structure.
  • It is made of nodes that have a left child, right child and a data element.

Tree traversal:

  • There are 3 common methods
    • Inorder traversal
    • Preorder traversal
    • Postorder traversal
  • In inorder traversal, the left subtree is encountered first, then data node and then the right subtree.
  • In preorder traversal, the data node is encountered first, then left subtree and then the right subtree.
  • In postorder traversal, the left subtree is encountered first, then right subtree and then the data node.

Algorithm for Preorder traversal:

  • Visit and print the root node.
  • Now traverse through the leftmost subtree and then print the element.
  • Traverse the rightmost subtree and then print the element.

Blurred answer
Students have asked these similar questions
The tree pointer is the first node of the binary tree and has both data and two reference links.   True False
To insert an element into a binary search tree (BST), you need to locate where to insert it in the tree. The key idea is to locate the parent for the new node.  True  False
question 5 : A node in a binary tree has the capacity to hold references to how many other nodes? Answer: 2     ( Please type answer note write by hend )
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education