Search in sources :

Example 21 with In

use of edu.princeton.cs.algs4.In in project AlgorithmsSolutions by Allenskoo856.

the class Ex35 method main.

public static void main(String[] args) {
    Graph G = new Graph(new In(args[0]));
    Ex35 ex = new Ex35(G);
    System.out.println("Is Edge Connected Graph? " + ex.isEdgeConnectedGraph());
}
Also used : In(edu.princeton.cs.algs4.In)

Example 22 with In

use of edu.princeton.cs.algs4.In in project AlgorithmsSolutions by Allenskoo856.

the class Selection method main.

public static void main(String[] args) {
    String[] a = new In().readAllStrings();
    sort(a);
    assert isSorted(a);
    show(a);
}
Also used : In(edu.princeton.cs.algs4.In)

Example 23 with In

use of edu.princeton.cs.algs4.In in project AlgorithmsSolutions by Allenskoo856.

the class Ex18 method main.

public static void main(String[] args) {
    String[] a = new In().readAllStrings();
    String sort = args[0];
    if (sort.equals("selection")) {
        Selection.drawSort(a);
    } else if (sort.equals("insertion")) {
        Insertion.drawSort(a);
    }
}
Also used : In(edu.princeton.cs.algs4.In)

Example 24 with In

use of edu.princeton.cs.algs4.In in project AlgorithmsSolutions by Allenskoo856.

the class Example method main.

public static void main(String[] args) {
    String[] a = new In().readAllStrings();
    sort(a);
    assert isSorted(a);
    show(a);
}
Also used : In(edu.princeton.cs.algs4.In)

Example 25 with In

use of edu.princeton.cs.algs4.In in project algorithms-sedgewick-wayne by reneargento.

the class Exercise32_Dictionary method doExperiment.

private void doExperiment() {
    LookupCSV lookupCSV = new LookupCSV();
    int[] numberOfQueries = { 100000, 1000000, 10000000, 100000000, 1000000000 };
    String[] filePaths = { LARGE_INPUT_FILE_PATH1, LARGE_INPUT_FILE_PATH2 };
    String[] fileNames = { Constants.SURNAMES_CSV_FILE, Constants.SDSS_CSV_FILE };
    StdOut.printf("%18s %20s %10s\n", "Large input | ", "Number of queries | ", "Time spent");
    for (int q = 0; q < numberOfQueries.length; q++) {
        for (int f = 0; f < filePaths.length; f++) {
            In in = new In(filePaths[f]);
            String line = in.readLine();
            String[] tokens = line.split(",");
            int randomKeyIndex = StdRandom.uniform(tokens.length);
            int randomValueIndex = StdRandom.uniform(tokens.length);
            Stopwatch stopwatch = new Stopwatch();
            lookupCSV.lookup(filePaths[f], randomKeyIndex, randomValueIndex, numberOfQueries[q]);
            double timeSpent = stopwatch.elapsedTime();
            printResults(fileNames[f], numberOfQueries[q], timeSpent);
        }
    }
}
Also used : In(edu.princeton.cs.algs4.In) Stopwatch(edu.princeton.cs.algs4.Stopwatch)

Aggregations

In (edu.princeton.cs.algs4.In)71 StdIn (edu.princeton.cs.algs4.StdIn)10 HashSet (chapter3.section5.HashSet)5 ArrayList (java.util.ArrayList)5 SeparateChainingHashTable (chapter3.section4.SeparateChainingHashTable)4 ST (edu.princeton.cs.algs4.ST)4 Stopwatch (edu.princeton.cs.algs4.Stopwatch)4 Bag (com.jimmysun.algorithms.chapter1_3.Bag)3 Queue (edu.princeton.cs.algs4.Queue)3 SET (edu.princeton.cs.algs4.SET)3 RedBlackBST (chapter3.section3.RedBlackBST)2 Transaction (edu.princeton.cs.algs4.Transaction)2 Bag (chapter1.section3.Bag)1 Queue (chapter1.section3.Queue)1 Queue (com.jimmysun.algorithms.chapter1_3.Queue)1 Date (edu.princeton.cs.algs4.Date)1 Out (edu.princeton.cs.algs4.Out)1 File (java.io.File)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1