Otniel113 / Square_BF

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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


Languages

Language:C++ 100.0%