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 started using a new Windows server three months ago. Since that time, you have found that the system slows down and crashes
Brut [27]

Answer: Open Reliability Monitor.

Explanation:

The simplest way to view this information is to open the reliability monitor.

The Reliability Monitor shows you the stability history of a system at a glance and also allows one to see the details of the events that has an effect on reliability on a daily basis.

The reliability and problem history chart which can be seen in the Reliability Monitor helps in keeping track of the overall health of the server on a daily basis.

4 0
2 years ago
Jim maintains attendance records for his employees for the year row B includes the dates of attendance and columns A includes th
never [62]

lock:row\A

set:row\b

this is the correct answer

3 0
3 years ago
Select the correct answer.
alukav5142 [94]

Answer:

The correct answer is: Option OB. Coding

Explanation:

Software Development Life Cycle is used to develop software. It is a general collection of steps that have to be followed in development of software.

The development phase comes after the system design phase of SDLC. The coding and programming for software is done in the development stage.

Hence,

The correct answer is: Option OB. Coding

6 0
2 years ago
Which best explains the widespread of Linux in academic environments?
antoniya [11.8K]
D, because everything software on Linux itself is free
6 0
3 years ago
Read 2 more answers
Which type of attack is being utilized when the attacker asks you to hold a security door open for them after you have successfu
ddd [48]
When the attacker <span>asks you to hold a security door open for them after you have successfully authenticated using your proximity badge or access badge backdoor attack is being utilized. The backdoor malware gives you to have normal authentication procedure and the remote access is granted.
</span><span>This attack exploits vulnerabilities within applications.</span>
Backdoors are used for a number of malicious activities: data theft, server hijacking, Website defacing and many more.
6 0
3 years ago
Other questions:
  • A(n) _____ identifies how you feel about an activity or subject. computer calculator interest inventory both b and c
    7·2 answers
  • Blender questions
    8·1 answer
  • How can you tell if a website is secure
    13·1 answer
  • What group in the review tab contains the commands and to accept or reject changes made to a document
    14·2 answers
  • 2. What is an inanimate object? (1.0 points)
    14·1 answer
  • To ____ a public member function of a base class in the derived class, the corresponding function in the derived class must have
    12·1 answer
  • What is computer. Write full form of mips​
    15·1 answer
  • Explain how the use of Git and a shared public Git repository simplifies the process of managing opensource development when man
    8·1 answer
  • You have a small business.Due to the recent pandemic you seem to be losing contacts with your suppliers and customers.You want t
    10·1 answer
  • Explain the bad effect and good effect of mobile phone and internet.<br>​
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!