Python program to find the Decreasing point in a List

When it is required to find the decreasing point in a list, a simple iteration and the break statement are used. The decreasing point is the first index where an element is greater than its next element.

Example

Below is a demonstration of the same ?

my_list = [21, 62, 53, 94, 55, 66, 18, 1, 0]

print("The list is :")
print(my_list)

my_result = -1
for index in range(0, len(my_list) - 1):
    if my_list[index + 1] < my_list[index]:
        my_result = index
        break

print("The result is :")
print(my_result)

Output

The list is :
[21, 62, 53, 94, 55, 66, 18, 1, 0]
The result is :
1

How It Works

List: [21, 62, 53, 94, 55, 66, 18, 1, 0] 21 i=0 62 i=1 53 i=2 94 i=3 55 i=4 Decreasing Point! 62 > 53 Algorithm Steps: 1. Compare element at index i with element at index i+1 2. If current > next, we found the decreasing point 3. Return the index where decrease starts 4. In this case: my_list[1] = 62 > my_list[2] = 53, so result = 1

Explanation

  • A list of integers is defined and displayed on the console.

  • A variable my_result is initialized to -1 (indicates no decreasing point found).

  • The list is iterated from index 0 to length-2 to avoid index out of bounds.

  • For each index, we compare the current element with the next element.

  • If the next element is smaller than the current element, we found the decreasing point.

  • The index where the decrease starts is stored and the loop breaks.

  • In this example, at index 1, element 62 is greater than element 53 at index 2, so the result is 1.

Conclusion

This program efficiently finds the first decreasing point in a list by comparing consecutive elements. The algorithm returns -1 if no decreasing point exists (i.e., the list is non-decreasing).

Updated on: 2026-03-26T01:26:55+05:30

268 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements