Thread: O() notation
View Single Post
  #9 (permalink)  
Old 03-25-2008, 04:36 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,467
Last Blog:
Joomla! And Incompeten...
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default Re: O() notation

It is 4n because there are 4 "instructions" that are ran n times.

Yes, it is O(n) and not O(4n) because the 4 is a constant which is ignored. Both O(4n) and O(n) says the algorithm is linear. Since oh-notation is only used to described how the algorithm grows [linearly, quadratically, exponentially, logarithmically, ect...] the constant has no purpose.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Reply With Quote