Software Design
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreSoftware Design

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 25th, 2003, 10:45 PM
Deek Deek is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 1 Deek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
really basic question

I am starting analysis of algorithms for a class and I am having trouble with the basics, could someone help me work through this simple problem. Im not asking do it for me but I am not sure where to start. I read my prof book(which the problem is out of) but its explanations are too hard for me to understand.

prove or disprove each of the following:

f ( n ) = O(( f ( n ))^2)

if the statement is true prove it if false show how my example demonstrates it's false.

Reply With Quote
  #2  
Old March 26th, 2003, 02:26 AM
riv's Avatar
riv riv is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 465 riv User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 46 m 15 sec
Reputation Power: 13
Quote:
f ( n ) = O(( f ( n ))^2)


To me it looks like algebra, just respect the basic rules of precedence: PEMDAS. Sounds hard to be true but then again, who is O?

BTW, what language is that?
__________________
Words must be weighed, not counted.

Reply With Quote
  #3  
Old March 26th, 2003, 05:11 AM
tony825 tony825 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Greece
Posts: 63 tony825 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 11
well it is 100% algorithms (comlexity, i think its called) but the question is what the f(n) is.

I mean the very same n ( an array[n] for example) has an different complexity {O[f(n)]} for a different algorithm f.

expl. the bublesort is n^2 and the quicksort is an O(n).

but just F( )..... it doent say a thing to me soory, if you could be more specific.
__________________
No sign

Reply With Quote
  #4  
Old March 26th, 2003, 09:59 PM
infamous41md's Avatar
infamous41md infamous41md is offline
not a fan of fascism (n00b)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Feb 2003
Location: ct
Posts: 2,756 infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 11 h 4 m 29 sec
Reputation Power: 94
that is bigO notation, referring to the asymptotic complexity of the algorithm. if i remember correctly, bigO is the worst case scenario, or upper bounds, of how an algorithm will perform. basically, the performance of an algorithm(f(n)) will never be worse than its bigO. that example is not true. one way to prove would be to take the function: n^2 + 2n + 50
the bigO of that is n^2, which is clearly not = to (n^2 + 2n + 50)^2 ... how did i get this? this stuff should be in ur book, and its rather hard to explain over a computer, but i can tell u this: with simple quadratic functions, the term with the highest power in it is almost always the bigO. This is b/c with extremely large values of n, that is the term that will grow at the highest rate.

Reply With Quote
  #5  
Old March 27th, 2003, 03:16 AM
yassoor's Avatar
yassoor yassoor is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Canada - Egypt
Posts: 60 yassoor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 11
This link should be helpful


Extract from the link

Quote:
Formal Definition: f(n) = O(g(n)) means there are positive constants c and k, such that 0 <= f(n) <= cg(n) for all n <= k. The values of c and k must be fixed for the function f and must not depend on n.



This formal definition is what you should be looking at to answer your question.

notice the difference between wour prof's question and the definition

The prof replaced g(n) by f(n)^2

so the real question is
Can this hold for all times
0 <= f(n) <= c( f(n)^2 ) for all n <= k.

is g(n) "the complixity of a function" always < (f(n)^2) ?
could it ever be possible that the big O complixity of a function be greater than f(n)^2 ?


I hope I have put you in the right direction, without answering the question for you.
__________________
I hope this is of any help to anyone.

Yassoor
http://www.WebsitesCreation.ca

Reply With Quote
  #6  
Old April 16th, 2003, 08:38 AM
lazy_yogi lazy_yogi is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 325 lazy_yogi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 58 m 36 sec
Reputation Power: 11
just disprove by example

let f(n) = n^2 + 1

then [ f(n) ]^2 = n^4 + 2*(n^2) + 1

then O( [ f(n) ]^2 ) is n^4


and clearly n^2 + 1 != n^4

hence
f ( n ) != O(( f ( n ))^2)

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreSoftware Design > really basic question

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap