COMPUTER SCIENCE ILLUMIN.-TEXT
COMPUTER SCIENCE ILLUMIN.-TEXT
7th Edition
ISBN: 9781284156010
Author: Dale
Publisher: Jones & Barlett
Question
Book Icon
Chapter 8, Problem 47E
Program Plan Intro

Binary search tree:

  • Binary search tree is a tree; the nodes are sorted in the semantic order.
  • Binary search tree nodes can have zero, one, or two children.
  • Node without children is called a leaf or end node.
  • A node that does not have a superior node is called a root node or starting node.
    • In binary search tree, the left subtree contains the nodes lesser than the root node.
    • The right subtree contains the nodes greater than the root node.
  • The binary search will performed until finding a search node or reaching the end of the tree.

Expert Solution & Answer
Check Mark

Explanation of Solution

Insertion of elements in the binary search tree:

Given elements to construct a binary search tree are as follows:

50, 72, 96, 107, 26, 12, 11, 9, 2, 10, 25, 51, 16, 17, 95.

Step 1:

Insert the element 50, which is the root node of a binary search tree.

COMPUTER SCIENCE ILLUMIN.-TEXT, Chapter 8, Problem 47E , additional homework tip  1

Step 2:

Next element is 72, which is greater than root node element 50, so insert the element 72 as the right child of the root node.

COMPUTER SCIENCE ILLUMIN.-TEXT, Chapter 8, Problem 47E , additional homework tip  2

Step 3:

  • Next element is 96, which is greater than root node element 50, so insert the element 96 as the right child of the root node.
  • The root node already contains the element 72 as the right child and the element 96 is greater than the element 72.
  • So, insert the element 96 as the right child of 72.

COMPUTER SCIENCE ILLUMIN.-TEXT, Chapter 8, Problem 47E , additional homework tip  3

Step 4:

  • Next element is 107, which is greater than root node element 50, so insert the element 107 as the right child of the root node.
  • The root node already contains the element 72 as the right child and the element 107 is greater than the element 72.
  • The element 72 already contains the element 96 as the right child and the element 107 is greater than the element 96.
  • So, insert the element 107 as the right child of 96.

COMPUTER SCIENCE ILLUMIN.-TEXT, Chapter 8, Problem 47E , additional homework tip  4

Step 5:

Next element is 26, which is less than root node value 50, so insert the element 26 as the left child of the root node.

COMPUTER SCIENCE ILLUMIN.-TEXT, Chapter 8, Problem 47E , additional homework tip  5

Step 6:

  • Next element is 12, which is less than the root node value 50, so insert the element 12 as left child of the root node.
  • The root node already contains the element 26 as the left child and the element 12 is less than the element 26.
  • So, insert the element 12 as left child of the element 26.

COMPUTER SCIENCE ILLUMIN.-TEXT, Chapter 8, Problem 47E , additional homework tip  6

Step 7:

  • Next element is 11, which is less than the root node value 50, so insert the element 11 as left child of the root node.
  • The root node already contains the element 26 as the left child and the element 11 is less than the element 26.
  • The element 26 already contains the element 12 as the left child and the element 11 is lesser than the element 12.
  • So, insert the element 11 as left child of the element 12.

COMPUTER SCIENCE ILLUMIN.-TEXT, Chapter 8, Problem 47E , additional homework tip  7

Step 8:

  • Next element is 9, which is less than the root node value 50, so insert the element 9 as left child of the root node.
  • The root node already contains the element 26 as the left child and the element 9 is less than the element 26.
  • The element 26 already contains the element 12 as the left child and the element 9 is lesser than the element 12.
  • The element 12 already contains the element 11 as the left child and the element 9 is lesser than the element 11.
  • So, insert the element 9 as left child of the element 11.

COMPUTER SCIENCE ILLUMIN.-TEXT, Chapter 8, Problem 47E , additional homework tip  8

Step 9:

  • Next element is 2, which is less than the root node value 50, so insert the element 2 as left child of the root node.
  • The root node already contains the element 26 as the left child and the element 2 is less than the element 26.
  • The element 26 already contains the element 12 as the left child and the element 2 is lesser than the element 12.
  • The element 12 already contains the element 11 as the left child and the element 2 is lesser than the element 11.
  • The element 11 already contains the element 9 as the left child and the element 2 is lesser than the element 9.
  • So, insert the element 2 as left child of the element 9.

COMPUTER SCIENCE ILLUMIN.-TEXT, Chapter 8, Problem 47E , additional homework tip  9

Step 10:

  • Next element is 10, which is less than the root node value 50, so insert the element 10 as left child of the root node.
  • The root node already contains the element 26 as the left child and the element 10 is less than the element 26.
  • The element 26 already contains the element 12 as the left child and the element 10 is lesser than the element 12.
  • The element 12 already contains the element 11 as the left child and the element 10 is lesser than the element 11.
  • The element 11 already contains the element 9 as the left child and the element 10 is greater than the element 9.
  • So, insert the element 10 as right child of the element 9.

COMPUTER SCIENCE ILLUMIN.-TEXT, Chapter 8, Problem 47E , additional homework tip  10

Step 11:

  • Next element is 25, which is less than the root node value 50, so insert the element 25 as left child of the root node.
  • The root node already contains the element 26 as the left child and the element 25 is less than the element 26.
  • The element 26 already contains the element 12 as the left child and the element 25 is greater than the element 12.
  • So, insert the element 25 as right child of the element 12.

COMPUTER SCIENCE ILLUMIN.-TEXT, Chapter 8, Problem 47E , additional homework tip  11

Step 12:

  • Next element is 51, which is greater than root node element 50, so insert the element 51 as the right child of the root node.
  • The root node already contains the element 72 as the right child and the element 51 is lesser than the element 72.
  • So, insert the element 51 as the left child of 72.

COMPUTER SCIENCE ILLUMIN.-TEXT, Chapter 8, Problem 47E , additional homework tip  12

Step 13:

  • Next element is 16, which is less than the root node value 50, so insert the element 16 as left child of the root node.
  • The root node already contains the element 26 as the left child and the element 16 is less than the element 26.
  • The element 26 already contains the element 12 as the left child and the element 16 is greater than the element 12.
  • The element 12 already contains the element 25 as the right child and the element 16 is lesser than the element 25.
  • So, insert the element 16 as left child of the element 25.

COMPUTER SCIENCE ILLUMIN.-TEXT, Chapter 8, Problem 47E , additional homework tip  13

Step 14:

  • Next element is 17, which is less than the root node value 50, so insert the element 17 as left child of the root node.
  • The root node already contains the element 26 as the left child and the element 17 is less than the element 26.
  • The element 26 already contains the element 12 as the left child and the element 17 is greater than the element 12.
  • The element 12 already contains the element 25 as the right child and the element 17 is lesser than the element 25.
  • The element 25 already contains the element 16 as the left child and the element 17 is greater than the element 16.
  • So, insert the element 17 as right child of the element 16.

COMPUTER SCIENCE ILLUMIN.-TEXT, Chapter 8, Problem 47E , additional homework tip  14

Step 15:

  • Next element is 95, which is greater than root node element 50, so insert the element 95 as the right child of the root node.
  • The root node already contains the element 72 as the right child and the element 95 is greater than the element 72.
  • The element 72 already contains the element 96 as the right child and the element 95 is lesser than the element 96.
  • So, insert the element 95 as the left child of 96.

COMPUTER SCIENCE ILLUMIN.-TEXT, Chapter 8, Problem 47E , additional homework tip  15

Therefore, the above tree is the final constructed binary search tree for the given elements.

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
For the control system plot root Locus and find the D gain of stability? by Matlab Ris Kp (5+3) S+5 (s+1) +CUST s(S+2) (565+18) 5-1 5²+35+4
CIS 115 Introduction to C++ May I please have a written review expressing my gratitude for a tutor that has given me guidance throughout the computer programming course? Thank you so much!
Math 130 Introduction to Java programming May I please have a written review expressing my gratitude for a tutor that has given my guidance throughout my computer programming course? Thank you
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