EBK BIG JAVA: EARLY OBJECTS, INTERACTIV
EBK BIG JAVA: EARLY OBJECTS, INTERACTIV
6th Edition
ISBN: 8220102010314
Author: Horstmann
Publisher: YUZU
Question
Book Icon
Chapter 17, Problem 11PE
Program Plan Intro

Implementing RedBlackTree

Program plan:

RedBlackTree.java:

  • Define the class “RedBlackTree”.
    • Declare “Node” to access the package and variables.
    • Defining the “RedBlackTree()” constructor.
      • Generate empty tree.
    • Defining the “isValid()” method.
      • This function returns a Boolean value by visiting very node.
    • Defining the “exitCount()” function.
      • This computes the exit cost for n-nodes.
      • Returns the value of exit cost.
    • Define a “add()” method which incorporates comparable class.
      • This function used to add a node to the tree.
    • Define a “find()” function.
      • This finds a node in the tree.
      • Return a Boolean value true, if the node is found, otherwise returns a false.
    • Define a “remove()” function.
      • This function removes an object from the tree.
    • Define a method “toString()”.
      • This function gets the information of the subtree.
      • Returns all the elements in inorder method.
    • Define a static method “toString()”, which gets the information of the subtree with given root node.
      • Returns all the elements in inorder with a space between each element.
    • Define a class “Node”.
      • Define a constructor “Node()”.
        • This develops a red node with no information.
          • Define a “setLeftChild()”.
            • This function used to set the left child.
            • Then update its parent reference data.
          • Define a “setLeftRight()”.
            • This function used to set the right child.
            • Then update its parent reference data.
          • Define a “addNode()” function.
            • This function adds a node as descendant.
    • Define a “replacewith()” function.
      • This function updates the parent’s and replace the node’s link.
      • Then update the root reference.
    • Define a “fixAfterAdd()” function.
      • This restores the tree after a new node added.
    • Define a “fixBeforeRemove()” function.
      • This function fixes the tree after a node is removed.
    • Define a “bubbleUp()” function.
      • This function moves a charge from two children of a parent.
    • Define a “bubbleUpFix()” function.
      • This function fixes the negative-red or doble-red violation that caused by bubble up.
      • Returns a true value if the tree is fixed.
    • Define a “fixDoubleRed()” function.
      • This function fixes the double red violation.
    • Define a “fixNegativeRed()” function.
      • This function used to fix the negative red violation.

RedBlackTreeTester.java:

  • Define “RedBlackTreeTester” class.
    • Define the “main()” function.
      • Create an object “t” for “RedBlackTreeTester”.
      • Add the tree elements using the object “t”.
      • Now print the output by calling the member functions of “RedBlackTreeTester”.

Blurred answer
Students have asked these similar questions
What are the major threats of using the internet? How do you use it? How do children use it? How canwe secure it? Provide four references with your answer. Two of the refernces can be from an article and the other two from websites.
Assume that a string of name & surname is saved in S. The alphabetical characters in S can be in lowercase and/or uppercase letters. Name and surname are assumed to be separated by a space character and the string ends with a full stop "." character. Write an assembly language program that will copy the name to NAME in lowercase and the surname to SNAME in uppercase letters. Assume that name and/or surname cannot exceed 20 characters. The program should be general and work with every possible string with name & surname. However, you can consider the data segment definition given below in your program. .DATA S DB 'Mahmoud Obaid." NAME DB 20 DUP(?) SNAME DB 20 DUP(?) Hint: Uppercase characters are ordered between 'A' (41H) and 'Z' (5AH) and lowercase characters are ordered between 'a' (61H) and 'z' (7AH) in the in the ASCII Code table. For lowercase letters, bit 5 (d5) of the ASCII code is 1 where for uppercase letters it is 0. For example, Letter 'h' Binary ASCII 01101000 68H 'H'…
What did you find most interesting or surprising about the scientist Lavoiser?

Chapter 17 Solutions

EBK BIG JAVA: EARLY OBJECTS, INTERACTIV

Ch. 17.2 - Prob. 11SCCh. 17.2 - Prob. 12SCCh. 17.3 - Prob. 13SCCh. 17.3 - Prob. 14SCCh. 17.3 - Prob. 15SCCh. 17.3 - Prob. 16SCCh. 17.3 - Prob. 17SCCh. 17.3 - Prob. 18SCCh. 17.4 - Prob. 19SCCh. 17.4 - Prob. 20SCCh. 17.4 - Prob. 21SCCh. 17.4 - Prob. 22SCCh. 17.4 - Prob. 23SCCh. 17.4 - Prob. 24SCCh. 17.5 - Prob. 25SCCh. 17.5 - Prob. 26SCCh. 17.5 - Prob. 27SCCh. 17.5 - Prob. 28SCCh. 17.5 - Prob. 29SCCh. 17.5 - Prob. 30SCCh. 17.6 - Prob. 31SCCh. 17.6 - Prob. 32SCCh. 17.6 - Prob. 33SCCh. 17.6 - Prob. 34SCCh. 17.6 - Prob. 35SCCh. 17.7 - Prob. 36SCCh. 17.7 - Prob. 37SCCh. 17.7 - Prob. 38SCCh. 17.7 - Prob. 39SCCh. 17.7 - Prob. 40SCCh. 17 - Prob. 1RECh. 17 - Prob. 2RECh. 17 - Prob. 3RECh. 17 - Prob. 4RECh. 17 - Prob. 5RECh. 17 - Prob. 6RECh. 17 - Prob. 7RECh. 17 - Prob. 8RECh. 17 - Prob. 9RECh. 17 - Prob. 10RECh. 17 - Prob. 11RECh. 17 - Prob. 12RECh. 17 - Prob. 13RECh. 17 - Prob. 14RECh. 17 - Prob. 16RECh. 17 - Prob. 18RECh. 17 - Prob. 19RECh. 17 - Prob. 20RECh. 17 - Prob. 21RECh. 17 - Prob. 22RECh. 17 - Prob. 23RECh. 17 - Prob. 24RECh. 17 - Prob. 25RECh. 17 - Prob. 26RECh. 17 - Prob. 27RECh. 17 - Prob. 28RECh. 17 - Prob. 1PECh. 17 - Prob. 2PECh. 17 - Prob. 3PECh. 17 - Prob. 4PECh. 17 - Prob. 5PECh. 17 - Prob. 6PECh. 17 - Prob. 7PECh. 17 - Prob. 8PECh. 17 - Prob. 9PECh. 17 - Prob. 10PECh. 17 - Prob. 11PECh. 17 - Prob. 12PECh. 17 - Prob. 13PECh. 17 - Prob. 1PPCh. 17 - Prob. 2PPCh. 17 - Prob. 3PPCh. 17 - Prob. 4PPCh. 17 - Prob. 5PPCh. 17 - Prob. 6PPCh. 17 - Prob. 7PPCh. 17 - Prob. 8PPCh. 17 - Prob. 9PPCh. 17 - Prob. 10PPCh. 17 - Prob. 11PP
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