Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

C program to find length of the longest bitonic subarray

In this Program, we are going to share a C program to find length of the longest bitonic subarray. If you are a beginner and want to start learning the C programming, then keep your close attention in this tutorial as I am going to share a C program to find length of the longest bitonic subarray with the output.

  • Collection of 200+ C problems with solutions.

We have designed this program for beginners for learning purpose. Copy below c program and execute it with c compiler to see the output of the program.

#include
#include
 
int bitonic(int arr[], int n)
{
    int inc[n];
    int dec[n];
    int i, max;
 
    inc[0] = 1;
 
    dec[n-1] = 1;

    for (i = 1; i = arr[i-1])? inc[i-1] + 1: 1;
 
    for (i = n-2; i >= 0; i--)
       dec[i] = (arr[i] >= arr[i+1])? dec[i+1] + 1: 1;

    max = inc[0] + dec[0] - 1;
    for (i = 1; i  max)
            max = inc[i] + dec[i] - 1;
 
    return max;
}
 
int main()
{
    int arr[] = {12, 4, 78, 90, 45, 23};
    int n = sizeof(arr)/sizeof(arr[0]);
    printf("nLength of max length Bitnoic Subarray is %d",
            bitonic(arr, n));
    return 0;
}

Program Output

Length of max length Bitnoic Subarray is 5

The post C program to find length of the Longest Bitonic Subarray appeared first on FreeWebMentor.



This post first appeared on Programming Blog Focused On Web Technologies, please read the originial post: here

Share the post

C program to find length of the longest bitonic subarray

×

Subscribe to Programming Blog Focused On Web Technologies

Get updates delivered right to your inbox!

Thank you for your subscription

×