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
A software application used at one computer to interact with other nodes on a network is called_____.
Ivanshal [37]

Answer:

A MIRCOCOMPTER NETWORK

Explanation:

3 0
4 years ago
_____ assures the interface will act as the users expect, while _____ assures it will look pleasing. Select one:
Agata [3.3K]

Answer:

C. consistency, aesthetics

Explanation:

Based on the descriptions given to us in the question we can deduce that the answer is C. consistency, aesthetics. This is because "consistency" is defined as something that always delivers the same results, which is what users need from the interface in order to understand it and continue using it. While "aesthetics" is defined as the visual representation of something (how something will look).

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

7 0
3 years ago
A place in memory who's contents cannot change while the program is running
maria [59]
Constant will be the answer
6 0
3 years ago
write a function copy(s, n) that takes as inputs a string s and an integer n, and that uses recursion to create and return a str
Yuri [45]

Answer:

Following are the method to the given question:

def copy(s, n):#defining a method copy that takes two parameters

   if n <= 0:#definig if to compare n value is less than equal to 0

       return ''#return space  

   else:#definig else block  

       return s + copy(s, n-1)#use recursive method that return value

print(copy("by",2))#calling method and print value

print(copy("ta",2))#calling method and print value

print(copy("good by ",2))#calling method and print value

Output:

byby

tata

good by good by

Explanation:

In this code, a method "copy" is declared that takes two parameters that are "s and n" inside the method a conditional statement is used which can be defined as follows.

In the if block is used "n" variable that checks n value which is less than equal to 0 if it is true it will return a space value.

In the else block it use the recursive method that returns a value which is a copy of s that is concatenated together.

8 0
3 years ago
Given that Euro 1 is equal to Rs 114.60​
kirill [66]
Given? What’s the question ? Could you elaborate
4 0
3 years ago
Other questions:
  • Write a program which selects two integer numbers randomly, adds the numbers and asks the user to enter the answer and then chec
    13·1 answer
  • help users calculate their car miles per gallon. write a program to allow a user to enter the number of miles driven and the num
    15·1 answer
  • Which education level has the highest return on investment (ROI)?
    14·1 answer
  • In a database list, fields are displayed as _____. rows columns tables records
    10·1 answer
  • Many Web browsers allow users to open anonymous windows. During a browsing session in an anonymous window, the browser does not
    14·1 answer
  • After Brooke has helped Simon to resolve his original problem, Simon asks her about another linked workbook he has received. The
    7·1 answer
  • Which of the following demonstrates how digital music are files played? An analog player changes the recording to digital, and s
    9·1 answer
  • Which layer in the Internet Protocol Suite model verifies that data arrives without being lost or damaged?
    8·1 answer
  • Portable Document Format is a proprietary document file type created by Adobe Systems that is compatible with most computer syst
    7·1 answer
  • Open the same text file that you have created in Exercise-Four ( in the sample output, I have created the file name personal). W
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!