Answered step by step
Verified Expert Solution
Question
1 Approved Answer
IN JAVA PLEASE! IN JAVA PLEASE! Part 1 - Linked List Iterator Write a program that creates a linked list of integers, assigns integers to
IN JAVA PLEASE!
IN JAVA PLEASE!
Part 1 - Linked List Iterator Write a program that creates a linked list of integers, assigns integers to the linked list, prints a range of values in the list and eliminates duplicate numbers in the list. Your program must have two methods: First method is called printRange which has two parameters, x and y. printRange should write out all integers in the list that are between the first occurrence of X (inclusive) and the first occurrence of y (but not including y). You may assume integers can be compared for equality using == Use the following header for the method: void printRange (int x, int y); Use the following logic to develop printRange This makes the implementation easier. Print integers from x to y including x but not including y If there isn't an entry with a value equal to x, then print nothing If there isn't an entry after x, that has a value equal to y, then print the integers from x (inclusive) to the end of the list Print the values on one line separated by space. Put an end of line after the values are ALL printed. Hint, your program will need to make multiple calls to printRange For this program, you are [hard coding] creating your data in the program, and not entering it from the console. In your program create a linked list with the following members: {1, 1, 2, 3, 3, 75, 4, 4, 8, 9}. Review the sample output below. You MUST USE the values for x and y, shown (shown in bold) as parameters in multiple calls to printRange to test the logic of your program Below is a sample output. // Comments List [1,2,3,4,5,6,7] Il x = 2 y = 5 prints 234 Il prints list including x but not y List [1,2,3,4,5,6,7] Il x = 2 y = 78 prints 2 3 4 5 6 7 // prints list including x, no value sy so print to end Il x = 2 y = 1 List [1,2,3,4,5,6,7) prints 2 3 4 5 6 7 // prints list including x, no value sy so print to end List [1,2,3,4,5,6,7] Il x = 8 y = 5 Il prints nothing The second method is called removeRepetitions. removeRepetitions steps through the linked list comparing numbers and when duplicate numbers are found, removes one of the duplicate numbers. Again, you may assume integers can be compared for equality using == Use the following header for the method removeRepetitions: void remove_repetitions() Here is a brief outline of an algorithm for removeRepetitions: variable p steps through the list for each number in the list, define a new variable q equal top While q is not the last number in the list If the next number has data equal to the data in p, remove the next number Otherwise move to the next numberStep 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