Question: for java please. None of the methods should modify the list, unless that is the purpose of the method. * * You may not add
* * You may not add any fields to the node or list classes. * You may not add any methods to the node class. * You may not create any new node objects or other objects. * For example, you cannot create a new Stack or ArrayList. * * Each function must be independent: you cannot call one solution function from the other. * You MAY add private methods to the list class (helper functions for the recursion). */
W write a function to compute the size of the list, using a forward recursion // empty list has size public int sizeForward return StdRandon.uniform(100); // TODO fix this W write a function to compote the size of the list, using a backward recursion //epty list has side - public int sizeBackward) return StdRandon.uniform(100)//T000 for this W compute the position of the first 5.0 in the list, counting as an offset from the Wir 5.e is the FIRST element, the position is Wir 5. does not appear, return a negative number w you can write this using a loop or recursion, 10 any style, but you should only be W I would expect W 10,1,2,5,5,5,5,5,8,9). position FirstFiveFromBeginning) - 110,1,2,5,5,5,5,5,8,9). positionofastFiveFrond) - 2 public int positionofFirstFiveFronbeginning return StdRandom uniform (200) = 1/7000: fix this > W compute the position of the last 5.0 in the list, counting as an offset from the // lr 5.0 is the LAST element, the positions // if 5.0 does not appear, return a negative number w you can write this using a loop or recursion in any style, but you should only to X Hint One way to do this is to use a backwards recursio. If the number does appear return a non-begative number 11 If the number does not appear, return the distance to the END of the list as For example: 1.positoreastFiveFront) 1.position Lastiveronnol 131 41.position ofLastFiveFronEod) - 3 (21 31 411.positioflastFiverrand) - (11 21 31 411.positionofas tiverond) = -5 15 11 21 31 41).position LastFivefrond) - 4 15 5 11 21 31 41.positionerlast FiveFromEnd) - 4 1155 11 21 31 41).position LastFiveFromendf) 1.positi onorastFiveFronEnd) 15).positioneftastFiveFrond 11.positionorLastFiveFrond() 1.position Lastiverond 731 41).stionorLastFiveFronEnd -- 15 31 41). position last FiveFronEndl) - 121 5 31 41).position Last FiveFronEnd() - 2 15 21 5 31 411.positionerlast FiveFromEnd) - 2 publicist position LastFiveFromEnd return StdRandon.uniform(100); //TODO: Pix this 11 delete the first element public void deleteFirst) // TODO public static void main(String args 11) * mainRunTests( > private static void mainDebug 77 Use this for debugging // Add the names of helper functions if you use then. Trace.drawStepsOfMethod size oop"); Trace.drawStepsOfMethodszefonard Trace. drawSteps of Method ("sizeBackward") Trace, drawStepsOfMethod positionOfFirst Fivefronbeginning Trace.drawStepsOf Method"position LastFiveFront); Trace.drawStepsOfMethod ("deleteFirst"): Trace.run: // TODO: Put the test here you want to dehu testSizeloop. 11-21.2 11 41"); private static void maintenTests ) testSizeLoop (2,"11 21); testSizeLoop (4,"11-21.2 31 41"); testSizeLoop (1, -11"); testsizeLoop (*): testSizeForward 12. "11 21"} testSizeForward 141 tantsinforvard 41 W write a function to compute the size of the list, using a forward recursion // empty list has size public int sizeForward return StdRandon.uniform(100); // TODO fix this W write a function to compote the size of the list, using a backward recursion //epty list has side - public int sizeBackward) return StdRandon.uniform(100)//T000 for this W compute the position of the first 5.0 in the list, counting as an offset from the Wir 5.e is the FIRST element, the position is Wir 5. does not appear, return a negative number w you can write this using a loop or recursion, 10 any style, but you should only be W I would expect W 10,1,2,5,5,5,5,5,8,9). position FirstFiveFromBeginning) - 110,1,2,5,5,5,5,5,8,9). positionofastFiveFrond) - 2 public int positionofFirstFiveFronbeginning return StdRandom uniform (200) = 1/7000: fix this > W compute the position of the last 5.0 in the list, counting as an offset from the // lr 5.0 is the LAST element, the positions // if 5.0 does not appear, return a negative number w you can write this using a loop or recursion in any style, but you should only to X Hint One way to do this is to use a backwards recursio. If the number does appear return a non-begative number 11 If the number does not appear, return the distance to the END of the list as For example: 1.positoreastFiveFront) 1.position Lastiveronnol 131 41.position ofLastFiveFronEod) - 3 (21 31 411.positioflastFiverrand) - (11 21 31 411.positionofas tiverond) = -5 15 11 21 31 41).position LastFivefrond) - 4 15 5 11 21 31 41.positionerlast FiveFromEnd) - 4 1155 11 21 31 41).position LastFiveFromendf) 1.positi onorastFiveFronEnd) 15).positioneftastFiveFrond 11.positionorLastFiveFrond() 1.position Lastiverond 731 41).stionorLastFiveFronEnd -- 15 31 41). position last FiveFronEndl) - 121 5 31 41).position Last FiveFronEnd() - 2 15 21 5 31 411.positionerlast FiveFromEnd) - 2 publicist position LastFiveFromEnd return StdRandon.uniform(100); //TODO: Pix this 11 delete the first element public void deleteFirst) // TODO public static void main(String args 11) * mainRunTests( > private static void mainDebug 77 Use this for debugging // Add the names of helper functions if you use then. Trace.drawStepsOfMethod size oop"); Trace.drawStepsOfMethodszefonard Trace. drawSteps of Method ("sizeBackward") Trace, drawStepsOfMethod positionOfFirst Fivefronbeginning Trace.drawStepsOf Method"position LastFiveFront); Trace.drawStepsOfMethod ("deleteFirst"): Trace.run: // TODO: Put the test here you want to dehu testSizeloop. 11-21.2 11 41"); private static void maintenTests ) testSizeLoop (2,"11 21); testSizeLoop (4,"11-21.2 31 41"); testSizeLoop (1, -11"); testsizeLoop (*): testSizeForward 12. "11 21"} testSizeForward 141 tantsinforvard 41 W write a function to compute the size of the list, using a forward recursion // empty list has size public int sizeForward return StdRandon.uniform(100); // TODO fix this W write a function to compote the size of the list, using a backward recursion //epty list has side - public int sizeBackward) return StdRandon.uniform(100)//T000 for this W compute the position of the first 5.0 in the list, counting as an offset from the Wir 5.e is the FIRST element, the position is Wir 5. does not appear, return a negative number w you can write this using a loop or recursion, 10 any style, but you should only be W I would expect W 10,1,2,5,5,5,5,5,8,9). position FirstFiveFromBeginning) - 110,1,2,5,5,5,5,5,8,9). positionofastFiveFrond) - 2 public int positionofFirstFiveFronbeginning return StdRandom uniform (200) = 1/7000: fix this > W compute the position of the last 5.0 in the list, counting as an offset from the // lr 5.0 is the LAST element, the positions // if 5.0 does not appear, return a negative number w you can write this using a loop or recursion in any style, but you should only to X Hint One way to do this is to use a backwards recursio. If the number does appear return a non-begative number 11 If the number does not appear, return the distance to the END of the list as For example: 1.positoreastFiveFront) 1.position Lastiveronnol 131 41.position ofLastFiveFronEod) - 3 (21 31 411.positioflastFiverrand) - (11 21 31 411.positionofas tiverond) = -5 15 11 21 31 41).position LastFivefrond) - 4 15 5 11 21 31 41.positionerlast FiveFromEnd) - 4 1155 11 21 31 41).position LastFiveFromendf) 1.positi onorastFiveFronEnd) 15).positioneftastFiveFrond 11.positionorLastFiveFrond() 1.position Lastiverond 731 41).stionorLastFiveFronEnd -- 15 31 41). position last FiveFronEndl) - 121 5 31 41).position Last FiveFronEnd() - 2 15 21 5 31 411.positionerlast FiveFromEnd) - 2 publicist position LastFiveFromEnd return StdRandon.uniform(100); //TODO: Pix this 11 delete the first element public void deleteFirst) // TODO public static void main(String args 11) * mainRunTests( > private static void mainDebug 77 Use this for debugging // Add the names of helper functions if you use then. Trace.drawStepsOfMethod size oop"); Trace.drawStepsOfMethodszefonard Trace. drawSteps of Method ("sizeBackward") Trace, drawStepsOfMethod positionOfFirst Fivefronbeginning Trace.drawStepsOf Method"position LastFiveFront); Trace.drawStepsOfMethod ("deleteFirst"): Trace.run: // TODO: Put the test here you want to dehu testSizeloop. 11-21.2 11 41"); private static void maintenTests ) testSizeLoop (2,"11 21); testSizeLoop (4,"11-21.2 31 41"); testSizeLoop (1, -11"); testsizeLoop (*): testSizeForward 12. "11 21"} testSizeForward 141 tantsinforvard 41 W write a function to compute the size of the list, using a forward recursion // empty list has size public int sizeForward return StdRandon.uniform(100); // TODO fix this W write a function to compote the size of the list, using a backward recursion //epty list has side - public int sizeBackward) return StdRandon.uniform(100)//T000 for this W compute the position of the first 5.0 in the list, counting as an offset from the Wir 5.e is the FIRST element, the position is Wir 5. does not appear, return a negative number w you can write this using a loop or recursion, 10 any style, but you should only be W I would expect W 10,1,2,5,5,5,5,5,8,9). position FirstFiveFromBeginning) - 110,1,2,5,5,5,5,5,8,9). positionofastFiveFrond) - 2 public int positionofFirstFiveFronbeginning return StdRandom uniform (200) = 1/7000: fix this > W compute the position of the last 5.0 in the list, counting as an offset from the // lr 5.0 is the LAST element, the positions // if 5.0 does not appear, return a negative number w you can write this using a loop or recursion in any style, but you should only to X Hint One way to do this is to use a backwards recursio. If the number does appear return a non-begative number 11 If the number does not appear, return the distance to the END of the list as For example: 1.positoreastFiveFront) 1.position Lastiveronnol 131 41.position ofLastFiveFronEod) - 3 (21 31 411.positioflastFiverrand) - (11 21 31 411.positionofas tiverond) = -5 15 11 21 31 41).position LastFivefrond) - 4 15 5 11 21 31 41.positionerlast FiveFromEnd) - 4 1155 11 21 31 41).position LastFiveFromendf) 1.positi onorastFiveFronEnd) 15).positioneftastFiveFrond 11.positionorLastFiveFrond() 1.position Lastiverond 731 41).stionorLastFiveFronEnd -- 15 31 41). position last FiveFronEndl) - 121 5 31 41).position Last FiveFronEnd() - 2 15 21 5 31 411.positionerlast FiveFromEnd) - 2 publicist position LastFiveFromEnd return StdRandon.uniform(100); //TODO: Pix this 11 delete the first element public void deleteFirst) // TODO public static void main(String args 11) * mainRunTests( > private static void mainDebug 77 Use this for debugging // Add the names of helper functions if you use then. Trace.drawStepsOfMethod size oop"); Trace.drawStepsOfMethodszefonard Trace. drawSteps of Method ("sizeBackward") Trace, drawStepsOfMethod positionOfFirst Fivefronbeginning Trace.drawStepsOf Method"position LastFiveFront); Trace.drawStepsOfMethod ("deleteFirst"): Trace.run: // TODO: Put the test here you want to dehu testSizeloop. 11-21.2 11 41"); private static void maintenTests ) testSizeLoop (2,"11 21); testSizeLoop (4,"11-21.2 31 41"); testSizeLoop (1, -11"); testsizeLoop (*): testSizeForward 12. "11 21"} testSizeForward 141 tantsinforvard 41
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
