EBK STARTING OUT W/JAVA:...DATA...
EBK STARTING OUT W/JAVA:...DATA...
4th Edition
ISBN: 9780134757179
Author: GADDIS
Publisher: PEARSON CO
bartleby

Concept explainers

Question
Book Icon
Chapter 21, Problem 6PC
Program Plan Intro

Binary Tree Input and Display

Program plan:

  • Import required packages.
  • Define the class named “JTreeDemo”.
    • Declare required private variables.
    • Define the constructor.
      • Initialize the values.
      • Load the “JTree”.
    • Give function definition “readData ()” to read data from the file.
      • Create the objects for “FileInputStream”, “InputStreamReader”, and “BufferedReader” in order to read the file
      • Declare variables “line”, and “countNode”.
      • Inside the “try” block,
        • Do until the file becomes empty using “while” condition.
          • Check if the line contains the given matches,
            • Assign the values to “numNodes”.
          • Else,
            • Assign line to “data[countNode]”.
            • Increment the value of “countNode”.
        • Close the file.
              • Catch the exception using “catch” block and print the exception.
    • Give function definition to populate the tree.
      • Create an object for “DefaultMutableTreeNode”.
      • Loop through the number of nodes.
        • Split the string.
        • Check if the length is greater than 1.
          • Add the node to the tree.
          • Loop through the length of node.
            • Add the node to the tree.
        • Check if the length is equal to 1.
          • Add the node to the tree.
              • Load the nodes to the tree.
    • Give function definition to create GUI.
      • Create a frame and add the tree to the frame.
      • Set the close operation and call the function “pack ()”.
      • Make the frame visible.
    • Give “main ()” function.
      • Assign a filename to the variable.
      • Create an object for the class.
      • Call the function “readData ()”.
      • Call the function “populateTree ()”.
      • Call the function “createAndShowGUI()”.

Blurred answer
Students have asked these similar questions
Domino cycledef domino_cycle(tiles):A single domino tile is represented as a two-tuple of its pip values, such as (2,5) or (6,6). This function should determine whether the given list of tiles forms a cycle so that each tile in the list ends with the exact same pip value that its successor tile starts with, the successor of the last tile being the first tile of the list since this is supposed to be a cycle instead of a chain. Return True if the given list of domino tiles form such a cycle, and False otherwise. tiles Expected result [(3, 5), (5, 2), (2, 3)] True [(4, 4)] True [] True [(2, 6)] False [(5, 2), (2, 3), (4, 5)] False [(4, 3), (3, 1)] False
struct nodeType {    int infoData;    nodeType * next; };   nodeType *first;   … and containing the values(see image) Using a loop to reach the end of the list, write a code segment that deletes all the nodes in the list. Ensure the code performs all memory ‘cleanup’ functions.
Unique WordsWrite a python program that opens a specified text file then displays a list of all the unique words foundin the file.Hint: Store each word as an element of a set.
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
  • Text book image
    Systems Architecture
    Computer Science
    ISBN:9781305080195
    Author:Stephen D. Burd
    Publisher:Cengage Learning
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning