Answered step by step
Verified Expert Solution
Question
1 Approved Answer
It's in Java and I can only code in Python. Problem No.1 is writing Junits for the methods and Problem No.2 is implementing the methods
It's in Java and I can only code in Python.
1. (30 points) Write JUnit test cases for the following list methods: (a) A method most common which assumes the list is organized so that duplicate values are together. (For example, it could be sorted.) The method returns the value that appears the most times. When more than one value appears the most number of times, the first occurring such value is returned. If the list is empty, the method throws a NoSuchElementException. (b) A method doubleIt that takes no arguments and adds a duplicate of each list element after its original occurrence. (It's actually creating duplicate references. For example, calling this method on the list ("a", "b", "c", "d") changes it to ("a", "a", "b", "b", "c", "c", "d", "d"). (c) A method moveToTail that takes an index. It should move the value at that index to the "tail" of the list, i.e. so that it's the last element. For example, calling the method with argument 2 on the list ("a", "b", "c", "d") changes the list to ("a", "b", "d", "c"). If the index is invalid, the method should throw an IndexOutOf BoundsException. You can build off the given code, other code we/you have written this term, and code from the text. I suggest that you use the code from HW 3, either the original given code or your HW submission. Be sure to use these test cases on the implementations you create for the problems below. 2. (30 points) Implement each of the methods above for an array-based list. 3. (30 points) Implement each of the methods from problem 1 for a linked-memory list implementation. public class MyArrayListProblem No.1 is writing Junits for the methods and Problem No.2 is implementing the methods in the given code.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started