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
Aurelia is designing a user interface for a new game app. Which of the following should she taken into consideration for the use
serious [3.7K]

Answer:

C

Explanation:

what types of loop will be used.

4 0
2 years ago
Question 2 Unsaved Which of these is NOT an example of an emerging technology? Question 2 options: Sixth Sense Close Range Drone
alexandr1967 [171]

The answer is <em>B.) Close Range Drones</em>

I just took the test

3 0
3 years ago
True or False <br><br> Rootkits are only made by black-hat hackers.
andreyandreev [35.5K]

Answer:

True

Explanation:

Rootkits are malicious software that allows an unauthorized user to access a computer and restricted areas of software. Rootkits are difficult to detect on your computer because it may be able to subvert there that is intended to find it. Rootkits are created by Black-hat hackers to attack your computer and steal.

Rootkit tools:

1. Keyloggers

2. antivirus disablers

3. password stealers

4. banking credential stealers

5. bots for DDoS attacks

8 0
3 years ago
What types of information should have their sources cited to avoid plagiarism? List at least 3
Sindrei [870]

Answer:

Everything.It doesn't matter the information because there's always a way to plagiarize.No matter what the information, always, ALWAYS, cite the source.

Explanation:

6 0
3 years ago
Anyone have good websites to cure boredom
Sav [38]

Answer:

cool math if its not blocked

Explanation:

6 0
3 years ago
Read 2 more answers
Other questions:
  • Explain why blocking ping (ICMP echo request) packets at an organization's edge router is not an effective defense against ping
    11·1 answer
  • A 2-dimensional 3x3 array of ints, has been created and assigned to tictactoe. Write an expression whose value is true if the el
    10·1 answer
  • A commonly used font style is _____. superscript periwinkle times new roman point
    7·1 answer
  • Why Stockholder are interested in the way a company operate?
    12·1 answer
  • Reasons for the growth of decision-making systems include:
    13·1 answer
  • 1) Prompt the user to enter two words and a number, storing each into separate variables. Then, output those three values on a s
    11·1 answer
  • True or False? At any point in time, an open file has a current file pointer indicating the place where the next read or write o
    15·1 answer
  • When you are working in Performance Monitor, in the "Add Counters" dialog box, and need more information about a particular coun
    8·1 answer
  • You can place an insertion point by clicking in the field or by pressing ____.
    13·1 answer
  • When an external device becomes ready to be serviced by the processor the device sends a(n)_________ signal to the processor.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!