Skip to content

When you can just calculate it, but instead use "dumb" Brute Force approach

Notifications You must be signed in to change notification settings

Otniel113/Square_BF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Square_BF

When you can just calculate it, but instead use "dumb" Brute Force approach

How to Open

  1. The main program is in main.cpp
  2. If you have codeblocks, you can open SquareBF.cbp
  3. If you don't have any IDE, you can run .exe file in /bin/Debug

Complexity

Square Normal = O(1)

Square Brute Force = O(n^2)

Algorithm

With Normal Approach, just return the result

int square_normal(int n){
    return n*n;
}

With Brute Force Approach

int square_bf(int n){
    int k = 0;
    do{
        k++;
    }while(k != n*n);
    return k;
}

Graph

Graph

Green = Brute Force

Purple = Normal

About

When you can just calculate it, but instead use "dumb" Brute Force approach

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages