Git Product home page Git Product logo

percolation's Introduction

This is Assignment 1 from Princeton's Algorithms Part I course, made using Eclipse, version: Neon.2 Release (4.6.2).

Description

This program models percolation which is found everywhere, from liquid seeping through openings to electricity going through conductors within insulation.

The Percolation class uses weighted quick union union-find to connect adjacent open squares in a grid until the top row is connected to the bottom row of squares, or in other words, until the system percolates.

The PercolationStats class utilizes the Percolation class to run a series of randomized trials on a grid of the requested size. In these trials random squares will be opened until the system percolates, then statistics are given on the percentage of open squares in the grid at that point. PercolationStats can return the mean percentage of open squares over all of the trials, the standard deviation of that percentage, as well as a 95% confidence interval.

The PercolationVisualizer class utilizes Percolation to show an animation of what is actually happening. The .png files in the testing folder show what the corresponding .txt file should output if ran with PercolationVisualizer. The PercolationVisualizer class was provided in the assignment details, I did not write it.

Command Line Instructions

cd src/

Windows:

Compile:
javac -cp ".;../algs4.jar" *.java

Run Visualizer with test text file:
java -cp ".;../algs4.jar" PercolationVisualizer ../testing/<txt-file-name>

Run with custom number of trials on custom grid size for statistics:
java -cp ".;../algs4.jar" PercolationStats gridSize numTrials

Mac:

Compile:
javac -cp ".:../algs4.jar" *.java

Run Visualizer with test text file:
java -cp ".:../algs4.jar" PercolationVisualizer ../testing/<txt-file-name>

Run with custom number of trials on custom grid size for statistics:
java -cp ".:../algs4.jar" PercolationStats <gridSize> <numTrials>

percolation's People

Contributors

gregdardis avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.