Live nodes and garbage collection in java

Assignment Help JAVA Programming
Reference no: EM13940737

class Node
{
int value;
Node next;
Node(int value, Node next)
{
this.value = value;
this.next = next;
}
Node(int value)
{
this.value = value;
}
}
class List {
Node start;
void inverse()
{
Node p = null;
for (Node q = start; q != null; q = q.next)
{
p = new Node(q.value,p);
}
start = p;
}

Please provide answers to the following questions based on above Java classes.

1. For a list with n Nodes, what is the maximum number of nodes that are "live" (i.e., accessible from a "root set" of variables) during the method inverse(), and when does this maximum occur?

2. Give a simple modification of the method inverse() above that minimizes the number of "live" nodes that are necessary for the method to work, so that any item that will not be used later can be immediately reclaimed as "garbage."

3. Suppose there is "heap space" for 10,000 nodes as Java objects and a list of 7,000 nodes which are stored in that heap. When method inverse() with the modification in (2) is applied to that list, at what stages of the computation does garbage collection take place?

Reference no: EM13940737

Questions Cloud

Determine the speed at which the clutch starts to engage : Determine the speed at which the clutch starts to engage, the power transmitted at a speed of 1500 rpm.
Record acquisition of the building and the delivery truck : Record the acquisition of the building and the delivery truck. Compute and record the amortization expense on the patent for 2009 on a straightline basis.
What will be extension of the spring at a rotational speed : A body of mass 1 kg is whirled in a horizontal plane at the end of a spring. The spring stiff ness is 5 kN m 1 and the initial distance from the centre of rotation to the centre of the body is 200 mm. What will be the extension of the spring at a ..
What primary factors that contribute to wrongful conviction : Briefly identify your working solution to the problem. How might your working solution solve the problem? Be sure to note here that your working solution will evolve through continued research and analysis.
Live nodes and garbage collection in java : For a list with n Nodes, what is the maximum number of nodes that are "live" (i.e., accessible from a "root set" of variables) during the method inverse(), and when does this maximum occur?
Importance of decision-management activity : Has what you have learned in this subject created an increased awareness of the importance of decision making as a management activity? Why or why not?
Main stakeholders in the mg rover business : Set out the main stakeholders in the MG Rover business at the time of its collapse. How would you determine the relative importance of their stake?
Annual interest rates on comparable investments : If annual interest rates on comparable investments are 3.5%,(a) What would be a reasonable price to pay for an annuity paying £17,500 a year for the next 25 years?
Determine the rotational speed at which the wire will break : The distance from the centre of rotation to the centre of the mass is 1.5 m and the diameter of the wire is 2 mm. If the ultimate tensile strength of the steel is 500 MPa, determine the rotational speed at which the wire will break.

Reviews

Write a Review

JAVA Programming Questions & Answers

  How do you provide a link from one class to a related class

How do you provide a link from one class to a related class

  1 create a recursive factorial program that prompts the

1. create a recursive factorial program that prompts the user for an integer n and writes out a series of equations

  Write a java application that prompts the user for input

Write a Java application that prompts the user for pairs of inputs of a product number (1-5), and then an integer quantity of units sold (these are two separate prompts for input values).

  Discussion htmlcssjavascript placementnbspplease respond to

discussion htmlcssjavascript placementnbspplease respond to the followingcompare and contrast the process of adding

  Compute the temperature in centigrade

Compute the temperature in Centigrade - Display the temperatures in both Centrigrade and Fahrenheit with appropriate labels, using the + operator to concatenate the labels with the variables

  Sample run of the program to illustrates the expected outpu

Write a program WordCount.java that takes contents of a file and list the five most frequently used words in it.Your program should prompt user for a filename and - assuming that afile with specified filename exists - attempt to read the file and pro..

  Disadvantages to using data structures

How are data structures managed and organized in this language. How does the management or syntax of data structures in this language differ from how data structures are handled in other language.

  Implement the application using a singly linked list

Implement the following application using a singly linked list. This application accepts from console and stores a list of 10 names of your friends in the singly linked list

  What is server-side and client-side scripting

What is Server-side and Client-side scripting - Explain the differences between server-side and client - side scripting languages.

  Write a generic class

Write a generic class (using Java generics) called Pair that stores two values of the generic type.  It should have a constructor to set them, two methods getfirst() and getsecond() to retrieve them.

  Algorithm analysis with advanced data

algorithm analysis with advanced data structuresalchemy-mines of oreland yield unlimited amounts of silver but no gold.

  Calculate the body mass index

Write an application (BMICalc) that reads the user's weight in poinds and height in inches, then calculates the Body Mass Index.

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