Write a routine to list out the nodes of a binary tree

Assignment Help Computer Engineering
Reference no: EM132213282

Write a routine to list out the nodes of a binary tree in level-order. List the root, then nodes at depth 1, followed by nodes at depth 2, and so on. You must do this in linear time. Prove your time bound.

Assume that what is meant by "list out" is that the method returns a java.util.List<Integer> containing the data from the tree in level order. Add a new method to your BinaryTree class named levelOrder(). You will need to maintain a data structure to help you control the traversal.

You should use something from java.util, but make a good choice that is well-suited to the task at hand. In the comment for levelOrder(), write a brief statement justifying your decision. Test thoroughly.

This is in Java.

Reference no: EM132213282

Questions Cloud

Write a remove method for an integer array : Write a "remove" method for an integer array. The method takes in two arguments, the array to remove the value from (oldArray), and a value to remove (value).
Retrieve a program to apply the method to several data sets : Write/retrieve a program to apply the method to several data sets, obtaining comparison counts and swap counts for shell sort in JAVA.
Compute morgans dependent tax credit : Morgan (age 45) is single and provides more than 50% of the support of Rosalyn (a family friend, age 36), Flo (a niece, age 18), and Jerold (a nephew, age 18).
Write a regular expression that describes the language : Write a regular expression that describes the following language: the set of strings that that contain an even number of a's.
Write a routine to list out the nodes of a binary tree : Write a routine to list out the nodes of a binary tree in level-order. List the root, then nodes at depth 1, followed by nodes at depth 2, and so on.
Write a recursive function that will take a nonnegative int : Write a recursive function that will take a nonnegative integer n as formal parameter and return its factorial. Trace the function calls for n = 4.
Simulate a simple four function calculator without a memory : Write a Ruby Script that simulates a simple four function calculator without a memory.
Write a regular expression to pass to grep to determine : Write a regular expression to pass to grep to determine if a Chicago area (773 or 312) phone number, in the form (312) 281-3303, is present in a given file.
Write a research about the importance of servers rooms : Write a research about the importance of servers rooms or (network devices rooms) in any organization or institutions.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Determine the outer surface temperature of the pipe

Hot water is being transported in a horizontal pipe (k = 0.15 W/m·K, Di = 2.5 cm, Do = 4.5 cm), where the pipe inner surface temperature is at 100°C.

  Write down program for a bank account

Write down program for a bank account

  What processes and properties would you include

Visual Basic.NET allows you to create your own classes. Provide an instance of a useful class you could create. What methods and properties would you include? Show an example of a method declaration for your class.

  Demonstrate how the pseudocode you wrote

Rewrite the above pseudocode so that it takes into account that T is actually an array.

  Describe any advances in rfid that are used in the system

Describe Any advances in RFID that are used in the system and Security concerns or practices associated with the RFID system.

  Distinguish between a stream cipher and a block cipher

Distinguish between a stream cipher and a block cipher. Are all stream ciphers mono alphabetic? Explain. Are all block ciphers polyalphabetic? Explain.

  What are the functions of database management software

What are functions of database management software? Name common database management software. Describe how Dell reduced its operating costs. Why are wireless transmission systems favored over wired transmission systems?

  Explain the temporal locality spatial locality

Explain the temporal locality spatial locality and sequential locality associated with program data access in a memory hierarchy.

  Why database re-engineering and redesign is required

define what should be done when adding tables and relationships for normalization.

  The best function prototype for the given function

Assume a program contains a void function named calcNewPrice(). The function receives two double variables named oldPrice and newPrice.

  What situations would not warrant the use of an array

What situations would not warrant the use of an array? Provide an example showing why. Research the concept of C++ vectors.

  Questiondescribe what java environment would contain to do

questiondescribe what java environment would contain to do if you were trying to pass an arraylist a collection class

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd