1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Tanya [424]
3 years ago
10

Write a method max() which take a generic singly linked list as an argument and returns the maximum element reference in the lis

t.If the list is empty, please throw an empty collection exception.The method prototype is defined as follows.public static > T max(SingleLinkedList list) throws EmptyCollectionException.
Computers and Technology
1 answer:
max2010maxim [7]3 years ago
6 0

Answer:

See explaination

Explanation:

java code:

class DONALD

{

static class Node

{

int data;

Node next;

}

static Node head=null;

static int largestElement(Node head)

{

Int max=Integer.MIN_VALUE;

while(head!=null)

{

if(max<head.data)

max=head.data;

head=head.next;

}

return max;

}

static int smallestElement(Node head)

{

int min=Integer.MAX_VALUE;

while(head!=null)

{

if(min>head.data)

min=head.data;

head=head.next;

}

return min;

}

static void push(int data)

{

Node newNode=new Node();

newNode.data= data;

newNode.next=(head);

(head)=newNode;

}

static void printList(Node head)

{

while(head!=null)

{

System.out.println(head.data + " -> ");

head=head.next;

}

System.out.println("NULL");

}

public static void main(String[] args)

push(15);

push(14);

push(13);

push(22);

push(17);

System.out.println("Linked list is : ");

printList(head);

System.out.println("Maximum element in linked list: ");

System.out.println(largestelement(head));

System.out.print("Maximum element in Linked List: " );

System.out.print(smallestElement(head));

}

}

You might be interested in
you'll be organizing the various databases in your organization, and have recommended hiring a/an?A. internet specialist B. comp
jek_recluse [69]
Either c or d, most probably D
7 0
3 years ago
Read 2 more answers
How might a company gain followers on Twitter?
Tresset [83]
By sending persuasive / informable and interesting posts to gain followers.
3 0
3 years ago
Provide one example of how information technology has created an ethical dilemma that would not have existed before the advent o
Vitek1552 [10]

Answer:

grip

Explanation:

aaaaaaaaaaaaaaaaaaa

8 0
3 years ago
You just finished training a decision tree for spam classification, and it is gettingabnormally bad performance on both your tra
strojnjashka [21]

Answer:

Option B is the correct option.

Explanation:

The following answer is true because when the person completed our training of a decision tree and after the following presentation he getting not good working performance on both side i.e., test sets and during the training period. After the training there is no bug on the implementation of the presentation then, he has to increase the rate of the learning.

5 0
3 years ago
Please select the word from the list that best fits the definition
Svetllana [295]

A pie graph shows the percent something takes of a whole. With a pie graph it is always out of 100%, therefor for this question the answer is B. Pie graph

I hope this helped!

7 0
3 years ago
Other questions:
  • Which of the following criteria would not make a person eligible to receive medicare benefits?Which of the following criteria wo
    12·2 answers
  • Next, determine if the given number is a prime number. A prime number is a number that has no positive divisors other than 1 and
    11·1 answer
  • John's Plumbing prides itself on excellent customer service, especially during after-hours service calls. They want to connect w
    11·1 answer
  • How do you validate the type of text that a user enters?
    7·1 answer
  • Are storage devices input devices
    8·1 answer
  • Explain 3 ways you can be an upstander when seeing cyberbullying.
    13·2 answers
  • Your employer is opening a new location, and the IT director has assigned you the task of calculating the subnet numbers for the
    14·1 answer
  • Technician A says that PTC heaters can be built into a conventional heater core assembly. Technician B says that a PTC heater's
    11·1 answer
  • You open a folder Properties box to encrypt the folder, click Advanced, and discover that Encrypt contents to secure data is dim
    10·1 answer
  • How does the dns help the world wide web scale so that billions of users can access billions of web pages?.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!