473,387 Members | 1,603 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,387 software developers and data experts.

Big (o) notation

Hi Everyone,

I'm sorry that this is not specific to C language as such, however
as i'm currently programming on C, i'm posting it here.

I read a lot about BIG(0) notation that determines the complexity of
an algorithm, however it is very confusing and difficult to determine
for some cases, can anyone post a good link or give suggestions as to
how to work on it???

Dec 17 '06 #1
9 3510

<sa*****@yahoo.co.inwrote in message
news:11*********************@t46g2000cwa.googlegro ups.com...
Hi Everyone,

I'm sorry that this is not specific to C language as such, however
as i'm currently programming on C, i'm posting it here.

I read a lot about BIG(0) notation that determines the complexity of
an algorithm, however it is very confusing and difficult to determine
for some cases, can anyone post a good link or give suggestions as to
how to work on it???
Try comp.programming.
Big O notation is not confusing, but it can be made to appear confusing if
you give a student tricky examples and ask him to determine the order of the
algorithm.
--
www.personal.leeds.ac.uk/~bgy1mm
freeware games to download.
Dec 17 '06 #2
sa*****@yahoo.co.in writes:
I'm sorry that this is not specific to C language as such, however
as i'm currently programming on C, i'm posting it here.
If you were currently riding motorcycles, would you post to
rec.motorcycles?

Try comp.programming.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Dec 17 '06 #3
<sa*****@yahoo.co.inwrote in message
news:11*********************@t46g2000cwa.googlegro ups.com...
Hi Everyone,

I'm sorry that this is not specific to C language as such, however
as i'm currently programming on C, i'm posting it here.

I read a lot about BIG(0) notation that determines the complexity of
an algorithm, however it is very confusing and difficult to determine
for some cases, can anyone post a good link or give suggestions as to
how to work on it???
This may help:

http://en.wikipedia.org/wiki/Big_O_Notation

In general, the notation is an upper limit on the number of steps or
operations required to implement some algorithm as some parameter of
interest (typically number of data records) increases.

The mathematical notion will quickly identify algorithms (such as sort
algorithms) that don't scale up well. An algorithm that is O(N**2) may work
great on your computer when you use 100 records, but you may have a surprise
coming if you try to perform the operation on a billion records.

In order of decreasing desirability, we have:

O(log N)
O(N)
O(N log N)
O(N**2)
O(N**q), q>2
O(e**N)

The notions aren't that hard to apply for most algorithms. For example, for
the "rock" or "bubble" sort, it is easy to show that up to

(N) + (N-1) + (N-2) + ... + (N-N+2) + (N-N+1)

exchanges are required. I'm sure one can prove with a little algebra that a
tight upper bound on the number of exchanges is N**2.

Disclaimer: The above expression looks wrong somehow. I don't warranty the
math.


Dec 18 '06 #4
David T. Ashley said:

<snip>
>
(N) + (N-1) + (N-2) + ... + (N-N+2) + (N-N+1)

exchanges are required. I'm sure one can prove with a little algebra that
a tight upper bound on the number of exchanges is N**2.
Rearrange in two rows, each half as long, like so:

N + N-1 + N-2 + ...
N-N+1 + N-N+2 + N-N+3

Now add the columns:

N + N-1 + N-2 + ...
N-N+1 + N-N+2 + N-N+3
---------------------
N+1 + N+1 + N+1 + ...

So the total number of exchanges is N(N+1)/2, which is (N^2 + N) / 2.

So the worst case is O((N^2+N)/2).

We can get rid of the 2 by buying a computer twice as fast, which gives us
O(N^2+N). If N is really, really small, say 10 or less, we can ignore it as
being too small to bother with, and if it's really, really large, say, 11
or more, then it is so dwarfed by N^2 then we can ignore it as being too
small to bother with.

So yes, it's O(N^2).

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Dec 18 '06 #5
There is a excellent book which explains the concepts.

Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford
Stein. Introduction to Algorithms, Second Edition. MIT Press and
McGraw-Hill, 2001. ISBN 0-262-03293-7. Section 3.1: Asymptotic
notation, pp.41-50.
sa*****@yahoo.co.in wrote:
Hi Everyone,

I'm sorry that this is not specific to C language as such, however
as i'm currently programming on C, i'm posting it here.

I read a lot about BIG(0) notation that determines the complexity of
an algorithm, however it is very confusing and difficult to determine
for some cases, can anyone post a good link or give suggestions as to
how to work on it???
Dec 18 '06 #6
it simply means that, there is function f(n) whose value is always
less than an snother function g(n) for all n's greater than or equal to
(some) n0.

The above statement is stated as f(n)=O(g(n))
note that '=' is in fact "membership of a set"

hope that helps,
Onkar
sa*****@yahoo.co.in wrote:
Hi Everyone,

I'm sorry that this is not specific to C language as such, however
as i'm currently programming on C, i'm posting it here.

I read a lot about BIG(0) notation that determines the complexity of
an algorithm, however it is very confusing and difficult to determine
for some cases, can anyone post a good link or give suggestions as to
how to work on it???
Dec 18 '06 #7
onkar wrote:
it simply means that, there is function f(n) whose value is always
less than an snother function g(n) for all n's greater than or equal
to (some) n0.
Please don't top-post. Your replies belong following or interspersed
with properly trimmed quotes. See the majority of other posts in the
newsgroup, or:
<http://www.caliburn.nl/topposting.html>
Dec 18 '06 #8
"onkar" <on*******@gmail.comwrote in message
news:11**********************@73g2000cwn.googlegro ups.com...
There is a excellent book which explains the concepts.

Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford
Stein. Introduction to Algorithms, Second Edition. MIT Press and
McGraw-Hill, 2001. ISBN 0-262-03293-7. Section 3.1: Asymptotic
notation, pp.41-50.
Ron Rivest ... doesn't he keep giving us those cryptographic hashes that
keep getting compromised (i.e. MD4, MD5)?

Dec 19 '06 #9
David T. Ashley said:
"onkar" <on*******@gmail.comwrote in message
news:11**********************@73g2000cwn.googlegro ups.com...
>There is a excellent book which explains the concepts.

Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford
Stein. Introduction to Algorithms, Second Edition. MIT Press and
McGraw-Hill, 2001. ISBN 0-262-03293-7. Section 3.1: Asymptotic
notation, pp.41-50.

Ron Rivest ... doesn't he keep giving us those cryptographic hashes that
keep getting compromised (i.e. MD4, MD5)?
<shrugCan you explain to him how to fix them?

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Dec 19 '06 #10

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

Similar topics

6
by: jova | last post by:
Does anyone know of a good site where I can learn of this?
3
by: Robert Mark Bram | last post by:
Howdy All! Is there any difference between referencing objects and attributes with dot notation or bracket notation? Example, document.formname.controlname document Can I access...
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...
17
by: Thomas Lorenz | last post by:
Hello, I'm a little confused about object initialization. According to Stroustrup (The C++ Programming Language, Special Edition, Section 10.2.3) constructor arguments should be supplied in one...
4
by: Matthias | last post by:
I have been told not to use preceding underscores when notating data members for example. What kind of notation do you use in general? I have seen Microsoft uses hungarian notation a lot. Is that...
14
by: John T. | last post by:
I have a number in 8.8 notation that I wish to convert to a float....... 8.8 notation is a 16 bit fixed notation, so: 0xFF11 is the number 255.17 0x0104 is the number 1.4 0x2356 is the number...
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...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...

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.