R11 Check if array is sorted (Recursion) Dry Run in C

R11 Check if array is sorted (Recursion) is an interactive C 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.

R11 Check if array is sorted (Recursion) Program Code

#include <stdio.h>
#include <stdbool.h>

bool isSorted(int arr[], int n, int index) {
    if(index == n - 1) {
        return true;
    }

    if(arr[index] > arr[index + 1]) {
        return false;
    }

    bool remainingSorted = isSorted(arr, n, index + 1);
    return remainingSorted;
}

int main() {
    int arr1[] = {10, 20, 30, 40, 50};
    int arr2[] = {10, 30, 20, 40, 50};
    
    printf("Array1 sorted? %s\n", isSorted(arr1, 5, 0) ? "Yes" : "No");
    printf("Array2 sorted? %s\n", isSorted(arr2, 5, 0) ? "Yes" : "No");
    return 0;
}

View the complete Recursion programs page.

Program Console R11 Check if array is sorted (Recursion) Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.