| | |
Help me with this Question
Please support our Computer Science advertiser: Learn about neural networks and artificial intelligence.
![]() |
•
•
Join Date: Aug 2005
Posts: 76
Reputation:
Solved Threads: 1
Tarek: have you done a course on this subject? Did you go to classes? Did you get any notes? Have you tried a search for "time and space complexities"? Have you thought about this question? Have you asked yourself why you are studying if you can't be bothered to do any of the learning?
•
•
•
•
Originally Posted by Tarek
I think the answer to time complexity is :
nm+n+m+2
but I can't give the Big Oh for it .
Your answer for the time complexity is generally correct. The question is, do you know what Big O notation really means?
It is used to compare growth rates between functions. Hopefully, you know what it means for one function to grow faster than another. If a function f grows slower than or equal to a function g defined by g(x) = x^2, we would say that f is in O(x^2). For example, if f(x) = 3x^2, then their growth rates are equal, hence O(x^2) is an upper bound for f. O(x^3) would be another valid upper bound, since 3x^2 grows slower than x^3. But saying O(x^2) is tighter and more informative.
You have found a correct formula for the running time of your algorithm. If you wanted, a cheapo growth bound for your algorithm could be O(nm+n+m+2). Your function certainly grows at the same rate as or slower than itself. But it can be shown using some math that f(x,y) = xy grows at the same rate as xy+x+y+2, so the growth bound of O(nm) works, too.
Formally, big-O notation represents sets of functions -- the set of all functions that grow slower than or equal to the contained expression (using a certain definition of "slower than or equal to"). For example, O(n^2) is a set of functions that includes functions like f(n) = n + 3, g(n) = 3n^2 + 5n + 7, h(n) = log n + n + n log n, and so on.
If you don't understand why 3n^2 + 5n + 7 is said to grow at the same rate as n^2, say so and I'll explain it to you completely. The above explanation of big O notation is kind of quick and might be insufficient.
All my posts may be redistributed under the GNU Free Documentation License.
![]() |
Similar Threads
- C command-line I/O question (C++)
- Apache Alias Directive... mod_alias question (Linux Servers and Apache)
- Completely new to C++ and have question about using char (C++)
- Question (Geeks' Lounge)
- question on cooling (Cases, Fans and Power Supplies)
- Context-sensitive grammar question :( (Computer Science)
- Welcome PC Mod Kingdom peeps! (Geeks' Lounge)
- Laptop LCD built into a car? (Monitors, Displays and Video Cards)
- Changing Network Configuration (*nix Software)
Other Threads in the Computer Science Forum
- Previous Thread: algorithm performance measure
- Next Thread: What is Big O ?
| Thread Tools | Search this Thread |
ai algorithm algorithms amazon assignment assignments automata battery bigbrother binary bittorrent bizarre bletchleypark blogging bomb business cern codebreaker compiler computer computers computerscience computertrackingsoftware connect conversion csc dataanalysis dataintepretation development dfa dissertation dissertationthesis dissertationtopic ebook employment energy floatingpoint foreclosure foreclosuresoftware fuel gadgets geeks givemetehcodez government graphics hardware history homeowners homeworkassignment homeworkhelp humor ibm idea ideas internet iphone ipod itcontracts jobs kindle laser laws linkbait lsmeans mainframes marketing mobileapplication msaccess nano netbeans networking news os p2p piracy piratebay principles programming rasterizer research sam-being-cute sas science security sex simulation software spying stephenfry study supercomputer supercomputing sweden technology textfield turing turingtest two'scompliment virus ww2






