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
On the seventh day of the iteration, the team realizes that they will not complete 5 of the 13 stories. the product owner says s
nika2105 [10]

Answer:

First of all the team should excuse to the product owner for not being responsible and committed to the deadline.

Secondly, as they have completed the 8 stories, so they should revise and check the flaws in those stories and send to her.

Because when the product owner will check and happy with them, she will surely discuss the remaining stories with the team.

6 0
3 years ago
Giving out 15 points to whoever answers early!
Lemur [1.5K]

Answer:

No

It just let us see moving but actually they doesn't move

7 0
2 years ago
Read 2 more answers
Ben uses a table that has few columns. He knows about a particular value in the first column and wants to find the corresponding
igor_vitrenko [27]
I'd suggest he uses LOOKUP Function.

You can use the LOOKUP function when you need to look in a single column or row and find a value from the same position in a corresponding column or row. We have a much improved VLOOKUP that can also be used to search one row or column or multiple rows and columns.



4 0
3 years ago
Read 2 more answers
Write a program that reads the balance and annual percentage interest rate and displays the interest for the next month. Python
denis23 [38]

Answer:

Explanation:

The following code is written in Python. It asks the user to enter the current balance and the annual interest rate. It then calculates the monthly interest rate and uses that to detect the interest that will be earned for the next month. Finally, printing that to the screen. A test output can be seen in the attached picture below.

balance = int(input("Enter current Balance: "))

interest = int(input("Enter current annual interest %: "))

interest = (interest / 12) / 100

next_month_interest = balance * interest

print('$ ' + str(next_month_interest))

7 0
2 years ago
What are the steps to configure user information in a document?
chubhunter [2.5K]

Answer:

file, properties, options, general

Explanation:

4 0
2 years ago
Read 2 more answers
Other questions:
  • In the C-SCAN disk scheduling algorithm, the disk arm is required to move in one direction only until it reaches the last track
    7·1 answer
  • Which of the following characters at the beginning of a cell signifies to Excel that it should perform a calculation for the val
    13·1 answer
  • Which type of movement lets the player control an object's movement?
    5·1 answer
  • How to move files and folders from desktop in w10?
    13·1 answer
  • Instructions:Type the correct answer in the box. Spell all words correctly.
    14·2 answers
  • How to do pseudocode and flowchart in BMI ( computer programming ​
    11·1 answer
  • Select each task that may be completed using a word processor.
    8·2 answers
  • What steps might a company or organization need take in order to keep its digital data secure online?
    8·1 answer
  • ---------------is a systematic review of a person’swork and achievements over a recent period, usually leading toplans for the f
    11·1 answer
  • Does anyone have any tips on how to begin a 10 page Capstone project paper? I've got to write a write a research paper on the ty
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!