public LinkedIntListR evens () { // TODO throw new RuntimeException("Not implemented"); // HINT: // // } Have the private method return a list via the first node. Have the public method create an empty list and then set first in that empty list to the list returned by the helper /** * Constructs a new int list where each entry in the new list is the sum of the * corresponding entries in this list and the argument list. * @arg otherList the other list to be added to this list * @return a new list where each entry in the new list is the sum of the corresponding entries in this list and the argument list * @throws IllegalArgumentException if this list and the other list have have different lengths */ public LinkedIntListR listAddition(LinkedIntListR otherList) { // TODO throw new RuntimeException("Not implemented"); // HINT: // // } Have the private method return a list via the first node. Have the public method create an empty list and then set first in that empty list to the list returned by the helper

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

import edu.princeton.cs.algs4.StdOut;

 

public class LinkedIntListR {

 

// helper linked list node class

private class Node {

private int item;

private Node next;

 

public Node(int item, Node next) {

this.item = item;

this.next = next;

}

}

 

private Node first; // first node of the list

 

public LinkedIntListR() {

first = null;

}

 

public LinkedIntListR(int[] data) {

for (int i = data.length - 1; i >= 0; i--)

first = new Node(data[i], first);

}

 

 

public void addFirst(int data) {

first = new Node(data, first);

}

 

public void printList() {

if (first == null) {

StdOut.println("[]");

} else if (first.next == null) {

StdOut.println("[" + first.item + "]");

} else {

StdOut.print("[" + first.item);

for(Node ptr = first.next; ptr != null; ptr = ptr.next)

StdOut.print(", " + ptr.item);

StdOut.println("]");

}

}

 

@Override

public boolean equals(Object obj) {

if (this == obj)

return true;

if (obj == null)

return false;

if (getClass() != obj.getClass())

return false;

LinkedIntListR other = (LinkedIntListR) obj;

Node thisPtr = first;

Node otherPtr = other.first;

while(thisPtr != null && otherPtr != null) {

if (thisPtr.item != otherPtr.item)

return false;

thisPtr = thisPtr.next;

otherPtr = otherPtr.next;

}

if (thisPtr != null || otherPtr != null)

return false;

return true;

}

 

public LinkedIntListR evens () { // TODO
throw new RuntimeException ("Not implemented");
// HINT:
//
//
}
Have the private method return a list via the first node.
Have the public method create an empty list and then set
first in that empty list to the list returned by the helper
/**
* Constructs a new int list where each entry in the new list is the sum of the
* corresponding entries in this list and the argument list.
* carg otherList the other list to be added to this list
* @return a new list where each entry in the new list is the sum of the
corresponding entries in this list and the argument list
* @throws IllegalArgumentException if this list and the other list have have
*
different lengths
*/
public LinkedIntListR listAddition (LinkedIntListR otherList) { // TODO
throw new RuntimeException("Not implemented");
// HINT:
//
//
}
Have the private method return a list via the first node.
Have the public method create an empty list and then set
first in that empty list to the list returned by the helper
Transcribed Image Text:public LinkedIntListR evens () { // TODO throw new RuntimeException ("Not implemented"); // HINT: // // } Have the private method return a list via the first node. Have the public method create an empty list and then set first in that empty list to the list returned by the helper /** * Constructs a new int list where each entry in the new list is the sum of the * corresponding entries in this list and the argument list. * carg otherList the other list to be added to this list * @return a new list where each entry in the new list is the sum of the corresponding entries in this list and the argument list * @throws IllegalArgumentException if this list and the other list have have * different lengths */ public LinkedIntListR listAddition (LinkedIntListR otherList) { // TODO throw new RuntimeException("Not implemented"); // HINT: // // } Have the private method return a list via the first node. Have the public method create an empty list and then set first in that empty list to the list returned by the helper
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Similar questions
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