Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a method that will Remove the smallest of all the integers in a double linked list. The method should have a parameter of type

Write a method that will Remove the smallest of all the integers in a double linked list. The method should have a parameter of type Node and should return a value of type int.
image text in transcribed
java code
java code image text in transcribed
Assignment #2: Q1. [25 pts] Write the following classes that implement a single Linked List of integers: 1) Class Node: It includes two instance variables: int number and Node next. It contains the following methods: A constructor that initializes the instance variable number. o Set and get method for each instance variable. 2) Class SingleLinkedlist: It includes two instance variables: Node head and Node tail. It contains the following methods: o public void insert (int n) that creates and adds a Node at the end of the linked List. o public void print () that prints the values of all nodes in the linked list, separated by an arrow ( - ), as shown in the sample output. o public boolean oneDigit () that returns true if all nodes in the linked List have a one-digit value and false otherwise. o public void iterativeReverse () that reverses the original linked list iteratively. public void recursiveReverse () that calls the private method void recursiveReverse (Node head) private void recursiveReverse (Node current) that reverses the original linked list recursively. 3) Class TestSingleLinkedlist. In the main method, do the following: Create an object of class Singlelinkedlist. Read integer values from the user. The user must enter -1 to stop. Call method print() Call method oneDigit() and print a proper message based on the returning value. Call method recursiveReverse() and then call method print() Call method iterativeReverse() and then call method print() Q1. [25 pts) Write the following classes that implement a single Linked List of integers: 1) Class Node: It includes two instance variables: int number and Node next. It contains the following methods: A constructor that initializes the instance variable number. o Set and get method for each instance variable. 2) Class SingleLinkedList: It includes two instance variables: Node head and Node tail. It contains the following methods: o public void insert (int n) that creates and adds a Node at the end of the linked List. o public void print () that prints the values of all nodes in the linked list, separated by an arrow ( - ), as shown in the sample output o public boolean oneDigit () that returns true if all nodes in the linked List have a one-digit value and false otherwise. public void iterativeReverse () that reverses the original linked list iteratively. o public void recursiveReverse () that calls the private method void recursiveReverse(Node head) o private void recursiveReverse (Node current) that reverses the original linked list recursively. 3) Class TestSingleLinkedlist. In the main method, do the following: Create an object of class SingleLinkedlist. Read integer values from the user. The user must enter -1 to stop. Call method print() Call method oneDigit() and print a proper message based on the returning value. Call method recursiveReverse() and then call method print() Call method iterativeReverse() and then call method print()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

More Books

Students also viewed these Databases questions

Question

1. Which is the most abundant gas presented in the atmosphere?

Answered: 1 week ago