Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question

Data Structure & Algorithum java program

Do the following:

1) Add a constructor to the class "LList" that creates a list from a given array of objects.
2) Add a method "addAll" to the "LList" class that adds an array of items to the end of the list. The header of the method is as follows, where "T" is the generic type of the objects in the list.
3) Write a Test/Driver program that thoroughly tests all the methods in the class "LList".

[画像:number0fEntries++; } else { throw new Index0ut0fBoundsException ("Illegal position given."); 48 49 50 51 } 52 53 54 550 A 56 @0verride public T remove (int givenPosition) { T result = null; if((givenPosition >= 1) && (givenPosition <= number0fEntries)) { 57 58 if(givenPosition == 1) { result = firstNode = firstNode.getNextNode(); }else Node<T> nodeBefore = Node<T> nodeToRemove = nodeBefore.getNextNode(); Node<T> nodeAfter result = nodeToRemove.getData(); nodeBefore.setNextNode(nodeAfter); 59 60 61 firstNode.getData(); 62 63 64 getNodeAt (givenPosition - 1); 65 66 nodeToRemove.getNextNode(); 67 68 69 number0fEntries++; return result; } else { throw new IndexOut0fBoundsException ("Illegal position given."); 70 71 72 73 74 } 75 7660 A 77 @Override public void clear() { whlutlllAuto-aenerated method stub I. 78 79 80 81 82e A 83 84 85 @Override public T replace(int givenPosition, T newEntry) { if((givenPosition >= 1) && (givenPosition <= number0fEntries)) { Node<T> desiredNode = T originalEntry = desiredNode.getData(); desiredNode.setData(newEntry); return originalEntry; } else { throw new IndexOut0fBoundsException ("Illegal position given"); getNodeAt (givenPosition); 86 87 88 89 %3D 90 01 Problems @Javadoc Declaration Console X No consoles to display at this time. ]
expand button
Transcribed Image Text:number0fEntries++; } else { throw new Index0ut0fBoundsException ("Illegal position given."); 48 49 50 51 } 52 53 54 550 A 56 @0verride public T remove (int givenPosition) { T result = null; if((givenPosition >= 1) && (givenPosition <= number0fEntries)) { 57 58 if(givenPosition == 1) { result = firstNode = firstNode.getNextNode(); }else Node<T> nodeBefore = Node<T> nodeToRemove = nodeBefore.getNextNode(); Node<T> nodeAfter result = nodeToRemove.getData(); nodeBefore.setNextNode(nodeAfter); 59 60 61 firstNode.getData(); 62 63 64 getNodeAt (givenPosition - 1); 65 66 nodeToRemove.getNextNode(); 67 68 69 number0fEntries++; return result; } else { throw new IndexOut0fBoundsException ("Illegal position given."); 70 71 72 73 74 } 75 7660 A 77 @Override public void clear() { whlutlllAuto-aenerated method stub I. 78 79 80 81 82e A 83 84 85 @Override public T replace(int givenPosition, T newEntry) { if((givenPosition >= 1) && (givenPosition <= number0fEntries)) { Node<T> desiredNode = T originalEntry = desiredNode.getData(); desiredNode.setData(newEntry); return originalEntry; } else { throw new IndexOut0fBoundsException ("Illegal position given"); getNodeAt (givenPosition); 86 87 88 89 %3D 90 01 Problems @Javadoc Declaration Console X No consoles to display at this time.
[画像:Lijava 44 A 3 import chapter10.ListInterface; 4 Unit13 src src chapter12 O LList<T> ► o firstNode: Node<T> 5 public class LList<T> implements ListInterface<T> { 6. private NodeT firstNode; private int number0fEntries%; 8 6. public LList( { firstNode = null; number0fEntries = 0; } 100 11 12 %3D 13 14 private Node<T> getNodeAt (int givenPostion) { Node<T> currentNode = firstNode; for (int count = currentNode = currentNode.getNextNode(); } return currentNode; 150 16 %3D 17 1; count < givenPostion; count++) { 18 19 20 21 22 23e A 24 @Override public void add(T newEntry) { Node<T> newNode = new Node<>(newEntry); if(isEmpty()) firstNode = newNode; else { Node<T> lastNode = lastNode.setNextNode (neWNode); 25 26 27 28 29 30 31 32 33 34 35e A 36 37 38 39 40 41 42 getNodeAt (number0fEntries); number0fEntries++3; I @Override public void add(int givenPosition, T newEntry) { if(givenPosition >= 1 && (givenPosition <= number0fEntries + 1)) { Node<T> newNode = new Node<>(newEntry)%3; if(givenPosition = 1) { newNode.setNextNode(firstNode); firstNode = newNode; Jelse { Node<T> nodeBefore = getNodeAt (givenPosition - 1); Node<T> nodeAfter = nodeBefore.getNextNode(); newNode.setNextNode(nodeAfter); nodeBefore.setNextNode(newNode) : %3D 43 44 %3D 45 46 Problems @ Javadoc Declaration Console X No consoles to display at this time. ]
expand button
Transcribed Image Text:Lijava 44 A 3 import chapter10.ListInterface; 4 Unit13 src src chapter12 O LList<T> ► o firstNode: Node<T> 5 public class LList<T> implements ListInterface<T> { 6. private NodeT firstNode; private int number0fEntries%; 8 6. public LList( { firstNode = null; number0fEntries = 0; } 100 11 12 %3D 13 14 private Node<T> getNodeAt (int givenPostion) { Node<T> currentNode = firstNode; for (int count = currentNode = currentNode.getNextNode(); } return currentNode; 150 16 %3D 17 1; count < givenPostion; count++) { 18 19 20 21 22 23e A 24 @Override public void add(T newEntry) { Node<T> newNode = new Node<>(newEntry); if(isEmpty()) firstNode = newNode; else { Node<T> lastNode = lastNode.setNextNode (neWNode); 25 26 27 28 29 30 31 32 33 34 35e A 36 37 38 39 40 41 42 getNodeAt (number0fEntries); number0fEntries++3; I @Override public void add(int givenPosition, T newEntry) { if(givenPosition >= 1 && (givenPosition <= number0fEntries + 1)) { Node<T> newNode = new Node<>(newEntry)%3; if(givenPosition = 1) { newNode.setNextNode(firstNode); firstNode = newNode; Jelse { Node<T> nodeBefore = getNodeAt (givenPosition - 1); Node<T> nodeAfter = nodeBefore.getNextNode(); newNode.setNextNode(nodeAfter); nodeBefore.setNextNode(newNode) : %3D 43 44 %3D 45 46 Problems @ Javadoc Declaration Console X No consoles to display at this time.
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY