Write a java program to find min and max of a list

Further Learning.

write a java program to find min and max of a list

If max is less than current's data then, max will hold current's data. This is the most simple logic of finding maximum of three numbers, it can't be simpler than this. This new node will become the new tail of the list. Display the max value.

Logic to find Greatest of Three Integers Algorithm or logic is independent of programming language. So to find maximum of three numbers, we have done 2 comparisons, which means to find maximum of n numbers, we need to do n-1 comparison.

The algorithm to find the maximum and the minimum node is given below. We have also learned about use of ternary operator to solve this problem. Create another class MinMax which has two attributes: head and tail. If the list is empty, both head and tail will point to a newly added node.

This means you need to write a Java program and function which takes three numbers and print the largest and smallest of them.

max and min value of integer in java

Second logic uses a special operator, known as ternary operator, as it has three arguments, that's why it can only be applied to languages which supports ternary operator e. If you have any trouble understanding logic or executing this program, please drop a note and I would be happy to help.

Rated 6/10 based on 32 review
Download
C Program To Find Maximum & Minimum Element In Array