Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following LinkedList class. Note the type of each node s data - this linked list is meant to store only integers! DO NOT

Consider the following LinkedList class. Note the type of each node

s data - this linked list is meant to store only integers! DO NOT assume existence of any other instance variables.

public class LinkedList{

private static vlass Node{

private int dta;

private Node next;

provate Node(int data Node next){

this.data = data;

this.next = next;

}

}

private Node head;

//adds the newData to the back of the list

public void add(int newData){

//code not shown here, but you can assume the method works

}

}

Write the method sumAboveThreshold(int n) for LinkedList. This method should return the sum of all node data that

s greater than n. If no such nodes exist, the method should return 0.

image text in transcribed

Programming 17 of each node's data- f any other instances (11 pts) Consider the following LinkedList class. Note the type of meant to store only integers! Do not assume the existence of an methods public class LinkedList! private statie class Node/ private int data; private Node next; private Node(int data, Node next) { this.data = data; this.next next; private Node head; // Adds the newData to the back of the list public void add(int newData) { // Code not shown here, but you can assume the method works Write the method sumAbove Thresholdint n) for Linkedlist. This method should return the sum of all node data that's greater than n. If no such nodes exist, the method should return O. Example: If list contains 3, 6, 4, 8 in that order, then calling list.sumAbove Threshold(4) should returns +8 = 14. Calling list.sumAbove Threshoid(8) should return 0

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

JDBC Database Programming With J2ee

Authors: Art Taylor

1st Edition

0130453234, 978-0130453235

More Books

Students also viewed these Databases questions