Linked List, create your own code. (Do not use the build in function or classes of Java or from the textbook).  Create a LinkedList class: Call the class MyLinkedList,  (hint) Create a second class called Node.java and use it, remember in the class I put the Node class inside the LinkedList Class, but you should do it outside. This class should have o Variables you may need for a Node, o (optional) Constructor  Your linked list is of an int type. (you may do it as General type as )  For this Linked List you need to have the following methods: add, addAfter, remove, size, contain, toString, compare, addInOrder. This is just a suggestion, if you use Generic type, you must modify this  Write a main function or Main class to test all the methods, o Create a 2 linked list and test all your methods. (Including the compare)

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

 Linked List, create your own code. (Do not use the build in function or classes of Java or from the textbook).
 Create a LinkedList class: Call the class MyLinkedList,
 (hint) Create a second class called Node.java and use it, remember in the class I put the Node class inside the LinkedList Class, but you should do it outside. This class should have
o Variables you may need for a Node,
o (optional) Constructor
 Your linked list is of an int type. (you may do it as General type as <E>)
 For this Linked List you need to have the following methods:

add, addAfter, remove, size, contain, toString, compare, addInOrder.

This is just a suggestion, if you use Generic type, you must modify this
 Write a main function or Main class to test all the methods,
o Create a 2 linked list and test all your methods. (Including the compare)

Name of
the method
Constructor
add
addAfter
remove
size
contain
toString
compare
Possible* signature of the method
public void add(int element)
public void addAfter(int element, int
afterint)
public void remove(int value)
public int size()
public boolean contains(int value)
public String toString()
public boolean compare(MyLinkedList
otherList)
addinOrder public void addinOrder (int element)
Explanation
Optional
Add the elements to the head of the Linked
List.
This function add value after a specific
value(int), if the value does not exist, then
add it to the tail. If there are multiple
values of specific value, add it after the
very first one
Given a value in int, if the Linked List has it,
delete it (if the linked list has multiple
places the same value, only the first
occurrence needs to be deleted)
returns the size of the linked list, if empty,
return 0
Check if a Linked List has a value if it does,
return true, else False.
ToString method will override ToString
method to return string containing the
Linked List elements (ready to be printed)
compare two linked list to check if they
have the same value.
This function will add the given elements in
order, as you add, it will after largest value
that is smaller than our element.
If the Linked List is empty, or the element
we want to add is smallest, add to head,
If the value is largest, add to the tail.
Example
We have a linked List:
1->2->4->5->4->3,
call addAfter(9, 4) should add
9 after 4, so the Linked List
will look like:
1->2->4->9->5->4->3
1->2->3->1->3 and we try to
delete 3 we should get 1->2-
>1->3
In the following linked list:
1->3->6->8,
contain(2) should return
False and contain(8) should
return true
Ex: A=1->2->3, B=1->3->2
return false
Ex: A=1->2->3, B=1->2->3
return true
Given: 1->5->12->20
If we try to add 6, it should
add It
1->5->6->12->20
Transcribed Image Text:Name of the method Constructor add addAfter remove size contain toString compare Possible* signature of the method public void add(int element) public void addAfter(int element, int afterint) public void remove(int value) public int size() public boolean contains(int value) public String toString() public boolean compare(MyLinkedList otherList) addinOrder public void addinOrder (int element) Explanation Optional Add the elements to the head of the Linked List. This function add value after a specific value(int), if the value does not exist, then add it to the tail. If there are multiple values of specific value, add it after the very first one Given a value in int, if the Linked List has it, delete it (if the linked list has multiple places the same value, only the first occurrence needs to be deleted) returns the size of the linked list, if empty, return 0 Check if a Linked List has a value if it does, return true, else False. ToString method will override ToString method to return string containing the Linked List elements (ready to be printed) compare two linked list to check if they have the same value. This function will add the given elements in order, as you add, it will after largest value that is smaller than our element. If the Linked List is empty, or the element we want to add is smallest, add to head, If the value is largest, add to the tail. Example We have a linked List: 1->2->4->5->4->3, call addAfter(9, 4) should add 9 after 4, so the Linked List will look like: 1->2->4->9->5->4->3 1->2->3->1->3 and we try to delete 3 we should get 1->2- >1->3 In the following linked list: 1->3->6->8, contain(2) should return False and contain(8) should return true Ex: A=1->2->3, B=1->3->2 return false Ex: A=1->2->3, B=1->2->3 return true Given: 1->5->12->20 If we try to add 6, it should add It 1->5->6->12->20
Expert Solution
steps

Step by step

Solved in 5 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY