Skip to content

Commit

Permalink
commits greyby version of .gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-wayne committed Aug 25, 2016
1 parent c093a65 commit 2a9b08c
Show file tree
Hide file tree
Showing 35 changed files with 415 additions and 153 deletions.
57 changes: 54 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,54 @@
/build/*
/target/*
*IGNORE
# OS generated files
.DS_Store
Thumbs.db
*~
# Thumbnails
._*

### Java ###
*.class

# Package Files #
*.jar
*.war
*.ear

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# Gradle Files
.gradle
.m2

# Build output directies
build/
/target

### Eclipse project file ###
.metadata
.classpath
.project
.settings/
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
.loadpath
.launch
.cproject


# IntelliJ project files
*.iml
*.iws
*.ipr
.idea
out
test-output

.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml
161 changes: 161 additions & 0 deletions README-IGNORE
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
git add -A .
git commit -m "Describes commit"
git push origin master


add link to image of book

add fixed URL to github (in case it is forked)


Algorithms 4/e textbook libraries
=================================

by Robert Sedgewick and Kevin Wayne
-----------------------------------


This repository stores all of the algorithms and data structures from the textbook
Algorithms, Fourth Edition by Robert Sedgewick and Kevin Wayne packaged as algs4-`<version>`.jar.
For more details, see

http://algs4.cs.princeton.edu/code/

This is the library used in Algorithms Part I and II on Coursera.


<dependency>
<groupId>gov.nist.math</groupId>
<artifactId>jama</artifactId>
<version>1.0.3</version>
</dependency>

<dependency>
<groupId>classmexer</groupId>
<artifactId>classmexer</artifactId>
<version>0.03</version>
</dependency>



Prerequisites to use this code
------------------------------

To import current project in your favourite IDE (Eclipse, IntelliJ, etc) you need following:

1) Java (JRE or JDK), last version can be found here: http://www.oracle.com/technetwork/java/javase/downloads/index.html

2) Your favourite IDE , e.g. Eclipse for Java Developers: https://eclipse.org/downloads/ or intellij https://www.jetbrains.com/idea/

3) Maven - build tool : https://maven.apache.org/ (optional step, because most modern IDE have an embedded Maven installation)


Install Java (obligatory)
-------------------------

Download and unpackage(or install) Java JRE or JDK.

Download link: http://www.oracle.com/technetwork/java/javase/downloads/index.html

I recommend use JDK for development purposes, because JDK contains many tools for performance measurements.

However, JRE is also appropriate to run this code.

This code compatible with Java 1.6 and higher

But I recommend latest Java version.

Note, where java landed after installation.

For example , if java ended up in C:\Program Files\Java\\`<JDK-x-y-z>`, then this directory considered JAVA_HOME



Note for command line users:

%JAVA_HOME%\bin on Windows or $JAVA_HOME\bin on Linux must be part of system PATH to start command line build.




Install your IDE
----------------

Free Eclipse IDE for Java Developers is OK: https://eclipse.org/downloads/

Intellij IDE https://www.jetbrains.com/idea/ , use community edition for free



Watch sources and build in your favourite IDE
---------------------------------------------

To view source files and run this project you can simply open the project with your favourite IDE , using open project or import project wizards.

In any case open or import this project "As Maven Project".




Command line build (for people who like hard core)
--------------------------------------------------

If you need command line build, use the approach below:

Install Maven
-------------

Download Maven from https://maven.apache.org/

Install it. (Usually just unpack/unzip it)

For example, your maven is here C:\\`<appache-maven-x-y-z>`

This directory considered M2_HOME

Note, maven will use your disk space to save downloaded dependencies

If you configure nothing, default maven repository on your disk will be at

on Windows : C:\Users\\`<username>`\\.m2\repository

On Linux : /home/`<username>`/.m2/repository


Run build from command line
---------------------------

Open Windows command line or linux shell

Specify following parameters:

On Windows:

set JAVA_HOME=C:\Program Files\Java\\`<JDK-x-y-z>`

set PATH=%JAVA_HOME%\bin;%PATH%

set M2_HOME=C:\\`<appache-maven-x-y-z>`

set PATH=%M2_HOME%\bin;%PATH%

On Linux:

export JAVA_HOME=/my/java/`<JDK-x-y-z>`

export PATH=$JAVA_HOME/bin:$PATH

export M2_HOME=/my/maven/`<appache-maven-x-y-z>`

export PATH=$M2_HOME/bin:$PATH


Change to directory of the project and run build on Windows or Linux in the same command line/shell:

cd `<algs4 directory>`

mvn clean install

In your `<algs4 directory>`/target you will find a algs4-`<version>`.jar

This jar you can use as dependency in your projects (according to license of course)
4 changes: 2 additions & 2 deletions src/main/java/edu/princeton/cs/algs4/Accumulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


/**
* The <tt>Accumulator</tt> class is a data type for computing the running
* The {@code Accumulator} class is a data type for computing the running
* mean, sample standard deviation, and sample variance of a stream of real
* numbers. It provides an example of a mutable data type and a streaming
* algorithm.
Expand Down Expand Up @@ -88,7 +88,7 @@ public int count() {
}

/**
* Unit tests the <tt>Accumulator</tt> data type.
* Unit tests the {@code Accumulator} data type.
* Reads in a stream of real number from standard input;
* adds them to the accumulator; and prints the mean,
* sample standard deviation, and sample variance to standard
Expand Down
1 change: 1 addition & 0 deletions src/main/java/edu/princeton/cs/algs4/Alphabet.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public boolean contains(char c) {
* @return the number of characters in this alphabet
* @deprecated Replaced by {@link #radix()}.
*/
@Deprecated
public int R() {
return R;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/princeton/cs/algs4/Average.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package edu.princeton.cs.algs4;

/**
* The <tt>Average</tt> class provides a client for reading in a sequence
* The {@code Average} class provides a client for reading in a sequence
* of real numbers and printing out their average.
* <p>
* For additional documentation, see <a href="http://algs4.cs.princeton.edu/11model">Section 1.1</a> of
Expand Down
1 change: 0 additions & 1 deletion src/main/java/edu/princeton/cs/algs4/BST.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
* For other implementations, see {@link ST}, {@link BinarySearchST},
* {@link SequentialSearchST}, {@link RedBlackBST},
* {@link SeparateChainingHashST}, and {@link LinearProbingHashST},
* <i>Algorithms, 4th Edition</i> by Robert Sedgewick and Kevin Wayne.
*
* @author Robert Sedgewick
* @author Kevin Wayne
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/edu/princeton/cs/algs4/BinarySearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.util.Arrays;

/**
* The <tt>BinarySearch</tt> class provides a static method for binary
* The {@code BinarySearch} class provides a static method for binary
* searching for an integer in a sorted array of integers.
* <p>
* The <em>indexOf</em> operations takes logarithmic time in the worst case.
Expand All @@ -51,7 +51,7 @@ private BinarySearch() { }
*
* @param a the array of integers, must be sorted in ascending order
* @param key the search key
* @return index of key in array <tt>a</tt> if present; <tt>-1</tt> otherwise
* @return index of key in array {@code a} if present; {@code -1} otherwise
*/
public static int indexOf(int[] a, int key) {
int lo = 0;
Expand All @@ -73,9 +73,10 @@ public static int indexOf(int[] a, int key) {
*
* @param key the search key
* @param a the array of integers, must be sorted in ascending order
* @return index of key in array <tt>a</tt> if present; <tt>-1</tt> otherwise
* @return index of key in array {@code a} if present; {@code -1} otherwise
* @deprecated Replaced by {@link #indexOf(int[], int)}.
*/
@Deprecated
public static int rank(int key, int[] a) {
return indexOf(a, key);
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/edu/princeton/cs/algs4/CC.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
* 1 components
* 0 1 2 3 4 5 6 7 8 9 10 ...
*
* Note: This implementation uses a recursive DFS. To avoid needing
* a potentially very large stack size, replace with a non-recurisve
* DFS ala NonrecursiveDFS.java.
*
******************************************************************************/

package edu.princeton.cs.algs4;
Expand Down Expand Up @@ -140,6 +144,7 @@ public boolean connected(int v, int w) {
* connected component; <tt>false</tt> otherwise
* @deprecated Replaced by {@link #connected(int, int)}.
*/
@Deprecated
public boolean areConnected(int v, int w) {
return id(v) == id(w);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/princeton/cs/algs4/Cat.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
package edu.princeton.cs.algs4;

/**
* The <tt>Cat</tt> class provides a client for concatenating the results
* The {@code Cat} class provides a client for concatenating the results
* of several text files.
* <p>
* For additional documentation, see <a href="http://algs4.cs.princeton.edu/11model">Section 1.1</a> of
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/edu/princeton/cs/algs4/Complex.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public String toString() {
return re + " + " + im + "i";
}

// return abs/modulus/magnitude and angle/phase/argument
/**
* Returns the absolute value of this complex number.
* This quantity is also known as the <em>modulus</em> or <em>magnitude</em>.
Expand All @@ -84,7 +83,7 @@ public double abs() {

/**
* Returns the phase of this complex number.
* This quantity is also known as the <em>ange</em> or <em>argument</em>.
* This quantity is also known as the <em>angle</em> or <em>argument</em>.
*
* @return the phase of this complex number, a real number between -pi and pi
*/
Expand Down Expand Up @@ -146,6 +145,7 @@ public Complex scale(double alpha) {
* @return the complex number whose value is <tt>(alpha * this)</tt>
* @deprecated Replaced by {@link #scale(double)}.
*/
@Deprecated
public Complex times(double alpha) {
return new Complex(alpha * re, alpha * im);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/edu/princeton/cs/algs4/Counter.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
package edu.princeton.cs.algs4;

/**
* The <tt>Counter</tt> class is a mutable data type to encapsulate a counter.
* The {@code Counter} class is a mutable data type to encapsulate a counter.
* <p>
* For additional documentation,
* see <a href="http://algs4.cs.princeton.edu/12oop">Section 1.2</a> of
Expand Down Expand Up @@ -73,7 +73,7 @@ public String toString() {
* Compares this counter to the specified counter.
*
* @param that the other counter
* @return <tt>0</tt> if the value of this counter equals
* @return {@code 0} if the value of this counter equals
* the value of that counter; a negative integer if
* the value of this counter is less than the value of
* that counter; and a positive integer if the value
Expand Down
Loading

0 comments on commit 2a9b08c

Please sign in to comment.