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

  • SEARCH
  • Home
  • 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
  • 3 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
Let us have some sequence A, {-1, 3, 2, 5} for example. We can
I'm using a Sequence to generate an id for me, but I use that
Is there a sequence of characters that can be used after malformed javascript code,
Looking for a regexp sequence of matches and replaces (preferably PHP but doesn't matter)
I have a sequence of functions that look very similar but for a single
I have a sequence of FileInfo, but I only care about their string names,
We know some escape sequence '\n' - new line but say we don't know
I have a sequence of elements. The sequence can only be iterated once and
My class represents a sequence of items. There can be many instances of such

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.