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
In a computer instant messaging​ survey, respondents were asked to choose the most fun way to​ flirt, and it found that ​P(D)equ
MA_775_DIABLO [31]

Answer:

P(D) = 0.4

Explanation:

P(D) is the probability of randomly selecting someone.

who does not choose a direct​ in-person encounter as the most fun way to flirt.

1 – 0.600 = 0.4

P(D) = 0.4

hence the upper D over bar right parenthesis represent and its value is 0.4

8 0
3 years ago
How does an Ac Machine work
Pani-rosa [81]

Answer:

In a split system, the compressor condenses and circulates the refrigerant through the outdoor unit, changing it from a gas to a liquid. The liquid is then forced through the indoor evaporator coil or cooling compartment. The indoor unit's fan circulates the inside air to pass across the evaporator fins.

Explanation:

(hope this helps)

6 0
3 years ago
What kind of loop should be used in a game where the user is guessing a secret code and the message"guess again" appears until t
GenaCL600 [577]

Answer:

While loop

Explanation:

It should be noted that the number of times which the computer will ask the user to take a guess is not known.

When we have a condition like this, the while loop (or in some programs; the do-while loop) is to be used.

To further back my point, see the following program in python.

<em>secret_code = 1234</em>

<em>user_guess = int(input("Take a guess: "))</em>

<em>while user_guess != secret_code:</em>

<em>     user_guess = int(input("guess again: "))</em>

<em>print("You guessed right")</em>

<em />

The above program will keep asking the user to take a guess until the user enters 1234.

<em>This may or may not be possible with a for loop.</em>

3 0
3 years ago
What is the seven major components of IT infrastructure?​
Mkey [24]

Answer:

Explanation:

These are the seven major components of IT infrastructure

1. Operating system platforms

2. Networking & telecommunication

3. Computer Hardwares

4. Data storage and management

5. Internet network

6. Consulting and system integeration service

7. Enterprise softwares

These components are necessary in order to run a success business in the IT field.

3 0
3 years ago
Read 2 more answers
What is the primary language used to write web content and is the default format for Outlook messages?
iris [78.8K]

Answer:

HTML

Explanation:

It is the HTML format, and it is the default format for Outlook messages as well. However, the Outlook messages support the Rich Text Format and Plain text as well. However, the default format is certainly the HTML format. And the rest of the options can be selected. Hence, the correct option for this question is certainly the HTML.

3 0
3 years ago
Read 2 more answers
Other questions:
  • While Angela is making modifications to Katie’s Word document, she would like to inform Katie of the reasoning for the change. W
    10·1 answer
  • Is the conversation recorded when the party answers or when they dial the number?
    7·1 answer
  • Your isp connects to the core routers of the internet via a _____. cable mode spine backbone satellite
    12·1 answer
  • (20 POINTS AND BAINLIEST)
    9·1 answer
  • What are the importance of switches in our electron device
    15·1 answer
  • Which of the following is the most reliable way to check the accuracy of a website?
    13·1 answer
  • Need help with 4.7 lesson practice
    15·1 answer
  • What is the benefit of hosting a website on a personali
    6·1 answer
  • Select the three concepts of capital outlay.
    15·1 answer
  • 7. Suppose that a RISC machine uses 5 register windows. a. How deep can the procedure calls go before registers must be saved in
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!