Space complexity for Recursive Binary Search




Comment hidden because of low score. Click to expand.
2
of 2 vote

The recursive version has O(log n) space complexity.
2 possible reasons why you see O(1) everywhere may be:
a) Many people forget about the recursion stack
b) I believe most people/libraries implement the iterative version

- Miguel Oliveira November 15, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

// @owner: James.T.Kirk.
class Space {
   final frontier; 
}

- Anonymous November 09, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

What is that supposed to mean?

- teli.vaibhav November 10, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Yeah. What? What? Tell us...

- ask.vaibhav November 12, 2013 | Flag
Comment hidden because of low score. Click to expand.
-1
of 1 vote

its a joke. Star Trek - space - the final frontier

- raj November 17, 2013 | Flag
Comment hidden because of low score. Click to expand.
-2
of 2 vote

WRONG Miguel. It is tail recursive so O(1) space just like iterative.

Google James.T.Kirk.

- Anonymous November 16, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

that's *if* you assume the compiler will make those optimizations

- Miguel Oliveira November 16, 2013 | Flag




Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More