Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 853965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:50:44+00:00 2026-05-15T07:50:44+00:00

A sequence is bitonic if it monotonically increases and then monotonically de- creases, or

  • 0

A sequence is bitonic if it monotonically increases and then monotonically de-
creases, or if it can be circularly shifted to monotonically increase and then
monotonically decrease. For example the sequences (1, 4, 6, 8, 3, −2) ,
(9, 2, −4, −10, −5) , and (1, 2, 3, 4) are bitonic, but (1, 3, 12, 4, 2, 10) is not
bitonic.

How can it be determined if given sequence is bitonic?

I have the following opinion. We can walk till n/2, where n is the length of the array, and check if

(a[i] < a[i + 1]) and (a[n - i - 1] < a[n-1 - (i + 1)])

Is this correct?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T07:50:44+00:00Added an answer on May 15, 2026 at 7:50 am

    A bitonic sequence:

     /\
    /  \
        \/
    

    Not a bitonic sequence:

     /\    
    /  \  / (higher than start)
        \/
    

    Obviously if the direction changes more than two times we cannot have a bitonic sequence.
    If the direction changes less than two times, we must have a bitonic sequence.

    If there are two changes in direction, we MAY have a bitonic sequence. Consider the two ascii images above. Clearly a sequence with two changes in direction will match one of the patterns (allowing for a reflection). Thus, we set the initial direction by comparing the first and last elements. Since these can be the same, we use the first element that is not equal to the last element.

    Here is an implementation in Java:

        public static Boolean bitonic(int[] array) {
            if (array == null) return false;
            if (array.length < 4) return true;
            Boolean dir;// false is decreasing, true is increasing
            int pos = 0, switches = 0;
            while (pos < array.length) {
                if (array[pos] != array[array.length - 1])
                    break;
                pos++;
            }
            if (pos == array.length) return true;
            //pos here is the first element that differs from the last
            dir = array[pos] > array[array.length - 1];
            while (pos < array.length - 1 && switches <= 2) {
                if ((array[pos + 1] != array[pos]) &&
                   ((array[pos + 1] <= array[pos]) == dir)) {
                    dir ^= true;
                    switches++;
                }
                pos++;
            }
            return switches <= 2;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have sequence of sequences (maybe a list of tuples) I can use
The sequence goes like this.. 7,8,77,78,87,88,777,778,787,788 and so on.. What can be the logic
I have a sequence of migrations in a rails app which includes the following
Given an arbitrary sequence of points in space, how would you produce a smooth
I have one hibernate sequence, that generates all sequence-numbers in my app. When I
If you have a sequence of block elements and you wanted to place margin
I have a sequence of SQL calls, which I want to use to detect
In the Fibonacci sequence, I have seen conventional implementations which recursively call the same
I have a long sequence of hex digits in a string, such as 000000000000484240FA063DE5D0B744ADBED63A81FAEA390000C8428640A43D5005BD44
I have a table that records a sequence of actions with a field that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.