예제 #1
0
파일: main.cpp 프로젝트: irtefa/dumbshit
void generateGraphs( Gnuplot const & g, string func ) {
    cout << endl << "Generating "+func+" graphs...";
    fflush( stdout );
    bool show_n2 = func == "buildTree";
    g.graph("Increasing Inserts: "+func, "ms", func+"Increasing.dat",
            func+"Increasing.png", show_n2, show_n2 );
    g.graph("Alternating Inserts: "+func, "ms", func+"Alternating.dat",
            func+"Alternating.png", show_n2, show_n2 );
    g.graph("Random Inserts: "+func, "ms", func+"Random.dat",
            func+"Random.png", false, show_n2 );
    cout << " Done." << endl;
}
예제 #2
0
파일: main.cpp 프로젝트: irtefa/dumbshit
void testRandomHeights( Gnuplot const & g ) {

    cout << "Building random trees..." << endl;

    ofstream outfile;
    outfile.open( "randomHeights.dat", ios::out | ios::trunc );

    int max_trees = 200;

    int size = SIZE_START;
    vector< BST<int, int> > trees;
    trees.resize(NUM_TREES*max_trees);
    int i = 0;
    for( int x = 0; x < NUM_TREES; x++ ) {
        cout << "Trees of size " << size << "... ";
        fflush(stdout);
        for( int j = 0; j < max_trees; j++ )
            buildTree( trees[i++], randm, size );
        size *= 2;
        cout << "Done." << endl;
    }

    i = 0;
    size = SIZE_START;
    for( int x = 0; x < NUM_TREES; x++ ) {
        cout << "Average height of size " << size << ": ";
        fflush(stdout);
        int avg = 0;
        for( int j = 0; j < max_trees; j++ )
            avg += trees[i++].height();
        avg = avg / max_trees;
        cout << avg << endl;
        outfile << size << " " << avg << endl;

        size *= 2;
    }
    outfile.close();

    cout << endl << "Generating graph... ";
    fflush(stdout);
    g.graph("Average Case Tree Height", "Height", "randomHeights.dat",
            "randomHeights.png", false, false);
    cout << "Done." << endl << endl;

}