Question: Python The list a is a list of int numbers. It is called almost sorted if for every indexes i, j, such that i a[j]

 Python The list a is a list of int numbers. Itis called almost sorted if for every indexes i, j, such that

Python The list a is a list of int numbers. It is called almost sorted if for every indexes i, j, such that ia[j] we get j-i==1 example 1 : a=[11, 21, 41, 31, 51, 71, 61, 81] a[2]>a[3] -> 3-2==1 a[5]>a[6] > 6-5==1 Therefore a is almost sorted. example 2 : a=[11, 21, 41, 31, 32, 51, 71, 61, 81] a[2]>a[4] -> 4-2 != 1 Therefore a is NOT almost sorted. Remark : Please notice that a sorted list (left to right, small to big) is also almost sorted

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!