Write a static recursive java method

Assignment Help JAVA Programming
Reference no: EM131104750

1. Write a static recursive Java method that will accept an int and write the base 2 (binary) representation of that int, one bit per recursive call, to System.out.

2. Write a static recursive Java method that will accept two int's (A and B) and will write the representation of A base B, one character per call, to System.out. Assume that B is less than 36, and use digits 0 through 9, followed by characters A through Z to represent the characters of B. For example, 15 base 10 would be printed as F base 16.

3. For the following tree, what is the order if the root is taken to be node A and the tree is traversed?

a) in pre-order

b) in post-order

c) in level-order

1983_Figure.png

4. For the tree in part 1, same questions but take the root as node L.

5. In a 5-ary tree, that is a tree with at most 5 children at each node, how many nodes can a tree of height H have. Recall that the height of a tree is a length of the longest path from the root to the leaf nodes of the tree.

6. In a 5-ary tree, what is the maximum height of a tree with N nodes. Since that was easy, let's try one a little harder: what is the minimum height of a tree with N nodes?

7. Write a recursive method listLinks that will list all the links in a tree or subtree of a node.

The context should be a Node (a class with a getChildren method that will return a List <Node> of the child nodes of that node) and use the toString method of the Node class. The output for each call of the listLinks method should be to System.out, with the first token the representation of the node followed by a space-separated list of the children of the node. Calling this method in the context of the root node of a tree will result in a listing of all the links in the tree. The call would be something like:

tree.root.listLinks ();

The signature of this method should be:

void listLinks ()

And you will use a method with the following signature:

List <Node> getChildren ()

Reference no: EM131104750

Questions Cloud

Find and discuss an interesting example of recursion : Find and discuss an interesting example of recursion - thus, an example other than those presented in the readings. Your discussion should: give citations
Difference between an estate tax deduction : Explain the difference between an estate tax deduction and an estate tax credit - The estate tax deduction is the difference between the estate taxincluding IRD items and the estate tax without IRD items.
What is the required passband of the doppler filter : What is the required passband of the Doppler filter?
What effect will this investment have on edmund enterprises : What effect will this investment have on Edmund Enterprises earnings per share this year? What effect might this investment have on the companys intrinsic value and stock price?
Write a static recursive java method : Write a static recursive Java method that will accept an int and write the base 2 (binary) representation of that int, one bit per recursive call, to System.out
How should ace allocate proceeds received among components : Should the various components of each MEDS be accounted for separately? If so, how should Ace allocate the proceeds received among the components?
Prepare an appropriate bankruptcy petition : Prepare an appropriate bankruptcy petition for Tim, along with all of the appropriate schedules.
Is tiaa-cref an ordinary shareholder : Is TIAA-CREF an ordinary shareholder? Explain.Due to its asset size, TIAA-CREF owns many shares in a number of companies.
Promote a more optimal use of contraceptives : Health officials have suggested that teen pregnancy and sexually transmitted diseases can be reduced if contraceptives are more widely used. Use the concept of a demand-side externality to explain why the amount of contraceptives in the United States..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write java program to store employee id number

Use employee data file called employees.txt should comprise at least 5 employee records. Each record stores employee ID number (six digits) last name, first name, middle inital,gender(m or f).

  Rewrittting codes in java

However, I am told the above code would not be written by an experienced Java programmer because the showMessageDialog method is static within the class. How would a pro would write it?

  Creates an array of six divsales objects

Write a program that creates an array of six DivSales objects. The program should ask the user to enter the sales for four quarters for each division.

  Write a method called add uneven arrays

Write a method called addUnevenArrays that takes two arrays, a and b, and returns a new array, c, with alength that is the maximum of the lengths of a and b. Each c[i] is the sum of the corresponding elementsof a and b if both elements exist.

  Template files contain the message text

Template files contain the message text, together with variable fields(such as Dear [Title] [Last Name ] ...). A database (stored as a text file) contains the field values for each recipient. Use HTML as the output file format. Then design and implem..

  How many data items are within one standard deviation

How many data items are within One Standard Deviation - Generate a list of 100 values between 0 and 100 using the generator (int)(Math.random()*101).

  What steps are involved in your analysis of this problem

Write code to process the 3 possible searches. Sample data is included for testing.

  Implement a class called reversewords

Implement a class called ReverseWords that uses a stack to output a set of elements input by the user in reverse order.

  Which allows to input a year and when hit the check button

Create a JAVA GUI (With Frame), which allows to input a year and when hit the check button, will show the picture of Chinese zodiac animal! I am trying to make a calculator: i have the method for or the calculation method to show how to calculate:

  Determine the length of a string

Determine the length of a string. The first version should use array subscripting, and the second version should use pointer arithmetic

  What is the relationship between an exception and signaling

What is the relationship between an exception, signaling and an exception handler

  Maximum number of processes

The amount of disk space that must be available for page storage is related to the maximum number of processes, n, the number of bytes in the virtual address space, v, and the number of bytes of RAM, r. Give an expression for the worst-case disk-spac..

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