Problem: Sorted-Rotated Array Search(no duplication).

Shankar Sundaram
1 min readJan 23, 2019

--

Hints:

Finding an element in the array (unsorted n-element) requires a time complexity of n.

Finding an element in the array (sorted n-element) using binary search requires time complexity of log n.

Problem Statement: Search in Rotated Sorted Array

We can solve the problem by splitting into two sub-problem.

  • Find the pivot element (starting element of the ascending) using the modified version of binary search. — time complexity (log n)
  • Using the pivot element, finalize the range and do a binary search over it. — time complexity (log n)

overall time complexity:

log n + log n = 2 log n — > O(log n)

If you have feedback and suggestion feel free to give your comments.

Reach out to me at Twitter, LinkedIn.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Shankar Sundaram
Shankar Sundaram

Written by Shankar Sundaram

Full- Stack Software Consultant

No responses yet

Write a response