and Contains list does not a) Ad a public , dynamie famellen called Reversel). This funellen takes no arguments, returns

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

and Contains list does not a) Ad a public , dynamie famellen called Reversel). This funellen takes no arguments, returns

Post by answerhappygod »

And Contains List Does Not A Ad A Public Dynamie Famellen Called Reversel This Funellen Takes No Arguments Returns 1
And Contains List Does Not A Ad A Public Dynamie Famellen Called Reversel This Funellen Takes No Arguments Returns 1 (318.46 KiB) Viewed 52 times
class LinkedList
{
Node head;
Node current;
Node previous;
// Return the data associated with the current element, or null
if the
// current element is past-the-end.
public Object Get()
{
return current != null ? current.GetData() : null;
}
// Go to the next element if the current element is not
past-the-end.
public void Next()
{
if (current != null)
{
previous = current;
current = current.next;
}
}
// Go back to the first element
public void Head()
{
previous = null;
current = head;
}
// Insert a new element before the current element, or at the
end if
// the current element is past-the-end.
public void Insert(Object data)
{
// Create new node
Node node = new Node(data);
// Set 'next' reference of new node
node.next = current;
// Set 'next' reference for previous node. Treat the special
// case where the current node is the head of the list.
if (current == head)
head = node;
else
previous.next = node;
// Update current node
current = node;
}
// Remove the current element in the list, and set the current
element
// to the followig element.
public void Remove()
{
// Past-the-end is an invalid position for this operation
if (current == null)
throw new RuntimeException("Invalid position to remove");
// Remove element. Consider special case where the current
// element is the head.
if (current == head)
head = current.next;
else
previous.next = current.next;
// Move current element
current = current.next;
}
public void Print()
{
// Traverse list
for (Head(); Get() != null; Next())
System.out.println(Get());
}
}
class Node
{
// Public reference to next node
public Node next;
// Private data field
Object data;
Node(Object data)
{
this.data = data;
}
public Object GetData()
{
return data;
}
}
All parts write code in JAVA
and Contains list does not a) Ad a public , dynamie famellen called Reversel). This funellen takes no arguments, returns a new list that the same elements as the current in reverse ordera The function modify the list that it is applied on. You may invoke any of the functions class Linked List { publie Linkedlist Reverse() ). in the Code. 3 3 В 1B write a main program that creates linked list called list1 and inserts integers 1,2,3. Then, call the reverse(). function to create a new list called list with the same elements in reverse order. Then, print all elements în list 2. You can invoke any functhen in the Code.

Class Test public static void main(String args[]) 3 3 c) What is the asymptor the reverse() function? Cost of
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply