In Java: 001 package algs13; 002 import java.text. DecimalFormat; 003 import stdlib.*; 004 005 006 * Complete
Fantastic news! We've Found the answer you've been seeking!
Question:
In Java:
Transcribed Image Text:
001 package algs13; 002 import java.text. DecimalFormat; 003 import stdlib.*; 004 005 006 * Complete the methods below. 007 * All of these methods modify the list. 008 009 010 011 012 * Use the function check Invariants to ensure that your list is well-formed after you modify it. * Note that this list keeps track of the number of elements N. * It is important that N accurately reflect the length of the list. * * You may not add any fields to the node or list classes. 013 * You may not add any methods to the node class. 014 * You may not create any new objects objects. 015 * For example, you may not create a new Node, new Stack, or new ArrayList. 016 * 017 * new Node (...) // Forbidden: create a new Node object. 018 * 019 020 * * You *may* declare variables of type Node. Node x = first; // Allowed: declare variable of type Node. 021 022 * 023 * You may not change the item value of any existing node, only change the next pointer. 024 * 025 * 026 * x.item ... // Forbidden x.next... // Allowed 027 * first 028 * // Allowed 029 * Each function must be independent. 030 031 * For example, you cannot call delete to implement remove. * You MAY add private methods to the list class (helper functions for the recursion). 032 * You do NOT need to use recursion for this homework. 033 * You can use Loops in each problem. 034 */ 035 public class MyLinked2 { static class Node { 036 037 038 039 040 } public Node (double item, Node next) { this.item = item; this.next next; } public double item; public Node next; 041 int N; 042 Node first; 043 044 045 046 047 048 049 // delete the kth element (where k is between 0 and N-1 inclusive) public void delete (int k) { } if (k|| k >= N) throw new IllegalArgumentException (); // TODO // reverse the list "in place"... public void reverse () { 050 051 052 053 054 } 055 056 057 058 } 059 // TODO // remove all occurrences of item from the List public void remove (double item) { // TODO 001 package algs13; 002 import java.text. DecimalFormat; 003 import stdlib.*; 004 005 006 * Complete the methods below. 007 * All of these methods modify the list. 008 009 010 011 012 * Use the function check Invariants to ensure that your list is well-formed after you modify it. * Note that this list keeps track of the number of elements N. * It is important that N accurately reflect the length of the list. * * You may not add any fields to the node or list classes. 013 * You may not add any methods to the node class. 014 * You may not create any new objects objects. 015 * For example, you may not create a new Node, new Stack, or new ArrayList. 016 * 017 * new Node (...) // Forbidden: create a new Node object. 018 * 019 020 * * You *may* declare variables of type Node. Node x = first; // Allowed: declare variable of type Node. 021 022 * 023 * You may not change the item value of any existing node, only change the next pointer. 024 * 025 * 026 * x.item ... // Forbidden x.next... // Allowed 027 * first 028 * // Allowed 029 * Each function must be independent. 030 031 * For example, you cannot call delete to implement remove. * You MAY add private methods to the list class (helper functions for the recursion). 032 * You do NOT need to use recursion for this homework. 033 * You can use Loops in each problem. 034 */ 035 public class MyLinked2 { static class Node { 036 037 038 039 040 } public Node (double item, Node next) { this.item = item; this.next next; } public double item; public Node next; 041 int N; 042 Node first; 043 044 045 046 047 048 049 // delete the kth element (where k is between 0 and N-1 inclusive) public void delete (int k) { } if (k|| k >= N) throw new IllegalArgumentException (); // TODO // reverse the list "in place"... public void reverse () { 050 051 052 053 054 } 055 056 057 058 } 059 // TODO // remove all occurrences of item from the List public void remove (double item) { // TODO
Expert Answer:
Related Book For
Understanding Basic Statistics
ISBN: 9781111827021
6th Edition
Authors: Charles Henry Brase, Corrinne Pellillo Brase
Posted Date:
Students also viewed these programming questions
-
Consider a binomial distribution with n = 5 trials. Use the probabilities given in Table 2 of the Appendix to make histograms showing the probabilities of r = 0, 1, 2, 3, 4, and 5 successes for each...
-
Consider a binomial distribution with 10 trials. Look at Table 2 in the Appendix showing binomial probabilities for various values of p, the probability of success on a single trial. (a) For what...
-
QUESTION 9 The output expression for an AND-OR-Invert circuit having one AND gate with inputs A, B and C and one AND gate with inputs D, E and Fis O(A+B+C)(D+E+F) O (A+B+C)(D+E+F) ABC + DEF...
-
Charles has AGI of $50,000 and has made the following payments related to (1) land he inherited from his deceased aunt and (2) a personal vacation taken last year. Calculate the amount of taxes...
-
In a statistics class with 36 students, the professor wanted to know the probability that at least two students share the same birthday. The probability wills be___ a. 0.1 b. Much smaller than 0.1 c....
-
Are the input specifiers for scanf() identical to the output specifiers for printf()?
-
Russell Furniture manufactures computer desks in its Westlake, Ohio, plant. The company uses activity- based costing to allocate all manufacturing conversion costs (direct labor and manufacturing...
-
17-x, 2 for x 0 Let f(x) = Find each limit. 17+x, for x>0 (A) lim f(x) (B) lim f(x) x-0 (C) lim f(x) x-0 (D) f(0)
-
(b) (A)-, (c) A-2, use the inverse matrices to find (a) (AB), and (d) (2A)-. 2 5 A- - 4 = [ __7 8 4 3]. 6 B-1 -12-31 =
-
Evaluate the effect of each of the following events on the market for loanable funds. Explain the effects on savings, investment, and the neutral real interest rate. a. The government runs a...
-
Determine if the following people are demanders, suppliers, or not involved in the market for loanable funds. a. Latisha wants to save up for a new laptop to use in her business, so she puts aside...
-
Cyber Monday falls on the first Monday following the Thanksgiving holiday. During Cyber Monday, employers find that a significant number of employees are surfing the web for holiday deals. A recent...
-
Find two Web sites that would provide sports marketing managers with information about whether their planning assumptions regarding the demographics of the U.S. population remain valid.
-
When reading the business press, it seems that leaders are regularly challenged by ethical dilemmas. Is this a function of the individual leader or the situation, or both?
-
AB Tic. and San. Legal procedures for the establishment of Koll.ti with a capital of 10.000 TL have been completed. The capital commitment of Partner A, one of the shareholders of the company, has...
-
The population of Detroit, Michigan, decreased from 1,027,974 in 1990 to 688,701 in 2013 (Source: U.S. Census Bureau). Find the average rate of change in the population of Detroit, Michigan, over the...
-
For a site chosen at random, estimate the following probabilities. (a) P(0 x < 30) (b) P(10 x , 40) (c) P(x < 20) (d) P(x 20) (e) P(30 x) (f) P(x not less than 10) (g) P(0 x < 10 or 40 x) (h)...
-
Make a stem-and-leaf display. Use five lines per stem so that leaf values 0 and 1 are on one line, 2 and 3 are on the next line, 4 and 5 are on the next, 6 and 7 are on the next, and 8 and 9 are on...
-
Consider the following events for a college student selected at random: A = student is female B = student is majoring in business Translate each of the following phrases into symbols: (a) The...
-
Validate Eq. (4.20) and Eq. (4.25). Data From Equation (4.20) Data From Equation (4.25) t= 12 n dr. n
-
Derive Eq. (4.24). Data From Equation (4.24) sin =1- noro cos Bo nr
-
Reproduce Figures 4.11 and 4.12 by using \(f=8 \mathrm{GHz}\) and: (a) \(\varepsilon^{\prime}=2.8\) and \(\varepsilon^{\prime \prime}=0.032\) (dry soil); (b) \(\varepsilon^{\prime}=47\) and...
Study smarter with the SolutionInn App