473,435 Members | 1,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,435 software developers and data experts.

Big O notation (Maybe offtopic)

Hello:

I have seen that many interviewers ask, so what is the Big O for that
algorithm (say Binary Search) which is o(log n) + 1 (in most cases).

I know what is the Big O for most algorithms, but I am wondering how
can one derive the same ? I want to know if any places on the web have
concrete proof or methodology to do so.

Because of this Big O I have almost failed in an interview but my
conscience refused to answer the question by memorization as I really
don't know how to derive it mathematically.

Sorry I am unable to afford a Data Structure course or buy expensive
books. So if you know any good links kindly share else ignore this
e-mail.

Sorry for the spam if it's offtopic.

Thanks you.

Aug 18 '05 #1
3 1843
co*******@gmail.com wrote:
Hello:

I have seen that many interviewers ask, so what is the Big O for that
algorithm (say Binary Search) which is o(log n) + 1 (in most cases).

I know what is the Big O for most algorithms, but I am wondering how
can one derive the same ? I want to know if any places on the web have
concrete proof or methodology to do so.

Because of this Big O I have almost failed in an interview but my
conscience refused to answer the question by memorization as I really
don't know how to derive it mathematically.

Sorry I am unable to afford a Data Structure course or buy expensive
books. So if you know any good links kindly share else ignore this
e-mail.

Sorry for the spam if it's offtopic.

Thanks you.


http://en.wikipedia.org/wiki/Big_O_notation
Aug 18 '05 #2
On Thu, 18 Aug 2005 04:20:52 UTC, co*******@gmail.com wrote:
Hello:

I have seen that many interviewers ask, so what is the Big O for that
algorithm (say Binary Search) which is o(log n) + 1 (in most cases).

I know what is the Big O for most algorithms, but I am wondering how
can one derive the same ? I want to know if any places on the web have
concrete proof or methodology to do so.

Because of this Big O I have almost failed in an interview but my
conscience refused to answer the question by memorization as I really
don't know how to derive it mathematically.

Sorry I am unable to afford a Data Structure course or buy expensive
books. So if you know any good links kindly share else ignore this
e-mail.

Sorry for the spam if it's offtopic.

Thanks you.


Hello,

Someone else has pointed out a link. Basically, Big O Notation is
just a way of expressing the complexity of a problem in terms of what
one thinks are the expensive operations of an algorithm. It is usually
expressed in the number of records or items that need to be processed.

Memorization is good to some degree. You won't have time to derive
the complexity for every task that you decide to check, so being able
to classify the problem is helpful. On the other hand, it is good
that you want to understand what the notation means and how it can be
helpful to you and your team.

David
Aug 18 '05 #3
In message <11**********************@f14g2000cwb.googlegroups .com>,
co*******@gmail.com writes
Hello:

I have seen that many interviewers ask, so what is the Big O for that
algorithm (say Binary Search) which is o(log n) + 1 (in most cases).
O-notation is about the limit as n tends to infinity. log(n) grows
faster than any constant, so adding 1 is meaningless. It's just
O(log(n)).
I know what is the Big O for most algorithms, but I am wondering how
can one derive the same ? I want to know if any places on the web have
concrete proof or methodology to do so.

Because of this Big O I have almost failed in an interview but my
conscience refused to answer the question by memorization as I really
don't know how to derive it mathematically.
Just estimate the number of operations, considering the "average" case.
For example, binary search: each pass makes one comparison and on
average it halves the number of items to be searched, so the question is
really "how many times do I have to divide n by 2 to get 1?" In
mathematical terms, you're solving n/2^x = 1, and the answer is x =
log_2(n).
Sorry I am unable to afford a Data Structure course or buy expensive
books. So if you know any good links kindly share else ignore this
e-mail.

Sorry for the spam if it's offtopic.

Thanks you.


--
Richard Herring
Aug 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Timothy Fitz | last post by:
Why are all numberical literals in exponential notation floats? To me it is counter-intuitive for 1e3 to behave so fundamentally different from 1000. Timothy Fitz
6
by: S. | last post by:
if in my website i am using the sgml { notation, is it accurate to say to my users that the site uses unicode or that it requires unicode? is there a mathematical formula to calculate a unicode...
4
by: Casper | last post by:
In a recent posting, my notation was corrected: > tree* prootNode = new tree; > tree* psubNode = new tree; > > prootNode->child = psubNode; > psubNode->parent =...
28
by: Phill | last post by:
Does anyone know the reasoning for Microsoft abandoning Hungarina Notation in C#? I have found it very usefull in C++. I like this style: constant: MY_CONSTANT methos: myMethod() class: ...
2
by: funcSter | last post by:
I was asked to program using the Dutch Notation with C#. I am not familiar with the Dutch notation at all. I use the Hungarian. I asked a programmer friend "What is the Dutch Notation?" He...
19
by: | last post by:
Just seeking some advice (or solace)... Am I the only who's having trouble letting go of notation? Having extensive experience in C++ years ago (both before I jumped into VB3 in college and at...
66
by: CMM | last post by:
So after three years of working in .NET and stubbornly holding on to my old hungarian notation practices--- I resolved to try to rid myself of the habit. Man, I gotta say that it is liberating!!! I...
7
by: Sam Kong | last post by:
Hello! My question would not be very practical but just out of curiosity. In JavaScript, Array is a subclass of Object. Well maybe not exactly... but sort of... For normal objects, you can...
22
by: bearophileHUGS | last post by:
>From this interesting blog entry by Lawrence Oluyede: http://www.oluyede.org/blog/2006/07/05/europython-day-2/ and the Py3.0 PEPs, I think the people working on Py3.0 are doing a good job, I am...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.