From 95ffd5880e9e6fb409159672038e0ca9e56bc1e8 Mon Sep 17 00:00:00 2001 From: Abwas Date: Tue, 20 Jun 2017 07:36:34 +0100 Subject: [PATCH 1/2] percolation assignment --- Percolation.class | Bin 0 -> 2788 bytes Percolation.java | 170 +++++++++++++++++++++- PercolationStats.class | Bin 0 -> 2249 bytes PercolationStats.java | 78 +++++++++- StdOut.class | Bin 0 -> 3469 bytes StdOut.java | 318 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 552 insertions(+), 14 deletions(-) create mode 100644 Percolation.class create mode 100644 PercolationStats.class create mode 100644 StdOut.class create mode 100644 StdOut.java diff --git a/Percolation.class b/Percolation.class new file mode 100644 index 0000000000000000000000000000000000000000..07afc185d47c5929dad70d1d2e5c97bcbf59a598 GIT binary patch literal 2788 zcmb7G-*XdH6#h23X_|EV6T%OZNNK6IX-j|tDnBX|TUtyh^cS>%WSeZ$g*02!4Fc-$ zqRi+F%7Ze(i$YO^VVrTswrU+2-W+}KN&XlI#qaKJlRCnK!{qL{_nv#scfar4Q-1yX z$DaXggAqgseE|-K{CK?_i6Fe_FUR2^p2L72M}jEFfZRVShe0_E`7s&=dqSc_W?Ba~W$&fzqd-%$OaR(Q^tsC&m?2 z%;@=)nbj=A9ey6s?QmDtDt3v&6&PjT0gI#&Ryv;Ez6vC7X!0~rMtGTxv#HAft9PUzm|7Ve2@ z&0y*^%_kCPv~yZKtK~BBA&W|7c1z$w%V+4k>M7dSFoRIk;W1*_hite>!nS6TPe zB*F?SOy^vmiU0bf6f~?zmCfoIExSLTDNO4*tC&ee6wj+@Ktx5OgxC5%s#QYiP_Y5^ zDmKbt6Pi?{M=<7{M@5WF zA~_G0c!T^^h+)@KX)U30j0{)Jqk4s1BRZquIrNI1A{G+SMbz%}@ldrq9`Y@qjz&#! zLT#44%3LosR7S7&yvm&?Ka?05CnsPT3hY7vyHSh1TM2{aYvu^%EzoPufWQu%8t{69Y6@uzGjspc#$j}NIv^ONw`6*<}FW>-czVSlI5IYiR+|kl44~j))^c}7897} zn8P`|iOZP9Ram&e$9x;-v51R!h_~?@-oYQZWD7RPSGbk2cae0#)2kUxT32c9v8{)+ z_SzO%E(-Rj_*@>j&&7}5`M~6BmeK_v9-~{?(k_K!Z*=6sIJafHsQQ;&rDhVO^1%DN z=4BgR%<(R!ttzIiDyH?jX%*J+a-K_Wo~BYB`?W+Du==|Fa9AbR;TLxxyfVGhFr4&P znEvAx>6?n_n~Le1is_$Uacj2F$7odc@qZ7p@w=Bk%}dC>w@J#+f>|X?kG~53R06us zZ!jj<(`q|PSgME#_=Ng=igozR#-loMTs)FzFO+p8y9)>0WZ!T}9_(F0XpAA(Bw81+ z_Is>r6|D93?nG|-xY^(4Y_{2(%M+jUbSJU|J$5(U%r*^t&TL<>1aGo$+@i8`{A+QW wZTw5V^{-e)cX;uy**WgofSoSe%Z}2`vjHl!fqxF gridLength || a < 1 ) + { + throw new IndexOutOfBoundsException("row index a out of bounds"); + } + if (b > gridLength || b < 1) + { + throw new IndexOutOfBoundsException("column index b out of bounds"); + } + } + + // create n-by-n grid, with all sites blocked + public Percolation(int n) + { + if (n < 1) { + throw new IllegalArgumentException(); + } + gridLength = n; + int arraySize = n * n + 2; + isOpen = new boolean[arraySize]; + + virtualTopIndex = 0; + virtualBottomIndex = (n * n) + 1; + + isOpen[virtualTopIndex] = true; /// open virtual top site + isOpen[virtualBottomIndex] = true; /// open virtual bottom site + + percolation = new WeightedQuickUnionUF(arraySize); + fullness = new WeightedQuickUnionUF(arraySize); + for (int b = 1; b <= n; b++) + { + /// connect all top row sites to virtual top site + int a = 1; + int topSiteIndex = siteIndex(a, b); + percolation.union(virtualTopIndex, topSiteIndex); + fullness.union(virtualTopIndex, topSiteIndex); + + /// connect all bottom row sites to virtual bottom site + a = n; + int bottomSiteIndex = siteIndex(a, b); + percolation.union(virtualBottomIndex, bottomSiteIndex); + + } + }; + + // open site (row a, column b) if it is not already + public void open(int a, int b) + { + int siteIndex = siteIndex(a,b); + if (!isOpen[siteIndex]) + { + /// to open a site, change boolean value, and union with any adjacent open sites + isOpen[siteIndex] = true; - public static void main(String[] args) // test client (optional) + // before connecting to a neighbor, first check that site is not on an edge, and is open + if (b > 1 && isOpen(a, b - 1)) + { + int indexToLeft = siteIndex(a, b - 1); + percolation.union(siteIndex, indexToLeft); + fullness.union(siteIndex, indexToLeft); + } + + if (b < gridLength && isOpen(a, b + 1)) + { + int indexToRight = siteIndex(a, b + 1); + percolation.union(siteIndex, indexToRight); + fullness.union(siteIndex,indexToRight); + } + + if (a > 1 && isOpen(a - 1, b)) // site is not top edge + { + int indexToTop = siteIndex(a - 1, b); + percolation.union(siteIndex, indexToTop); + fullness.union(siteIndex,indexToTop); + } + + if (a < gridLength && isOpen(a + 1, b)) /// site is not on bottom edge + { + int indexToBottom = siteIndex(a + 1, b); + percolation.union(siteIndex, indexToBottom); + fullness.union(siteIndex,indexToBottom); + } + } + }; + + // is site (row a, column b) open? + //// openness represented by boolean value in isOpen array + public boolean isOpen(int a, int b) + { + int siteIndex = siteIndex(a, b); + return isOpen[siteIndex]; + } + + // is site (row a, column b) full? + /// fullness represented by union with virtual top node + public boolean isFull(int a, int b) + { + int siteIndex = siteIndex(a, b); + //return (percolation.connected(virtualTopIndex,siteIndex) && isOpen[siteIndex]); + return (fullness.connected(virtualTopIndex,siteIndex) && isOpen[siteIndex]); + } + + // does the system percolate? + public boolean percolates() { + if (gridLength > 1) { + return percolation.connected(virtualTopIndex,virtualBottomIndex); + } + else { + return isOpen[siteIndex(1,1)]; + } + + } + + public static void main(String[] args) + { + Percolation percolation = new Percolation(1); + StdOut.println(percolation.percolates()); + percolation.open(1,1); + StdOut.println(percolation.percolates()); + Percolation percolation2 = new Percolation(2); + StdOut.println(percolation2.percolates()); + percolation2.open(1,1); + StdOut.println(percolation2.percolates()); + percolation2.open(2,1); + StdOut.println(percolation2.percolates()); + } } \ No newline at end of file diff --git a/PercolationStats.class b/PercolationStats.class new file mode 100644 index 0000000000000000000000000000000000000000..5e22c0daa67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DdU~*)wRF*Rhv- zK_Wb$?|!aQdy9L**JNJ= 0. + if (n < 1 || T < 1) + { + throw new IllegalArgumentException("both arguments n and T must be greater than 1"); + } + + this.T = T; + thresholdResults = new double[T]; + for (int t = 0; t < T; t++) + { + Percolation percolation = new Percolation(n); + int openSites = 0; + while (!percolation.percolates()) + { + int a = StdRandom.uniform(1, n+1); + int b = StdRandom.uniform(1, n+1); + + if (!percolation.isOpen(a, b)) + { + percolation.open(a, b); + openSites += 1; + } + } + double threshold = (double)openSites/(double)(n * n); + thresholdResults[t] = threshold; + } + } + + // sample mean of percolation threshold + public double mean() + { + return StdStats.mean(thresholdResults); + } + + // sample standard deviation of percolation threshold + public double stddev() + { + return StdStats.stddev(thresholdResults); + } + + // returns lower bound of the 95% confidence interval + public double confidenceLo() + { + return mean() - (1.96 * stddev() / Math.sqrt(T)); + } + + // returns upper bound of the 95% confidence interval + public double confidenceHi() + { + return mean() + (1.96 * stddev() / Math.sqrt(T)); + } + + public static void main(String[] args) + { + int n = Integer.parseInt(args[0]); + int T = Integer.parseInt(args[1]); + PercolationStats stats = new PercolationStats(n, T); + StdOut.println("mean = "+ stats.mean()); + StdOut.println("standard deviation = "+ stats.stddev()); + StdOut.println("95% confidence interval = "+ stats.confidenceLo() + " , " + stats.confidenceHi()); + } + } \ No newline at end of file diff --git a/StdOut.class b/StdOut.class new file mode 100644 index 0000000000000000000000000000000000000000..32aa8f63501e97426e8dc0d73e50b4d70f892fdd GIT binary patch literal 3469 zcmbW4TXYju6o&sv(@q*vC~2u$6j~_Q3$%)g&=zT%w$PHaNP4lL!Zc0WK$?_fg511< z7Zkj(mOknuzEai-6_!4rPcHRQeN-RSNA(f?_slez4ui5}!OotUeZGD6KL0sq@%8N+ zUjW#K%YLlI;c_(Lh#&RP#7v5biJ1};7c(tpM$D|3gqWjZj)_T%nG=%|lNK{C=D3hE z;$?l%{d^#|Nf=F-@*$_oRL>+*GaU*lLg`di*HZeJ zmdwQ!l!b>w-Qi+%PERD;!s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K1DRid8bqX*Cb10CBp AxBvhE literal 0 HcmV?d00001 diff --git a/StdOut.java b/StdOut.java new file mode 100644 index 0000000..4501df7 --- /dev/null +++ b/StdOut.java @@ -0,0 +1,318 @@ +/****************************************************************************** + * Compilation: javac StdOut.java + * Execution: java StdOut + * Dependencies: none + * + * Writes data of various types to standard output. + * + ******************************************************************************/ + +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.util.Locale; + +/** + * This class provides methods for printing strings and numbers to standard output. + *

+ * Getting started. + * To use this class, you must have {@code StdOut.class} in your + * Java classpath. If you used our autoinstaller, you should be all set. + * Otherwise, download + * StdOut.java + * and put a copy in your working directory. + *

+ * Here is an example program that uses {@code StdOut}: + *

+ *   public class TestStdOut {
+ *       public static void main(String[] args) {
+ *           int a = 17;
+ *           int b = 23;
+ *           int sum = a + b;
+ *           StdOut.println("Hello, World");
+ *           StdOut.printf("%d + %d = %d\n", a, b, sum);
+ *       }
+ *   }
+ *  
+ *

+ * Differences with System.out. + * The behavior of {@code StdOut} is similar to that of {@link System#out}, + * but there are a few subtle differences: + *

    + *
  • {@code StdOut} coerces the character-set encoding to UTF-8, + * which is a standard character encoding for Unicode. + *
  • {@code StdOut} coerces the locale to {@link Locale#US}, + * for consistency with {@link StdIn}, {@link Double#parseDouble(String)}, + * and floating-point literals. + *
  • {@code StdOut} flushes standard output after each call to + * {@code print()} so that text will appear immediately in the terminal. + *
+ *

+ * Reference. + * For additional documentation, + * see Section 1.5 of + * Computer Science: An Interdisciplinary Approach + * by Robert Sedgewick and Kevin Wayne. + * + * @author Robert Sedgewick + * @author Kevin Wayne + */ +public final class StdOut { + + // force Unicode UTF-8 encoding; otherwise it's system dependent + private static final String CHARSET_NAME = "UTF-8"; + + // assume language = English, country = US for consistency with StdIn + private static final Locale LOCALE = Locale.US; + + // send output here + private static PrintWriter out; + + // this is called before invoking any methods + static { + try { + out = new PrintWriter(new OutputStreamWriter(System.out, CHARSET_NAME), true); + } + catch (UnsupportedEncodingException e) { + System.out.println(e); + } + } + + // don't instantiate + private StdOut() { } + + /** + * Closes standard output. + */ + public static void close() { + out.close(); + } + + /** + * Terminates the current line by printing the line-separator string. + */ + public static void println() { + out.println(); + } + + /** + * Prints an object to this output stream and then terminates the line. + * + * @param x the object to print + */ + public static void println(Object x) { + out.println(x); + } + + /** + * Prints a boolean to standard output and then terminates the line. + * + * @param x the boolean to print + */ + public static void println(boolean x) { + out.println(x); + } + + /** + * Prints a character to standard output and then terminates the line. + * + * @param x the character to print + */ + public static void println(char x) { + out.println(x); + } + + /** + * Prints a double to standard output and then terminates the line. + * + * @param x the double to print + */ + public static void println(double x) { + out.println(x); + } + + /** + * Prints an integer to standard output and then terminates the line. + * + * @param x the integer to print + */ + public static void println(float x) { + out.println(x); + } + + /** + * Prints an integer to standard output and then terminates the line. + * + * @param x the integer to print + */ + public static void println(int x) { + out.println(x); + } + + /** + * Prints a long to standard output and then terminates the line. + * + * @param x the long to print + */ + public static void println(long x) { + out.println(x); + } + + /** + * Prints a short integer to standard output and then terminates the line. + * + * @param x the short to print + */ + public static void println(short x) { + out.println(x); + } + + /** + * Prints a byte to standard output and then terminates the line. + *

+ * To write binary data, see {@link BinaryStdOut}. + * + * @param x the byte to print + */ + public static void println(byte x) { + out.println(x); + } + + /** + * Flushes standard output. + */ + public static void print() { + out.flush(); + } + + /** + * Prints an object to standard output and flushes standard output. + * + * @param x the object to print + */ + public static void print(Object x) { + out.print(x); + out.flush(); + } + + /** + * Prints a boolean to standard output and flushes standard output. + * + * @param x the boolean to print + */ + public static void print(boolean x) { + out.print(x); + out.flush(); + } + + /** + * Prints a character to standard output and flushes standard output. + * + * @param x the character to print + */ + public static void print(char x) { + out.print(x); + out.flush(); + } + + /** + * Prints a double to standard output and flushes standard output. + * + * @param x the double to print + */ + public static void print(double x) { + out.print(x); + out.flush(); + } + + /** + * Prints a float to standard output and flushes standard output. + * + * @param x the float to print + */ + public static void print(float x) { + out.print(x); + out.flush(); + } + + /** + * Prints an integer to standard output and flushes standard output. + * + * @param x the integer to print + */ + public static void print(int x) { + out.print(x); + out.flush(); + } + + /** + * Prints a long integer to standard output and flushes standard output. + * + * @param x the long integer to print + */ + public static void print(long x) { + out.print(x); + out.flush(); + } + + /** + * Prints a short integer to standard output and flushes standard output. + * + * @param x the short integer to print + */ + public static void print(short x) { + out.print(x); + out.flush(); + } + + /** + * Prints a byte to standard output and flushes standard output. + * + * @param x the byte to print + */ + public static void print(byte x) { + out.print(x); + out.flush(); + } + + /** + * Prints a formatted string to standard output, using the specified format + * string and arguments, and then flushes standard output. + * + * + * @param format the format string + * @param args the arguments accompanying the format string + */ + public static void printf(String format, Object... args) { + out.printf(LOCALE, format, args); + out.flush(); + } + + /** + * Prints a formatted string to standard output, using the locale and + * the specified format string and arguments; then flushes standard output. + * + * @param locale the locale + * @param format the format string + * @param args the arguments accompanying the format string + */ + public static void printf(Locale locale, String format, Object... args) { + out.printf(locale, format, args); + out.flush(); + } + + /** + * Unit tests some of the methods in {@code StdOut}. + * + * @param args the command-line arguments + */ + public static void main(String[] args) { + + // write to stdout + StdOut.println("Test"); + StdOut.println(17); + StdOut.println(true); + StdOut.printf("%.6f\n", 1.0/7.0); + } + +} From 624468dc7b897c7142c885076fd69a1ae254ad92 Mon Sep 17 00:00:00 2001 From: Abwas Date: Fri, 23 Jun 2017 11:01:00 +0100 Subject: [PATCH 2/2] percolation assignment --- Percolation.class | Bin 2788 -> 2578 bytes Percolation.java | 15 +++------------ PercolationStats.class | Bin 2249 -> 1655 bytes PercolationStats.java | 11 +++-------- StdOut.class | Bin 3469 -> 0 bytes 5 files changed, 6 insertions(+), 20 deletions(-) delete mode 100644 StdOut.class diff --git a/Percolation.class b/Percolation.class index 07afc185d47c5929dad70d1d2e5c97bcbf59a598..cbea07f7b98b0e3b53dcc0e8b4bafcd87e5488b5 100644 GIT binary patch delta 1225 zcmYjQO-~b16g{sUn6?ZR4Ic#&2C#rsT0lTWL==h?(b&8h zoiN9uu}Juq0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|$8<8W+SR?x&EuD<(pOY++2Mye zf$kS()QXK^Dy4WcTkK_R{Gct{|IB?V_WSo(+?&43k{_u|`~F>CT==lTA_e=J3c)59 zeEKn6WREU<-4U3lj-!`SBKx({UDG67*L2@deQzr5oZj9yn#ga}&F`e-d(HPP$GGsS bGMf8t-A$;1)q2C0YAtWd^W<-H88ZI?EUB*> diff --git a/Percolation.java b/Percolation.java index d53dc06..4f22999 100644 --- a/Percolation.java +++ b/Percolation.java @@ -1,3 +1,4 @@ +import edu.princeton.cs.algs4.StdOut; import edu.princeton.cs.algs4.StdRandom; import edu.princeton.cs.algs4.StdStats; import edu.princeton.cs.algs4.WeightedQuickUnionUF; @@ -154,17 +155,7 @@ public boolean percolates() { } - public static void main(String[] args) - { - Percolation percolation = new Percolation(1); - StdOut.println(percolation.percolates()); - percolation.open(1,1); - StdOut.println(percolation.percolates()); - Percolation percolation2 = new Percolation(2); - StdOut.println(percolation2.percolates()); - percolation2.open(1,1); - StdOut.println(percolation2.percolates()); - percolation2.open(2,1); - StdOut.println(percolation2.percolates()); + public static void main(String[] args) { + } } \ No newline at end of file diff --git a/PercolationStats.class b/PercolationStats.class index 5e22c0daa67aea53abb46b065884671de7869785..9219224d2d031c8718098ec54f6a42f021422d38 100644 GIT binary patch delta 776 zcmZvaO-~b16o#KWh2C}?)J74?hgy(Qt)QrA73ISZ5ER6sqEb%U+Bf~&{{6_?bFMgdmHze;F9ICWzw*{ zw78NlE*6#_Wb?(R%cY{hn|t-{W1Y4KD`iux{4`ym7N#m4-t1BfR|1-e2kfHBuw^>G za=);=P+BTH320$D;3`?mOu#j+2i#yb;3ln>TLC@X4mjjO54|qywaf+NxFZ)eLNld> zQn6A9eNB>(-A2v9)1`vdOx5)aV^ptIv8|G=e_d|Z+7vq!w^2uot;(Bqrd_A@DNBp) z7oVYxVRkdl9w9+BiR-8>^jS^RSjh(hk7ViTg{s+rZ!US(EV6I$(1tqfyy z=CxR_!x2e!2~2WVcbt$UUPv~jr_1(h%~U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