Settings

Theme

Show HN: Data Structures and Algorithms

github.com

2 points by xennygrimmato 10 years ago · 1 comment

Reader

S4M 10 years ago

Are you trying to give the community a bunch of algorithms ready to use? One suggestion: for each algorithm, your main function seems to be an example of how to call the algorithm. Instead, can you make it take an argument so it can be called from the command line?

For example, for the Eratosthenes sieve, your main is:

    int main()
    {
        sieveOptimized(100);
        for(int j=0;j<100;j++)
    	    if(isPrime[j])
    		 cout <<j <<"\n";
    } 
I am suggesting to change it into:

    int main(int argc, char* args[])
    {
        int n = atoi(args[1]);
        sieveOptimized(n);
        for(int j=0;j<n;j++)
    	    if(isPrime[j])
    		cout <<j <<"\n";
    }

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection