|
||||||
| Programming Theory Discuss programming theory, algorithm efficiency, logic, and other any other category where math and computer science overlap. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Hi guys, I was wondering if anyone could give me any tips on these exercises I am trying.
I'm trying to make an algorithm that runs proportional to O(log(nČ)). The attempt I've coded (in java) looks something like this: Code:
int count = 0;
for(int i=1; i<n; i*=2) {
for(int j=0; j<n; j++) {
for(int k=0; k<n; k++) {
count++; }}}
Now from my understanding I thought that the two inner loops would give an NČ complexity, which would then be multiplied by the outer loop which has a log complexity. I assume something fairly fundamental is tripping me up, I suspect either the order of my loops or a math error based on the log part. Anyway thanks for any advice you can give, feel free to give any general tips on algorithm analysis if you want as I think I only have a vague grasp on the topic. |
| Sponsored Links |
|
|
|
|||||
|
O(log(n^2)) is actually O(2*log(n)) or O(log(n)). A typical algorithm of this complexity is a binary search.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Programming is a branch of mathematics. |
|
|||||
|
The "number guessing game" is generally a good example of an O(log(n)) algorithm.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| best algorithm for given problem | artartart | General Programming | 1 | 05-14-2008 11:53 AM |
| Peterson's Algorithm | zm1723 | C# Programming | 1 | 12-13-2007 11:47 AM |
| Help : days algorithm | rivci | Java Help | 4 | 12-13-2007 05:57 AM |
| New Algorithm Matches Any Tumor Cells To Best Possible Anticancer Treatments | Kernel | Programming News | 0 | 07-29-2007 08:52 PM |
| efficient algorithm | sovixi | Python | 3 | 04-19-2007 02:47 PM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |