Check if list is sorted Dry Run in PYTHON

Check if list is sorted is an interactive PYTHON dry run visualizer from the Recursion programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.

This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.

Check if list is sorted Program Code

def is_sorted(arr):
    if len(arr) <= 1:
        return True
    if arr[0] > arr[1]:
        return False
    return is_sorted(arr[1:])

arr1 = [10, 20, 30, 40, 50]
arr2 = [10, 30, 20, 40, 50]
print(f"arr1 sorted? {is_sorted(arr1)}")
print(f"arr2 sorted? {is_sorted(arr2)}")

View the complete Recursion programs page.

Program Console Check if list is sorted Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.