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
What major criteria must a product or process meet in order to be considered emerging technology?
STALIN [3.7K]
If I understand the question correctly it is anything you are people consider helpful or useful that makes things easier!! Hope this helped!
6 0
3 years ago
Shelly tells a friend that her computer needs to be fixed because it has been producing a lot of heat and is smoking. Where is t
abruzzese [7]

Answer:

Her computer is producing thermal energy, not heat.

Explanation:

Shelly informs her friend that she wants to repair her system because it has generated a lot of heat and therefore is smoking. Her device produces thermal energy but not heat because when she's working continuously and her system's CPU inside any blocked area at that time electricity pass through the CPU and blocked inside then it producing the thermal energy.

4 0
3 years ago
The average price of milk increased from $3.00 last year to $3.50 this year. This is most likely due to:
Natali5045456 [20]

Answer:

High Demand

Explanation:

If more people want to buy something the price will likely go up.

4 0
3 years ago
If an if-else statement is true, it will include which kinds of results?
FinnZ [79.3K]

Answer:

> It will run out the function under the if statement.

Explanation:

> As an if-else statement is saying if (something = something, etc) do (this this and this [let’s refer to this as 1]) Else do (this this and not this [let’s refer to this as 2]) Since it is true, it will do the original function (1).

> It is saying if this is true, then do this (1). If it is not true, then do this (2). Basically the else is there in case the if is not true, or equal to anything other than what’s intended.

> Since it is true however, it will do what the original function (1) is. So this is our correct answer. Once again, it is; “It will do the original function under the if statement”.

> I hope this answered your query, and any other questions you may have had on the subject. #LearningWithBrainly

8 0
2 years ago
The picture that graphically since the items you use in windows is called
katrin2010 [14]
Flip board or in some cases it is called a life at a glance
5 0
3 years ago
Other questions:
  • Which of the following is considered information?
    6·2 answers
  • After you enter the details for the first selected recipient in the New Address List dialog box, click _______ to add another re
    9·1 answer
  • A _____ is a harmful program that resides in the active memory of a computer and duplicates itself. Select one: a. scareware b.
    7·1 answer
  • Select the correct answer.
    13·1 answer
  • David would like to send a letter to more than one hundred people. He would like the letter to have names and addresses inserted
    12·2 answers
  • What is TSM Hamlinz’s discord
    6·2 answers
  • True or False The two types of general construction projects are residential for homes or dwellings and commercial for a commerc
    7·1 answer
  • Lucas wants to expand his vocabulary to better understand the sentence below. The insidious burglar moved through the house unhe
    7·2 answers
  • 8
    7·1 answer
  • What do people in the movie e.t think about the character E.T
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!