Write a algorithm to find a minimum number in the given list of numbers
Answers
Answered by
8
Algorithm: find the Smallest
Input: integer Array list [ ] of N positive integers
Output: the Smallest number in list [ ]
Process:
smallest list [0]
count 1
while (count < size of list)
If (list [count] < smallest) then
smallest list [count]
End if
count count + 1
End while
return smallest
Answered by
5
list1 = []
num = int(input("Enter number of elements in list: "))
for i in range(1, num + 1):
ele= int(input("Enter elements: "))
list1.append(ele)
print("Smallest element is:", min(list1))
- Make a single variable to keep track of the minimum value.
- To your minimal variables, set the value of the first array element.
- Go through the array one by one.
- If the present value is less than the minimum on each iteration, apply the present value to the minimum variable.
- Your minimal variable will contain the array minimum value after iterating over all N array elements.
Similar questions