Question

Do it in Java: Directions Linked Reverse Step 1. In the reverse method of LList, implement...

Do it in Java: Directions

Linked Reverse Step 1. In the reverse method of LList, implement your algorithm from the pre-lab exercises. Iteration is needed. Checkpoint: Compile and run LinkedListExtensionsTest. The checkReverse tests should pass. If not, debug and retest.

Linked Cycle Step 2. In the cycle method of LList, implement your algorithm from the pre-lab exercises. Final checkpoint: Compile and run LinkedListExtensionsTest. All tests should pass. If not, debug and retest.

-----LList Skele Code------

https://codeshare.io/5QqeOe <----LList Code

-------LinkedListExtensionsTest code-----

https://codeshare.io/G6LbmO <--------LinkedListExtensionsTest.java This test LList

0 0
Add a comment Improve this question Transcribed image text
Answer #1
public void reverse() {

    if (!isEmpty()) {

        Node current = firstNode;
        Node prev = null;
        Node next = null;

        while (current != null) {
            next = current.getNextNode();
            current.setNextNode(prev);
            prev = current;
            current = next;
        }

        firstNode = prev;
    }
}


public void cycle() {

    if (numberOfEntries > 1) {

        Node f = firstNode;

        firstNode = firstNode.next;

        f.setNextNode(null);

        Node start = firstNode;
        while(start.next != null) {
            start = start.next;
        }

        start.setNextNode(f);
    }
}

Please upvote, as i have given the exact answer as asked in question. Still in case of any concerns in code, let me know in comments. Thanks!

Add a comment
Know the answer?
Add Answer to:
Do it in Java: Directions Linked Reverse Step 1. In the reverse method of LList, implement...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please do it in JAVA!!! Thank you. Directions below Array Reverse :Step 1. In the reverse...

    Please do it in JAVA!!! Thank you. Directions below Array Reverse :Step 1. In the reverse method of AList, implement your algorithm from the pre-lab exercises. Iteration is needed. Checkpoint: Compile and run ArrayListExtensionsTest. The checkReverse tests should pass. If not, debug and retest. Array Cycle :Step 2. In the cycle method of AList, implement your algorithm from the pre-lab exercises. This method needs some form of iteration, but it may not be explicit. It can use the private methods...

  • IMPLEMENT AN IMMUTABLE SINGLY LINKED LIST IN JAVASCRIPT ------------------------------------------------------------------------------------------------------------------------- So I am trying to implement a...

    IMPLEMENT AN IMMUTABLE SINGLY LINKED LIST IN JAVASCRIPT ------------------------------------------------------------------------------------------------------------------------- So I am trying to implement a singly linked list that given the below function will pass the bottom four tests when ran. Please help me generate the singly linked list that will work and pass the tests. I will only use this as a reference so please add comments to explain what you are doing so I can understand and write this myself. I think a join method may need...

  • Programming Assignment 1 Data structure Java Implement Shellsort for a linked list, based on a variant...

    Programming Assignment 1 Data structure Java Implement Shellsort for a linked list, based on a variant of bubble sort. The rather severe constraints imposed by the singly-linked list organization presents special problems for implementing Shellsort. Your task is to overcome these constraints and develop a simple, elegant implementation that does not sacrifice efficiency or waste space. Step 1. First, implement a routine to build a list: read integers from standard input, and build a list node for each item consisting...

  • in java : Create Java Application you are to create a project using our designated IDE...

    in java : Create Java Application you are to create a project using our designated IDE (which you must download to your laptop). Create the code to fulfill the requirements below. Demonstrate as stipulated below. Create a Main Application Class called AddressBookApplication (a counsole application / command line application). It should Contain a Class called Menu that contains the following methods which print out to standard output a corresponding prompt asking for related information which will be used to update...

  • java This lab is intended to give you practice creating a class with a constructor method,...

    java This lab is intended to give you practice creating a class with a constructor method, accessor methods, mutator methods, equals method , toString method and a equals method. In this lab you need to create two separate classes, one Student class and other Lab10 class. You need to define your instance variables, accessor methods, mutator methods, constructor, toString method and equals method in Student class. You need to create objects in Lab10 class which will have your main method...

  • Bottom section is the what they expect in the code in java Create a class in...

    Bottom section is the what they expect in the code in java Create a class in JobApplicant.java that holds data about a job applicant. Include a name, a phone number, and four Boolean fields that represent whether the applicant is skilled in each of the following areas: word processing, spreadsheets, databases, and graphics. Include a constructor that accepts values for each of the fields. Also include a get method for each field. The get method should be the field name...

  • 1. What does a Java compiler do? Select one: a. Runs Java programs b. Translates byte...

    1. What does a Java compiler do? Select one: a. Runs Java programs b. Translates byte code in ".class" files into machine language c. Translates source code in ".class" files into machine language d. Translates source code in ".java" files into Java byte code in ".class" files e. Translates source code in ".java" files into machine language 2. A subclass will _____ one superclass. Select one: a. abstract b. extend c. implement d. inherit e. override 3. Consider the following...

  • Stacks and Java 1. Using Java design and implement a stack on an array. Implement the...

    Stacks and Java 1. Using Java design and implement a stack on an array. Implement the following operations: push, pop, top, size, isEmpty. Make sure that your program checks whether the stack is full in the push operation, and whether the stack is empty in the pop operation. None of the built-in classes/methods/functions of Java can be used and must be user implemented. Practical application 1: Arithmetic operations. (a) Design an algorithm that takes a string, which represents an arithmetic...

  • Java Write a Simple Program This question is about following the directions below. Failure to do...

    Java Write a Simple Program This question is about following the directions below. Failure to do so, results in lost credit. Write the definition of a method that takes in an integer number, and returns true if the number is prime, otherwise, returns false. A prime number is only divisible by itself and 1. Do not write the code for main here. The code must follow these steps in the order shown: 1. Name the method isPrime, and make it...

  • Java, Please implement the way the interface specifies. Part A:Radix Sort Implement a radix sort as...

    Java, Please implement the way the interface specifies. Part A:Radix Sort Implement a radix sort as described in the last section of Chapter 7 in your text. It should handle variable amounts of data and variable numbers of digits in the key values. Use testing to ensure radix sort works for at least three examples of different input sizes and various max digit length. I need to implement the radix sort using the below java interface. /** * <h1><LeastSignificantDigit Radix...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT