Full Code of kevin-wayne/algs4 for AI

master 7bb62c32f03f cached
208 files
2.0 MB
517.5k tokens
2767 symbols
1 requests
Download .txt
Showing preview only (2,091K chars total). Download the full file or copy to clipboard to get everything.
Repository: kevin-wayne/algs4
Branch: master
Commit: 7bb62c32f03f
Files: 208
Total size: 2.0 MB

Directory structure:
gitextract_86oov4vw/

├── .gitignore
├── LICENSE
├── README-MAVEN.txt
├── README.md
├── USING-MAVEN.md
├── build.gradle
├── pom.xml
└── src/
    └── main/
        └── java/
            └── edu/
                └── princeton/
                    └── cs/
                        └── algs4/
                            ├── AVLTreeST.java
                            ├── Accumulator.java
                            ├── AcyclicLP.java
                            ├── AcyclicSP.java
                            ├── AdjMatrixEdgeWeightedDigraph.java
                            ├── AllowFilter.java
                            ├── Allowlist.java
                            ├── Alphabet.java
                            ├── AmericanFlag.java
                            ├── AmericanFlagX.java
                            ├── Arbitrage.java
                            ├── AssignmentProblem.java
                            ├── Average.java
                            ├── BST.java
                            ├── BTree.java
                            ├── Bag.java
                            ├── BellmanFordSP.java
                            ├── BinaryDump.java
                            ├── BinaryIn.java
                            ├── BinaryInsertion.java
                            ├── BinaryOut.java
                            ├── BinarySearch.java
                            ├── BinarySearchST.java
                            ├── BinaryStdIn.java
                            ├── BinaryStdOut.java
                            ├── BinomialMinPQ.java
                            ├── Bipartite.java
                            ├── BipartiteMatching.java
                            ├── BipartiteX.java
                            ├── BlockFilter.java
                            ├── BoruvkaMST.java
                            ├── BoyerMoore.java
                            ├── BreadthFirstDirectedPaths.java
                            ├── BreadthFirstPaths.java
                            ├── CC.java
                            ├── CPM.java
                            ├── Cat.java
                            ├── ClosestPair.java
                            ├── CollisionSystem.java
                            ├── Complex.java
                            ├── Count.java
                            ├── Counter.java
                            ├── Cycle.java
                            ├── Date.java
                            ├── DeDup.java
                            ├── DegreesOfSeparation.java
                            ├── DepthFirstDirectedPaths.java
                            ├── DepthFirstOrder.java
                            ├── DepthFirstPaths.java
                            ├── DepthFirstSearch.java
                            ├── Digraph.java
                            ├── DigraphGenerator.java
                            ├── DijkstraAllPairsSP.java
                            ├── DijkstraSP.java
                            ├── DijkstraUndirectedSP.java
                            ├── DirectedCycle.java
                            ├── DirectedCycleX.java
                            ├── DirectedDFS.java
                            ├── DirectedEdge.java
                            ├── DirectedEulerianCycle.java
                            ├── DirectedEulerianPath.java
                            ├── DoublingRatio.java
                            ├── DoublingTest.java
                            ├── Draw.java
                            ├── DrawListener.java
                            ├── Edge.java
                            ├── EdgeWeightedDigraph.java
                            ├── EdgeWeightedDirectedCycle.java
                            ├── EdgeWeightedGraph.java
                            ├── EulerianCycle.java
                            ├── EulerianPath.java
                            ├── FFT.java
                            ├── FarthestPair.java
                            ├── FenwickTree.java
                            ├── FibonacciMinPQ.java
                            ├── FileIndex.java
                            ├── FlowEdge.java
                            ├── FlowNetwork.java
                            ├── FloydWarshall.java
                            ├── FordFulkerson.java
                            ├── FrequencyCounter.java
                            ├── GREP.java
                            ├── GabowSCC.java
                            ├── GaussJordanElimination.java
                            ├── GaussianElimination.java
                            ├── Genome.java
                            ├── GlobalMincut.java
                            ├── GrahamScan.java
                            ├── Graph.java
                            ├── GraphGenerator.java
                            ├── GrayscalePicture.java
                            ├── Heap.java
                            ├── HexDump.java
                            ├── HopcroftKarp.java
                            ├── Huffman.java
                            ├── In.java
                            ├── IndexBinomialMinPQ.java
                            ├── IndexFibonacciMinPQ.java
                            ├── IndexMaxPQ.java
                            ├── IndexMinPQ.java
                            ├── IndexMultiwayMinPQ.java
                            ├── InplaceMSD.java
                            ├── Insertion.java
                            ├── InsertionX.java
                            ├── Interval1D.java
                            ├── Interval2D.java
                            ├── Inversions.java
                            ├── KMP.java
                            ├── KWIK.java
                            ├── Knuth.java
                            ├── KosarajuSharirSCC.java
                            ├── KruskalMST.java
                            ├── LSD.java
                            ├── LZW.java
                            ├── LazyPrimMST.java
                            ├── LinearProbingHashST.java
                            ├── LinearProgramming.java
                            ├── LinearRegression.java
                            ├── LinkedBag.java
                            ├── LinkedQueue.java
                            ├── LinkedStack.java
                            ├── LongestCommonSubstring.java
                            ├── LongestRepeatedSubstring.java
                            ├── LookupCSV.java
                            ├── LookupIndex.java
                            ├── MSD.java
                            ├── MaxPQ.java
                            ├── Merge.java
                            ├── MergeBU.java
                            ├── MergeX.java
                            ├── MinPQ.java
                            ├── Multiway.java
                            ├── MultiwayMinPQ.java
                            ├── NFA.java
                            ├── NonrecursiveDFS.java
                            ├── NonrecursiveDirectedDFS.java
                            ├── Out.java
                            ├── Particle.java
                            ├── PatriciaSET.java
                            ├── PatriciaST.java
                            ├── Picture.java
                            ├── PictureDump.java
                            ├── Point2D.java
                            ├── Polynomial.java
                            ├── PrimMST.java
                            ├── Queue.java
                            ├── Quick.java
                            ├── Quick3string.java
                            ├── Quick3way.java
                            ├── QuickBentleyMcIlroy.java
                            ├── QuickFindUF.java
                            ├── QuickUnionUF.java
                            ├── QuickX.java
                            ├── RabinKarp.java
                            ├── RandomSeq.java
                            ├── RectHV.java
                            ├── RedBlackBST.java
                            ├── ResizingArrayBag.java
                            ├── ResizingArrayQueue.java
                            ├── ResizingArrayStack.java
                            ├── RunLength.java
                            ├── SET.java
                            ├── ST.java
                            ├── SegmentTree.java
                            ├── Selection.java
                            ├── SeparateChainingHashST.java
                            ├── SequentialSearchST.java
                            ├── Shell.java
                            ├── SparseVector.java
                            ├── Stack.java
                            ├── StaticSETofInts.java
                            ├── StdArrayIO.java
                            ├── StdAudio.java
                            ├── StdAudioStereo.java
                            ├── StdDraw.java
                            ├── StdIn.java
                            ├── StdOut.java
                            ├── StdPicture.java
                            ├── StdRandom.java
                            ├── StdStats.java
                            ├── Stopwatch.java
                            ├── StopwatchCPU.java
                            ├── SuffixArray.java
                            ├── SuffixArrayX.java
                            ├── SymbolDigraph.java
                            ├── SymbolGraph.java
                            ├── TST.java
                            ├── TarjanSCC.java
                            ├── ThreeSum.java
                            ├── ThreeSumFast.java
                            ├── TopM.java
                            ├── Topological.java
                            ├── TopologicalX.java
                            ├── Transaction.java
                            ├── TransitiveClosure.java
                            ├── TrieSET.java
                            ├── TrieST.java
                            ├── TwoPersonZeroSumGame.java
                            ├── UF.java
                            ├── Vector.java
                            └── WeightedQuickUnionUF.java

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
# 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

# files intended to be ignored
*IGNORE


================================================
FILE: LICENSE
================================================
                    GNU GENERAL PUBLIC LICENSE
                       Version 3, 29 June 2007

 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

                            Preamble

  The GNU General Public License is a free, copyleft license for
software and other kinds of works.

  The licenses for most software and other practical works are designed
to take away your freedom to share and change the works.  By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.  We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors.  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.

  To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights.  Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received.  You must make sure that they, too, receive
or can get the source code.  And you must show them these terms so they
know their rights.

  Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.

  For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software.  For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.

  Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so.  This is fundamentally incompatible with the aim of
protecting users' freedom to change the software.  The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable.  Therefore, we
have designed this version of the GPL to prohibit the practice for those
products.  If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.

  Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary.  To prevent this, the GPL assures that
patents cannot be used to render the program non-free.

  The precise terms and conditions for copying, distribution and
modification follow.

                       TERMS AND CONDITIONS

  0. Definitions.

  "This License" refers to version 3 of the GNU General Public License.

  "Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.

  "The Program" refers to any copyrightable work licensed under this
License.  Each licensee is addressed as "you".  "Licensees" and
"recipients" may be individuals or organizations.

  To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy.  The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.

  A "covered work" means either the unmodified Program or a work based
on the Program.

  To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy.  Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.

  To "convey" a work means any kind of propagation that enables other
parties to make or receive copies.  Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.

  An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License.  If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.

  1. Source Code.

  The "source code" for a work means the preferred form of the work
for making modifications to it.  "Object code" means any non-source
form of a work.

  A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.

  The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form.  A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.

  The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities.  However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work.  For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.

  The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.

  The Corresponding Source for a work in source code form is that
same work.

  2. Basic Permissions.

  All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met.  This License explicitly affirms your unlimited
permission to run the unmodified Program.  The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work.  This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.

  You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force.  You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright.  Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.

  Conveying under any other circumstances is permitted solely under
the conditions stated below.  Sublicensing is not allowed; section 10
makes it unnecessary.

  3. Protecting Users' Legal Rights From Anti-Circumvention Law.

  No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.

  When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.

  4. Conveying Verbatim Copies.

  You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.

  You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.

  5. Conveying Modified Source Versions.

  You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:

    a) The work must carry prominent notices stating that you modified
    it, and giving a relevant date.

    b) The work must carry prominent notices stating that it is
    released under this License and any conditions added under section
    7.  This requirement modifies the requirement in section 4 to
    "keep intact all notices".

    c) You must license the entire work, as a whole, under this
    License to anyone who comes into possession of a copy.  This
    License will therefore apply, along with any applicable section 7
    additional terms, to the whole of the work, and all its parts,
    regardless of how they are packaged.  This License gives no
    permission to license the work in any other way, but it does not
    invalidate such permission if you have separately received it.

    d) If the work has interactive user interfaces, each must display
    Appropriate Legal Notices; however, if the Program has interactive
    interfaces that do not display Appropriate Legal Notices, your
    work need not make them do so.

  A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit.  Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.

  6. Conveying Non-Source Forms.

  You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:

    a) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by the
    Corresponding Source fixed on a durable physical medium
    customarily used for software interchange.

    b) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by a
    written offer, valid for at least three years and valid for as
    long as you offer spare parts or customer support for that product
    model, to give anyone who possesses the object code either (1) a
    copy of the Corresponding Source for all the software in the
    product that is covered by this License, on a durable physical
    medium customarily used for software interchange, for a price no
    more than your reasonable cost of physically performing this
    conveying of source, or (2) access to copy the
    Corresponding Source from a network server at no charge.

    c) Convey individual copies of the object code with a copy of the
    written offer to provide the Corresponding Source.  This
    alternative is allowed only occasionally and noncommercially, and
    only if you received the object code with such an offer, in accord
    with subsection 6b.

    d) Convey the object code by offering access from a designated
    place (gratis or for a charge), and offer equivalent access to the
    Corresponding Source in the same way through the same place at no
    further charge.  You need not require recipients to copy the
    Corresponding Source along with the object code.  If the place to
    copy the object code is a network server, the Corresponding Source
    may be on a different server (operated by you or a third party)
    that supports equivalent copying facilities, provided you maintain
    clear directions next to the object code saying where to find the
    Corresponding Source.  Regardless of what server hosts the
    Corresponding Source, you remain obligated to ensure that it is
    available for as long as needed to satisfy these requirements.

    e) Convey the object code using peer-to-peer transmission, provided
    you inform other peers where the object code and Corresponding
    Source of the work are being offered to the general public at no
    charge under subsection 6d.

  A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.

  A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling.  In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage.  For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product.  A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.

  "Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source.  The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.

  If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information.  But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).

  The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed.  Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.

  Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.

  7. Additional Terms.

  "Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law.  If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.

  When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it.  (Additional permissions may be written to require their own
removal in certain cases when you modify the work.)  You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.

  Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:

    a) Disclaiming warranty or limiting liability differently from the
    terms of sections 15 and 16 of this License; or

    b) Requiring preservation of specified reasonable legal notices or
    author attributions in that material or in the Appropriate Legal
    Notices displayed by works containing it; or

    c) Prohibiting misrepresentation of the origin of that material, or
    requiring that modified versions of such material be marked in
    reasonable ways as different from the original version; or

    d) Limiting the use for publicity purposes of names of licensors or
    authors of the material; or

    e) Declining to grant rights under trademark law for use of some
    trade names, trademarks, or service marks; or

    f) Requiring indemnification of licensors and authors of that
    material by anyone who conveys the material (or modified versions of
    it) with contractual assumptions of liability to the recipient, for
    any liability that these contractual assumptions directly impose on
    those licensors and authors.

  All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10.  If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term.  If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.

  If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.

  Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.

  8. Termination.

  You may not propagate or modify a covered work except as expressly
provided under this License.  Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).

  However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.

  Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.

  Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License.  If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.

  9. Acceptance Not Required for Having Copies.

  You are not required to accept this License in order to receive or
run a copy of the Program.  Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance.  However,
nothing other than this License grants you permission to propagate or
modify any covered work.  These actions infringe copyright if you do
not accept this License.  Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.

  10. Automatic Licensing of Downstream Recipients.

  Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License.  You are not responsible
for enforcing compliance by third parties with this License.

  An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations.  If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.

  You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License.  For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.

  11. Patents.

  A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based.  The
work thus licensed is called the contributor's "contributor version".

  A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version.  For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.

  Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.

  In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement).  To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.

  If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients.  "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.

  If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.

  A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License.  You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.

  Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.

  12. No Surrender of Others' Freedom.

  If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all.  For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.

  13. Use with the GNU Affero General Public License.

  Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work.  The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.

  14. Revised Versions of this License.

  The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

  Each version is given a distinguishing version number.  If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation.  If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.

  If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.

  Later license versions may give you additional or different
permissions.  However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.

  15. Disclaimer of Warranty.

  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

  16. Limitation of Liability.

  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.

  17. Interpretation of Sections 15 and 16.

  If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

                     END OF TERMS AND CONDITIONS

            How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    {one line to give the program's name and a brief idea of what it does.}
    Copyright (C) {year}  {name of author}

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

  If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

    {project}  Copyright (C) {year}  {fullname}
    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".

  You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.

  The GNU General Public License does not permit incorporating your program
into proprietary programs.  If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library.  If this is what you want to do, use the GNU Lesser General
Public License instead of this License.  But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.


================================================
FILE: README-MAVEN.txt
================================================
This file provides brief instructions on how to add this repository to
a Maven build, from Eclipse, NetBeans, IntelliJ, or the command line.
Specifically, it provides instructions on creating a version of algs4.jar
that you can use as a dependency in your projects.

These instructions assume that you already have installed Java 7
(JDK 1.7) or above.


Using Maven in Eclipse for Java Developers
------------------------------------------
If m2e (Maven plugin) is not built into Eclipse, follow these steps to install the plugin:

  * Open Eclipse.
  * Go to Help -> Eclipse Marketplace.
  * Search for Maven.
  * Click "Install" button at "Maven Integration for Eclipse" or "m2e" section.
  * Follow the instruction step by step.,

Restart Eclipse after installing m2e.

Now you can import algs4 as "Maven Project" into Eclipse:

  * Open menu: File-> Import-> Maven-> Existing Maven Projects...
  * Choose directory of algs4.
  * Confirm import.

To complete dependencies resolution after import:
  * Right click on the project, choose Maven -> Update Project...
  * Confirm project update.

To build project in Eclipse:
Eclipse automatically builds the project every time it saved.
But if you want enforce build, do following:
  * Right click on the project in Eclipse.
  * Choose Run as... Maven build.

Maven will put algs4-<version>.jar in the directory <algs4 directory>/target.
You can use this jar as a dependency in your projects.


Using Maven in IntelliJ IDEA
----------------------------


Using Maven in Netbeans
-----------------------


Using Maven from the Windows Command Prompt
-------------------------------------------
Download and install Maven by following the instructions at
https://maven.apache.org.

Locate the installation directory for Maven, e.g., C:\<apache-maven-x-y-z>

Locate the installation directory for Java, e.g., C:\Program Files\Java\<JDK-x-y-z>

Set the following environment variables:

set JAVA_HOME=C:\Program Files\Java\<JDK-x-y-z>
set PATH=%JAVA_HOME%\bin;%PATH%
set M2_HOME=C:\<apache-maven-x-y-z>
set PATH=%M2_HOME%\bin;%PATH%

To create the algs4-<version>.jar package and install it in the local
repository for reuse from other projects, change to the directory of
the algs4 repository and run Maven.

cd <algs4 directory>
mvn clean install

Maven will put algs4-<version>.jar in the directory <algs4 directory>/target.
You can use this jar as a dependency in your projects.



Using Maven from the Linux / Mac OS X bash shell
------------------------------------------------
Download and install Maven, either by using your favorite package
manager  (such as apt-get) or by following the instructions at
https://maven.apache.org.

Locate the installation directory for Maven, e.g., /my/maven/<apache-maven-x-y-z>

Locate the installation directory for Java, e.g., /my/java/<JDK-x-y-z->

Set the following environment variables:

export JAVA_HOME=/my/java/<JDK-x-y-z>
export PATH=$JAVA_HOME/bin:$PATH
export M2_HOME=/my/maven/<apache-maven-x-y-z>
export PATH=$M2_HOME/bin:$PATH

To create the algs4-<version>.jar package and install it in the local
repository for reuse from other projects, change to the directory of
the algs4 repository and run Maven.

cd <algs4 directory>
mvn clean install

Maven will put algs4-<version>.jar in the directory <algs4 directory>/target.
You can use this jar as a dependency in your projects.



================================================
FILE: README.md
================================================
## Overview

<IMG SRC="http://algs4.cs.princeton.edu/cover.png"  align=right hspace=25 width=100 alt = "Algorithms 4/e textbook">
This <a href = "https://github.com/kevin-wayne/algs4">public repository</a>
contains the Java <a href = "http://algs4.cs.princeton.edu/code/">source code</a>
for the algorithms and clients in the textbook
<a href = "http://amzn.to/13VNJi7">Algorithms, 4th Edition</a> by Robert Sedgewick and Kevin Wayne.
The official version at <a href = "https://github.com/kevin-wayne/algs4">https://github.com/kevin-wayne/algs4</a>
is actively maintained and updated by the authors.
The programs are organized in the package <code>edu.princeton.cs.algs4</code>.
If you need only the class files (and not the source code), you can use
<a href = "http://algs4.cs.princeton.edu/code/algs4.jar">algs4.jar</a> instead.

<br>

## Design goals

Our original goal was to cover the <em>50 algorithms that every programmer should know</em>.
We use the word <em>programmer</em> to refer to anyone engaged in trying to accomplish
something with the help of a computer, including scientists, engineers, and applications
developers, not to mention college students in science, engineering, and computer science.
The code is optimized for clarity, portability, and efficiency. While some of our 
implementations are as fast as (or faster than) their counterparts in <tt>java.util</tt>,
our main goal is to express the core algorithmic ideas in an elegant and simple manner.
While we embrace some advanced Java features (such as generics and iterators),
we avoid those that interfere with the exposition (such as inheritance and concurrency).

## Build managers

This repository is intended for use with either the <a href = "https://maven.apache.org">Maven</a>
or <a href = "https://gradle.org">Gradle</a> build managers.
It can be run from either the command line or integrated into
Eclipse, NetBeans, and IntelliJ.
You can also access it via <a href = "https://bintray.com/algs4/maven/algs4">Bintray</a>.

## Coursera Algorithms, Part I and II students

Feel free to use this public repository to develop solutions to the programming assignments.
However, please do not store solutions to programming assignments in public repositories.


## Copyright

Copyright &copy; 2000&ndash;2023 by Robert Sedgewick and Kevin Wayne.

## License

This code is released under GPLv3.

## Contribute to this repository

This <a href = "http://algs4.cs.princeton.edu/code/wishlist.txt">wishlist.txt</a>
contains a list of algorithms and data structures that we would
like to add to the repository. Indeed, several of the algorithms and
data structures in this repository were contributed by others. If interested, please
follow the same style as the code in the repository and thoroughly test your
code before contacting us.

## Support for other programming languages

Some of the code in this repository has been translated to other languages:
<ul>
<li><a href = "https://github.com/garyaiki/Scala-Algorithms">Scala</a> by Gary Struthers
<li><a href = "https://github.com/nguyenqthai/Algs4Net">.NET</a> by Quoc Thai
<li><a href = "https://github.com/itu-algorithms/itu.algs4">Python</a> by ITU Copenhagen
<li><a href = "https://github.com/shellfly/algs4-py">Python</a> by Li Hao
<li><a href = "https://github.com/shellfly/algo">Go</a> by Li Hao
</ul>


## Credits

Thanks to Peter Korgan for Maven and Gradle support.


================================================
FILE: USING-MAVEN.md
================================================
This file provides brief instructions on how to add this repository to
a Maven build, from Eclipse, NetBeans, IntelliJ, or the command line.
Specifically, it provides instructions on creating a version of algs4.jar
that you can use as a dependency in your projects.

These instructions assume that you already have installed Java 7
(JDK 1.7) or above.


Using Maven in Eclipse for Java Developers
------------------------------------------
If m2e (Maven plugin) is not built into Eclipse, follow these steps to install the plugin:

  * Open Eclipse.
  * Go to Help -> Eclipse Marketplace.
  * Search for Maven.
  * Click "Install" button at "Maven Integration for Eclipse" or "m2e" section.
  * Follow the instruction step by step.,

Restart Eclipse after installing m2e.

Now you can import algs4 as "Maven Project" into Eclipse:

  * Open menu: File-> Import-> Maven-> Existing Maven Projects...
  * Choose directory of algs4.
  * Confirm import.

To complete dependencies resolution after import:
  * Right click on the project, choose Maven -> Update Project...
  * Confirm project update.

To build project in Eclipse:
Eclipse automatically builds the project every time it saved.
But if you want enforce build, do following:
  * Right click on the project in Eclipse.
  * Choose Run as... Maven build.

Maven will put algs4-<version>.jar in the directory <algs4 directory>/target.
You can use this jar as a dependency in your projects.


Using Maven in IntelliJ IDEA
----------------------------
Import algs4 as "Maven Project" into IntelliJ IDEA:

1. Open menu: File -> New -> Module from Existing Sources...
2. Choose directory of algs4.
3. Choose Import module from external model - Maven.
4. Finish.

Last, edit `pom.xml` to add dependency:
```xml
<dependency>
    <groupId>edu.princeton.cs</groupId>
    <artifactId>algs4</artifactId>
    <version>1.0.0.0</version>
</dependency>
```

Using Maven in Netbeans
-----------------------


Using Maven from the Windows Command Prompt
-------------------------------------------
Download and install Maven by following the instructions at
https://maven.apache.org.

Locate the installation directory for Maven, e.g., C:\<apache-maven-x-y-z>

Locate the installation directory for Java, e.g., C:\Program Files\Java\<JDK-x-y-z>

Set the following environment variables:

set JAVA_HOME=C:\Program Files\Java\<JDK-x-y-z>
set PATH=%JAVA_HOME%\bin;%PATH%
set M2_HOME=C:\<apache-maven-x-y-z>
set PATH=%M2_HOME%\bin;%PATH%

To create the algs4-<version>.jar package and install it in the local
repository for reuse from other projects, change to the directory of
the algs4 repository and run Maven.

cd <algs4 directory>
mvn clean install

Maven will put algs4-<version>.jar in the directory <algs4 directory>/target.
You can use this jar as a dependency in your projects.



Using Maven from the Linux / Mac OS X bash shell
------------------------------------------------
Download and install Maven, either by using your favorite package
manager  (such as apt-get) or by following the instructions at
https://maven.apache.org.

Locate the installation directory for Maven, e.g., /my/maven/<apache-maven-x-y-z>

Locate the installation directory for Java, e.g., /my/java/<JDK-x-y-z->

Set the following environment variables:

export JAVA_HOME=/my/java/<JDK-x-y-z>
export PATH=$JAVA_HOME/bin:$PATH
export M2_HOME=/my/maven/<apache-maven-x-y-z>
export PATH=$M2_HOME/bin:$PATH

To create the algs4-<version>.jar package and install it in the local
repository for reuse from other projects, change to the directory of
the algs4 repository and run Maven.

cd <algs4 directory>
mvn clean install

Maven will put algs4-<version>.jar in the directory <algs4 directory>/target.
You can use this jar as a dependency in your projects.



================================================
FILE: build.gradle
================================================
buildscript {
  repositories {
        jcenter()
   }
}

plugins {
    id "com.jfrog.bintray" version "1.7"
}

group = 'edu.princeton.cs'
version = '1.0.1'


allprojects {
    repositories {
        jcenter()
    }
    apply plugin: 'java'
    apply plugin: 'eclipse'
    apply plugin: 'idea'
    apply plugin: 'maven-publish'

    sourceCompatibility = 1.7
    targetCompatibility = 1.7
}

task sourcesJar(type: Jar, dependsOn:classes) {
    classifier = 'sources'
    from sourceSets.main.allSource
}

task javadocJar(type: Jar) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

artifacts {
    archives sourcesJar
    archives javadocJar
}

publishing {
    publications {
        MyPublication(MavenPublication) {
            from components.java
            artifact sourcesJar
            artifact javadocJar
            groupId 'edu.princeton.cs'
                    artifactId 'algs4'
                    version '1.0.2'
        }
    }
}

bintray {
    user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
    key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
    publications = ['MyPublication']
    publish = true
    override = false
    pkg {
        repo = 'maven'
        name = 'algs4'
        userOrg = 'algs4'
        desc = 'Source Code for Algorithms, 4th Edition'
        licenses = ['GPL-3.0']
        vcsUrl = 'https://github.com/kevin-wayne/algs4.git'
        websiteUrl = 'https://github.com/kevin-wayne/algs4'
        labels = ['algorithms', 'java', 'Robert Sedgewick', 'Kevin Wayne']
        publicDownloadNumbers = true
        githubRepo = 'kevin-wayne/algs4'
        githubReleaseNotesFile = 'README.md'
        version {
            name = '1.0.2'
            vcsTag = '1.0.2'
        }
    }
}

wrapper {
  gradleVersion = '2.6'
}

================================================
FILE: pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>edu.princeton.cs</groupId>
	<artifactId>algs4</artifactId>
	<packaging>jar</packaging>
	<version>1.0.0.0</version>
	<name>algs4</name>
	<licenses>
		<license>
			<name>GNU GENERAL PUBLIC LICENSE</name>
			<url>http://www.gnu.org/licenses/gpl-3.0.en.html</url>
		</license>
	</licenses>
	<developers>
		<developer>
			<id>kevin</id>
			<name>Kevin Wayne</name>
			<email>wayne@CS.Princeton.EDU</email>
			<url>https://www.cs.princeton.edu/~wayne/contact/</url>
			<organization>Princeton University </organization>
			<organizationUrl>https://www.cs.princeton.edu</organizationUrl>
			<roles>
				<role>author</role>
				<role>developer</role>
			</roles>
			<timezone>UTC/GMT -4:00 hours</timezone>
			<properties>
				<picUrl>https://www.cs.princeton.edu/~wayne/contact/KevinWayne.jpg</picUrl>
			</properties>
		</developer>
		<developer>
			<id>robert</id>
			<name>Robert Sedgewick</name>
			<roles>
				<role>author</role>
			</roles>
		</developer>
	</developers>
	<issueManagement>
		<system>github.com</system>
		<url>https://github.com/kevin-wayne/algs4/issues</url>
	</issueManagement>
	<profiles>
		<profile>
			<id>main-build</id>
				<activation>
					<activeByDefault>true</activeByDefault>
				</activation>
			<properties>
				<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
				<java.version>1.8</java.version>
			</properties>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-compiler-plugin</artifactId>
						<version>3.3</version>
						<configuration>
							<source>${java.version}</source>
							<target>${java.version}</target>
						</configuration>
					</plugin>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-source-plugin</artifactId>
						<version>3.0.1</version>
						<executions>
							<execution>
								<id>attach-sources</id>
								<goals>
									<goal>jar</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
			<repositories>
			</repositories>
		</profile>
	</profiles>
	<dependencies>
	</dependencies>  
</project>


================================================
FILE: src/main/java/edu/princeton/cs/algs4/AVLTreeST.java
================================================
/******************************************************************************
 *  Compilation:  javac AVLTreeST.java
 *  Execution:    java AVLTreeST < input.txt
 *  Dependencies: StdIn.java StdOut.java  
 *  Data files:   https://algs4.cs.princeton.edu/33balanced/tinyST.txt  
 *    
 *  A symbol table implemented using an AVL tree.
 *
 *  % more tinyST.txt
 *  S E A R C H E X A M P L E
 *  
 *  % java AVLTreeST < tinyST.txt
 *  A 8
 *  C 4
 *  E 12
 *  H 5
 *  L 11
 *  M 9
 *  P 10
 *  R 3
 *  S 0
 *  X 7
 *
 ******************************************************************************/

package edu.princeton.cs.algs4;

import java.util.NoSuchElementException;

/**
 *  The {@code AVLTreeST} class represents an ordered symbol table of
 *  generic key-value pairs. It supports the usual <em>put</em>, <em>get</em>,
 *  <em>contains</em>, <em>delete</em>, <em>size</em>, and <em>is-empty</em>
 *  methods. It also provides ordered methods for finding the <em>minimum</em>,
 *  <em>maximum</em>, <em>floor</em>, and <em>ceiling</em>. It also provides a
 *  <em>keys</em> method for iterating over all of the keys. A symbol table
 *  implements the <em>associative array</em> abstraction: when associating a
 *  value with a key that is already in the symbol table, the convention is to
 *  replace the old value with the new value. Unlike {@link java.util.Map}, this
 *  class uses the convention that values cannot be {@code null}
 *  —setting the value associated with a key to {@code null} is
 *  equivalent to deleting the key from the symbol table.
 *  <p>
 *  This symbol table implementation uses internally an
 *  <a href="https://en.wikipedia.org/wiki/AVL_tree"> AVL tree </a> (Georgy
 *  Adelson-Velsky and Evgenii Landis' tree) which is a self-balancing BST.
 *  In an AVL tree, the heights of the two child subtrees of any
 *  node differ by at most one; if at any time they differ by more than one,
 *  rebalancing is done to restore this property.
 *  <p>
 *  This implementation requires that the key type implements the
 *  {@code Comparable} interface and calls the {@code compareTo()} and
 *  method to compare two keys. It does not call either {@code equals()} or
 *  {@code hashCode()}. The <em>put</em>, <em>get</em>, <em>contains</em>,
 *  <em>delete</em>, <em>minimum</em>, <em>maximum</em>, <em>ceiling</em>, and
 *  <em>floor</em> operations each take logarithmic time in the worst case. The
 *  <em>size</em>, and <em>is-empty</em> operations take constant time.
 *  Construction also takes constant time.
 * 
 *  For other implementations of the same API, see {@link ST}, {@link BinarySearchST},
 *  {@link SequentialSearchST}, {@link BST}, {@link RedBlackBST},
 *  {@link SeparateChainingHashST}, and {@link LinearProbingHashST}.
 * 
 *  @author Marcelo Silva
 */

public class AVLTreeST<Key extends Comparable<Key>, Value> {

    /**
     * The root node.
     */
    private Node root;

    /**
     * This class represents an inner node of the AVL tree.
     */
    private class Node {
        private final Key key;   // the key
        private Value val;       // the associated value
        private int height;      // height of the subtree
        private int size;        // number of nodes in subtree
        private Node left;       // left subtree
        private Node right;      // right subtree

        public Node(Key key, Value val, int height, int size) {
            this.key = key;
            this.val = val;
            this.size = size;
            this.height = height;
        }
    }

    /**
     * Initializes an empty symbol table.
     */
    public AVLTreeST() {
    }

    /**
     * Checks if the symbol table is empty.
     * 
     * @return {@code true} if the symbol table is empty.
     */
    public boolean isEmpty() {
        return root == null;
    }

    /**
     * Returns the number key-value pairs in the symbol table.
     * 
     * @return the number key-value pairs in the symbol table
     */
    public int size() {
        return size(root);
    }

    /**
     * Returns the number of nodes in the subtree.
     * 
     * @param x the subtree
     * 
     * @return the number of nodes in the subtree
     */
    private int size(Node x) {
        if (x == null) return 0;
        return x.size;
    }

    /**
     * Returns the height of the internal AVL tree. It is assumed that the
     * height of an empty tree is -1 and the height of a tree with just one node
     * is 0.
     * 
     * @return the height of the internal AVL tree
     */
    public int height() {
        return height(root);
    }

    /**
     * Returns the height of the subtree.
     * 
     * @param x the subtree
     * 
     * @return the height of the subtree.
     */
    private int height(Node x) {
        if (x == null) return -1;
        return x.height;
    }

    /**
     * Returns the value associated with the given key.
     * 
     * @param key the key
     * @return the value associated with the given key if the key is in the
     *         symbol table and {@code null} if the key is not in the
     *         symbol table
     * @throws IllegalArgumentException if {@code key} is {@code null}
     */
    public Value get(Key key) {
        if (key == null) throw new IllegalArgumentException("argument to get() is null");
        Node x = get(root, key);
        if (x == null) return null;
        return x.val;
    }

    /**
     * Returns value associated with the given key in the subtree or
     * {@code null} if no such key.
     * 
     * @param x the subtree
     * @param key the key
     * @return value associated with the given key in the subtree or
     *         {@code null} if no such key
     */
    private Node get(Node x, Key key) {
        if (x == null) return null;
        int cmp = key.compareTo(x.key);
        if (cmp < 0) return get(x.left, key);
        else if (cmp > 0) return get(x.right, key);
        else return x;
    }

    /**
     * Checks if the symbol table contains the given key.
     * 
     * @param key the key
     * @return {@code true} if the symbol table contains {@code key}
     *         and {@code false} otherwise
     * @throws IllegalArgumentException if {@code key} is {@code null}
     */
    public boolean contains(Key key) {
        return get(key) != null;
    }

    /**
     * Inserts the specified key-value pair into the symbol table, overwriting
     * the old value with the new value if the symbol table already contains the
     * specified key. Deletes the specified key (and its associated value) from
     * this symbol table if the specified value is {@code null}.
     * 
     * @param key the key
     * @param val the value
     * @throws IllegalArgumentException if {@code key} is {@code null}
     */
    public void put(Key key, Value val) {
        if (key == null) throw new IllegalArgumentException("first argument to put() is null");
        if (val == null) {
            delete(key);
            return;
        }
        root = put(root, key, val);
        assert check();
    }

    /**
     * Inserts the key-value pair in the subtree. It overrides the old value
     * with the new value if the symbol table already contains the specified key
     * and deletes the specified key (and its associated value) from this symbol
     * table if the specified value is {@code null}.
     * 
     * @param x the subtree
     * @param key the key
     * @param val the value
     * @return the subtree
     */
    private Node put(Node x, Key key, Value val) {
        if (x == null) return new Node(key, val, 0, 1);
        int cmp = key.compareTo(x.key);
        if (cmp < 0) {
            x.left = put(x.left, key, val);
        }
        else if (cmp > 0) {
            x.right = put(x.right, key, val);
        }
        else {
            x.val = val;
            return x;
        }
        x.size = 1 + size(x.left) + size(x.right);
        x.height = 1 + Math.max(height(x.left), height(x.right));
        return balance(x);
    }

    /**
     * Restores the AVL tree property of the subtree.
     * 
     * @param x the subtree
     * @return the subtree with restored AVL property
     */
    private Node balance(Node x) {
        if (balanceFactor(x) < -1) {
            if (balanceFactor(x.right) > 0) {
                x.right = rotateRight(x.right);
            }
            x = rotateLeft(x);
        }
        else if (balanceFactor(x) > 1) {
            if (balanceFactor(x.left) < 0) {
                x.left = rotateLeft(x.left);
            }
            x = rotateRight(x);
        }
        return x;
    }

    /**
     * Returns the balance factor of the subtree. The balance factor is defined
     * as the difference in height of the left subtree and right subtree, in
     * this order. Therefore, a subtree with a balance factor of -1, 0 or 1 has
     * the AVL property since the heights of the two child subtrees differ by at
     * most one.
     * 
     * @param x the subtree
     * @return the balance factor of the subtree
     */
    private int balanceFactor(Node x) {
        return height(x.left) - height(x.right);
    }

    /**
     * Rotates the given subtree to the right.
     * 
     * @param x the subtree
     * @return the right rotated subtree
     */
    private Node rotateRight(Node x) {
        Node y = x.left;
        x.left = y.right;
        y.right = x;
        y.size = x.size;
        x.size = 1 + size(x.left) + size(x.right);
        x.height = 1 + Math.max(height(x.left), height(x.right));
        y.height = 1 + Math.max(height(y.left), height(y.right));
        return y;
    }

    /**
     * Rotates the given subtree to the left.
     * 
     * @param x the subtree
     * @return the left rotated subtree
     */
    private Node rotateLeft(Node x) {
        Node y = x.right;
        x.right = y.left;
        y.left = x;
        y.size = x.size;
        x.size = 1 + size(x.left) + size(x.right);
        x.height = 1 + Math.max(height(x.left), height(x.right));
        y.height = 1 + Math.max(height(y.left), height(y.right));
        return y;
    }

    /**
     * Removes the specified key and its associated value from the symbol table
     * (if the key is in the symbol table).
     * 
     * @param key the key
     * @throws IllegalArgumentException if {@code key} is {@code null}
     */
    public void delete(Key key) {
        if (key == null) throw new IllegalArgumentException("argument to delete() is null");
        if (!contains(key)) return;
        root = delete(root, key);
        assert check();
    }

    /**
     * Removes the specified key and its associated value from the given
     * subtree.
     * 
     * @param x the subtree
     * @param key the key
     * @return the updated subtree
     */
    private Node delete(Node x, Key key) {
        int cmp = key.compareTo(x.key);
        if (cmp < 0) {
            x.left = delete(x.left, key);
        }
        else if (cmp > 0) {
            x.right = delete(x.right, key);
        }
        else {
            if (x.left == null) {
                return x.right;
            }
            else if (x.right == null) {
                return x.left;
            }
            else {
                Node y = x;
                x = min(y.right);
                x.right = deleteMin(y.right);
                x.left = y.left;
            }
        }
        x.size = 1 + size(x.left) + size(x.right);
        x.height = 1 + Math.max(height(x.left), height(x.right));
        return balance(x);
    }

    /**
     * Removes the smallest key and associated value from the symbol table.
     * 
     * @throws NoSuchElementException if the symbol table is empty
     */
    public void deleteMin() {
        if (isEmpty()) throw new NoSuchElementException("called deleteMin() with empty symbol table");
        root = deleteMin(root);
        assert check();
    }

    /**
     * Removes the smallest key and associated value from the given subtree.
     * 
     * @param x the subtree
     * @return the updated subtree
     */
    private Node deleteMin(Node x) {
        if (x.left == null) return x.right;
        x.left = deleteMin(x.left);
        x.size = 1 + size(x.left) + size(x.right);
        x.height = 1 + Math.max(height(x.left), height(x.right));
        return balance(x);
    }

    /**
     * Removes the largest key and associated value from the symbol table.
     * 
     * @throws NoSuchElementException if the symbol table is empty
     */
    public void deleteMax() {
        if (isEmpty()) throw new NoSuchElementException("called deleteMax() with empty symbol table");
        root = deleteMax(root);
        assert check();
    }

    /**
     * Removes the largest key and associated value from the given subtree.
     * 
     * @param x the subtree
     * @return the updated subtree
     */
    private Node deleteMax(Node x) {
        if (x.right == null) return x.left;
        x.right = deleteMax(x.right);
        x.size = 1 + size(x.left) + size(x.right);
        x.height = 1 + Math.max(height(x.left), height(x.right));
        return balance(x);
    }

    /**
     * Returns the smallest key in the symbol table.
     * 
     * @return the smallest key in the symbol table
     * @throws NoSuchElementException if the symbol table is empty
     */
    public Key min() {
        if (isEmpty()) throw new NoSuchElementException("called min() with empty symbol table");
        return min(root).key;
    }

    /**
     * Returns the node with the smallest key in the subtree.
     * 
     * @param x the subtree
     * @return the node with the smallest key in the subtree
     */
    private Node min(Node x) {
        if (x.left == null) return x;
        return min(x.left);
    }

    /**
     * Returns the largest key in the symbol table.
     * 
     * @return the largest key in the symbol table
     * @throws NoSuchElementException if the symbol table is empty
     */
    public Key max() {
        if (isEmpty()) throw new NoSuchElementException("called max() with empty symbol table");
        return max(root).key;
    }

    /**
     * Returns the node with the largest key in the subtree.
     * 
     * @param x the subtree
     * @return the node with the largest key in the subtree
     */
    private Node max(Node x) {
        if (x.right == null) return x;
        return max(x.right);
    }

    /**
     * Returns the largest key in the symbol table less than or equal to
     * {@code key}.
     * 
     * @param key the key
     * @return the largest key in the symbol table less than or equal to
     *         {@code key}
     * @throws NoSuchElementException if the symbol table is empty
     * @throws IllegalArgumentException if {@code key} is {@code null}
     */
    public Key floor(Key key) {
        if (key == null) throw new IllegalArgumentException("argument to floor() is null");
        if (isEmpty()) throw new NoSuchElementException("called floor() with empty symbol table");
        Node x = floor(root, key);
        if (x == null) return null;
        else return x.key;
    }

    /**
     * Returns the node in the subtree with the largest key less than or equal
     * to the given key.
     * 
     * @param x the subtree
     * @param key the key
     * @return the node in the subtree with the largest key less than or equal
     *         to the given key
     */
    private Node floor(Node x, Key key) {
        if (x == null) return null;
        int cmp = key.compareTo(x.key);
        if (cmp == 0) return x;
        if (cmp < 0) return floor(x.left, key);
        Node y = floor(x.right, key);
        if (y != null) return y;
        else return x;
    }

    /**
     * Returns the smallest key in the symbol table greater than or equal to
     * {@code key}.
     * 
     * @param key the key
     * @return the smallest key in the symbol table greater than or equal to
     *         {@code key}
     * @throws NoSuchElementException if the symbol table is empty
     * @throws IllegalArgumentException if {@code key} is {@code null}
     */
    public Key ceiling(Key key) {
        if (key == null) throw new IllegalArgumentException("argument to ceiling() is null");
        if (isEmpty()) throw new NoSuchElementException("called ceiling() with empty symbol table");
        Node x = ceiling(root, key);
        if (x == null) return null;
        else return x.key;
    }

    /**
     * Returns the node in the subtree with the smallest key greater than or
     * equal to the given key.
     * 
     * @param x the subtree
     * @param key the key
     * @return the node in the subtree with the smallest key greater than or
     *         equal to the given key
     */
    private Node ceiling(Node x, Key key) {
        if (x == null) return null;
        int cmp = key.compareTo(x.key);
        if (cmp == 0) return x;
        if (cmp > 0) return ceiling(x.right, key);
        Node y = ceiling(x.left, key);
        if (y != null) return y;
        else return x;
    }

    /**
     * Returns the kth smallest key in the symbol table.
     * 
     * @param k the order statistic
     * @return the kth smallest key in the symbol table
     * @throws IllegalArgumentException unless {@code k} is between 0 and
     *             {@code size() -1 }
     */
    public Key select(int k) {
        if (k < 0 || k >= size()) throw new IllegalArgumentException("k is not in range 0-" + (size() - 1));
        Node x = select(root, k);
        return x.key;
    }

    /**
     * Returns the node with key the kth smallest key in the subtree.
     * 
     * @param x the subtree
     * @param k the kth smallest key in the subtree
     * @return the node with key the kth smallest key in the subtree
     */
    private Node select(Node x, int k) {
        if (x == null) return null;
        int t = size(x.left);
        if (t > k) return select(x.left, k);
        else if (t < k) return select(x.right, k - t - 1);
        else return x;
    }

    /**
     * Returns the number of keys in the symbol table strictly less than
     * {@code key}.
     * 
     * @param key the key
     * @return the number of keys in the symbol table strictly less than
     *         {@code key}
     * @throws IllegalArgumentException if {@code key} is {@code null}
     */
    public int rank(Key key) {
        if (key == null) throw new IllegalArgumentException("argument to rank() is null");
        return rank(key, root);
    }

    /**
     * Returns the number of keys in the subtree less than key.
     * 
     * @param key the key
     * @param x the subtree
     * @return the number of keys in the subtree less than key
     */
    private int rank(Key key, Node x) {
        if (x == null) return 0;
        int cmp = key.compareTo(x.key);
        if (cmp < 0) return rank(key, x.left);
        else if (cmp > 0) return 1 + size(x.left) + rank(key, x.right);
        else return size(x.left);
    }

    /**
     * Returns all keys in the symbol table.
     * 
     * @return all keys in the symbol table
     */
    public Iterable<Key> keys() {
        return keysInOrder();
    }

    /**
     * Returns all keys in the symbol table following an in-order traversal.
     * 
     * @return all keys in the symbol table following an in-order traversal
     */
    public Iterable<Key> keysInOrder() {
        Queue<Key> queue = new Queue<Key>();
        keysInOrder(root, queue);
        return queue;
    }

    /**
     * Adds the keys in the subtree to queue following an in-order traversal.
     * 
     * @param x the subtree
     * @param queue the queue
     */
    private void keysInOrder(Node x, Queue<Key> queue) {
        if (x == null) return;
        keysInOrder(x.left, queue);
        queue.enqueue(x.key);
        keysInOrder(x.right, queue);
    }

    /**
     * Returns all keys in the symbol table following a level-order traversal.
     * 
     * @return all keys in the symbol table following a level-order traversal.
     */
    public Iterable<Key> keysLevelOrder() {
        Queue<Key> queue = new Queue<Key>();
        if (!isEmpty()) {
            Queue<Node> queue2 = new Queue<Node>();
            queue2.enqueue(root);
            while (!queue2.isEmpty()) {
                Node x = queue2.dequeue();
                queue.enqueue(x.key);
                if (x.left != null) {
                    queue2.enqueue(x.left);
                }
                if (x.right != null) {
                    queue2.enqueue(x.right);
                }
            }
        }
        return queue;
    }

    /**
     * Returns all keys in the symbol table in the given range.
     * 
     * @param lo the lowest key
     * @param hi the highest key
     * @return all keys in the symbol table between {@code lo} (inclusive)
     *         and {@code hi} (exclusive)
     * @throws IllegalArgumentException if either {@code lo} or {@code hi}
     *             is {@code null}
     */
    public Iterable<Key> keys(Key lo, Key hi) {
        if (lo == null) throw new IllegalArgumentException("first argument to keys() is null");
        if (hi == null) throw new IllegalArgumentException("second argument to keys() is null");
        Queue<Key> queue = new Queue<Key>();
        keys(root, queue, lo, hi);
        return queue;
    }

    /**
     * Adds the keys between {@code lo} and {@code hi} in the subtree
     * to the {@code queue}.
     * 
     * @param x the subtree
     * @param queue the queue
     * @param lo the lowest key
     * @param hi the highest key
     */
    private void keys(Node x, Queue<Key> queue, Key lo, Key hi) {
        if (x == null) return;
        int cmplo = lo.compareTo(x.key);
        int cmphi = hi.compareTo(x.key);
        if (cmplo < 0) keys(x.left, queue, lo, hi);
        if (cmplo <= 0 && cmphi >= 0) queue.enqueue(x.key);
        if (cmphi > 0) keys(x.right, queue, lo, hi);
    }

    /**
     * Returns the number of keys in the symbol table in the given range.
     * 
     * @param lo minimum endpoint
     * @param hi maximum endpoint
     * @return the number of keys in the symbol table between {@code lo}
     *         (inclusive) and {@code hi} (exclusive)
     * @throws IllegalArgumentException if either {@code lo} or {@code hi}
     *             is {@code null}
     */
    public int size(Key lo, Key hi) {
        if (lo == null) throw new IllegalArgumentException("first argument to size() is null");
        if (hi == null) throw new IllegalArgumentException("second argument to size() is null");
        if (lo.compareTo(hi) > 0) return 0;
        if (contains(hi)) return rank(hi) - rank(lo) + 1;
        else return rank(hi) - rank(lo);
    }

    /**
     * Checks if the AVL tree invariants are fine.
     * 
     * @return {@code true} if the AVL tree invariants are fine
     */
    private boolean check() {
        if (!isBST()) StdOut.println("Symmetric order not consistent");
        if (!isAVL()) StdOut.println("AVL property not consistent");
        if (!isSizeConsistent()) StdOut.println("Subtree counts not consistent");
        if (!isRankConsistent()) StdOut.println("Ranks not consistent");
        return isBST() && isAVL() && isSizeConsistent() && isRankConsistent();
    }

    /**
     * Checks if AVL property is consistent.
     * 
     * @return {@code true} if AVL property is consistent.
     */
    private boolean isAVL() {
        return isAVL(root);
    }

    /**
     * Checks if AVL property is consistent in the subtree.
     * 
     * @param x the subtree
     * @return {@code true} if AVL property is consistent in the subtree
     */
    private boolean isAVL(Node x) {
        if (x == null) return true;
        int bf = balanceFactor(x);
        if (bf > 1 || bf < -1) return false;
        return isAVL(x.left) && isAVL(x.right);
    }

    /**
     * Checks if the symmetric order is consistent.
     * 
     * @return {@code true} if the symmetric order is consistent
     */
    private boolean isBST() {
        return isBST(root, null, null);
    }

    /**
     * Checks if the tree rooted at x is a BST with all keys strictly between
     * min and max (if min or max is null, treat as empty constraint) Credit:
     * Bob Dondero's elegant solution
     * 
     * @param x the subtree
     * @param min the minimum key in subtree
     * @param max the maximum key in subtree
     * @return {@code true} if if the symmetric order is consistent
     */
    private boolean isBST(Node x, Key min, Key max) {
        if (x == null) return true;
        if (min != null && x.key.compareTo(min) <= 0) return false;
        if (max != null && x.key.compareTo(max) >= 0) return false;
        return isBST(x.left, min, x.key) && isBST(x.right, x.key, max);
    }

    /**
     * Checks if size is consistent.
     * 
     * @return {@code true} if size is consistent
     */
    private boolean isSizeConsistent() {
        return isSizeConsistent(root);
    }

    /**
     * Checks if the size of the subtree is consistent.
     * 
     * @return {@code true} if the size of the subtree is consistent
     */
    private boolean isSizeConsistent(Node x) {
        if (x == null) return true;
        if (x.size != size(x.left) + size(x.right) + 1) return false;
        return isSizeConsistent(x.left) && isSizeConsistent(x.right);
    }

    /**
     * Checks if rank is consistent.
     * 
     * @return {@code true} if rank is consistent
     */
    private boolean isRankConsistent() {
        for (int i = 0; i < size(); i++)
            if (i != rank(select(i))) return false;
        for (Key key : keys())
            if (key.compareTo(select(rank(key))) != 0) return false;
        return true;
    }

    /**
     * Unit tests the {@code AVLTreeST} data type.
     *
     * @param args the command-line arguments
     */
    public static void main(String[] args) {
        AVLTreeST<String, Integer> st = new AVLTreeST<String, Integer>();
        for (int i = 0; !StdIn.isEmpty(); i++) {
            String key = StdIn.readString();
            st.put(key, i);
        }
        for (String s : st.keys())
            StdOut.println(s + " " + st.get(s));
        StdOut.println();
    }
}

/******************************************************************************
 *  Copyright 2002-2025, Robert Sedgewick and Kevin Wayne.
 *
 *  This file is part of algs4.jar, which accompanies the textbook
 *
 *      Algorithms, 4th edition by Robert Sedgewick and Kevin Wayne,
 *      Addison-Wesley Professional, 2011, ISBN 0-321-57351-X.
 *      http://algs4.cs.princeton.edu
 *
 *
 *  algs4.jar is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  algs4.jar is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with algs4.jar.  If not, see http://www.gnu.org/licenses.
 ******************************************************************************/


================================================
FILE: src/main/java/edu/princeton/cs/algs4/Accumulator.java
================================================
/******************************************************************************
 *  Compilation:  javac Accumulator.java
 *  Execution:    java Accumulator < input.txt
 *  Dependencies: StdOut.java StdIn.java
 *
 *  Mutable data type that calculates the mean, sample standard
 *  deviation, and sample variance of a stream of real numbers
 *  use a stable, one-pass algorithm.
 *
 ******************************************************************************/

package edu.princeton.cs.algs4;


/**
 *  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.
 *  <p>
 *  This implementation uses a one-pass algorithm that is less susceptible
 *  to floating-point roundoff error than the more straightforward
 *  implementation based on saving the sum of the squares of the numbers.
 *  This technique is due to
 *  <a href = "https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_online_algorithm">B. P. Welford</a>.
 *  Each operation takes constant time in the worst case.
 *  The amount of memory is constant - the data values are not stored.
 *  <p>
 *  For additional documentation,
 *  see <a href="https://algs4.cs.princeton.edu/12oop">Section 1.2</a> of
 *  <i>Algorithms, 4th Edition</i> by Robert Sedgewick and Kevin Wayne.
 *
 *  @author Robert Sedgewick
 *  @author Kevin Wayne
 */
public class Accumulator {
    private int n = 0;          // number of data values
    private double sum = 0.0;   // sample variance * (n-1)
    private double mu = 0.0;    // sample mean

    /**
     * Initializes an accumulator.
     */
    public Accumulator() {
    }

    /**
     * Adds the specified data value to the accumulator.
     * @param  x the data value
     */
    public void addDataValue(double x) {
        n++;
        double delta = x - mu;
        mu  += delta / n;
        sum += ((double) (n - 1) / n) * delta * delta;
    }

    /**
     * Returns the mean of the data values.
     * @return the mean of the data values
     */
    public double mean() {
        return mu;
    }

    /**
     * Returns the sample variance of the data values.
     * @return the sample variance of the data values
     */
    public double var() {
        if (n <= 1) return Double.NaN;
        return sum / (n - 1);
    }

    /**
     * Returns the sample standard deviation of the data values.
     * @return the sample standard deviation of the data values
     */
    public double stddev() {
        return Math.sqrt(this.var());
    }

    /**
     * Returns the number of data values.
     * @return the number of data values
     */
    public int count() {
        return n;
    }

    /**
     * Returns a string representation of this accumulator.
     * @return a string representation of this accumulator
     */
    public String toString() {
        return "n = " + n + ", mean = " + mean() + ", stddev = " + stddev();
    }

    /**
     * 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
     * output.
     *
     * @param args the command-line arguments
     */
    public static void main(String[] args) {
        Accumulator stats = new Accumulator();
        while (!StdIn.isEmpty()) {
            double x = StdIn.readDouble();
            stats.addDataValue(x);
        }

        StdOut.printf("n      = %d\n",   stats.count());
        StdOut.printf("mean   = %.5f\n", stats.mean());
        StdOut.printf("stddev = %.5f\n", stats.stddev());
        StdOut.printf("var    = %.5f\n", stats.var());
        StdOut.println(stats);
    }
}

/******************************************************************************
 *  Copyright 2002-2025, Robert Sedgewick and Kevin Wayne.
 *
 *  This file is part of algs4.jar, which accompanies the textbook
 *
 *      Algorithms, 4th edition by Robert Sedgewick and Kevin Wayne,
 *      Addison-Wesley Professional, 2011, ISBN 0-321-57351-X.
 *      http://algs4.cs.princeton.edu
 *
 *
 *  algs4.jar is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  algs4.jar is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with algs4.jar.  If not, see http://www.gnu.org/licenses.
 ******************************************************************************/


================================================
FILE: src/main/java/edu/princeton/cs/algs4/AcyclicLP.java
================================================
/******************************************************************************
 *  Compilation:  javac AcyclicLP.java
 *  Execution:    java AcyclicP V E
 *  Dependencies: EdgeWeightedDigraph.java DirectedEdge.java Topological.java
 *  Data files:   https://algs4.cs.princeton.edu/44sp/tinyEWDAG.txt
 *
 *  Computes longest paths in an edge-weighted acyclic digraph.
 *
 *  Remark: should probably check that graph is a DAG before running
 *
 *  % java AcyclicLP tinyEWDAG.txt 5
 *  5 to 0 (2.44)  5->1  0.32   1->3  0.29   3->6  0.52   6->4  0.93   4->0  0.38
 *  5 to 1 (0.32)  5->1  0.32
 *  5 to 2 (2.77)  5->1  0.32   1->3  0.29   3->6  0.52   6->4  0.93   4->7  0.37   7->2  0.34
 *  5 to 3 (0.61)  5->1  0.32   1->3  0.29
 *  5 to 4 (2.06)  5->1  0.32   1->3  0.29   3->6  0.52   6->4  0.93
 *  5 to 5 (0.00)
 *  5 to 6 (1.13)  5->1  0.32   1->3  0.29   3->6  0.52
 *  5 to 7 (2.43)  5->1  0.32   1->3  0.29   3->6  0.52   6->4  0.93   4->7  0.37
 *
 ******************************************************************************/

package edu.princeton.cs.algs4;

/**
 *  The {@code AcyclicLP} class represents a data type for solving the
 *  single-source longest paths problem in edge-weighted directed
 *  acyclic graphs (DAGs). The edge weights can be positive, negative, or zero.
 *  <p>
 *  This implementation uses a topological-sort based algorithm.
 *  The constructor takes &Theta;(<em>V</em> + <em>E</em>) time in the
 *  worst case, where <em>V</em> is the number of vertices and
 *  <em>E</em> is the number of edges.
 *  Each instance method takes &Theta;(1) time.
 *  It uses &Theta;(<em>V</em>) extra space (not including the
 *  edge-weighted digraph).
 *  <p>
 *  This correctly computes longest paths if all arithmetic performed is
 *  without floating-point rounding error or arithmetic overflow.
 *  This is the case if all edge weights are integers and if none of the
 *  intermediate results exceeds 2<sup>52</sup>. Since all intermediate
 *  results are sums of edge weights, they are bounded by <em>V C</em>,
 *  where <em>V</em> is the number of vertices and <em>C</em> is the maximum
 *  absolute value of any edge weight.
 *  <p>
 *  For additional documentation,
 *  see <a href="https://algs4.cs.princeton.edu/44sp">Section 4.4</a> of
 *  <i>Algorithms, 4th Edition</i> by Robert Sedgewick and Kevin Wayne.
 *
 *  @author Robert Sedgewick
 *  @author Kevin Wayne
 */
public class AcyclicLP {
    private double[] distTo;          // distTo[v] = distance  of longest s->v path
    private DirectedEdge[] edgeTo;    // edgeTo[v] = last edge on longest s->v path

    /**
     * Computes a longest paths tree from {@code s} to every other vertex in
     * the directed acyclic graph {@code digraph}.
     * @param digraph the acyclic digraph
     * @param s the source vertex
     * @throws IllegalArgumentException if the digraph is not acyclic
     * @throws IllegalArgumentException unless {@code 0 <= s < V}
     */
    public AcyclicLP(EdgeWeightedDigraph digraph, int s) {
        distTo = new double[digraph.V()];
        edgeTo = new DirectedEdge[digraph.V()];

        validateVertex(s);

        for (int v = 0; v < digraph.V(); v++)
            distTo[v] = Double.NEGATIVE_INFINITY;
        distTo[s] = 0.0;

        // relax vertices in topological order
        Topological topological = new Topological(digraph);
        if (!topological.hasOrder())
            throw new IllegalArgumentException("Digraph is not acyclic.");
        for (int v : topological.order()) {
            for (DirectedEdge e : digraph.adj(v))
                relax(e);
        }
    }

    // relax edge e, but update if you find a *longer* path
    private void relax(DirectedEdge e) {
        int v = e.from(), w = e.to();
        if (distTo[w] < distTo[v] + e.weight()) {
            distTo[w] = distTo[v] + e.weight();
            edgeTo[w] = e;
        }
    }

    /**
     * Returns the length of a longest path from the source vertex {@code s} to vertex {@code v}.
     * @param  v the destination vertex
     * @return the length of a longest path from the source vertex {@code s} to vertex {@code v};
     *         {@code Double.NEGATIVE_INFINITY} if no such path
     * @throws IllegalArgumentException unless {@code 0 <= v < V}
     */
    public double distTo(int v) {
        validateVertex(v);
        return distTo[v];
    }

    /**
     * Is there a path from the source vertex {@code s} to vertex {@code v}?
     * @param  v the destination vertex
     * @return {@code true} if there is a path from the source vertex
     *         {@code s} to vertex {@code v}, and {@code false} otherwise
     * @throws IllegalArgumentException unless {@code 0 <= v < V}
     */
    public boolean hasPathTo(int v) {
        validateVertex(v);
        return distTo[v] > Double.NEGATIVE_INFINITY;
    }

    /**
     * Returns a longest path from the source vertex {@code s} to vertex {@code v}.
     * @param  v the destination vertex
     * @return a longest path from the source vertex {@code s} to vertex {@code v}
     *         as an iterable of edges, and {@code null} if no such path
     * @throws IllegalArgumentException unless {@code 0 <= v < V}
     */
    public Iterable<DirectedEdge> pathTo(int v) {
        validateVertex(v);
        if (!hasPathTo(v)) return null;
        Stack<DirectedEdge> path = new Stack<DirectedEdge>();
        for (DirectedEdge e = edgeTo[v]; e != null; e = edgeTo[e.from()]) {
            path.push(e);
        }
        return path;
    }

    // throw an IllegalArgumentException unless {@code 0 <= v < V}
    private void validateVertex(int v) {
        int V = distTo.length;
        if (v < 0 || v >= V)
            throw new IllegalArgumentException("vertex " + v + " is not between 0 and " + (V-1));
    }

    /**
     * Unit tests the {@code AcyclicLP} data type.
     *
     * @param args the command-line arguments
     */
    public static void main(String[] args) {
        In in = new In(args[0]);
        int s = Integer.parseInt(args[1]);
        EdgeWeightedDigraph digraph = new EdgeWeightedDigraph(in);

        AcyclicLP lp = new AcyclicLP(digraph, s);

        for (int v = 0; v < digraph.V(); v++) {
            if (lp.hasPathTo(v)) {
                StdOut.printf("%d to %d (%.2f)  ", s, v, lp.distTo(v));
                for (DirectedEdge e : lp.pathTo(v)) {
                    StdOut.print(e + "   ");
                }
                StdOut.println();
            }
            else {
                StdOut.printf("%d to %d         no path\n", s, v);
            }
        }
    }
}

/******************************************************************************
 *  Copyright 2002-2025, Robert Sedgewick and Kevin Wayne.
 *
 *  This file is part of algs4.jar, which accompanies the textbook
 *
 *      Algorithms, 4th edition by Robert Sedgewick and Kevin Wayne,
 *      Addison-Wesley Professional, 2011, ISBN 0-321-57351-X.
 *      http://algs4.cs.princeton.edu
 *
 *
 *  algs4.jar is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  algs4.jar is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with algs4.jar.  If not, see http://www.gnu.org/licenses.
 ******************************************************************************/


================================================
FILE: src/main/java/edu/princeton/cs/algs4/AcyclicSP.java
================================================
/******************************************************************************
 *  Compilation:  javac AcyclicSP.java
 *  Execution:    java AcyclicSP V E
 *  Dependencies: EdgeWeightedDigraph.java DirectedEdge.java Topological.java
 *  Data files:   https://algs4.cs.princeton.edu/44sp/tinyEWDAG.txt
 *
 *  Computes shortest paths in an edge-weighted acyclic digraph.
 *
 *  % java AcyclicSP tinyEWDAG.txt 5
 *  5 to 0 (0.73)  5->4  0.35   4->0  0.38
 *  5 to 1 (0.32)  5->1  0.32
 *  5 to 2 (0.62)  5->7  0.28   7->2  0.34
 *  5 to 3 (0.61)  5->1  0.32   1->3  0.29
 *  5 to 4 (0.35)  5->4  0.35
 *  5 to 5 (0.00)
 *  5 to 6 (1.13)  5->1  0.32   1->3  0.29   3->6  0.52
 *  5 to 7 (0.28)  5->7  0.28
 *
 ******************************************************************************/

package edu.princeton.cs.algs4;

/**
 *  The {@code AcyclicSP} class represents a data type for solving the
 *  single-source shortest paths problem in edge-weighted directed acyclic
 *  graphs (DAGs). The edge weights can be positive, negative, or zero.
 *  <p>
 *  This implementation uses a topological-sort based algorithm.
 *  The constructor takes &Theta;(<em>V</em> + <em>E</em>) time in the
 *  worst case, where <em>V</em> is the number of vertices and
 *  <em>E</em> is the number of edges.
 *  Each instance method takes &Theta;(1) time.
 *  It uses &Theta;(<em>V</em>) extra space (not including the
 *  edge-weighted digraph).
 *  <p>
 *  This correctly computes shortest paths if all arithmetic performed is
 *  without floating-point rounding error or arithmetic overflow.
 *  This is the case if all edge weights are integers and if none of the
 *  intermediate results exceeds 2<sup>52</sup>. Since all intermediate
 *  results are sums of edge weights, they are bounded by <em>V C</em>,
 *  where <em>V</em> is the number of vertices and <em>C</em> is the maximum
 *  absolute value of any edge weight.
 *  <p>
 *  For additional documentation,
 *  see <a href="https://algs4.cs.princeton.edu/44sp">Section 4.4</a> of
 *  <i>Algorithms, 4th Edition</i> by Robert Sedgewick and Kevin Wayne.
 *
 *  @author Robert Sedgewick
 *  @author Kevin Wayne
 */
public class AcyclicSP {
    private double[] distTo;         // distTo[v] = distance  of shortest s->v path
    private DirectedEdge[] edgeTo;   // edgeTo[v] = last edge on shortest s->v path


    /**
     * Computes a shortest paths tree from {@code s} to every other vertex in
     * the directed acyclic graph {@code digraph}.
     * @param digraph the acyclic digraph
     * @param s the source vertex
     * @throws IllegalArgumentException if the digraph is not acyclic
     * @throws IllegalArgumentException unless {@code 0 <= s < V}
     */
    public AcyclicSP(EdgeWeightedDigraph digraph, int s) {
        distTo = new double[digraph.V()];
        edgeTo = new DirectedEdge[digraph.V()];

        validateVertex(s);

        for (int v = 0; v < digraph.V(); v++)
            distTo[v] = Double.POSITIVE_INFINITY;
        distTo[s] = 0.0;

        // visit vertices in topological order
        Topological topological = new Topological(digraph);
        if (!topological.hasOrder())
            throw new IllegalArgumentException("Digraph is not acyclic.");
        for (int v : topological.order()) {
            for (DirectedEdge e : digraph.adj(v))
                relax(e);
        }
    }

    // relax edge e
    private void relax(DirectedEdge e) {
        int v = e.from(), w = e.to();
        if (distTo[w] > distTo[v] + e.weight()) {
            distTo[w] = distTo[v] + e.weight();
            edgeTo[w] = e;
        }
    }

    /**
     * Returns the length of a shortest path from the source vertex {@code s} to vertex {@code v}.
     * @param  v the destination vertex
     * @return the length of a shortest path from the source vertex {@code s} to vertex {@code v};
     *         {@code Double.POSITIVE_INFINITY} if no such path
     * @throws IllegalArgumentException unless {@code 0 <= v < V}
     */
    public double distTo(int v) {
        validateVertex(v);
        return distTo[v];
    }

    /**
     * Is there a path from the source vertex {@code s} to vertex {@code v}?
     * @param  v the destination vertex
     * @return {@code true} if there is a path from the source vertex
     *         {@code s} to vertex {@code v}, and {@code false} otherwise
     * @throws IllegalArgumentException unless {@code 0 <= v < V}
     */
    public boolean hasPathTo(int v) {
        validateVertex(v);
        return distTo[v] < Double.POSITIVE_INFINITY;
    }

    /**
     * Returns a shortest path from the source vertex {@code s} to vertex {@code v}.
     * @param  v the destination vertex
     * @return a shortest path from the source vertex {@code s} to vertex {@code v}
     *         as an iterable of edges, and {@code null} if no such path
     * @throws IllegalArgumentException unless {@code 0 <= v < V}
     */
    public Iterable<DirectedEdge> pathTo(int v) {
        validateVertex(v);
        if (!hasPathTo(v)) return null;
        Stack<DirectedEdge> path = new Stack<DirectedEdge>();
        for (DirectedEdge e = edgeTo[v]; e != null; e = edgeTo[e.from()]) {
            path.push(e);
        }
        return path;
    }

    // throw an IllegalArgumentException unless {@code 0 <= v < V}
    private void validateVertex(int v) {
        int V = distTo.length;
        if (v < 0 || v >= V)
            throw new IllegalArgumentException("vertex " + v + " is not between 0 and " + (V-1));
    }

    /**
     * Unit tests the {@code AcyclicSP} data type.
     *
     * @param args the command-line arguments
     */
    public static void main(String[] args) {
        In in = new In(args[0]);
        int s = Integer.parseInt(args[1]);
        EdgeWeightedDigraph digraph = new EdgeWeightedDigraph(in);

        // find shortest path from s to each other vertex in DAG
        AcyclicSP sp = new AcyclicSP(digraph, s);
        for (int v = 0; v < digraph.V(); v++) {
            if (sp.hasPathTo(v)) {
                StdOut.printf("%d to %d (%.2f)  ", s, v, sp.distTo(v));
                for (DirectedEdge e : sp.pathTo(v)) {
                    StdOut.print(e + "   ");
                }
                StdOut.println();
            }
            else {
                StdOut.printf("%d to %d         no path\n", s, v);
            }
        }
    }
}

/******************************************************************************
 *  Copyright 2002-2025, Robert Sedgewick and Kevin Wayne.
 *
 *  This file is part of algs4.jar, which accompanies the textbook
 *
 *      Algorithms, 4th edition by Robert Sedgewick and Kevin Wayne,
 *      Addison-Wesley Professional, 2011, ISBN 0-321-57351-X.
 *      http://algs4.cs.princeton.edu
 *
 *
 *  algs4.jar is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  algs4.jar is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with algs4.jar.  If not, see http://www.gnu.org/licenses.
 ******************************************************************************/


================================================
FILE: src/main/java/edu/princeton/cs/algs4/AdjMatrixEdgeWeightedDigraph.java
================================================
/******************************************************************************
 *  Compilation:  javac AdjMatrixEdgeWeightedDigraph.java
 *  Execution:    java AdjMatrixEdgeWeightedDigraph V E
 *  Dependencies: StdOut.java
 *
 *  An edge-weighted digraph, implemented using an adjacency matrix.
 *  Parallel edges are disallowed; self-loops are allowed.
 *
 ******************************************************************************/

package edu.princeton.cs.algs4;

import java.util.Iterator;
import java.util.NoSuchElementException;

/**
 *  The {@code AdjMatrixEdgeWeightedDigraph} class represents an edge-weighted
 *  digraph of vertices named 0 through <em>V</em> - 1, where each
 *  directed edge is of type {@link DirectedEdge} and has a real-valued weight.
 *  It supports the following two primary operations: add a directed edge
 *  to the digraph and iterate over all of edges incident from a given vertex.
 *  It also provides
 *  methods for returning the number of vertices <em>V</em> and the number
 *  of edges <em>E</em>. Parallel edges are disallowed; self-loops are permitted.
 *  <p>
 *  This implementation uses an adjacency-matrix representation.
 *  All operations take constant time (in the worst case) except
 *  iterating over the edges incident from a given vertex, which takes
 *  time proportional to <em>V</em>.
 *  <p>
 *  For additional documentation,
 *  see <a href="https://algs4.cs.princeton.edu/44sp">Section 4.4</a> of
 *  <i>Algorithms, 4th Edition</i> by Robert Sedgewick and Kevin Wayne.
 *
 *  @author Robert Sedgewick
 *  @author Kevin Wayne
 */
public class AdjMatrixEdgeWeightedDigraph {
    private static final String NEWLINE = System.getProperty("line.separator");

    private final int V;
    private int E;
    private DirectedEdge[][] adj;

    /**
     * Initializes an empty edge-weighted digraph with {@code V} vertices and 0 edges.
     * @param V the number of vertices
     * @throws IllegalArgumentException if {@code V < 0}
     */
    public AdjMatrixEdgeWeightedDigraph(int V) {
        if (V < 0) throw new IllegalArgumentException("number of vertices must be non-negative");
        this.V = V;
        this.E = 0;
        this.adj = new DirectedEdge[V][V];
    }

    /**
     * Initializes a random edge-weighted digraph with {@code V} vertices and <em>E</em> edges.
     * @param V the number of vertices
     * @param E the number of edges
     * @throws IllegalArgumentException if {@code V < 0}
     * @throws IllegalArgumentException if {@code E < 0}
     */
    public AdjMatrixEdgeWeightedDigraph(int V, int E) {
        this(V);
        if (E < 0) throw new IllegalArgumentException("number of edges must be non-negative");
        if (E > V*V) throw new IllegalArgumentException("too many edges");

        // can be inefficient
        while (this.E != E) {
            int v = StdRandom.uniformInt(V);
            int w = StdRandom.uniformInt(V);
            double weight = 0.01 * StdRandom.uniformInt(0, 100);
            addEdge(new DirectedEdge(v, w, weight));
        }
    }

    /**
     * Returns the number of vertices in the edge-weighted digraph.
     * @return the number of vertices in the edge-weighted digraph
     */
    public int V() {
        return V;
    }

    /**
     * Returns the number of edges in the edge-weighted digraph.
     * @return the number of edges in the edge-weighted digraph
     */
    public int E() {
        return E;
    }

    /**
     * Adds the directed edge {@code e} to the edge-weighted digraph (if there
     * is not already an edge with the same endpoints).
     * @param e the edge
     */
    public void addEdge(DirectedEdge e) {
        int v = e.from();
        int w = e.to();
        validateVertex(v);
        validateVertex(w);
        if (adj[v][w] == null) {
            E++;
            adj[v][w] = e;
        }
    }

    /**
     * Returns the directed edges incident from vertex {@code v}.
     * @param v the vertex
     * @return the directed edges incident from vertex {@code v} as an Iterable
     * @throws IllegalArgumentException unless {@code 0 <= v < V}
     */
    public Iterable<DirectedEdge> adj(int v) {
        validateVertex(v);
        return new AdjIterator(v);
    }

    // support iteration over graph vertices
    private class AdjIterator implements Iterator<DirectedEdge>, Iterable<DirectedEdge> {
        private int v;
        private int w = 0;

        public AdjIterator(int v) {
            this.v = v;
        }

        public Iterator<DirectedEdge> iterator() {
            return this;
        }

        public boolean hasNext() {
            while (w < V) {
                if (adj[v][w] != null) return true;
                w++;
            }
            return false;
        }

        public DirectedEdge next() {
            if (!hasNext()) {
                throw new NoSuchElementException();
            }
            return adj[v][w++];
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    }

    /**
     * Returns a string representation of the edge-weighted digraph. This method takes
     * time proportional to <em>V</em><sup>2</sup>.
     * @return the number of vertices <em>V</em>, followed by the number of edges <em>E</em>,
     *   followed by the <em>V</em> adjacency lists of edges
     */
    public String toString() {
        StringBuilder s = new StringBuilder();
        s.append(V + " " + E + NEWLINE);
        for (int v = 0; v < V; v++) {
            s.append(v + ": ");
            for (DirectedEdge e : adj(v)) {
                s.append(e + "  ");
            }
            s.append(NEWLINE);
        }
        return s.toString();
    }

    // throw an IllegalArgumentException unless {@code 0 <= v < V}
    private void validateVertex(int v) {
        if (v < 0 || v >= V)
            throw new IllegalArgumentException("vertex " + v + " is not between 0 and " + (V-1));
    }


    /**
     * Unit tests the {@code AdjMatrixEdgeWeightedDigraph} data type.
     *
     * @param args the command-line arguments
     */
    public static void main(String[] args) {
        int V = Integer.parseInt(args[0]);
        int E = Integer.parseInt(args[1]);
        AdjMatrixEdgeWeightedDigraph G = new AdjMatrixEdgeWeightedDigraph(V, E);
        StdOut.println(G);
    }

}

/******************************************************************************
 *  Copyright 2002-2025, Robert Sedgewick and Kevin Wayne.
 *
 *  This file is part of algs4.jar, which accompanies the textbook
 *
 *      Algorithms, 4th edition by Robert Sedgewick and Kevin Wayne,
 *      Addison-Wesley Professional, 2011, ISBN 0-321-57351-X.
 *      http://algs4.cs.princeton.edu
 *
 *
 *  algs4.jar is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  algs4.jar is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with algs4.jar.  If not, see http://www.gnu.org/licenses.
 ******************************************************************************/


================================================
FILE: src/main/java/edu/princeton/cs/algs4/AllowFilter.java
================================================
/******************************************************************************
 *  Compilation:  javac AllowFilter.java
 *  Execution:    java AllowFilter allowlist.txt < input.txt
 *  Dependencies: SET In.java StdIn.java StdOut.java
 *  Data files:   https://algs4.cs.princeton.edu/35applications/tinyTale.txt
 *                https://algs4.cs.princeton.edu/35applications/allowlist.txt
 *
 *  Reads an allowlist of words from a file. Then readsa list of
 *  words from standard input and prints all those words that
 *  are in the first file.
 *
 *  % more tinyTale.txt
 *  it was the best of times it was the worst of times
 *  it was the age of wisdom it was the age of foolishness
 *  it was the epoch of belief it was the epoch of incredulity
 *  it was the season of light it was the season of darkness
 *  it was the spring of hope it was the winter of despair
 *
 *  % more list.txt
 *  was it the of
 *
 *  % java AllowFilter list.txt < tinyTale.txt
 *  it was the of it was the of
 *  it was the of it was the of
 *  it was the of it was the of
 *  it was the of it was the of
 *  it was the of it was the of
 *
 ******************************************************************************/

package edu.princeton.cs.algs4;

/**
 *  The {@code AllowFilter} class provides a client for reading in an <em>allowlist</em>
 *  of words from a file; then, reading in a sequence of words from standard input,
 *  printing out each word that appears in the file.
 *  It is useful as a test client for various symbol-table implementations.
 *  <p>
 *  For additional documentation,
 *  see <a href="https://algs4.cs.princeton.edu/35applications">Section 3.5</a> of
 *  <i>Algorithms, 4th Edition</i> by Robert Sedgewick and Kevin Wayne.
 *
 *  @author Robert Sedgewick
 *  @author Kevin Wayne
 */
public class AllowFilter {

    // Do not instantiate.
    private AllowFilter() { }

    public static void main(String[] args) {
        SET<String> set = new SET<String>();

        // read in strings and add to set
        In in = new In(args[0]);
        while (!in.isEmpty()) {
            String word = in.readString();
            set.add(word);
        }

        // read in string from standard input, printing out all exceptions
        while (!StdIn.isEmpty()) {
            String word = StdIn.readString();
            if (set.contains(word))
                StdOut.println(word);
        }
    }
}

/******************************************************************************
 *  Copyright 2002-2025, Robert Sedgewick and Kevin Wayne.
 *
 *  This file is part of algs4.jar, which accompanies the textbook
 *
 *      Algorithms, 4th edition by Robert Sedgewick and Kevin Wayne,
 *      Addison-Wesley Professional, 2011, ISBN 0-321-57351-X.
 *      http://algs4.cs.princeton.edu
 *
 *
 *  algs4.jar is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  algs4.jar is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with algs4.jar.  If not, see http://www.gnu.org/licenses.
 ******************************************************************************/


================================================
FILE: src/main/java/edu/princeton/cs/algs4/Allowlist.java
================================================
/******************************************************************************
 *  Compilation:  javac Allowlist.java
 *  Execution:    java Allowlist allowlist.txt < data.txt
 *  Dependencies: StaticSetOfInts.java In.java StdOut.java
 *
 *  Data files:   https://algs4.cs.princeton.edu/11model/tinyAllowlist.txt
 *                https://algs4.cs.princeton.edu/11model/tinyText.txt
 *                https://algs4.cs.princeton.edu/11model/largeAllowlist.txt
 *                https://algs4.cs.princeton.edu/11model/largeText.txt
 *
 *  Allowlist filter.
 *
 *
 *  % java Allowlist tinyAllowlist.txt < tinyText.txt
 *  50
 *  99
 *  13
 *
 *  % java Allowlist largeAllowlist.txt < largeText.txt | more
 *  499569
 *  984875
 *  295754
 *  207807
 *  140925
 *  161828
 *  [367,966 total values]
 *
 ******************************************************************************/

package edu.princeton.cs.algs4;

/**
 *  The {@code Allowlist} class provides a client for reading in
 *  a set of integers from a file; reading in a sequence of integers
 *  from standard input; and printing to standard output those
 *  integers not in the allowlist.
 *  <p>
 *  For additional documentation,
 *  see <a href="https://algs4.cs.princeton.edu/12oop">Section 1.2</a> of
 *  <i>Algorithms, 4th Edition</i> by Robert Sedgewick and Kevin Wayne.
 *
 *  @author Robert Sedgewick
 *  @author Kevin Wayne
 */
public class Allowlist {

    // Do not instantiate.
    private Allowlist() { }

    /**
     * Reads in a sequence of integers from the allowlist file, specified as
     * a command-line argument. Reads in integers from standard input and
     * prints to standard output those integers that are not in the file.
     *
     * @param args the command-line arguments
     */
    public static void main(String[] args) {
        In in = new In(args[0]);
        int[] white = in.readAllInts();
        StaticSETofInts set = new StaticSETofInts(white);

        // Read key, print if not in allowlist.
        while (!StdIn.isEmpty()) {
            int key = StdIn.readInt();
            if (!set.contains(key))
                StdOut.println(key);
        }
    }
}

/******************************************************************************
 *  Copyright 2002-2025, Robert Sedgewick and Kevin Wayne.
 *
 *  This file is part of algs4.jar, which accompanies the textbook
 *
 *      Algorithms, 4th edition by Robert Sedgewick and Kevin Wayne,
 *      Addison-Wesley Professional, 2011, ISBN 0-321-57351-X.
 *      http://algs4.cs.princeton.edu
 *
 *
 *  algs4.jar is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  algs4.jar is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with algs4.jar.  If not, see http://www.gnu.org/licenses.
 ******************************************************************************/


================================================
FILE: src/main/java/edu/princeton/cs/algs4/Alphabet.java
================================================
/******************************************************************************
 *  Compilation:  javac Alphabet.java
 *  Execution:    java Alphabet
 *  Dependencies: StdOut.java
 *  
 *  A data type for alphabets, for use with string-processing code
 *  that must convert between an alphabet of size R and the integers
 *  0 through R-1.
 *
 *  Warning: supports only the basic multilingual plane (BMP), i.e,
 *           Unicode characters between U+0000 and U+FFFF.
 *
 ******************************************************************************/

package edu.princeton.cs.algs4;

public class Alphabet {

    /**
     *  The binary alphabet { 0, 1 }.
     */
    public static final Alphabet BINARY = new Alphabet("01");

    /**
     *  The octal alphabet { 0, 1, 2, 3, 4, 5, 6, 7 }.
     */
    public static final Alphabet OCTAL = new Alphabet("01234567");

    /**
     *  The decimal alphabet { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }.
     */
    public static final Alphabet DECIMAL = new Alphabet("0123456789");

    /**
     *  The hexadecimal alphabet { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F }.
     */
    public static final Alphabet HEXADECIMAL = new Alphabet("0123456789ABCDEF");

    /**
     *  The DNA alphabet { A, C, T, G }.
     */
    public static final Alphabet DNA = new Alphabet("ACGT");

    /**
     *  The lowercase alphabet { a, b, c, ..., z }.
     */
    public static final Alphabet LOWERCASE = new Alphabet("abcdefghijklmnopqrstuvwxyz");

    /**
     *  The uppercase alphabet { A, B, C, ..., Z }.
     */

    public static final Alphabet UPPERCASE = new Alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZ");

    /**
     *  The protein alphabet { A, C, D, E, F, G, H, I, K, L, M, N, P, Q, R, S, T, V, W, Y }.
     */
    public static final Alphabet PROTEIN = new Alphabet("ACDEFGHIKLMNPQRSTVWY");

    /**
     *  The base-64 alphabet (64 characters).
     */
    public static final Alphabet BASE64 = new Alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");

    /**
     *  The ASCII alphabet (0-127).
     */
    public static final Alphabet ASCII = new Alphabet(128);

    /**
     *  The extended ASCII alphabet (0-255).
     */
    public static final Alphabet EXTENDED_ASCII = new Alphabet(256);

    /**
     *  The Unicode 16 alphabet (0-65,535).
     */
    public static final Alphabet UNICODE16      = new Alphabet(65536);


    private char[] alphabet;     // the characters in the alphabet
    private int[] inverse;       // indices
    private final int R;         // the radix of the alphabet

    /**
     * Initializes a new alphabet from the given set of characters.
     *
     * @param alpha the set of characters
     */
    public Alphabet(String alpha) {

        // check that alphabet contains no duplicate chars
        boolean[] unicode = new boolean[Character.MAX_VALUE];
        for (int i = 0; i < alpha.length(); i++) {
            char c = alpha.charAt(i);
            if (unicode[c])
                throw new IllegalArgumentException("Illegal alphabet: repeated character = '" + c + "'");
            unicode[c] = true;
        }

        alphabet = alpha.toCharArray();
        R = alpha.length();
        inverse = new int[Character.MAX_VALUE];
        for (int i = 0; i < inverse.length; i++)
            inverse[i] = -1;

        // can't use char since R can be as big as 65,536
        for (int c = 0; c < R; c++)
            inverse[alphabet[c]] = c;
    }

    /**
     * Initializes a new alphabet using characters 0 through R-1.
     *
     * @param radix the number of characters in the alphabet (the radix R)
     */
    private Alphabet(int radix) {
        this.R = radix;
        alphabet = new char[R];
        inverse = new int[R];

        // can't use char since R can be as big as 65,536
        for (int i = 0; i < R; i++)
            alphabet[i] = (char) i;
        for (int i = 0; i < R; i++)
            inverse[i] = i;
    }

    /**
     * Initializes a new alphabet using characters 0 through 255.
     */
    public Alphabet() {
        this(256);
    }

    /**
     * Returns true if the argument is a character in this alphabet.
     *
     * @param  c the character
     * @return {@code true} if {@code c} is a character in this alphabet;
     *         {@code false} otherwise
     */
    public boolean contains(char c) {
        return inverse[c] != -1;
    }

    /**
     * Returns the number of characters in this alphabet (the radix).
     * 
     * @return the number of characters in this alphabet
     * @deprecated Replaced by {@link #radix()}.
     */
    @Deprecated
    public int R() {
        return R;
    }

    /**
     * Returns the number of characters in this alphabet (the radix).
     * 
     * @return the number of characters in this alphabet
     */
    public int radix() {
        return R;
    }

    /**
     * Returns the binary logarithm of the number of characters in this alphabet.
     * 
     * @return the binary logarithm (rounded up) of the number of characters in this alphabet
     */
    public int lgR() {
        int lgR = 0;
        for (int t = R-1; t >= 1; t /= 2)
            lgR++;
        return lgR;
    }

    /**
     * Returns the index corresponding to the argument character.
     * 
     * @param  c the character
     * @return the index corresponding to the character {@code c}
     * @throws IllegalArgumentException unless {@code c} is a character in this alphabet
     */
    public int toIndex(char c) {
        if (c >= inverse.length || inverse[c] == -1) {
            throw new IllegalArgumentException("Character " + c + " not in alphabet");
        }
        return inverse[c];
    }

    /**
     * Returns the indices corresponding to the argument characters.
     * 
     * @param  s the characters
     * @return the indices corresponding to the characters {@code s}
     * @throws IllegalArgumentException unless every character in {@code s}
     *         is a character in this alphabet
     */
    public int[] toIndices(String s) {
        char[] source = s.toCharArray();
        int[] target  = new int[s.length()];
        for (int i = 0; i < source.length; i++)
            target[i] = toIndex(source[i]);
        return target;
    }

    /**
     * Returns the character corresponding to the argument index.
     * 
     * @param  index the index
     * @return the character corresponding to the index {@code index}
     * @throws IllegalArgumentException unless {@code 0 <= index < R}
     */
    public char toChar(int index) {
        if (index < 0 || index >= R) {
            throw new IllegalArgumentException("index must be between 0 and " + R + ": " + index);
        }
        return alphabet[index];
    }

    /**
     * Returns the characters corresponding to the argument indices.
     * 
     * @param  indices the indices
     * @return the characters corresponding to the indices {@code indices}
     * @throws IllegalArgumentException unless {@code 0 < indices[i] < R}
     *         for every {@code i}
     */
    public String toChars(int[] indices) {
        StringBuilder s = new StringBuilder(indices.length);
        for (int i = 0; i < indices.length; i++)
            s.append(toChar(indices[i]));
        return s.toString();
    }

    /**
     * Unit tests the {@code Alphabet} data type.
     *
     * @param args the command-line arguments
     */
    public static void main(String[] args) {
        int[]  encoded1 = Alphabet.BASE64.toIndices("NowIsTheTimeForAllGoodMen");
        String decoded1 = Alphabet.BASE64.toChars(encoded1);
        StdOut.println(decoded1);
 
        int[]  encoded2 = Alphabet.DNA.toIndices("AACGAACGGTTTACCCCG");
        String decoded2 = Alphabet.DNA.toChars(encoded2);
        StdOut.println(decoded2);

        int[]  encoded3 = Alphabet.DECIMAL.toIndices("01234567890123456789");
        String decoded3 = Alphabet.DECIMAL.toChars(encoded3);
        StdOut.println(decoded3);
    }
}

/******************************************************************************
 *  Copyright 2002-2025, Robert Sedgewick and Kevin Wayne.
 *
 *  This file is part of algs4.jar, which accompanies the textbook
 *
 *      Algorithms, 4th edition by Robert Sedgewick and Kevin Wayne,
 *      Addison-Wesley Professional, 2011, ISBN 0-321-57351-X.
 *      http://algs4.cs.princeton.edu
 *
 *
 *  algs4.jar is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  algs4.jar is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with algs4.jar.  If not, see http://www.gnu.org/licenses.
 ******************************************************************************/


================================================
FILE: src/main/java/edu/princeton/cs/algs4/AmericanFlag.java
================================================
/******************************************************************************
 *  Compilation:  javac AmericanFlag.java
 *  Execution:    java AmericanFlag < input.txt
 *                java AmericanFlag int < input-non-negative-ints.txt
 *  Dependencies: StdIn.java StdOut.java Stack.java
 *  Data files:   https://algs4.cs.princeton.edu/51radix/words3.txt
 *                https://algs4.cs.princeton.edu/51radix/shells.txt
 *
 *  Sort an array of strings or integers in-place using American flag sort.
 *
 *  % java AmericanFlag < shells.txt
 *  are
 *  by
 *  sea
 *  seashells
 *  seashells
 *  sells
 *  sells
 *  she
 *  she
 *  shells
 *  shore
 *  surely
 *  the
 *  the
 *
 ******************************************************************************/

package edu.princeton.cs.algs4;

/**
 *  The {@code AmericanFlag} class provides static methods for sorting an
 *  array of extended ASCII strings or integers in-place using
 *  American flag sort. This is a non-recursive implementation.
 *  <p>
 *  For additional documentation,
 *  see <a href="https://algs4.cs.princeton.edu/51radix">Section 5.1</a> of
 *  <i>Algorithms, 4th Edition</i> by Robert Sedgewick and Kevin Wayne
 *  and <a href = "http://static.usenix.org/publications/compsystems/1993/win_mcilroy.pdf">
 *  Engineering Radix Sort</a> by McIlroy and Bostic.
 *  For a version that uses only one auxiliary array, see {@link AmericanFlagX}.
 *
 *  @author Robert Sedgewick
 *  @author Kevin Wayne
 *  @author Ivan Pesin
 */

public class AmericanFlag {
    private static final int BITS_PER_BYTE =   8;
    private static final int BITS_PER_INT  =  32;   // each Java int is 32 bits
    private static final int R             = 256;   // extend ASCII alphabet size
    private static final int CUTOFF        =  15;   // cutoff to insertion sort

    // do not instantiate
    private AmericanFlag() { }

    // return dth character of s, -1 if d = length of string
    private static int charAt(String s, int d) {
        assert d >= 0 && d <= s.length();
        if (d == s.length()) return -1;
        return s.charAt(d);
    }

    /**
     * Rearranges the array of extended ASCII strings in ascending order.
     * This is an unstable sorting algorithm.
     *
     * @param a the array to be sorted
     */
    public static void sort(String[] a) {
        sort(a, 0, a.length - 1);
    }

    // sort from a[lo] to a[hi], starting at the dth character
    public static void sort(String[] a, int lo, int hi) {
        // one-time allocation of data structures
        Stack<Integer> st = new Stack<Integer>();
        int[] first = new int[R+2];
        int[] next  = new int[R+2];
        int d = 0; // character index to sort by

        st.push(lo);
        st.push(hi);
        st.push(d);

        while (!st.isEmpty()) {
            d = st.pop();
            hi = st.pop();
            lo = st.pop();

            if (hi <= lo + CUTOFF) {
                insertion(a, lo, hi, d);
                continue;
            }

            // compute frequency counts
            for (int i = lo; i <= hi; i++) {
                int c = charAt(a[i], d) + 1; // account for -1 representing end-of-string
                first[c+1]++;
            }

            // first[c] = location of first string whose dth character = c
            first[0] = lo;
            for (int c = 0; c <= R; c++) {
                first[c+1] += first[c];

                if (c > 0 && first[c+1]-1 > first[c]) {
                    // add subproblem for character c (excludes sentinel c == 0)
                    st.push(first[c]);
                    st.push(first[c+1] - 1);
                    st.push(d+1);
                }
            }

            // next[c] = location to place next string whose dth character = c
            for (int c = 0; c < R+2; c++)
                next[c] = first[c];

            // permute data in place
            for (int k = lo; k <= hi; k++) {
                int c = charAt(a[k], d) + 1;
                while (first[c] > k) {
                    exch(a, k, next[c]++);
                    c = charAt(a[k], d) + 1;
                }
                next[c]++;
            }

            // clear first[] and next[] arrays
            for (int c = 0; c < R+2; c++) {
                first[c] = 0;
                next[c] = 0;
            }
        }
    }

    // insertion sort a[lo..hi], starting at dth character
    private static void insertion(String[] a, int lo, int hi, int d) {
        for (int i = lo; i <= hi; i++)
            for (int j = i; j > lo && less(a[j], a[j-1], d); j--)
                exch(a, j, j-1);
    }

    // exchange a[i] and a[j]
    private static void exch(String[] a, int i, int j) {
        String temp = a[i];
        a[i] = a[j];
        a[j] = temp;
    }

    // is v less than w, starting at character d
    private static boolean less(String v, String w, int d) {
        // assert v.substring(0, d).equals(w.substring(0, d));
        for (int i = d; i <  Math.min(v.length(), w.length()); i++) {
            if (v.charAt(i) < w.charAt(i)) return true;
            if (v.charAt(i) > w.charAt(i)) return false;
        }
        return v.length() < w.length();
    }

   /**
     * Rearranges the array of 32-bit integers in ascending order.
     * Currently, assumes that the integers are nonnegative.
     *
     * @param a the array to be sorted
     */
    public static void sort(int[] a) {
        sort(a, 0, a.length-1);
    }

    // MSD sort from a[lo] to a[hi]
    private static void sort(int[] a, int lo, int hi) {
        // one-time allocation of data structures
        Stack<Integer> st = new Stack<Integer>();
        int[] first = new int[R+1];
        int[] next  = new int[R+1];
        int mask = R - 1;   // 0xFF;
        int d = 0;          // byte to sort by

        st.push(lo);
        st.push(hi);
        st.push(d);

        while (!st.isEmpty()) {
            d = st.pop();
            hi = st.pop();
            lo = st.pop();

            if (hi <= lo + CUTOFF) {
                insertion(a, lo, hi, d);
                continue;
            }

            // compute frequency counts (need R = 256)
            int shift = BITS_PER_INT - BITS_PER_BYTE*d - BITS_PER_BYTE;
            for (int i = lo; i <= hi; i++) {
                int c = (a[i] >> shift) & mask;
                first[c+1]++;
            }

            // first[c] = location of first int whose dth byte = c
            first[0] = lo;
            for (int c = 0; c < R; c++) {
                first[c+1] += first[c];

                if (d < 3 && first[c+1]-1 > first[c]) {
                    // add subproblem for byte c
                    st.push(first[c]);
                    st.push(first[c+1] - 1);
                    st.push(d+1);
                }
            }

            // next[c] = location to place next string whose dth byte = c
            for (int c = 0; c < R+1; c++)
                next[c] = first[c];

            // permute data in place
            for (int k = lo; k <= hi; k++) {
                int c = (a[k] >> shift) & mask;
                while (first[c] > k) {
                    exch(a, k, next[c]++);
                    c = (a[k] >> shift) & mask;
                }
                next[c]++;
            }

            // clear first[] and next[] arrays
            for (int c = 0; c < R+1; c++) {
                first[c] = 0;
                next[c] = 0;
            }
        }
    }

    // insertion sort a[lo..hi], starting at dth byte
    private static void insertion(int[] a, int lo, int hi, int d) {
        for (int i = lo; i <= hi; i++)
            for (int j = i; j > lo && less(a[j], a[j-1], d); j--)
                exch(a, j, j-1);
    }

    // exchange a[i] and a[j]
    private static void exch(int[] a, int i, int j) {
        int temp = a[i];
        a[i] = a[j];
        a[j] = temp;
    }

    // is v less than w, starting at byte d
    private static boolean less(int v, int w, int d) {
        int mask = R - 1;   // 0xFF;
        for (int i = d; i < 4; i++) {
            int shift = BITS_PER_INT - BITS_PER_BYTE*i - BITS_PER_BYTE;
            int a = (v >> shift) & mask;
            int b = (w >> shift) & mask;
            if (a < b) return true;
            if (a > b) return false;
        }
        return false;
    }

    /**
     * Reads in a sequence of extended ASCII strings or non-negative ints from standard input;
     * American flag sorts them;
     * and prints them to standard output in ascending order.
     *
     * @param args the command-line arguments: "int" to read input as non-negative integers
     */
    public static void main(String[] args) {
        if (args.length > 0 && args[0].equals("int")) {
            int[] a = StdIn.readAllInts();
            sort(a);

            // print results
            for (int i = 0; i < a.length; i++)
                StdOut.println(a[i]);
        }

        else {
            String[] a = StdIn.readAllStrings();
            sort(a);
            // print results
            for (int i = 0; i < a.length; i++)
                StdOut.println(a[i]);
        }
    }
}


/******************************************************************************
 *  Copyright 2002-2025, Robert Sedgewick and Kevin Wayne.
 *
 *  This file is part of algs4.jar, which accompanies the textbook
 *
 *      Algorithms, 4th edition by Robert Sedgewick and Kevin Wayne,
 *      Addison-Wesley Professional, 2011, ISBN 0-321-57351-X.
 *      http://algs4.cs.princeton.edu
 *
 *
 *  algs4.jar is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  algs4.jar is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with algs4.jar.  If not, see http://www.gnu.org/licenses.
 ******************************************************************************/


================================================
FILE: src/main/java/edu/princeton/cs/algs4/AmericanFlagX.java
================================================
/******************************************************************************
 *  Compilation:  javac AmericanFlagX.java
 *  Execution:    java AmericanFlagX < input.txt
 *  Dependencies: StdIn.java StdOut.java Stack.java
 *  Data files:   https://algs4.cs.princeton.edu/51radix/words3.txt
 *                https://algs4.cs.princeton.edu/51radix/shells.txt
 *
 *  Sort an array of strings or integers in-place using American Flag sort.
 *
 *  % java AmericanFlagX < shells.txt
 *  are
 *  by
 *  sea
 *  seashells
 *  seashells
 *  sells
 *  sells
 *  she
 *  she
 *  shells
 *  shore
 *  surely
 *  the
 *  the
 *
 ******************************************************************************/

package edu.princeton.cs.algs4;

/**
 *  The {@code AmericanFlagX} class provides static methods for sorting an
 *  array of extended ASCII strings or integers in-place using
 *  American Flag sort. This implementation is non-recursive and uses only
 *  one auxiliary array.
 *  <p>
 *  For additional documentation,
 *  see <a href="https://algs4.cs.princeton.edu/51radix">Section 5.1</a> of
 *  <i>Algorithms, 4th Edition</i> by Robert Sedgewick and Kevin Wayne
 *  and <a href = "http://static.usenix.org/publications/compsystems/1993/win_mcilroy.pdf">
 *  Engineering Radix Sort</a> by McIlroy and Bostic.
 *  For a version that uses two auxiliary arrays, see {@link AmericanFlag}.
 *
 *  @author Ivan Pesin
 */

public class AmericanFlagX {
    private static final int R      = 256;   // extend ASCII alphabet size
    private static final int CUTOFF =  15;   // cutoff to insertion sort

    // do not instantiate
    private AmericanFlagX() { }

    // return dth character of s, -1 if d = length of string
    private static int charAt(String s, int d) {
        assert d >= 0 && d <= s.length();
        if (d == s.length()) return -1;
        return s.charAt(d);
    }

    /**
     * Rearranges the array of extended ASCII strings in ascending order.
     * This is an unstable in-place sorting algorithm.
     *
     * @param a the array to be sorted
     */
    public static void sort(String[] a) {
        sort(a, 0, a.length - 1);
    }

    // sort from a[lo] to a[hi], starting at the dth character
    public static void sort(String[] a, int lo, int hi) {
        // one-time allocation of data structures
        Stack<Integer> st = new Stack<Integer>();
        int[] count = new int[R+1];
        int d = 0; // character index to sort by

        st.push(lo);
        st.push(hi);
        st.push(d);

        while (!st.isEmpty()) {
            d = st.pop();
            hi = st.pop();
            lo = st.pop();

            if (hi <= lo + CUTOFF) {
                insertion(a, lo, hi, d);
                continue;
            }

            // compute frequency counts
            for (int i = lo; i <= hi; i++) {
                int c = charAt(a[i], d) + 1; // account for -1 representing end-of-string
                count[c]++;
            }

            // accumulate counts relative to a[0], so that
            // count[c] is the number of keys <= c
            count[0] += lo;
            for (int c = 0; c < R; c++) {
                count[c+1] += count[c];

                if (c > 0 && count[c+1]-1 > count[c]) {
                    // add subproblem for character c (excludes sentinel c == 0)
                    st.push(count[c]);
                    st.push(count[c+1]-1);
                    st.push(d+1);
                }
            }

            // permute data in place
            // for details and proof see Knuth Theorem 5.1.2B and ch 5.2 exercise 13.
            for (int r = hi; r >= lo; r--) {

                // locate element that must be shifted right of r
                int c = charAt(a[r], d) + 1;
                while (r >= lo && count[c]-1 <= r) {
                    if (count[c]-1 == r) count[c]--;
                    r--;
                    if (r >= lo) c = charAt(a[r], d) + 1;
                }

                // if r < lo the subarray is sorted.
                if (r < lo) break;

                // permute a[r] until correct element is in place
                while (--count[c] != r) {
                    exch(a, r, count[c]);
                    c = charAt(a[r], d) + 1;
                }
            }

            // clear count[] array
            for (int c = 0; c < R+1; c++)
                count[c] = 0;
        }
    }

    // insertion sort a[lo..hi], starting at dth character
    private static void insertion(String[] a, int lo, int hi, int d) {
        for (int i = lo; i <= hi; i++)
            for (int j = i; j > lo && less(a[j], a[j-1], d); j--)
                exch(a, j, j-1);
    }

    // exchange a[i] and a[j]
    private static void exch(String[] a, int i, int j) {
        String temp = a[i];
        a[i] = a[j];
        a[j] = temp;
    }

    // is v less than w, starting at character d
    private static boolean less(String v, String w, int d) {
        // assert v.substring(0, d).equals(w.substring(0, d));
        for (int i = d; i <  Math.min(v.length(), w.length()); i++) {
            if (v.charAt(i) < w.charAt(i)) return true;
            if (v.charAt(i) > w.charAt(i)) return false;
        }
        return v.length() < w.length();
    }

    /**
     * Reads in a sequence of extended ASCII strings or non-negative ints from standard input;
     * American flag sorts them;
     * and prints them to standard output in ascending order.
     *
     * @param args the command-line arguments
     */
    public static void main(String[] args) {
        String[] a = StdIn.readAllStrings();
        sort(a);
        // print results
        for (int i = 0; i < a.length; i++)
            StdOut.println(a[i]);
    }
}


/******************************************************************************
 *  Copyright 2002-2025, Robert Sedgewick and Kevin Wayne.
 *
 *  This file is part of algs4.jar, which accompanies the textbook
 *
 *      Algorithms, 4th edition by Robert Sedgewick and Kevin Wayne,
 *      Addison-Wesley Professional, 2011, ISBN 0-321-57351-X.
 *      http://algs4.cs.princeton.edu
 *
 *
 *  algs4.jar is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  algs4.jar is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with algs4.jar.  If not, see http://www.gnu.org/licenses.
 ******************************************************************************/


================================================
FILE: src/main/java/edu/princeton/cs/algs4/Arbitrage.java
================================================
/******************************************************************************
 *  Compilation:  javac Arbitrage.java
 *  Execution:    java Arbitrage < input.txt
 *  Dependencies: EdgeWeightedDigraph.java DirectedEdge.java
 *                BellmanFordSP.java
 *  Data file:    https://algs4.cs.princeton.edu/44sp/rates.txt
 *
 *  Arbitrage detection.
 *
 *  % more rates.txt
 *  5
 *  USD 1      0.741  0.657  1.061  1.005
 *  EUR 1.349  1      0.888  1.433  1.366
 *  GBP 1.521  1.126  1      1.614  1.538
 *  CHF 0.942  0.698  0.619  1      0.953
 *  CAD 0.995  0.732  0.650  1.049  1
 *
 *  % java Arbitrage < rates.txt
 *  1000.00000 USD =  741.00000 EUR
 *   741.00000 EUR = 1012.20600 CAD
 *  1012.20600 CAD = 1007.14497 USD
 *
 ******************************************************************************/

package edu.princeton.cs.algs4;

/**
 *  The {@code Arbitrage} class provides a client that finds an arbitrage
 *  opportunity in a currency exchange table by constructing a
 *  complete-digraph representation of the exchange table and then finding
 *  a negative cycle in the digraph.
 *  <p>
 *  This implementation uses the Bellman-Ford algorithm to find a
 *  negative cycle in the complete digraph.
 *  The running time is proportional to <em>V</em><sup>3</sup> in the
 *  worst case, where <em>V</em> is the number of currencies.
 *  <p>
 *  This code is guaranteed to find an arbitrage opportunity in a
 *  currency exchange table (or report that no such arbitrage
 *  opportunity exists) under the assumption that all arithmetic
 *  performed is without floating-point rounding error or arithmetic
 *  overflow. Since the code computes the logarithms of the edge weights,
 *  floating-point rounding error will be present, and it may fail on
 *  some pathological inputs.
 *  <p>
 *  For additional documentation,
 *  see <a href="https://algs4.cs.princeton.edu/44sp">Section 4.4</a> of
 *  <i>Algorithms, 4th Edition</i> by Robert Sedgewick and Kevin Wayne.
 *
 *  @author Robert Sedgewick
 *  @author Kevin Wayne
 */
public class Arbitrage {

    // this class cannot be instantiated
    private Arbitrage() { }

    /**
     *  Reads the currency exchange table from standard input and
     *  prints an arbitrage opportunity to standard output (if one exists).
     *
     * @param args the command-line arguments
     */
    public static void main(String[] args) {

        // V currencies
        int V = StdIn.readInt();
        String[] name = new String[V];

        // create complete network
        EdgeWeightedDigraph G = new EdgeWeightedDigraph(V);
        for (int v = 0; v < V; v++) {
            name[v] = StdIn.readString();
            for (int w = 0; w < V; w++) {
                double rate = StdIn.readDouble();
                DirectedEdge e = new DirectedEdge(v, w, -Math.log(rate));
                G.addEdge(e);
            }
        }

        // find negative cycle
        BellmanFordSP spt = new BellmanFordSP(G, 0);
        if (spt.hasNegativeCycle()) {
            double stake = 1000.0;
            for (DirectedEdge e : spt.negativeCycle()) {
                StdOut.printf("%10.5f %s ", stake, name[e.from()]);
                stake *= Math.exp(-e.weight());
                StdOut.printf("= %10.5f %s\n", stake, name[e.to()]);
            }
        }
        else {
            StdOut.println("No arbitrage opportunity");
        }
    }

}

/******************************************************************************
 *  Copyright 2002-2025, Robert Sedgewick and Kevin Wayne.
 *
 *  This file is part of algs4.jar, which accompanies the textbook
 *
 *      Algorithms, 4th edition by Robert Sedgewick and Kevin Wayne,
 *      Addison-Wesley Professional, 2011, ISBN 0-321-57351-X.
 *      http://algs4.cs.princeton.edu
 *
 *
 *  algs4.jar is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  algs4.jar is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with algs4.jar.  If not, see http://www.gnu.org/licenses.
 ******************************************************************************/


================================================
FILE: src/main/java/edu/princeton/cs/algs4/AssignmentProblem.java
================================================
/******************************************************************************
 *  Compilation:  javac AssignmentProblem.java
 *  Execution:    java AssignmentProblem n
 *  Dependencies: DijkstraSP.java DirectedEdge.java
 *
 *  Solve an n-by-n assignment problem in n^3 log n time using the
 *  successive shortest path algorithm.
 *
 ******************************************************************************/

package edu.princeton.cs.algs4;

/**
 *  The {@code AssignmentProblem} class represents a data type for computing
 *  an optimal solution to an <em>n</em>-by-<em>n</em> <em>assignment problem</em>.
 *  The assignment problem is to find a minimum weight matching in an
 *  edge-weighted complete bipartite graph.
 *  <p>
 *  The data type supplies methods for determining the optimal solution
 *  and the corresponding dual solution.
 *  <p>
 *  This implementation uses the <em>successive shortest paths algorithm</em>.
 *  The order of growth of the running time in the worst case is
 *  O(<em>n</em>^3 log <em>n</em>) to solve an <em>n</em>-by-<em>n</em>
 *  instance.
 *  <p>
 *  This computes correct results if all arithmetic performed is
 *  without floating-point rounding error or arithmetic overflow.
 *  This is the case if all edge weights are integers and if none of the
 *  intermediate results exceeds 2<sup>52</sup>.
 *  <p>
 *  For additional documentation, see
 *  <a href="https://algs4.cs.princeton.edu/65reductions">Section 6.5</a>
 *  <i>Algorithms, 4th Edition</i> by Robert Sedgewick and Kevin Wayne.
 *
 *  @author Robert Sedgewick
 *  @author Kevin Wayne
 */
public class AssignmentProblem {
    private static final double FLOATING_POINT_EPSILON = 1.0E-14;
    private static final int UNMATCHED = -1;

    private int n;              // number of rows and columns
    private double[][] weight;  // the n-by-n cost matrix
    private double minWeight;   // minimum value of any weight
    private double[] px;        // px[i] = dual variable for row i
    private double[] py;        // py[j] = dual variable for col j
    private int[] xy;           // xy[i] = j means i-j is a match
    private int[] yx;           // yx[j] = i means i-j is a match

    /**
     * Determines an optimal solution to the assignment problem.
     *
     * @param  weight the <em>n</em>-by-<em>n</em> matrix of weights
     * @throws IllegalArgumentException unless all weights are nonnegative
     * @throws IllegalArgumentException if {@code weight} is {@code null}
     */
    public AssignmentProblem(double[][] weight) {
        if (weight == null) throw new IllegalArgumentException("constructor argument is null");

        n = weight.length;
        this.weight = new double[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (Double.isNaN(weight[i][j]))
                    throw new IllegalArgumentException("weight " + i + "-" + j  + " is NaN");
                if (weight[i][j] < minWeight) minWeight = weight[i][j];
                this.weight[i][j] = weight[i][j];
            }
        }

        // dual variables
        px = new double[n];
        py = new double[n];

        // initial matching is empty
        xy = new int[n];
        yx = new int[n];
        for (int i = 0; i < n; i++)
             xy[i] = UNMATCHED;
        for (int j = 0; j < n; j++)
             yx[j] = UNMATCHED;

        // add n edges to matching
        for (int k = 0; k < n; k++) {
            assert isDualFeasible();
            assert isComplementarySlack();
            augment();
        }
        assert certifySolution();
    }

    // find shortest augmenting path and update
    private void augment() {

        // build residual graph
        EdgeWeightedDigraph G = new EdgeWeightedDigraph(2*n+2);
        int s = 2*n, t = 2*n+1;
        for (int i = 0; i < n; i++) {
            if (xy[i] == UNMATCHED)
                G.addEdge(new DirectedEdge(s, i, 0.0));
        }
        for (int j = 0; j < n; j++) {
            if (yx[j] == UNMATCHED)
                G.addEdge(new DirectedEdge(n+j, t, py[j]));
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (xy[i] == j) G.addEdge(new DirectedEdge(n+j, i, 0.0));
                else            G.addEdge(new DirectedEdge(i, n+j, reducedCost(i, j)));
            }
        }

        // compute shortest path from s to every other vertex
        DijkstraSP spt = new DijkstraSP(G, s);

        // augment along alternating path
        for (DirectedEdge e : spt.pathTo(t)) {
            int i = e.from(), j = e.to() - n;
            if (i < n) {
                xy[i] = j;
                yx[j] = i;
            }
        }

        // update dual variables
        for (int i = 0; i < n; i++)
            px[i] += spt.distTo(i);
        for (int j = 0; j < n; j++)
            py[j] += spt.distTo(n+j);
    }

    // reduced cost of i-j
    // (subtracting off minWeight re-weights all weights to be non-negative)
    private double reducedCost(int i, int j) {
        double reducedCost = (weight[i][j] - minWeight) + px[i] - py[j];

        // to avoid issues with floating-point precision
        double magnitude = Math.abs(weight[i][j]) + Math.abs(px[i]) + Math.abs(py[j]);
        if (Math.abs(reducedCost) <= FLOATING_POINT_EPSILON * magnitude) return 0.0;

        assert reducedCost >= 0.0;
        return reducedCost;
    }

    /**
     * Returns the dual optimal value for the specified row.
     *
     * @param  i the row index
     * @return the dual optimal value for row {@code i}
     * @throws IllegalArgumentException unless {@code 0 <= i < n}
     *
     */
    // dual variable for row i
    public double dualRow(int i) {
        validate(i);
        return px[i];
    }

    /**
     * Returns the dual optimal value for the specified column.
     *
     * @param  j the column index
     * @return the dual optimal value for column {@code j}
     * @throws IllegalArgumentException unless {@code 0 <= j < n}
     *
     */
    public double dualCol(int j) {
        validate(j);
        return py[j];
    }

    /**
     * Returns the column associated with the specified row in the optimal solution.
     *
     * @param  i the row index
     * @return the column matched to row {@code i} in the optimal solution
     * @throws IllegalArgumentException unless {@code 0 <= i < n}
     *
     */
    public int sol(int i) {
        validate(i);
        return xy[i];
    }

    /**
     * Returns the total weight of the optimal solution
     *
     * @return the total weight of the optimal solution
     *
     */
    public double weight() {
        double total = 0.0;
        for (int i = 0; i < n; i++) {
            if (xy[i] != UNMATCHED)
                total += weight[i][xy[i]];
        }
        return total;
    }

    private void validate(int i) {
        if (i < 0 || i >= n) throw new IllegalArgumentException("index is not between 0 and " + (n-1) + ": " + i);
    }


    /**************************************************************************
     *
     *  The code below is solely for testing correctness of the data type.
     *
     **************************************************************************/

    // check that dual variables are feasible
    private boolean isDualFeasible() {
        // check that all edges have >= 0 reduced cost
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (reducedCost(i, j) < 0) {
                    StdOut.println("Dual variables are not feasible");
                    return false;
                }
            }
        }
        return true;
    }

    // check that primal and dual variables are complementary slack
    private boolean isComplementarySlack() {

        // check that all matched edges have 0-reduced cost
        for (int i = 0; i < n; i++) {
            if ((xy[i] != UNMATCHED) && (reducedCost(i, xy[i]) != 0)) {
                StdOut.println("Primal and dual variables are not complementary slack");
                return false;
            }
        }
        return true;
    }

    // check that primal variables are a perfect matching
    private boolean isPerfectMatching() {

        // check that xy[] is a perfect matching
        boolean[] perm = new boolean[n];
        for (int i = 0; i < n; i++) {
            if (perm[xy[i]]) {
                StdOut.println("Not a perfect matching");
                return false;
            }
            perm[xy[i]] = true;
        }

        // check that xy[] and yx[] are inverses
        for (int j = 0; j < n; j++) {
            if (xy[yx[j]] != j) {
                StdOut.println("xy[] and yx[] are not inverses");
                return false;
            }
        }
        for (int i = 0; i < n; i++) {
            if (yx[xy[i]] != i) {
                StdOut.println("xy[] and yx[] are not inverses");
                return false;
            }
        }

        return true;
    }

    // check optimality conditions
    private boolean certifySolution() {
        return isPerfectMatching() && isDualFeasible() && isComplementarySlack();
    }

    /**
     * Unit tests the {@code AssignmentProblem} data type.
     * Takes a command-line argument n; creates a random n-by-n matrix;
     * solves the n-by-n assignment problem; and prints the optimal
     * solution.
     *
     * @param args the command-line arguments
     */
    public static void main(String[] args) {

        // create random n-by-n matrix
        int n = Integer.parseInt(args[0]);
        double[][] weight = new double[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                weight[i][j] = StdRandom.uniformInt(900) + 100;  // 3 digits
            }
        }

        // solve assignment problem
        AssignmentProblem assignment = new AssignmentProblem(weight);
        StdOut.printf("weight = %.0f\n", assignment.weight());
        StdOut.println();

        // print n-by-n matrix and optimal solution
        if (n >= 20) return;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (j == assignment.sol(i))
                    StdOut.printf("*%.0f ", weight[i][j]);
                else
                    StdOut.printf(" %.0f ", weight[i][j]);
            }
            StdOut.println();
        }
    }

}

/******************************************************************************
 *  Copyright 2002-2025, Robert Sedgewick and Kevin Wayne.
 *
 *  This file is part of algs4.jar, which accompanies the textbook
 *
 *      Algorithms, 4th edition by Robert Sedgewick and Kevin Wayne,
 *      Addison-Wesley Professional, 2011, ISBN 0-321-57351-X.
 *      http://algs4.cs.princeton.edu
 *
 *
 *  algs4.jar is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  algs4.jar is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with algs4.jar.  If not, see http://www.gnu.org/licenses.
 ******************************************************************************/


================================================
FILE: src/main/java/edu/princeton/cs/algs4/Average.java
================================================
/******************************************************************************
 *  Compilation:  javac Average.java
 *  Execution:    java Average < data.txt
 *  Dependencies: StdIn.java StdOut.java
 *
 *  Reads in a sequence of real numbers, and computes their average.
 *
 *  % java Average
 *  10.0 5.0 6.0
 *  3.0 7.0 32.0
 *  [Ctrl-d]
 *  Average is 10.5
 *
 *  Note [Ctrl-d] signifies the end of file on Unix.
 *  On windows use [Ctrl-z].
 *
 ******************************************************************************/

package edu.princeton.cs.algs4;

/**
 *  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="https://algs4.cs.princeton.edu/11model">Section 1.1</a> of
 *  <i>Algorithms, 4th Edition</i> by Robert Sedgewick and Kevin Wayne.
 *
 *  @author Robert Sedgewick
 *  @author Kevin Wayne
 */
public class Average {

    // this class should not be instantiated
    private Average() { }

    /**
     * Reads in a sequence of real numbers from standard input and prints
     * out their average to standard output.
     *
     * @param args the command-line arguments
     */
    public static void main(String[] args) {
        int count = 0;       // number input values
        double sum = 0.0;    // sum of input values

        // read data and compute statistics
        while (!StdIn.isEmpty()) {
            double value = StdIn.readDouble();
            sum += value;
            count++;
        }

        // compute the average
        double average = sum / count;

        // print results
        StdOut.println("Average is " + average);
    }
}

/******************************************************************************
 *  Copyright 2002-2025, Robert Sedgewick and Kevin Wayne.
 *
 *  This file is part of algs4.jar, which accompanies the textbook
 *
 *      Algorithms, 4th edition by Robert Sedgewick and Kevin Wayne,
 *      Addison-Wesley Professional, 2011, ISBN 0-321-57351-X.
 *      http://algs4.cs.princeton.edu
 *
 *
 *  algs4.jar is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  algs4.jar is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with algs4.jar.  If not, see http://www.gnu.org/licenses.
 ******************************************************************************/


================================================
FILE: src/main/java/edu/princeton/cs/algs4/BST.java
================================================
/******************************************************************************
 *  Compilation:  javac BST.java
 *  Execution:    java BST
 *  Dependencies: StdIn.java StdOut.java Queue.java
 *  Data files:   https://algs4.cs.princeton.edu/32bst/tinyST.txt
 *
 *  A symbol table implemented with a binary search tree.
 *
 *  % more tinyST.txt
 *  S E A R C H E X A M P L E
 *
 *  % java BST < tinyST.txt
 *  A 8
 *  C 4
 *  E 12
 *  H 5
 *  L 11
 *  M 9
 *  P 10
 *  R 3
 *  S 0
 *  X 7
 *
 ******************************************************************************/

package edu.princeton.cs.algs4;

import java.util.NoSuchElementException;

/**
 *  The {@code BST} class represents an ordered symbol table of generic
 *  key-value pairs.
 *  It supports the usual <em>put</em>, <em>get</em>, <em>contains</em>,
 *  <em>delete</em>, <em>size</em>, and <em>is-empty</em> methods.
 *  It also provides ordered methods for finding the <em>minimum</em>,
 *  <em>maximum</em>, <em>floor</em>, <em>select</em>, <em>ceiling</em>.
 *  It also provides a <em>keys</em> method for iterating over all of the keys.
 *  A symbol table implements the <em>associative array</em> abstraction:
 *  when associating a value with a key that is already in the symbol table,
 *  the convention is to replace the old value with the new value.
 *  Unlike {@link java.util.Map}, this class uses the convention that
 *  values cannot be {@code null}—setting the
 *  value associated with a key to {@code null} is equivalent to deleting the key
 *  from the symbol table.
 *  <p>
 *  It requires that
 *  the key type implements the {@code Comparable} interface and calls the
 *  {@code compareTo()} and method to compare two keys. It does not call either
 *  {@code equals()} or {@code hashCode()}.
 *  <p>
 *  This implementation uses an (unbalanced) <em>binary search tree</em>.
 *  The <em>put</em>, <em>contains</em>, <em>remove</em>, <em>minimum</em>,
 *  <em>maximum</em>, <em>ceiling</em>, <em>floor</em>, <em>select</em>, and
 *  <em>rank</em>  operations each take &Theta;(<em>n</em>) time in the worst
 *  case, where <em>n</em> is the number of key-value pairs.
 *  The <em>size</em> and <em>is-empty</em> operations take &Theta;(1) time.
 *  The keys method takes &Theta;(<em>n</em>) time in the worst case.
 *  Construction takes &Theta;(1) time.
 *  <p>
 *  For alternative implementations of the symbol table API, see {@link ST},
 *  {@link BinarySearchST}, {@link SequentialSearchST}, {@link RedBlackBST},
 *  {@link SeparateChainingHashST}, and {@link LinearProbingHashST},
 *  For additional documentation, see
 *  <a href="https://algs4.cs.princeton.edu/32bst">Section 3.2</a> of
 *  <i>Algorithms, 4th Edition</i> by Robert Sedgewick and Kevin Wayne.
 *
 *  @author Robert Sedgewick
 *  @author Kevin Wayne
 */
public class BST<Key extends Comparable<Key>, Value> {
    private Node root;             // root of BST

    private class Node {
        private Key key;           // sorted by key
        private Value val;         // associated data
        private Node left, right;  // left and right subtrees
        private int size;          // number of nodes in subtree

        public Node(Key key, Value val, int size) {
            this.key = key;
            this.val = val;
            this.size = size;
        }
    }

    /**
     * Initializes an empty symbol table.
     */
    public BST() {
    }

    /**
     * Returns true if this symbol table is empty.
     * @return {@code true} if this symbol table is empty; {@code false} otherwise
     */
    public boolean isEmpty() {
        return size() == 0;
    }

    /**
     * Returns the number of key-value pairs in this symbol table.
     * @return the number of key-value pairs in this symbol table
     */
    public int size() {
        return size(root);
    }

    // return number of key-value pairs in BST rooted at x
    private int size(Node node) {
        if (node == null) return 0;
        else return node.size;
    }

    /**
     * Does this symbol table contain the given key?
     *
     * @param  key the key
     * @return {@code true} if this symbol table contains {@code key} and
     *         {@code false} otherwise
     * @throws IllegalArgumentException if {@code key} is {@code null}
     */
    public boolean contains(Key key) {
        if (key == null) throw new IllegalArgumentException("argument to contains() is null");
        return get(key) != null;
    }

    /**
     * Returns the value associated with the given key.
     *
     * @param  key the key
     * @return the value associated with the given key if the key is in the symbol table
     *         and {@code null} if the key is not in the symbol table
     * @throws IllegalArgumentException if {@code key} is {@code null}
     */
    public Value get(Key key) {
        return get(root, key);
    }

    private Value get(Node node, Key key) {
        if (key == null) throw new IllegalArgumentException("calls get() with a null key");
        if (node == null) return null;
        int cmp = key.compareTo(node.key);
        if      (cmp < 0) return get(node.left, key);
        else if (cmp > 0) return get(node.right, key);
        else              return node.val;
    }

    /**
     * Inserts the specified key-value pair into the symbol table, overwriting the old
     * value with the new value if the symbol table already contains the specified key.
     * Deletes the specified key (and its associated value) from this symbol table
     * if the specified value is {@code null}.
     *
     * @param  key the key
     * @param  val the value
     * @throws IllegalArgumentException if {@code key} is {@code null}
     */
    public void put(Key key, Value val) {
        if (key == null) throw new IllegalArgumentException("calls put() with a null key");
        if (val == null) {
            delete(key);
            return;
        }
        root = put(root, key, val);
        assert check();
    }

    private Node put(Node node, Key key, Value val) {
        if (node == null) return new Node(key, val, 1);
        int cmp = key.compareTo(node.key);
        if      (cmp < 0) node.left  = put(node.left,  key, val);
        else if (cmp > 0) node.right = put(node.right, key, val);
        else              node.val   = val;
        node.size = 1 + size(node.left) + size(node.right);
        return node;
    }


    /**
     * Removes the smallest key and associated value from the symbol table.
     *
     * @throws NoSuchElementException if the symbol table is empty
     */
    public void deleteMin() {
        if (isEmpty()) throw new NoSuchElementException("Symbol table underflow");
        root = deleteMin(root);
        assert check();
    }

    private Node deleteMin(Node node) {
        if (node.left == null) return node.right;
        node.left = deleteMin(node.left);
        node.size = size(node.left) + size(node.right) + 1;
        return node;
    }

    /**
     * Removes the largest key and associated value from the symbol table.
     *
     * @throws NoSuchElementException if the symbol table is empty
     */
    public void deleteMax() {
        if (isEmpty()) throw new NoSuchElementException("Symbol table underflow");
        root = deleteMax(root);
        assert check();
    }

    private Node deleteMax(Node node) {
        if (node.right == null) return node.left;
        node.right = deleteMax(node.right);
        node.size = size(node.left) + size(node.right) + 1;
        return node;
    }

    /**
     * Removes the specified key and its associated value from this symbol table
     * (if the key is in this symbol table).
     *
     * @param  key the key
     * @throws IllegalArgumentException if {@code key} is {@code null}
     */
    public void delete(Key key) {
        if (key == null) throw new IllegalArgumentException("calls delete() with a null key");
        root = delete(root, key);
        assert check();
    }

    private Node delete(Node node, Key key) {
        if (node == null) return null;

        int cmp = key.compareTo(node.key);
        if      (cmp < 0) node.left  = delete(node.left,  key);
        else if (cmp > 0) node.right = delete(node.right, key);
        else {
            if (node.right == null) return node.left;
            if (node.left  == null) return node.right;
            Node temp = node;
            node = min(temp.right);
            node.right = deleteMin(temp.right);
            node.left = temp.left;
        }
        node.size = size(node.left) + size(node.right) + 1;
        return node;
    }


    /**
     * Returns the smallest key in the symbol table.
     *
     * @return the smallest key in the symbol table
     * @throws NoSuchElementException if the symbol table is empty
     */
    public Key min() {
        if (isEmpty()) throw new NoSuchElementException("calls min() with empty symbol table");
        return min(root).key;
    }

    private Node min(Node node) {
        if (node.left == null) return node;
        else                   return min(node.left);
    }

    /**
     * Returns the largest key in the symbol table.
     *
     * @return the largest key in the symbol table
     * @throws NoSuchElementException if the symbol table is empty
     */
    public Key max() {
        if (isEmpty()) throw new NoSuchElementException("calls max() with empty symbol table");
        return max(root).key;
    }

    private Node max(Node node) {
        if (node.right == null) return node;
        else                    return max(node.right);
    }

    /**
     * Returns the largest key in the symbol table less than or equal to {@code key}.
     *
     * @param  key the key
     * @return the largest key in the symbol table less than or equal to {@code key}
     * @throws NoSuchElementException if there is no such key
     * @throws IllegalArgumentException if {@code key} is {@code null}
     */
    public Key floor(Key key) {
        if (key == null) throw new IllegalArgumentException("argument to floor() is null");
        if (isEmpty()) throw new NoSuchElementException("calls floor() with empty symbol table");
        Node node = floor(root, key);
        if (node == null) throw new NoSuchElementException("argument to floor() is too small");
        else return node.key;
    }

    private Node floor(Node node, Key key) {
        if (node == null) return null;
        int cmp = key.compareTo(node.key);
        if (cmp == 0) return node;
        if (cmp <  0) return floor(node.left, key);
        Node t = floor(node.right, key);
        if (t != null) return t;
        else return node;
    }

    public Key floor2(Key key) {
        Key floor = floor2(root, key, null);
        if (floor == null) throw new NoSuchElementException("argument to floor() is too small");
        else return floor;

    }

    private Key floor2(Node node, Key key, Key champ) {
        if (node == null) return champ;
        int cmp = key.compareTo(node.key);
        if      (cmp  < 0) return floor2(node.left, key, champ);
        else if (cmp  > 0) return floor2(node.right, key, node.key);
        else               return node.key;
    }

    /**
     * Returns the smallest key in the symbol table greater than or equal to {@code key}.
     *
     * @param  key the key
     * @return the smallest key in the symbol table greater than or equal to {@code key}
     * @throws NoSuchElementException if there is no such key
     * @throws IllegalArgumentException if {@code key} is {@code null}
     */
    public Key ceiling(Key key) {
        if (key == null) throw new IllegalArgumentException("argument to ceiling() is null");
        if (isEmpty()) throw new NoSuchElementException("calls ceiling() with empty symbol table");
        Node node = ceiling(root, key);
        if (node == null) throw new NoSuchElementException("argument to ceiling() is too large");
        else return node.key;
    }

    private Node ceiling(Node node, Key key) {
        if (node == null) return null;
        int cmp = key.compareTo(node.key);
        if (cmp == 0) return node;
        if (cmp < 0) {
            Node t = ceiling(node.left, key);
            if (t != null) return t;
            else return node;
        }
        return ceiling(node.right, key);
    }

    /**
     * Return the key in the symbol table of a given {@code rank}.
     * This key has the property that there are {@code rank} keys in
     * the symbol table that are smaller. In other words, this key is the
     * ({@code rank}+1)st smallest key in the symbol table.
     *
     * @param  rank the order statistic
     * @return the key in the symbol table of given {@code rank}
     * @throws IllegalArgumentException unless {@code rank} is between 0 and
     *        <em>n</em>–1
     */
    public Key select(int rank) {
        if (rank < 0 || rank >= size()) {
            throw new IllegalArgumentException("argument to select() is invalid: " + rank);
        }
        return select(root, rank);
    }

    // Return key in BST rooted at x of given rank.
    // Precondition: rank is in legal range.
    private Key select(Node node, int rank) {
        if (node == null) return null;
        int leftSize = size(node.left);
        if      (leftSize > rank) return select(node.left,  rank);
        else if (leftSize < rank) return select(node.right, rank - leftSize - 1);
        else                      return node.key;
    }

    /**
     * Return the number of keys in the symbol table strictly less than {@code key}.
     *
     * @param  key the key
     * @return the number of keys in the symbol table strictly less than {@code key}
     * @throws IllegalArgumentException if {@code key} is {@code null}
     */
    public int rank(Key key) {
        if (key == null) throw new IllegalArgumentException("argument to rank() is null");
        return rank(key, root);
    }

    // Number of keys in the subtree less than key.
    private int rank(Key key, Node node) {
        if (node == null) return 0;
        int cmp = key.compareTo(node.key);
        if      (cmp < 0) return rank(key, node.left);
        else if (cmp > 0) return 1 + size(node.left) + rank(key, node.right);
        else              return size(node.left);
    }

    /**
     * Returns all keys in the symbol table in ascending order,
     * as an {@code Iterable}.
     * To iterate over all of the keys in the symbol table named {@code st},
     * use the foreach notation: {@code for (Key key : st.keys())}.
     *
     * @return all keys in the symbol table in ascending order
     */
    public Iterable<Key> keys() {
        if (isEmpty()) return new Queue<Key>();
        return keys(min(), max());
    }

    /**
     * Returns all keys in the symbol table in the given range
     * in ascending order, as an {@code Iterable}.
     *
     * @param  lo minimum endpoint
     * @param  hi maximum endpoint
     * @return all keys in the symbol table between {@code lo}
     *         (inclusive) and {@code hi} (inclusive) in ascending order
     * @throws IllegalArgumentException if either {@code lo} or {@code hi}
     *         is {@code null}
     */
    public Iterable<Key> keys(Key lo, Key hi) {
        if (lo == null) throw new IllegalArgumentException("first argument to keys() is null");
        if (hi == null) throw new IllegalArgumentException("second argument to keys() is null");

        Queue<Key> queue = new Queue<Key>();
        keys(root, queue, lo, hi);
        return queue;
    }

    private void keys(Node node, Queue<Key> queue, Key lo, Key hi) {
        if (node == null) return;
        int cmplo = lo.compareTo(node.key);
        int cmphi = hi.compareTo(node.key);
        if (cmplo < 0) keys(node.left, queue, lo, hi);
        if (cmplo <= 0 && cmphi >= 0) queue.enqueue(node.key);
        if (cmphi > 0) keys(node.right, queue, lo, hi);
    }

    /**
     * Returns the number of keys in the symbol table in the given range.
     *
     * @param  lo minimum endpoint
     * @param  hi maximum endpoint
     * @return the number of keys in the symbol table between {@code lo}
     *         (inclusive) and {@code hi} (inclusive)
     * @throws IllegalArgumentException if either {@code lo} or {@code hi}
     *         is {@code null}
     */
    public int size(Key lo, Key hi) {
        if (lo == null) throw new IllegalArgumentException("first argument to size() is null");
        if (hi == null) throw new IllegalArgumentException("second argument to size() is null");

        if (lo.compareTo(hi) > 0) return 0;
        if (contains(hi)) return rank(hi) - rank(lo) + 1;
        else              return rank(hi) - rank(lo);
    }

    /**
     * Returns the height of the BST (for debugging).
     *
     * @return the height of the BST (a 1-node tree has height 0)
     */
    public int height() {
        return height(root);
    }
    private int height(Node node) {
        if (node == null) return -1;
        return 1 + Math.max(height(node.left), height(node.right));
    }

    /**
     * Returns the keys in the BST in level order (for debugging).
     *
     * @return the keys in the BST in level order traversal
     */
    public Iterable<Key> levelOrder() {
        Queue<Key> keys = new Queue<Key>();
        Queue<Node> queue = new Queue<Node>();
        queue.enqueue(root);
        while (!queue.isEmpty()) {
            Node node = queue.dequeue();
            if (node == null) continue;
            keys.enqueue(node.key);
            queue.enqueue(node.left);
            queue.enqueue(node.right);
        }
        return keys;
    }

  /*************************************************************************
    *  Check integrity of BST data structure.
    ***************************************************************************/
    private boolean check() {
        if (!isBST())            StdOut.println("Not in symmetric order");
        if (!isSizeConsistent()) StdOut.println("Subtree counts not consistent");
        if (!isRankConsistent()) StdOut.println("Ranks not consistent");
        return isBST() && isSizeConsistent() && isRankConsistent();
    }

    // does this binary tree satisfy symmetric order?
    // Note: this test also ensures that data structure is a binary tree since order is strict
    private boolean isBST() {
        return isBST(root, null, null);
    }

    // is the tree rooted at x a BST with all keys strictly between min and max
    // (if min or max is null, treat as empty constraint)
    // Credit: elegant solution due to Bob Dondero
    private boolean isBST(Node node, Key min, Key max) {
        if (node == null) return true;
        if (min != null && node.key.compareTo(min) <= 0) return false;
        if (max != null && node.key.compareTo(max) >= 0) return false;
        return isBST(node.left, min, node.key) && isBST(node.right, node.key, max);
    }

    // are the size fields correct?
    private boolean isSizeConsistent() { return isSizeConsistent(root); }
    private boolean isSizeConsistent(Node node) {
        if (node == null) return true;
        if (node.size != size(node.left) + size(node.right) + 1) return false;
        return isSizeConsistent(node.left) && isSizeConsistent(node.right);
    }

    // check that ranks are consistent
    private boolean isRankConsistent() {
        for (int i = 0; i < size(); i++)
            if (i != rank(select(i))) return false;
        for (Key key : keys())
            if (key.compareTo(select(rank(key))) != 0) return false;
        return true;
    }


    /**
     * Unit tests the {@code BST} data type.
     *
     * @param args the command-line arguments
     */
    public static void main(String[] args) {
        BST<String, Integer> st = new BST<String, Integer>();
        for (int i = 0; !StdIn.isEmpty(); i++) {
            String key = StdIn.readString();
            st.put(key, i);
        }

        for (String s : st.levelOrder())
            StdOut.println(s + " " + st.get(s));

        StdOut.println();

        for (String s : st.keys())
            StdOut.println(s + " " + st.get(s));
    }
}

/******************************************************************************
 *  Copyright 2002-2025, Robert Sedgewick and Kevin Wayne.
 *
 *  This file is part of algs4.jar, which accompanies the textbook
 *
 *      Algorithms, 4th edition by Robert Sedgewick and Kevin Wayne,
 *      Addison-Wesley Professional, 2011, ISBN 0-321-57351-X.
 *      http://algs4.cs.princeton.edu
 *
 *
 *  algs4.jar is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  algs4.jar is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with algs4.jar.  If not, see http://www.gnu.org/licenses.
 ******************************************************************************/


================================================
FILE: src/main/java/edu/princeton/cs/algs4/BTree.java
================================================
/******************************************************************************
 *  Compilation:  javac BTree.java
 *  Execution:    java BTree
 *  Dependencies: StdOut.java
 *
 *  B-tree.
 *
 *  Limitations
 *  -----------
 *   -  Assumes M is even and M >= 4
 *   -  should b be an array of children or list (it would help with
 *      casting to make it a list)
 *
 ******************************************************************************/

package edu.princeton.cs.algs4;

/**
 *  The {@code BTree} class represents an ordered symbol table of generic
 *  key-value pairs.
 *  It supports the <em>put</em>, <em>get</em>, <em>contains</em>,
 *  <em>size</em>, and <em>is-empty</em> methods.
 *  A symbol table implements the <em>associative array</em> abstraction:
 *  when associating a value with a key that is already in the symbol table,
 *  the convention is to replace the old value with the new value.
 *  Unlike {@link java.util.Map}, this class uses the convention that
 *  values cannot be {@code null}—setting the
 *  value associated with a key to {@code null} is equivalent to deleting the key
 *  from the symbol table.
 *  <p>
 *  This implementation uses a B-tree. It requires that
 *  the key type implements the {@code Comparable} interface and calls the
 *  {@code compareTo()} and method to compare two keys. It does not call either
 *  {@code equals()} or {@code hashCode()}.
 *  The <em>get</em>, <em>put</em>, and <em>contains</em> operations
 *  each make log<sub><em>m</em></sub>(<em>n</em>) probes in the worst case,
 *  where <em>n</em> is the number of key-value pairs
 *  and <em>m</em> is the branching factor.
 *  The <em>size</em>, and <em>is-empty</em> operations take constant time.
 *  Construction takes constant time.
 *  <p>
 *  For additional documentation, see
 *  <a href="https://algs4.cs.princeton.edu/62btree">Section 6.2</a> of
 *  <i>Algorithms, 4th Edition</i> by Robert Sedgewick and Kevin Wayne.
 */
public class BTree<Key extends Comparable<Key>, Value>  {
    // max children per B-tree node = M-1
    // (must be even and greater than 2)
    private static final int M = 4;

    private Node root;       // root of the B-tree
    private int height;      // height of the B-tree
    private int n;           // number of key-value pairs in the B-tree

    // helper B-tree node data type
    private static final class Node {
        private int m;                             // number of children
        private Entry[] children = new Entry[M];   // the array of children

        // create a node with k children
        private Node(int k) {
            m = k;
        }
    }

    // internal nodes: only use key and next
    // external nodes: only use key and value
    private static class Entry {
        private Comparable key;
        private Object val;
        private Node next;     // helper field to iterate over array entries
        public Entry(Comparable key, Object val, Node next) {
            this.key  = key;
            this.val  = val;
            this.next = next;
        }
    }

    /**
     * Initializes an empty B-tree.
     */
    public BTree() {
        root = new Node(0);
    }

    /**
     * Returns true if this symbol table is empty.
     * @return {@code true} if this symbol table is empty; {@code false} otherwise
     */
    public boolean isEmpty() {
        return size() == 0;
    }

    /**
     * Returns the number of key-value pairs in this symbol table.
     * @return the number of key-value pairs in this symbol table
     */
    public int size() {
        return n;
    }

    /**
     * Returns the height of this B-tree (for debugging).
     *
     * @return the height of this B-tree
     */
    public int height() {
        return height;
    }


    /**
     * Returns the value associated with the given key.
     *
     * @param  key the key
     * @return the value associated with the given key if the key is in the symbol table
     *         and {@code null} if the key is not in the symbol table
     * @throws IllegalArgumentException if {@code key} is {@code null}
     */
    public Value get(Key key) {
        if (key == null) throw new IllegalArgumentException("argument to get() is null");
        return search(root, key, height);
    }

    private Value search(Node x, Key key, int ht) {
        Entry[] children = x.children;

        // external node
        if (ht == 0) {
            for (int j = 0; j < x.m; j++) {
                if (eq(key, children[j].key)) return (Value) children[j].val;
            }
        }

        // internal node
        else {
            for (int j = 0; j < x.m; j++) {
                if (j+1 == x.m || less(key, children[j+1].key))
                    return search(children[j].next, key, ht-1);
            }
        }
        return null;
    }


    /**
     * Inserts the key-value pair into the symbol table, overwriting the old value
     * with the new value if the key is already in the symbol table.
     * If the value is {@code null}, this effectively deletes the key from the symbol table.
     *
     * @param  key the key
     * @param  val the value
     * @throws IllegalArgumentException if {@code key} is {@code null}
     */
    public void put(Key key, Value val) {
        if (key == null) throw new IllegalArgumentException("argument key to put() is null");
        Node u = insert(root, key, val, height);
        n++;
        if (u == null) return;

        // need to split root
        Node t = new Node(2);
        t.children[0] = new Entry(root.children[0].key, null, root);
        t.children[1] = new Entry(u.children[0].key, null, u);
        root = t;
        height++;
    }

    private Node insert(Node h, Key key, Value val, int ht) {
        int j;
        Entry t = new Entry(key, val, null);

        // external node
        if (ht == 0) {
            for (j = 0; j < h.m; j++) {
                if (less(key, h.children[j].key)) break;
            }
        }

        // internal node
        else {
            for (j = 0; j < h.m; j++) {
                if ((j+1 == h.m) || less(key, h.children[j+1].key)) {
                    Node u = insert(h.children[j++].next, key, val, ht-1);
                    if (u == null) return null;
                    t.key = u.children[0].key;
                    t.val = null;
                    t.next = u;
                    break;
                }
            }
        }

        for (int i = h.m; i > j; i--)
            h.children[i] = h.children[i-1];
        h.children[j] = t;
        h.m++;
        if (h.m < M) return null;
        else         return split(h);
    }

    // split node in half
    private Node split(Node h) {
        Node t = new Node(M/2);
        h.m = M/2;
        for (int j = 0; j < M/2; j++)
            t.children[j] = h.children[M/2+j];
        return t;
    }

    /**
     * Returns a string representation of this B-tree (for debugging).
     *
     * @return a string representation of this B-tree.
     */
    public String toString() {
        return toString(root, height, "") + "\n";
    }

    private String toString(Node h, int ht, String indent) {
        StringBuilder s = new StringBuilder();
        Entry[] children = h.children;

        if (ht == 0) {
            for (int j = 0; j < h.m; j++) {
                s.append(indent + children[j].key + " " + children[j].val + "\n");
            }
        }
        else {
            for (int j = 0; j < h.m; j++) {
                if (j > 0) s.append(indent + "(" + children[j].key + ")\n");
                s.append(toString(children[j].next, ht-1, indent + "     "));
            }
        }
        return s.toString();
    }


    // comparison functions - make Comparable instead of Key to avoid casts
    private boolean less(Comparable k1, Comparable k2) {
        return k1.compareTo(k2) < 0;
    }

    private boolean eq(Comparable k1, Comparable k2) {
        return k1.compareTo(k2) == 0;
    }


    /**
     * Unit tests the {@code BTree} data type.
     *
     * @param args the command-line arguments
     */
    public static void main(String[] args) {
        BTree<String, String> st = new BTree<String, String>();

        st.put("www.cs.princeton.edu", "128.112.136.12");
        st.put("www.cs.princeton.edu", "128.112.136.11");
        st.put("www.princeton.edu",    "128.112.128.15");
        st.put("www.yale.edu",         "130.132.143.21");
        st.put("www.simpsons.com",     "209.052.165.60");
        st.put("www.apple.com",        "17.112.152.32");
        st.put("www.amazon.com",       "207.171.182.16");
        st.put("www.ebay.com",         "66.135.192.87");
        st.put("www.cnn.com",          "64.236.16.20");
        st.put("www.google.com",       "216.239.41.99");
        st.put("www.nytimes.com",      "199.239.136.200");
        st.put("www.microsoft.com",    "207.126.99.140");
        st.put("www.dell.com",         "143.166.224.230");
        st.put("www.slashdot.org",     "66.35.250.151");
        st.put("www.espn.com",         "199.181.135.201");
        st.put("www.weather.com",      "63.111.66.11");
        st.put("www.yahoo.com",        "216.109.118.65");


        StdOut.println("cs.princeton.edu:  " + st.get("www.cs.princeton.edu"));
        StdOut.println("hardvardsucks.com: " + st.get("www.harvardsucks.com"));
        StdOut.println("simpsons.com:      " + st.get("www.simpsons.com"));
        StdOut.println("apple.com:         " + st.get("www.apple.com"));
        StdOut.println("ebay.com:          " + st.get("www.ebay.com"));
        StdOut.println("dell.com:          " + st.get("www.dell.com"));
        StdOut.println();

        StdOut.println("size:    " + st.size());
        StdOut.println("height:  " + st.height());
        StdOut.println(st);
        StdOut.println();
    }

}

/******************************************************************************
 *  Copyright 2002-2025, Robert Sedgewick and Kevin Wayne.
 *
 *  This file is part of algs4.jar, which accompanies the textbook
 *
 *      Algorithms, 4th edition by Robert Sedgewick and Kevin Wayne,
 *      Addison-Wesley Professional, 2011, ISBN 0-321-57351-X.
 *      http://algs4.cs.princeton.edu
 *
 *
 *  algs4.jar is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  algs4.jar is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with algs4.jar.  If not, see http://www.gnu.org/licenses.
 ******************************************************************************/


================================================
FILE: src/main/java/edu/princeton/cs/algs4/Bag.java
================================================
/******************************************************************************
 *  Compilation:  javac Bag.java
 *  Execution:    java Bag < input.txt
 *  Dependencies: StdIn.java StdOut.java
 *
 *  A generic bag or multiset, implemented using a singly linked list.
 *
 *  % more tobe.txt
 *  to be or not to - be - - that - - - is
 *
 *  % java Bag < tobe.txt
 *  size of bag = 14
 *  is
 *  -
 *  -
 *  -
 *  that
 *  -
 *  -
 *  be
 *  -
 *  to
 *  not
 *  or
 *  be
 *  to
 *
 ******************************************************************************/

package edu.princeton.cs.algs4;

import java.util.Iterator;
import java.util.NoSuchElementException;

/**
 *  The {@code Bag} class represents a bag (or multiset) of
 *  generic items. It supports insertion and iterating over the
 *  items in arbitrary order.
 *  <p>
 *  This implementation uses a singly linked list with a static nested class Node.
 *  See {@link LinkedBag} for the version from the
 *  textbook that uses a non-static nested class.
 *  See {@link ResizingArrayBag} for a version that uses a resizing array.
 *  The <em>add</em>, <em>isEmpty</em>, and <em>size</em> operations
 *  take constant time. Iteration takes time proportional to the number of items.
 *  <p>
 *  For additional documentation, see <a href="https://algs4.cs.princeton.edu/13stacks">Section 1.3</a> of
 *  <i>Algorithms, 4th Edition</i> by Robert Sedgewick and Kevin Wayne.
 *
 *  @author Robert Sedgewick
 *  @author Kevin Wayne
 *
 *  @param <Item> the generic type of each item in this bag
 */
public class Bag<Item> implements Iterable<Item> {
    private Node<Item> first;    // beginning of bag
    private int n;               // number of elements in bag

    // helper linked list class
    private static class Node<Item> {
        private Item item;
        private Node<Item> next;
    }

    /**
     * Initializes an empty bag.
     */
    public Bag() {
        first = null;
        n = 0;
    }

    /**
     * Returns true if this bag is empty.
     *
     * @return {@code true} if this bag is empty;
     *         {@code false} otherwise
     */
    public boolean isEmpty() {
        return first == null;
    }

    /**
     * Returns the number of items in this bag.
     *
     * @return the number of items in this bag
     */
    public int size() {
        return n;
    }

    /**
     * Adds the item to this bag.
     *
     * @param  item the item to add to this bag
     */
    public void add(Item item) {
        Node<Item> oldfirst = first;
        first = new Node<Item>();
        first.item = item;
        first.next = oldfirst;
        n++;
    }


    /**
     * Returns an iterator that iterates over the items in this bag in arbitrary order.
     *
     * @return an iterator that iterates over the items in this bag in arbitrary order
     */
    public Iterator<Item> iterator()  {
        return new LinkedIterator(first);
    }

    private class LinkedIterator implements Iterator<Item> {
        private Node<Item> current;

        public LinkedIterator(Node<Item> first) {
            current = first;
        }

        public boolean hasNext()  {
            return current != null;
        }

        public Item next() {
            if (!hasNext()) throw new NoSuchElementException();
            Item item = current.item;
            current = current.next;
            return item;
        }
    }

    /**
     * Unit tests the {@code Bag} data type.
     *
     * @param args the command-line arguments
     */
    public static void main(String[] args) {
        Bag<String> bag = new Bag<String>();
        while (!StdIn.isEmpty()) {
            String item = StdIn.readString();
            bag.add(item);
        }

        StdOut.println("size of bag = " + bag.size());
        for (String s : bag) {
            StdOut.println(s);
        }
    }

}

/******************************************************************************
 *  Copyright 2002-2025, Robert Sedgewick and Kevin Wayne.
 *
 *  This file is part of algs4.jar, which accompanies the textbook
 *
 *      Algorithms, 4th edition by Robert Sedgewick and Kevin Wayne,
 *      Addison-Wesley Professional, 2011, ISBN 0-321-57351-X.
 *      http://algs4.cs.princeton.edu
 *
 *
 *  algs4.jar is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  algs4.jar is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with algs4.jar.  If not, see http://www.gnu.org/licenses.
 ******************************************************************************/


================================================
FILE: src/main/java/edu/princeton/cs/algs4/BellmanFordSP.java
================================================
/******************************************************************************
 *  Compilation:  javac BellmanFordSP.java
 *  Execution:    java BellmanFordSP filename.txt s
 *  Dependencies: EdgeWeightedDigraph.java DirectedEdge.java Queue.java
 *                EdgeWeightedDirectedCycle.java
 *  Data files:   https://algs4.cs.princeton.edu/44sp/tinyEWDn.txt
 *                https://algs4.cs.princeton.edu/44sp/tinyEWDnc.txt
 *                https://algs4.cs.princeton.edu/44sp/mediumEWD.txt
 *                https://algs4.cs.princeton.edu/44sp/largeEWD.txt
 *
 *  Bellman-Ford shortest path algorithm. Computes the shortest path tree in
 *  edge-weighted digraph G from vertex s, or finds a negative cost cycle
 *  reachable from s.
 *
 *  % java BellmanFordSP tinyEWDn.txt 0
 *  0 to 0 ( 0.00)
 *  0 to 1 ( 0.93)  0->2  0.26   2->7  0.34   7->3  0.39   3->6  0.52   6->4 -1.25   4->5  0.35   5->1  0.32
 *  0 to 2 ( 0.26)  0->2  0.26
 *  0 to 3 ( 0.99)  0->2  0.26   2->7  0.34   7->3  0.39
 *  0 to 4 ( 0.26)  0->2  0.26   2->7  0.34   7->3  0.39   3->6  0.52   6->4 -1.25
 *  0 to 5 ( 0.61)  0->2  0.26   2->7  0.34   7->3  0.39   3->6  0.52   6->4 -1.25   4->5  0.35
 *  0 to 6 ( 1.51)  0->2  0.26   2->7  0.34   7->3  0.39   3->6  0.52
 *  0 to 7 ( 0.60)  0->2  0.26   2->7  0.34
 *
 *  % java BellmanFordSP tinyEWDnc.txt 0
 *  4->5  0.35
 *  5->4 -0.66
 *
 *
 ******************************************************************************/

package edu.princeton.cs.algs4;

/**
 *  The {@code BellmanFordSP} class represents a data type for solving the
 *  single-source shortest paths problem in edge-weighted digraphs with
 *  no negative cycles.
 *  The edge weights can be positive, negative, or zero.
 *  This class finds either a shortest path from the source vertex <em>s</em>
 *  to every other vertex or a negative cycle reachable fro
Download .txt
gitextract_86oov4vw/

├── .gitignore
├── LICENSE
├── README-MAVEN.txt
├── README.md
├── USING-MAVEN.md
├── build.gradle
├── pom.xml
└── src/
    └── main/
        └── java/
            └── edu/
                └── princeton/
                    └── cs/
                        └── algs4/
                            ├── AVLTreeST.java
                            ├── Accumulator.java
                            ├── AcyclicLP.java
                            ├── AcyclicSP.java
                            ├── AdjMatrixEdgeWeightedDigraph.java
                            ├── AllowFilter.java
                            ├── Allowlist.java
                            ├── Alphabet.java
                            ├── AmericanFlag.java
                            ├── AmericanFlagX.java
                            ├── Arbitrage.java
                            ├── AssignmentProblem.java
                            ├── Average.java
                            ├── BST.java
                            ├── BTree.java
                            ├── Bag.java
                            ├── BellmanFordSP.java
                            ├── BinaryDump.java
                            ├── BinaryIn.java
                            ├── BinaryInsertion.java
                            ├── BinaryOut.java
                            ├── BinarySearch.java
                            ├── BinarySearchST.java
                            ├── BinaryStdIn.java
                            ├── BinaryStdOut.java
                            ├── BinomialMinPQ.java
                            ├── Bipartite.java
                            ├── BipartiteMatching.java
                            ├── BipartiteX.java
                            ├── BlockFilter.java
                            ├── BoruvkaMST.java
                            ├── BoyerMoore.java
                            ├── BreadthFirstDirectedPaths.java
                            ├── BreadthFirstPaths.java
                            ├── CC.java
                            ├── CPM.java
                            ├── Cat.java
                            ├── ClosestPair.java
                            ├── CollisionSystem.java
                            ├── Complex.java
                            ├── Count.java
                            ├── Counter.java
                            ├── Cycle.java
                            ├── Date.java
                            ├── DeDup.java
                            ├── DegreesOfSeparation.java
                            ├── DepthFirstDirectedPaths.java
                            ├── DepthFirstOrder.java
                            ├── DepthFirstPaths.java
                            ├── DepthFirstSearch.java
                            ├── Digraph.java
                            ├── DigraphGenerator.java
                            ├── DijkstraAllPairsSP.java
                            ├── DijkstraSP.java
                            ├── DijkstraUndirectedSP.java
                            ├── DirectedCycle.java
                            ├── DirectedCycleX.java
                            ├── DirectedDFS.java
                            ├── DirectedEdge.java
                            ├── DirectedEulerianCycle.java
                            ├── DirectedEulerianPath.java
                            ├── DoublingRatio.java
                            ├── DoublingTest.java
                            ├── Draw.java
                            ├── DrawListener.java
                            ├── Edge.java
                            ├── EdgeWeightedDigraph.java
                            ├── EdgeWeightedDirectedCycle.java
                            ├── EdgeWeightedGraph.java
                            ├── EulerianCycle.java
                            ├── EulerianPath.java
                            ├── FFT.java
                            ├── FarthestPair.java
                            ├── FenwickTree.java
                            ├── FibonacciMinPQ.java
                            ├── FileIndex.java
                            ├── FlowEdge.java
                            ├── FlowNetwork.java
                            ├── FloydWarshall.java
                            ├── FordFulkerson.java
                            ├── FrequencyCounter.java
                            ├── GREP.java
                            ├── GabowSCC.java
                            ├── GaussJordanElimination.java
                            ├── GaussianElimination.java
                            ├── Genome.java
                            ├── GlobalMincut.java
                            ├── GrahamScan.java
                            ├── Graph.java
                            ├── GraphGenerator.java
                            ├── GrayscalePicture.java
                            ├── Heap.java
                            ├── HexDump.java
                            ├── HopcroftKarp.java
                            ├── Huffman.java
                            ├── In.java
                            ├── IndexBinomialMinPQ.java
                            ├── IndexFibonacciMinPQ.java
                            ├── IndexMaxPQ.java
                            ├── IndexMinPQ.java
                            ├── IndexMultiwayMinPQ.java
                            ├── InplaceMSD.java
                            ├── Insertion.java
                            ├── InsertionX.java
                            ├── Interval1D.java
                            ├── Interval2D.java
                            ├── Inversions.java
                            ├── KMP.java
                            ├── KWIK.java
                            ├── Knuth.java
                            ├── KosarajuSharirSCC.java
                            ├── KruskalMST.java
                            ├── LSD.java
                            ├── LZW.java
                            ├── LazyPrimMST.java
                            ├── LinearProbingHashST.java
                            ├── LinearProgramming.java
                            ├── LinearRegression.java
                            ├── LinkedBag.java
                            ├── LinkedQueue.java
                            ├── LinkedStack.java
                            ├── LongestCommonSubstring.java
                            ├── LongestRepeatedSubstring.java
                            ├── LookupCSV.java
                            ├── LookupIndex.java
                            ├── MSD.java
                            ├── MaxPQ.java
                            ├── Merge.java
                            ├── MergeBU.java
                            ├── MergeX.java
                            ├── MinPQ.java
                            ├── Multiway.java
                            ├── MultiwayMinPQ.java
                            ├── NFA.java
                            ├── NonrecursiveDFS.java
                            ├── NonrecursiveDirectedDFS.java
                            ├── Out.java
                            ├── Particle.java
                            ├── PatriciaSET.java
                            ├── PatriciaST.java
                            ├── Picture.java
                            ├── PictureDump.java
                            ├── Point2D.java
                            ├── Polynomial.java
                            ├── PrimMST.java
                            ├── Queue.java
                            ├── Quick.java
                            ├── Quick3string.java
                            ├── Quick3way.java
                            ├── QuickBentleyMcIlroy.java
                            ├── QuickFindUF.java
                            ├── QuickUnionUF.java
                            ├── QuickX.java
                            ├── RabinKarp.java
                            ├── RandomSeq.java
                            ├── RectHV.java
                            ├── RedBlackBST.java
                            ├── ResizingArrayBag.java
                            ├── ResizingArrayQueue.java
                            ├── ResizingArrayStack.java
                            ├── RunLength.java
                            ├── SET.java
                            ├── ST.java
                            ├── SegmentTree.java
                            ├── Selection.java
                            ├── SeparateChainingHashST.java
                            ├── SequentialSearchST.java
                            ├── Shell.java
                            ├── SparseVector.java
                            ├── Stack.java
                            ├── StaticSETofInts.java
                            ├── StdArrayIO.java
                            ├── StdAudio.java
                            ├── StdAudioStereo.java
                            ├── StdDraw.java
                            ├── StdIn.java
                            ├── StdOut.java
                            ├── StdPicture.java
                            ├── StdRandom.java
                            ├── StdStats.java
                            ├── Stopwatch.java
                            ├── StopwatchCPU.java
                            ├── SuffixArray.java
                            ├── SuffixArrayX.java
                            ├── SymbolDigraph.java
                            ├── SymbolGraph.java
                            ├── TST.java
                            ├── TarjanSCC.java
                            ├── ThreeSum.java
                            ├── ThreeSumFast.java
                            ├── TopM.java
                            ├── Topological.java
                            ├── TopologicalX.java
                            ├── Transaction.java
                            ├── TransitiveClosure.java
                            ├── TrieSET.java
                            ├── TrieST.java
                            ├── TwoPersonZeroSumGame.java
                            ├── UF.java
                            ├── Vector.java
                            └── WeightedQuickUnionUF.java
Download .txt
Showing preview only (204K chars total). Download the full file or copy to clipboard to get everything.
SYMBOL INDEX (2767 symbols across 201 files)

FILE: src/main/java/edu/princeton/cs/algs4/AVLTreeST.java
  class AVLTreeST (line 67) | public class AVLTreeST<Key extends Comparable<Key>, Value> {
    class Node (line 77) | private class Node {
      method Node (line 85) | public Node(Key key, Value val, int height, int size) {
    method AVLTreeST (line 96) | public AVLTreeST() {
    method isEmpty (line 104) | public boolean isEmpty() {
    method size (line 113) | public int size() {
    method size (line 124) | private int size(Node x) {
    method height (line 136) | public int height() {
    method height (line 147) | private int height(Node x) {
    method get (line 161) | public Value get(Key key) {
    method get (line 177) | private Node get(Node x, Key key) {
    method contains (line 193) | public boolean contains(Key key) {
    method put (line 207) | public void put(Key key, Value val) {
    method put (line 228) | private Node put(Node x, Key key, Value val) {
    method balance (line 252) | private Node balance(Node x) {
    method balanceFactor (line 278) | private int balanceFactor(Node x) {
    method rotateRight (line 288) | private Node rotateRight(Node x) {
    method rotateLeft (line 305) | private Node rotateLeft(Node x) {
    method delete (line 323) | public void delete(Key key) {
    method delete (line 338) | private Node delete(Node x, Key key) {
    method deleteMin (line 370) | public void deleteMin() {
    method deleteMin (line 382) | private Node deleteMin(Node x) {
    method deleteMax (line 395) | public void deleteMax() {
    method deleteMax (line 407) | private Node deleteMax(Node x) {
    method min (line 421) | public Key min() {
    method min (line 432) | private Node min(Node x) {
    method max (line 443) | public Key max() {
    method max (line 454) | private Node max(Node x) {
    method floor (line 469) | public Key floor(Key key) {
    method floor (line 486) | private Node floor(Node x, Key key) {
    method ceiling (line 506) | public Key ceiling(Key key) {
    method ceiling (line 523) | private Node ceiling(Node x, Key key) {
    method select (line 541) | public Key select(int k) {
    method select (line 554) | private Node select(Node x, int k) {
    method rank (line 571) | public int rank(Key key) {
    method rank (line 583) | private int rank(Key key, Node x) {
    method keys (line 596) | public Iterable<Key> keys() {
    method keysInOrder (line 605) | public Iterable<Key> keysInOrder() {
    method keysInOrder (line 617) | private void keysInOrder(Node x, Queue<Key> queue) {
    method keysLevelOrder (line 629) | public Iterable<Key> keysLevelOrder() {
    method keys (line 658) | public Iterable<Key> keys(Key lo, Key hi) {
    method keys (line 675) | private void keys(Node x, Queue<Key> queue, Key lo, Key hi) {
    method size (line 694) | public int size(Key lo, Key hi) {
    method check (line 707) | private boolean check() {
    method isAVL (line 720) | private boolean isAVL() {
    method isAVL (line 730) | private boolean isAVL(Node x) {
    method isBST (line 742) | private boolean isBST() {
    method isBST (line 756) | private boolean isBST(Node x, Key min, Key max) {
    method isSizeConsistent (line 768) | private boolean isSizeConsistent() {
    method isSizeConsistent (line 777) | private boolean isSizeConsistent(Node x) {
    method isRankConsistent (line 788) | private boolean isRankConsistent() {
    method main (line 801) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Accumulator.java
  class Accumulator (line 36) | public class Accumulator {
    method Accumulator (line 44) | public Accumulator() {
    method addDataValue (line 51) | public void addDataValue(double x) {
    method mean (line 62) | public double mean() {
    method var (line 70) | public double var() {
    method stddev (line 79) | public double stddev() {
    method count (line 87) | public int count() {
    method toString (line 95) | public String toString() {
    method main (line 108) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/AcyclicLP.java
  class AcyclicLP (line 53) | public class AcyclicLP {
    method AcyclicLP (line 65) | public AcyclicLP(EdgeWeightedDigraph digraph, int s) {
    method relax (line 86) | private void relax(DirectedEdge e) {
    method distTo (line 101) | public double distTo(int v) {
    method hasPathTo (line 113) | public boolean hasPathTo(int v) {
    method pathTo (line 125) | public Iterable<DirectedEdge> pathTo(int v) {
    method validateVertex (line 136) | private void validateVertex(int v) {
    method main (line 147) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/AcyclicSP.java
  class AcyclicSP (line 51) | public class AcyclicSP {
    method AcyclicSP (line 64) | public AcyclicSP(EdgeWeightedDigraph digraph, int s) {
    method relax (line 85) | private void relax(DirectedEdge e) {
    method distTo (line 100) | public double distTo(int v) {
    method hasPathTo (line 112) | public boolean hasPathTo(int v) {
    method pathTo (line 124) | public Iterable<DirectedEdge> pathTo(int v) {
    method validateVertex (line 135) | private void validateVertex(int v) {
    method main (line 146) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/AdjMatrixEdgeWeightedDigraph.java
  class AdjMatrixEdgeWeightedDigraph (line 38) | public class AdjMatrixEdgeWeightedDigraph {
    method AdjMatrixEdgeWeightedDigraph (line 50) | public AdjMatrixEdgeWeightedDigraph(int V) {
    method AdjMatrixEdgeWeightedDigraph (line 64) | public AdjMatrixEdgeWeightedDigraph(int V, int E) {
    method V (line 82) | public int V() {
    method E (line 90) | public int E() {
    method addEdge (line 99) | public void addEdge(DirectedEdge e) {
    method adj (line 116) | public Iterable<DirectedEdge> adj(int v) {
    class AdjIterator (line 122) | private class AdjIterator implements Iterator<DirectedEdge>, Iterable<...
      method AdjIterator (line 126) | public AdjIterator(int v) {
      method iterator (line 130) | public Iterator<DirectedEdge> iterator() {
      method hasNext (line 134) | public boolean hasNext() {
      method next (line 142) | public DirectedEdge next() {
      method remove (line 149) | public void remove() {
    method toString (line 160) | public String toString() {
    method validateVertex (line 174) | private void validateVertex(int v) {
    method main (line 185) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/AllowFilter.java
  class AllowFilter (line 46) | public class AllowFilter {
    method AllowFilter (line 49) | private AllowFilter() { }
    method main (line 51) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Allowlist.java
  class Allowlist (line 45) | public class Allowlist {
    method Allowlist (line 48) | private Allowlist() { }
    method main (line 57) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Alphabet.java
  class Alphabet (line 17) | public class Alphabet {
    method Alphabet (line 90) | public Alphabet(String alpha) {
    method Alphabet (line 117) | private Alphabet(int radix) {
    method Alphabet (line 132) | public Alphabet() {
    method contains (line 143) | public boolean contains(char c) {
    method R (line 153) | @Deprecated
    method radix (line 163) | public int radix() {
    method lgR (line 172) | public int lgR() {
    method toIndex (line 186) | public int toIndex(char c) {
    method toIndices (line 201) | public int[] toIndices(String s) {
    method toChar (line 216) | public char toChar(int index) {
    method toChars (line 231) | public String toChars(int[] indices) {
    method main (line 243) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/AmericanFlag.java
  class AmericanFlag (line 48) | public class AmericanFlag {
    method AmericanFlag (line 55) | private AmericanFlag() { }
    method charAt (line 58) | private static int charAt(String s, int d) {
    method sort (line 70) | public static void sort(String[] a) {
    method sort (line 75) | public static void sort(String[] a, int lo, int hi) {
    method insertion (line 138) | private static void insertion(String[] a, int lo, int hi, int d) {
    method exch (line 145) | private static void exch(String[] a, int i, int j) {
    method less (line 152) | private static boolean less(String v, String w, int d) {
    method sort (line 167) | public static void sort(int[] a) {
    method sort (line 172) | private static void sort(int[] a, int lo, int hi) {
    method insertion (line 237) | private static void insertion(int[] a, int lo, int hi, int d) {
    method exch (line 244) | private static void exch(int[] a, int i, int j) {
    method less (line 251) | private static boolean less(int v, int w, int d) {
    method main (line 270) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/AmericanFlagX.java
  class AmericanFlagX (line 46) | public class AmericanFlagX {
    method AmericanFlagX (line 51) | private AmericanFlagX() { }
    method charAt (line 54) | private static int charAt(String s, int d) {
    method sort (line 66) | public static void sort(String[] a) {
    method sort (line 71) | public static void sort(String[] a, int lo, int hi) {
    method insertion (line 140) | private static void insertion(String[] a, int lo, int hi, int d) {
    method exch (line 147) | private static void exch(String[] a, int i, int j) {
    method less (line 154) | private static boolean less(String v, String w, int d) {
    method main (line 170) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Arbitrage.java
  class Arbitrage (line 53) | public class Arbitrage {
    method Arbitrage (line 56) | private Arbitrage() { }
    method main (line 64) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/AssignmentProblem.java
  class AssignmentProblem (line 39) | public class AssignmentProblem {
    method AssignmentProblem (line 58) | public AssignmentProblem(double[][] weight) {
    method augment (line 94) | private void augment() {
    method reducedCost (line 135) | private double reducedCost(int i, int j) {
    method dualRow (line 155) | public double dualRow(int i) {
    method dualCol (line 168) | public double dualCol(int j) {
    method sol (line 181) | public int sol(int i) {
    method weight (line 192) | public double weight() {
    method validate (line 201) | private void validate(int i) {
    method isDualFeasible (line 213) | private boolean isDualFeasible() {
    method isComplementarySlack (line 227) | private boolean isComplementarySlack() {
    method isPerfectMatching (line 240) | private boolean isPerfectMatching() {
    method certifySolution (line 270) | private boolean certifySolution() {
    method main (line 282) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Average.java
  class Average (line 31) | public class Average {
    method Average (line 34) | private Average() { }
    method main (line 42) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/BST.java
  class BST (line 70) | public class BST<Key extends Comparable<Key>, Value> {
    class Node (line 73) | private class Node {
      method Node (line 79) | public Node(Key key, Value val, int size) {
    method BST (line 89) | public BST() {
    method isEmpty (line 96) | public boolean isEmpty() {
    method size (line 104) | public int size() {
    method size (line 109) | private int size(Node node) {
    method contains (line 122) | public boolean contains(Key key) {
    method get (line 135) | public Value get(Key key) {
    method get (line 139) | private Value get(Node node, Key key) {
    method put (line 158) | public void put(Key key, Value val) {
    method put (line 168) | private Node put(Node node, Key key, Value val) {
    method deleteMin (line 184) | public void deleteMin() {
    method deleteMin (line 190) | private Node deleteMin(Node node) {
    method deleteMax (line 202) | public void deleteMax() {
    method deleteMax (line 208) | private Node deleteMax(Node node) {
    method delete (line 222) | public void delete(Key key) {
    method delete (line 228) | private Node delete(Node node, Key key) {
    method min (line 253) | public Key min() {
    method min (line 258) | private Node min(Node node) {
    method max (line 269) | public Key max() {
    method max (line 274) | private Node max(Node node) {
    method floor (line 287) | public Key floor(Key key) {
    method floor (line 295) | private Node floor(Node node, Key key) {
    method floor2 (line 305) | public Key floor2(Key key) {
    method floor2 (line 312) | private Key floor2(Node node, Key key, Key champ) {
    method ceiling (line 328) | public Key ceiling(Key key) {
    method ceiling (line 336) | private Node ceiling(Node node, Key key) {
    method select (line 359) | public Key select(int rank) {
    method select (line 368) | private Key select(Node node, int rank) {
    method rank (line 383) | public int rank(Key key) {
    method rank (line 389) | private int rank(Key key, Node node) {
    method keys (line 405) | public Iterable<Key> keys() {
    method keys (line 421) | public Iterable<Key> keys(Key lo, Key hi) {
    method keys (line 430) | private void keys(Node node, Queue<Key> queue, Key lo, Key hi) {
    method size (line 449) | public int size(Key lo, Key hi) {
    method height (line 463) | public int height() {
    method height (line 466) | private int height(Node node) {
    method levelOrder (line 476) | public Iterable<Key> levelOrder() {
    method check (line 493) | private boolean check() {
    method isBST (line 502) | private boolean isBST() {
    method isBST (line 509) | private boolean isBST(Node node, Key min, Key max) {
    method isSizeConsistent (line 517) | private boolean isSizeConsistent() { return isSizeConsistent(root); }
    method isSizeConsistent (line 518) | private boolean isSizeConsistent(Node node) {
    method isRankConsistent (line 525) | private boolean isRankConsistent() {
    method main (line 539) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/BTree.java
  class BTree (line 46) | public class BTree<Key extends Comparable<Key>, Value>  {
    class Node (line 56) | private static final class Node {
      method Node (line 61) | private Node(int k) {
    class Entry (line 68) | private static class Entry {
      method Entry (line 72) | public Entry(Comparable key, Object val, Node next) {
    method BTree (line 82) | public BTree() {
    method isEmpty (line 90) | public boolean isEmpty() {
    method size (line 98) | public int size() {
    method height (line 107) | public int height() {
    method get (line 120) | public Value get(Key key) {
    method search (line 125) | private Value search(Node x, Key key, int ht) {
    method put (line 155) | public void put(Key key, Value val) {
    method insert (line 169) | private Node insert(Node h, Key key, Value val, int ht) {
    method split (line 203) | private Node split(Node h) {
    method toString (line 216) | public String toString() {
    method toString (line 220) | private String toString(Node h, int ht, String indent) {
    method less (line 240) | private boolean less(Comparable k1, Comparable k2) {
    method eq (line 244) | private boolean eq(Comparable k1, Comparable k2) {
    method main (line 254) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Bag.java
  class Bag (line 55) | public class Bag<Item> implements Iterable<Item> {
    class Node (line 60) | private static class Node<Item> {
    method Bag (line 68) | public Bag() {
    method isEmpty (line 79) | public boolean isEmpty() {
    method size (line 88) | public int size() {
    method add (line 97) | public void add(Item item) {
    method iterator (line 111) | public Iterator<Item> iterator()  {
    class LinkedIterator (line 115) | private class LinkedIterator implements Iterator<Item> {
      method LinkedIterator (line 118) | public LinkedIterator(Node<Item> first) {
      method hasNext (line 122) | public boolean hasNext()  {
      method next (line 126) | public Item next() {
    method main (line 139) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/BellmanFordSP.java
  class BellmanFordSP (line 66) | public class BellmanFordSP {
    method BellmanFordSP (line 84) | public BellmanFordSP(EdgeWeightedDigraph digraph, int s) {
    method relax (line 106) | private void relax(EdgeWeightedDigraph digraph, int v) {
    method hasNegativeCycle (line 129) | public boolean hasNegativeCycle() {
    method negativeCycle (line 139) | public Iterable<DirectedEdge> negativeCycle() {
    method findNegativeCycle (line 144) | private void findNegativeCycle() {
    method distTo (line 164) | public double distTo(int v) {
    method hasPathTo (line 178) | public boolean hasPathTo(int v) {
    method pathTo (line 192) | public Iterable<DirectedEdge> pathTo(int v) {
    method check (line 209) | private boolean check(EdgeWeightedDigraph digraph, int s) {
    method validateVertex (line 269) | private void validateVertex(int v) {
    method main (line 280) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/BinaryDump.java
  class BinaryDump (line 41) | public class BinaryDump {
    method BinaryDump (line 44) | private BinaryDump() { }
    method main (line 55) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/BinaryIn.java
  class BinaryIn (line 50) | public final class BinaryIn {
    method BinaryIn (line 60) | public BinaryIn() {
    method BinaryIn (line 70) | public BinaryIn(InputStream is) {
    method BinaryIn (line 80) | public BinaryIn(Socket socket) {
    method BinaryIn (line 96) | public BinaryIn(URL url) {
    method BinaryIn (line 113) | public BinaryIn(String name) {
    method fillBuffer (line 145) | private void fillBuffer() {
    method exists (line 163) | public boolean exists()  {
    method isEmpty (line 173) | public boolean isEmpty() {
    method readBoolean (line 183) | public boolean readBoolean() {
    method readChar (line 197) | public char readChar() {
    method readChar (line 230) | public char readChar(int r) {
    method readString (line 253) | public String readString() {
    method readShort (line 271) | public short readShort() {
    method readInt (line 287) | public int readInt() {
    method readInt (line 306) | public int readInt(int r) {
    method readLong (line 327) | public long readLong() {
    method readDouble (line 343) | public double readDouble() {
    method readFloat (line 353) | public float readFloat() {
    method readByte (line 364) | public byte readByte() {
    method main (line 376) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/BinaryInsertion.java
  class BinaryInsertion (line 50) | public class BinaryInsertion {
    method BinaryInsertion (line 53) | private BinaryInsertion() { }
    method sort (line 59) | public static void sort(Comparable[] a) {
    method less (line 88) | private static boolean less(Comparable v, Comparable w) {
    method isSorted (line 95) | private static boolean isSorted(Comparable[] a) {
    method isSorted (line 100) | private static boolean isSorted(Comparable[] a, int lo, int hi) {
    method show (line 107) | private static void show(Comparable[] a) {
    method main (line 119) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/BinaryOut.java
  class BinaryOut (line 39) | public final class BinaryOut {
    method BinaryOut (line 49) | public BinaryOut() {
    method BinaryOut (line 57) | public BinaryOut(OutputStream os) {
    method BinaryOut (line 68) | public BinaryOut(String filename) {
    method BinaryOut (line 92) | public BinaryOut(Socket socket) {
    method writeBit (line 111) | private void writeBit(boolean x) {
    method writeByte (line 125) | private void writeByte(int x) {
    method clearBuffer (line 147) | private void clearBuffer() {
    method flush (line 164) | public void flush() {
    method close (line 178) | public void close() {
    method write (line 193) | public void write(boolean x) {
    method write (line 201) | public void write(byte x) {
    method write (line 209) | public void write(int x) {
    method write (line 224) | public void write(int x, int r) {
    method write (line 242) | public void write(double x) {
    method write (line 250) | public void write(long x) {
    method write (line 265) | public void write(float x) {
    method write (line 273) | public void write(short x) {
    method write (line 284) | public void write(char x) {
    method write (line 297) | public void write(char x, int r) {
    method write (line 317) | public void write(String s) {
    method write (line 331) | public void write(String s, int r) {
    method main (line 343) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/BinarySearch.java
  class BinarySearch (line 42) | public class BinarySearch {
    method BinarySearch (line 47) | private BinarySearch() { }
    method indexOf (line 56) | public static int indexOf(int[] a, int key) {
    method rank (line 79) | @Deprecated
    method main (line 91) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/BinarySearchST.java
  class BinarySearchST (line 68) | public class BinarySearchST<Key extends Comparable<Key>, Value> {
    method BinarySearchST (line 77) | public BinarySearchST() {
    method BinarySearchST (line 85) | public BinarySearchST(int capacity) {
    method resize (line 91) | private void resize(int capacity) {
    method size (line 108) | public int size() {
    method isEmpty (line 118) | public boolean isEmpty() {
    method contains (line 131) | public boolean contains(Key key) {
    method get (line 144) | public Value get(Key key) {
    method rank (line 159) | public int rank(Key key) {
    method put (line 185) | public void put(Key key, Value val)  {
    method delete (line 222) | public void delete(Key key) {
    method deleteMin (line 254) | public void deleteMin() {
    method deleteMax (line 264) | public void deleteMax() {
    method min (line 280) | public Key min() {
    method max (line 291) | public Key max() {
    method select (line 304) | public Key select(int k) {
    method floor (line 319) | public Key floor(Key key) {
    method ceiling (line 335) | public Key ceiling(Key key) {
    method size (line 352) | public int size(Key lo, Key hi) {
    method keys (line 368) | public Iterable<Key> keys() {
    method keys (line 383) | public Iterable<Key> keys(Key lo, Key hi) {
    method check (line 400) | private boolean check() {
    method isSorted (line 405) | private boolean isSorted() {
    method rankCheck (line 412) | private boolean rankCheck() {
    method main (line 426) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/BinaryStdIn.java
  class BinaryStdIn (line 39) | public final class BinaryStdIn {
    method BinaryStdIn (line 48) | private BinaryStdIn() { }
    method initialize (line 51) | private static void initialize() {
    method fillBuffer (line 59) | private static void fillBuffer() {
    method close (line 74) | public static void close() {
    method isEmpty (line 89) | public static boolean isEmpty() {
    method readBoolean (line 100) | public static boolean readBoolean() {
    method readChar (line 116) | public static char readChar() {
    method readChar (line 147) | public static char readChar(int r) {
    method readString (line 169) | public static String readString() {
    method readShort (line 187) | public static short readShort() {
    method readInt (line 203) | public static int readInt() {
    method readInt (line 221) | public static int readInt(int r) {
    method readLong (line 242) | public static long readLong() {
    method readDouble (line 259) | public static double readDouble() {
    method readFloat (line 269) | public static float readFloat() {
    method readByte (line 280) | public static byte readByte() {
    method main (line 291) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/BinaryStdOut.java
  class BinaryStdOut (line 35) | public final class BinaryStdOut {
    method BinaryStdOut (line 42) | private BinaryStdOut() { }
    method initialize (line 45) | private static void initialize() {
    method writeBit (line 55) | private static void writeBit(boolean bit) {
    method writeByte (line 70) | private static void writeByte(int x) {
    method clearBuffer (line 94) | private static void clearBuffer() {
    method flush (line 113) | public static void flush() {
    method close (line 127) | public static void close() {
    method write (line 143) | public static void write(boolean x) {
    method write (line 151) | public static void write(byte x) {
    method write (line 159) | public static void write(int x) {
    method write (line 173) | public static void write(int x, int r) {
    method write (line 194) | public static void write(double x) {
    method write (line 202) | public static void write(long x) {
    method write (line 217) | public static void write(float x) {
    method write (line 225) | public static void write(short x) {
    method write (line 235) | public static void write(char x) {
    method write (line 247) | public static void write(char x, int r) {
    method write (line 266) | public static void write(String s) {
    method write (line 279) | public static void write(String s, int r) {
    method main (line 289) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/BinomialMinPQ.java
  class BinomialMinPQ (line 32) | public class BinomialMinPQ<Key> implements Iterable<Key> {
    class Node (line 37) | private class Node {
    method BinomialMinPQ (line 47) | public BinomialMinPQ() {
    method BinomialMinPQ (line 56) | public BinomialMinPQ(Comparator<Key> C) {
    method BinomialMinPQ (line 65) | public BinomialMinPQ(Key[] a) {
    method BinomialMinPQ (line 76) | public BinomialMinPQ(Comparator<Key> C, Key[] a) {
    method isEmpty (line 86) | public boolean isEmpty() {
    method size (line 96) | public int size() {
    method insert (line 111) | public void insert(Key key) {
    method minKey (line 126) | public Key minKey() {
    method delMin (line 143) | public Key delMin() {
    method union (line 171) | public BinomialMinPQ<Key> union(BinomialMinPQ<Key> heap) {
    method greater (line 199) | private boolean greater(Key n, Key m) {
    method link (line 206) | private void link(Node root1, Node root2) {
    method eraseMin (line 213) | private Node eraseMin() {
    method merge (line 234) | private Node merge(Node h, Node x, Node y) {
    method iterator (line 255) | public Iterator<Key> iterator() {
    class MyIterator (line 259) | private class MyIterator implements Iterator<Key> {
      method MyIterator (line 264) | public MyIterator() {
      method clone (line 269) | private Node clone(Node x, Node parent) {
      method hasNext (line 278) | public boolean hasNext() {
      method next (line 282) | public Key next() {
      method remove (line 287) | public void remove() {
    class MyComparator (line 297) | private class MyComparator implements Comparator<Key> {
      method compare (line 298) | @Override

FILE: src/main/java/edu/princeton/cs/algs4/Bipartite.java
  class Bipartite (line 42) | public class Bipartite {
    method Bipartite (line 55) | public Bipartite(Graph graph) {
    method dfs (line 69) | private void dfs(Graph graph, int v) {
    method isBipartite (line 101) | public boolean isBipartite() {
    method color (line 116) | public boolean color(int v) {
    method oddCycle (line 131) | public Iterable<Integer> oddCycle() {
    method check (line 135) | private boolean check(Graph graph) {
    method validateVertex (line 166) | private void validateVertex(int v) {
    method main (line 177) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/BipartiteMatching.java
  class BipartiteMatching (line 56) | public class BipartiteMatching {
    method BipartiteMatching (line 75) | public BipartiteMatching(Graph G) {
    method hasAugmentingPath (line 134) | private boolean hasAugmentingPath(Graph G) {
    method isResidualGraphEdge (line 169) | private boolean isResidualGraphEdge(int v, int w) {
    method mate (line 185) | public int mate(int v) {
    method isMatched (line 200) | public boolean isMatched(int v) {
    method size (line 210) | public int size() {
    method isPerfect (line 222) | public boolean isPerfect() {
    method inMinVertexCover (line 235) | public boolean inMinVertexCover(int v) {
    method validate (line 240) | private void validate(int v) {
    method certifySolution (line 252) | private boolean certifySolution(Graph G) {
    method main (line 312) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/BipartiteX.java
  class BipartiteX (line 40) | public class BipartiteX {
    method BipartiteX (line 56) | public BipartiteX(Graph graph) {
    method bfs (line 70) | private void bfs(Graph graph, int s) {
    method isBipartite (line 116) | public boolean isBipartite() {
    method color (line 131) | public boolean color(int v) {
    method oddCycle (line 147) | public Iterable<Integer> oddCycle() {
    method check (line 151) | private boolean check(Graph graph) {
    method validateVertex (line 181) | private void validateVertex(int v) {
    method main (line 192) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/BlockFilter.java
  class BlockFilter (line 46) | public class BlockFilter {
    method BlockFilter (line 49) | private BlockFilter() { }
    method main (line 51) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/BoruvkaMST.java
  class BoruvkaMST (line 60) | public class BoruvkaMST {
    method BoruvkaMST (line 70) | public BoruvkaMST(EdgeWeightedGraph graph) {
    method edges (line 111) | public Iterable<Edge> edges() {
    method weight (line 120) | public double weight() {
    method less (line 125) | private static boolean less(Edge e, Edge f) {
    method check (line 130) | private boolean check(EdgeWeightedGraph graph) {
    method main (line 193) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/BoyerMoore.java
  class BoyerMoore (line 46) | public class BoyerMoore {
    method BoyerMoore (line 58) | public BoyerMoore(String pat) {
    method BoyerMoore (line 76) | public BoyerMoore(char[] pattern, int R) {
    method search (line 98) | public int search(String txt) {
    method search (line 124) | public int search(char[] text) {
    method main (line 149) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/BreadthFirstDirectedPaths.java
  class BreadthFirstDirectedPaths (line 50) | public class BreadthFirstDirectedPaths {
    method BreadthFirstDirectedPaths (line 62) | public BreadthFirstDirectedPaths(Digraph digraph, int s) {
    method BreadthFirstDirectedPaths (line 82) | public BreadthFirstDirectedPaths(Digraph digraph, Iterable<Integer> so...
    method bfs (line 93) | private void bfs(Digraph digraph, int s) {
    method bfs (line 112) | private void bfs(Digraph digraph, Iterable<Integer> sources) {
    method hasPathTo (line 138) | public boolean hasPathTo(int v) {
    method distTo (line 151) | public int distTo(int v) {
    method pathTo (line 163) | public Iterable<Integer> pathTo(int v) {
    method validateVertex (line 176) | private void validateVertex(int v) {
    method validateVertices (line 184) | private void validateVertices(Iterable<Integer> vertices) {
    method main (line 206) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/BreadthFirstPaths.java
  class BreadthFirstPaths (line 64) | public class BreadthFirstPaths {
    method BreadthFirstPaths (line 77) | public BreadthFirstPaths(Graph graph, int s) {
    method BreadthFirstPaths (line 97) | public BreadthFirstPaths(Graph graph, Iterable<Integer> sources) {
    method bfs (line 109) | private void bfs(Graph graph, int s) {
    method bfs (line 131) | private void bfs(Graph graph, Iterable<Integer> sources) {
    method hasPathTo (line 157) | public boolean hasPathTo(int v) {
    method distTo (line 170) | public int distTo(int v) {
    method pathTo (line 182) | public Iterable<Integer> pathTo(int v) {
    method check (line 195) | private boolean check(Graph graph, int s) {
    method validateVertex (line 239) | private void validateVertex(int v) {
    method validateVertices (line 247) | private void validateVertices(Iterable<Integer> vertices) {
    method main (line 269) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/CC.java
  class CC (line 63) | public class CC {
    method CC (line 74) | public CC(Graph graph) {
    method CC (line 91) | public CC(EdgeWeightedGraph graph) {
    method dfs (line 104) | private void dfs(Graph graph, int v) {
    method dfs (line 116) | private void dfs(EdgeWeightedGraph graph, int v) {
    method id (line 136) | public int id(int v) {
    method size (line 148) | public int size(int v) {
    method count (line 158) | public int count() {
    method connected (line 173) | public boolean connected(int v, int w) {
    method areConnected (line 191) | @Deprecated
    method validateVertex (line 199) | private void validateVertex(int v) {
    method main (line 210) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/CPM.java
  class CPM (line 51) | public class CPM {
    method CPM (line 54) | private CPM() { }
    method main (line 62) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Cat.java
  class Cat (line 40) | public class Cat {
    method Cat (line 43) | private Cat() { }
    method main (line 52) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/ClosestPair.java
  class ClosestPair (line 37) | public class ClosestPair {
    method ClosestPair (line 50) | public ClosestPair(Point2D[] points) {
    method closest (line 91) | private double closest(Point2D[] pointsByX, Point2D[] pointsByY, Point...
    method either (line 137) | public Point2D either() {
    method other (line 147) | public Point2D other() {
    method distance (line 158) | public double distance() {
    method less (line 163) | private static boolean less(Comparable v, Comparable w) {
    method merge (line 169) | private static void merge(Comparable[] a, Comparable[] aux, int lo, in...
    method main (line 196) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/CollisionSystem.java
  class CollisionSystem (line 35) | public class CollisionSystem {
    method CollisionSystem (line 48) | public CollisionSystem(Particle[] particles) {
    method predict (line 53) | private void predict(Particle a, double limit) {
    method redraw (line 71) | private void redraw(double limit) {
    method simulate (line 89) | public void simulate(double limit) {
    class Event (line 137) | private static class Event implements Comparable<Event> {
      method Event (line 144) | public Event(double t, Particle a, Particle b) {
      method compareTo (line 155) | public int compareTo(Event that) {
      method isValid (line 160) | public boolean isValid() {
    method main (line 177) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Complex.java
  class Complex (line 50) | public class Complex {
    method Complex (line 60) | public Complex(double real, double imag) {
    method toString (line 71) | public String toString() {
    method abs (line 84) | public double abs() {
    method phase (line 94) | public double phase() {
    method plus (line 104) | public Complex plus(Complex that) {
    method minus (line 117) | public Complex minus(Complex that) {
    method times (line 129) | public Complex times(Complex that) {
    method scale (line 141) | public Complex scale(double alpha) {
    method times (line 152) | @Deprecated
    method conjugate (line 162) | public Complex conjugate() {
    method reciprocal (line 171) | public Complex reciprocal() {
    method re (line 181) | public double re() {
    method im (line 190) | public double im() {
    method divides (line 201) | public Complex divides(Complex that) {
    method exp (line 210) | public Complex exp() {
    method sin (line 219) | public Complex sin() {
    method cos (line 228) | public Complex cos() {
    method tan (line 237) | public Complex tan() {
    method main (line 247) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Count.java
  class Count (line 49) | public class Count {
    method Count (line 52) | private Count() { }
    method main (line 62) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Counter.java
  class Counter (line 33) | public class Counter implements Comparable<Counter> {
    method Counter (line 43) | public Counter(String id) {
    method increment (line 50) | public void increment() {
    method tally (line 59) | public int tally() {
    method toString (line 68) | public String toString() {
    method compareTo (line 83) | @Override
    method main (line 95) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Cycle.java
  class Cycle (line 49) | public class Cycle {
    method Cycle (line 60) | public Cycle(Graph graph) {
    method hasSelfLoop (line 77) | private boolean hasSelfLoop(Graph graph) {
    method hasParallelEdges (line 93) | private boolean hasParallelEdges(Graph graph) {
    method hasCycle (line 123) | public boolean hasCycle() {
    method cycle (line 132) | public Iterable<Integer> cycle() {
    method dfs (line 136) | private void dfs(Graph graph, int u, int v) {
    method main (line 165) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Date.java
  class Date (line 23) | public class Date implements Comparable<Date> {
    method Date (line 37) | public Date(int month, int day, int year) {
    method Date (line 49) | public Date(String date) {
    method month (line 64) | public int month() {
    method day (line 72) | public int day() {
    method year (line 80) | public int year() {
    method isValid (line 86) | private static boolean isValid(int m, int d, int y) {
    method isLeapYear (line 94) | private static boolean isLeapYear(int y) {
    method next (line 105) | public Date next() {
    method isAfter (line 117) | public boolean isAfter(Date that) {
    method isBefore (line 127) | public boolean isBefore(Date that) {
    method compareTo (line 139) | @Override
    method toString (line 155) | @Override
    method equals (line 166) | @Override
    method hashCode (line 180) | @Override
    method main (line 190) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/DeDup.java
  class DeDup (line 46) | public class DeDup {
    method DeDup (line 49) | private DeDup() { }
    method main (line 51) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/DegreesOfSeparation.java
  class DegreesOfSeparation (line 77) | public class DegreesOfSeparation {
    method DegreesOfSeparation (line 80) | private DegreesOfSeparation() { }
    method main (line 94) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/DepthFirstDirectedPaths.java
  class DepthFirstDirectedPaths (line 51) | public class DepthFirstDirectedPaths {
    method DepthFirstDirectedPaths (line 62) | public DepthFirstDirectedPaths(Digraph digraph, int s) {
    method dfs (line 70) | private void dfs(Digraph digraph, int v) {
    method hasPathTo (line 87) | public boolean hasPathTo(int v) {
    method pathTo (line 101) | public Iterable<Integer> pathTo(int v) {
    method validateVertex (line 112) | private void validateVertex(int v) {
    method main (line 123) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/DepthFirstOrder.java
  class DepthFirstOrder (line 55) | public class DepthFirstOrder {
    method DepthFirstOrder (line 68) | public DepthFirstOrder(Digraph digraph) {
    method DepthFirstOrder (line 84) | public DepthFirstOrder(EdgeWeightedDigraph digraph) {
    method dfs (line 95) | private void dfs(Digraph digraph, int v) {
    method dfs (line 109) | private void dfs(EdgeWeightedDigraph digraph, int v) {
    method pre (line 129) | public int pre(int v) {
    method post (line 140) | public int post(int v) {
    method post (line 149) | public Iterable<Integer> post() {
    method pre (line 157) | public Iterable<Integer> pre() {
    method reversePost (line 165) | public Iterable<Integer> reversePost() {
    method check (line 174) | private boolean check() {
    method validateVertex (line 200) | private void validateVertex(int v) {
    method main (line 211) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/DepthFirstPaths.java
  class DepthFirstPaths (line 52) | public class DepthFirstPaths {
    method DepthFirstPaths (line 63) | public DepthFirstPaths(Graph graph, int s) {
    method dfs (line 72) | private void dfs(Graph graph, int v) {
    method hasPathTo (line 88) | public boolean hasPathTo(int v) {
    method pathTo (line 101) | public Iterable<Integer> pathTo(int v) {
    method validateVertex (line 112) | private void validateVertex(int v) {
    method main (line 123) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/DepthFirstSearch.java
  class DepthFirstSearch (line 44) | public class DepthFirstSearch {
    method DepthFirstSearch (line 55) | public DepthFirstSearch(Graph graph, int s) {
    method dfs (line 62) | private void dfs(Graph graph, int v) {
    method marked (line 78) | public boolean marked(int v) {
    method count (line 87) | public int count() {
    method validateVertex (line 92) | private void validateVertex(int v) {
    method main (line 103) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Digraph.java
  class Digraph (line 65) | public class Digraph {
    method Digraph (line 79) | public Digraph(int V) {
    method Digraph (line 102) | public Digraph(In in) {
    method Digraph (line 131) | public Digraph(Digraph digraph) {
    method V (line 166) | public int V() {
    method E (line 175) | public int E() {
    method validateVertex (line 181) | private void validateVertex(int v) {
    method addEdge (line 193) | public void addEdge(int v, int w) {
    method adj (line 208) | public Iterable<Integer> adj(int v) {
    method outdegree (line 221) | public int outdegree(int v) {
    method indegree (line 234) | public int indegree(int v) {
    method reverse (line 244) | public Digraph reverse() {
    method toString (line 260) | public String toString() {
    method toDot (line 295) | public String toDot() {
    method main (line 314) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/DigraphGenerator.java
  class DigraphGenerator (line 24) | public class DigraphGenerator {
    class Edge (line 25) | private static final class Edge implements Comparable<Edge> {
      method Edge (line 29) | private Edge(int v, int w) {
      method compareTo (line 34) | public int compareTo(Edge that) {
    method DigraphGenerator (line 44) | private DigraphGenerator() { }
    method simple (line 54) | public static Digraph simple(int V, int E) {
    method simple (line 82) | public static Digraph simple(int V, double p) {
    method complete (line 101) | public static Digraph complete(int V) {
    method dag (line 118) | public static Digraph dag(int V, int E) {
    method tournament (line 146) | public static Digraph tournament(int V) {
    method completeRootedInDAG (line 165) | public static Digraph completeRootedInDAG(int V) {
    method rootedInDAG (line 187) | public static Digraph rootedInDAG(int V, int E) {
    method completeRootedOutDAG (line 226) | public static Digraph completeRootedOutDAG(int V) {
    method rootedOutDAG (line 248) | public static Digraph rootedOutDAG(int V, int E) {
    method rootedInTree (line 288) | public static Digraph rootedInTree(int V) {
    method rootedOutTree (line 300) | public static Digraph rootedOutTree(int V) {
    method path (line 309) | public static Digraph path(int V) {
    method binaryTree (line 326) | public static Digraph binaryTree(int V) {
    method cycle (line 343) | public static Digraph cycle(int V) {
    method eulerianCycle (line 365) | public static Digraph eulerianCycle(int V, int E) {
    method eulerianPath (line 390) | public static Digraph eulerianPath(int V, int E) {
    method strong (line 422) | public static Digraph strong(int V, int E, int c) {
    method main (line 493) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/DijkstraAllPairsSP.java
  class DijkstraAllPairsSP (line 35) | public class DijkstraAllPairsSP {
    method DijkstraAllPairsSP (line 45) | public DijkstraAllPairsSP(EdgeWeightedDigraph G) {
    method path (line 60) | public Iterable<DirectedEdge> path(int s, int t) {
    method hasPath (line 75) | public boolean hasPath(int s, int t) {
    method dist (line 90) | public double dist(int s, int t) {
    method validateVertex (line 97) | private void validateVertex(int v) {
    method main (line 109) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/DijkstraSP.java
  class DijkstraSP (line 63) | public class DijkstraSP {
    method DijkstraSP (line 77) | public DijkstraSP(EdgeWeightedDigraph digraph, int s) {
    method relax (line 106) | private void relax(DirectedEdge e) {
    method distTo (line 123) | public double distTo(int v) {
    method hasPathTo (line 136) | public boolean hasPathTo(int v) {
    method pathTo (line 149) | public Iterable<DirectedEdge> pathTo(int v) {
    method check (line 163) | private boolean check(EdgeWeightedDigraph digraph, int s) {
    method validateVertex (line 212) | private void validateVertex(int v) {
    method main (line 223) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/DijkstraUndirectedSP.java
  class DijkstraUndirectedSP (line 70) | public class DijkstraUndirectedSP {
    method DijkstraUndirectedSP (line 84) | public DijkstraUndirectedSP(EdgeWeightedGraph G, int s) {
    method relax (line 113) | private void relax(Edge e, int v) {
    method distTo (line 132) | public double distTo(int v) {
    method hasPathTo (line 146) | public boolean hasPathTo(int v) {
    method pathTo (line 159) | public Iterable<Edge> pathTo(int v) {
    method check (line 175) | private boolean check(EdgeWeightedGraph G, int s) {
    method validateVertex (line 224) | private void validateVertex(int v) {
    method main (line 235) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/DirectedCycle.java
  class DirectedCycle (line 45) | public class DirectedCycle {
    method DirectedCycle (line 56) | public DirectedCycle(Digraph digraph) {
    method dfs (line 65) | private void dfs(Digraph digraph, int v) {
    method hasCycle (line 97) | public boolean hasCycle() {
    method cycle (line 106) | public Iterable<Integer> cycle() {
    method check (line 112) | private boolean check() {
    method main (line 136) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/DirectedCycleX.java
  class DirectedCycleX (line 40) | public class DirectedCycleX {
    method DirectedCycleX (line 43) | public DirectedCycleX(Digraph digraph) {
    method cycle (line 104) | public Iterable<Integer> cycle() {
    method hasCycle (line 112) | public boolean hasCycle() {
    method check (line 117) | private boolean check() {
    method main (line 137) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/DirectedDFS.java
  class DirectedDFS (line 46) | public class DirectedDFS {
    method DirectedDFS (line 57) | public DirectedDFS(Digraph digraph, int s) {
    method DirectedDFS (line 73) | public DirectedDFS(Digraph digraph, Iterable<Integer> sources) {
    method dfs (line 81) | private void dfs(Digraph digraph, int v) {
    method marked (line 96) | public boolean marked(int v) {
    method count (line 107) | public int count() {
    method validateVertex (line 112) | private void validateVertex(int v) {
    method validateVertices (line 120) | private void validateVertices(Iterable<Integer> vertices) {
    method main (line 142) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/DirectedEdge.java
  class DirectedEdge (line 26) | public class DirectedEdge {
    method DirectedEdge (line 41) | public DirectedEdge(int v, int w, double weight) {
    method from (line 54) | public int from() {
    method to (line 62) | public int to() {
    method weight (line 70) | public double weight() {
    method toString (line 78) | public String toString() {
    method main (line 87) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/DirectedEulerianCycle.java
  class DirectedEulerianCycle (line 41) | public class DirectedEulerianCycle {
    method DirectedEulerianCycle (line 49) | public DirectedEulerianCycle(Digraph digraph) {
    method cycle (line 96) | public Iterable<Integer> cycle() {
    method hasEulerianCycle (line 106) | public boolean hasEulerianCycle() {
    method nonIsolatedVertex (line 111) | private static int nonIsolatedVertex(Digraph digraph) {
    method satisfiesNecessaryAndSufficientConditions (line 131) | private static boolean satisfiesNecessaryAndSufficientConditions(Digra...
    method certifySolution (line 158) | private boolean certifySolution(Digraph digraph) {
    method unitTest (line 179) | private static void unitTest(Digraph digraph, String description) {
    method main (line 205) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/DirectedEulerianPath.java
  class DirectedEulerianPath (line 40) | public class DirectedEulerianPath {
    method DirectedEulerianPath (line 48) | public DirectedEulerianPath(Digraph digraph) {
    method path (line 101) | public Iterable<Integer> path() {
    method hasEulerianPath (line 111) | public boolean hasEulerianPath() {
    method nonIsolatedVertex (line 117) | private static int nonIsolatedVertex(Digraph digraph) {
    method satisfiesNecessaryAndSufficientConditions (line 138) | private static boolean satisfiesNecessaryAndSufficientConditions(Digra...
    method check (line 166) | private boolean check(Digraph digraph) {
    method unitTest (line 187) | private static void unitTest(Digraph digraph, String description) {
    method main (line 212) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/DoublingRatio.java
  class DoublingRatio (line 31) | public class DoublingRatio {
    method DoublingRatio (line 35) | private DoublingRatio() { }
    method timeTrial (line 44) | public static double timeTrial(int n) {
    method main (line 61) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/DoublingTest.java
  class DoublingTest (line 29) | public class DoublingTest {
    method DoublingTest (line 33) | private DoublingTest() { }
    method timeTrial (line 42) | public static double timeTrial(int n) {
    method main (line 58) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Draw.java
  class Draw (line 97) | public final class Draw implements ActionListener, MouseListener, MouseM...
    method Draw (line 324) | public Draw() {
    method initCanvas (line 330) | private void initCanvas() {
    method initGUI (line 356) | private void initGUI() {
    method setVisible (line 390) | public void setVisible(boolean isVisible) {
    method setLocationOnScreen (line 403) | public void setLocationOnScreen(int x, int y) {
    method setDefaultCloseOperation (line 415) | public void setDefaultCloseOperation(int value) {
    method setCanvasSize (line 424) | public void setCanvasSize() {
    method setCanvasSize (line 438) | public void setCanvasSize(int canvasWidth, int canvasHeight) {
    method createMenuBar (line 450) | private JMenuBar createMenuBar() {
    method close (line 470) | public void close() {
    method validate (line 479) | private static void validate(double x, String name) {
    method validateNonnegative (line 485) | private static void validateNonnegative(double x, String name) {
    method validateNotNull (line 490) | private static void validateNotNull(Object x, String name) {
    method setTitle (line 505) | public void setTitle(String windowTitle) {
    method setXscale (line 518) | public void setXscale() {
    method setYscale (line 525) | public void setYscale() {
    method setXscale (line 537) | public void setXscale(double min, double max) {
    method setYscale (line 554) | public void setYscale(double min, double max) {
    method setScale (line 566) | public void setScale() {
    method setScale (line 578) | public void setScale(double min, double max) {
    method scaleX (line 585) | private double  scaleX(double x) { return width  * (x - xmin) / (xmax ...
    method scaleY (line 586) | private double  scaleY(double y) { return height * (ymax - y) / (ymax ...
    method factorX (line 587) | private double factorX(double w) { return w * width  / Math.abs(xmax -...
    method factorY (line 588) | private double factorY(double h) { return h * height / Math.abs(ymax -...
    method userX (line 589) | private double   userX(double x) { return xmin + x * (xmax - xmin) / w...
    method userY (line 590) | private double   userY(double y) { return ymax - y * (ymax - ymin) / h...
    method clear (line 596) | public void clear() {
    method clear (line 607) | public void clear(Color color) {
    method getPenRadius (line 622) | public double getPenRadius() {
    method setPenRadius (line 629) | public void setPenRadius() {
    method setPenRadius (line 639) | public void setPenRadius(double radius) {
    method getPenColor (line 654) | public Color getPenColor() {
    method getBackgroundColor (line 663) | public Color getBackgroundColor() {
    method setPenColor (line 670) | public void setPenColor() {
    method setPenColor (line 680) | public void setPenColor(Color color) {
    method setPenColor (line 695) | public void setPenColor(int red, int green, int blue) {
    method xorOn (line 706) | public void xorOn() {
    method xorOff (line 713) | public void xorOff() {
    method getJLabel (line 722) | public JLabel getJLabel() {
    method getFont (line 731) | public Font getFont() {
    method setFont (line 738) | public void setFont() {
    method setFont (line 748) | public void setFont(Font font) {
    method line (line 767) | public void line(double x0, double y0, double x1, double y1) {
    method pixel (line 783) | private void pixel(double x, double y) {
    method point (line 796) | public void point(double x, double y) {
    method circle (line 820) | public void circle(double x, double y, double radius) {
    method filledCircle (line 844) | public void filledCircle(double x, double y, double radius) {
    method ellipse (line 872) | public void ellipse(double x, double y, double semiMajorAxis, double s...
    method filledEllipse (line 901) | public void filledEllipse(double x, double y, double semiMajorAxis, do...
    method arc (line 931) | public void arc(double x, double y, double radius, double angle1, doub...
    method square (line 958) | public void square(double x, double y, double halfLength) {
    method filledSquare (line 982) | public void filledSquare(double x, double y, double halfLength) {
    method rectangle (line 1008) | public void rectangle(double x, double y, double halfWidth, double hal...
    method filledRectangle (line 1035) | public void filledRectangle(double x, double y, double halfWidth, doub...
    method polygon (line 1065) | public void polygon(double[] x, double[] y) {
    method filledPolygon (line 1099) | public void filledPolygon(double[] x, double[] y) {
    method getImage (line 1127) | private static Image getImage(String filename) {
    method picture (line 1178) | public void picture(double x, double y, String filename) {
    method picture (line 1207) | public void picture(double x, double y, String filename, double degree...
    method picture (line 1243) | public void picture(double x, double y, String filename, double scaled...
    method picture (line 1284) | public void picture(double x, double y, String filename, double scaled...
    method text (line 1326) | public void text(double x, double y, String text) {
    method text (line 1351) | public void text(double x, double y, String text, double degrees) {
    method textLeft (line 1372) | public void textLeft(double x, double y, String text) {
    method textRight (line 1396) | public void textRight(double x, double y, String text) {
    method show (line 1418) | @Deprecated
    method pause (line 1430) | public void pause(int t) {
    method show (line 1443) | public void show() {
    method draw (line 1457) | private void draw() {
    method enableDoubleBuffering (line 1467) | public void enableDoubleBuffering() {
    method disableDoubleBuffering (line 1477) | public void disableDoubleBuffering() {
    method save (line 1493) | public void save(String filename) {
    method actionPerformed (line 1525) | @Override
    method addListener (line 1552) | public void addListener(DrawListener listener) {
    method isMousePressed (line 1571) | public boolean isMousePressed() {
    method mousePressed (line 1584) | @Deprecated
    method mouseX (line 1595) | public double mouseX() {
    method mouseY (line 1606) | public double mouseY() {
    method mouseEntered (line 1617) | @Override
    method mouseExited (line 1625) | @Override
    method mousePressed (line 1633) | @Override
    method mouseReleased (line 1650) | @Override
    method mouseClicked (line 1664) | @Override
    method mouseDragged (line 1676) | @Override
    method mouseMoved (line 1690) | @Override
    method hasNextKeyTyped (line 1708) | public boolean hasNextKeyTyped() {
    method nextKeyTyped (line 1719) | public char nextKeyTyped() {
    method isKeyPressed (line 1737) | public boolean isKeyPressed(int keycode) {
    method keyTyped (line 1746) | @Override
    method keyPressed (line 1760) | @Override
    method keyReleased (line 1774) | @Override
    method enableTimer (line 1795) | public void enableTimer(int callsPerSecond) {
    method disableTimer (line 1801) | public void disableTimer() {
    class MyTimerTask (line 1805) | private class MyTimerTask extends TimerTask {
      method run (line 1806) | public void run() {
    class RetinaImageIcon (line 1816) | private static class RetinaImageIcon extends ImageIcon {
      method RetinaImageIcon (line 1818) | public RetinaImageIcon(Image image) {
      method getIconWidth (line 1822) | public int getIconWidth() {
      method getIconHeight (line 1831) | public int getIconHeight() {
      method paintIcon (line 1835) | public synchronized void paintIcon(Component c, Graphics g, int x, i...
    method main (line 1851) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/DrawListener.java
  type DrawListener (line 27) | public interface DrawListener {
    method mousePressed (line 35) | default void mousePressed(double x, double y) {
    method mouseDragged (line 45) | default void mouseDragged(double x, double y) {
    method mouseReleased (line 55) | default void mouseReleased(double x, double y) {
    method mouseClicked (line 70) | default void mouseClicked(double x, double y) {
    method keyTyped (line 79) | default void keyTyped(char c) {
    method keyPressed (line 88) | default void keyPressed(int keycode) {
    method keyReleased (line 97) | default void keyReleased(int keycode) {
    method update (line 104) | default void update() {

FILE: src/main/java/edu/princeton/cs/algs4/Edge.java
  class Edge (line 26) | public class Edge implements Comparable<Edge> {
    method Edge (line 43) | public Edge(int v, int w, double weight) {
    method weight (line 57) | public double weight() {
    method either (line 66) | public int either() {
    method other (line 78) | public int other(int vertex) {
    method compareTo (line 94) | @Override
    method toString (line 104) | public String toString() {
    method main (line 113) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/EdgeWeightedDigraph.java
  class EdgeWeightedDigraph (line 47) | public class EdgeWeightedDigraph {
    method EdgeWeightedDigraph (line 61) | public EdgeWeightedDigraph(int V) {
    method EdgeWeightedDigraph (line 79) | public EdgeWeightedDigraph(int V, int E) {
    method EdgeWeightedDigraph (line 103) | public EdgeWeightedDigraph(In in) {
    method EdgeWeightedDigraph (line 135) | public EdgeWeightedDigraph(EdgeWeightedDigraph G) {
    method V (line 157) | public int V() {
    method E (line 166) | public int E() {
    method validateVertex (line 171) | private void validateVertex(int v) {
    method addEdge (line 183) | public void addEdge(DirectedEdge e) {
    method adj (line 201) | public Iterable<DirectedEdge> adj(int v) {
    method outdegree (line 214) | public int outdegree(int v) {
    method indegree (line 227) | public int indegree(int v) {
    method edges (line 239) | public Iterable<DirectedEdge> edges() {
    method toString (line 255) | public String toString() {
    method toDot (line 290) | public String toDot() {
    method main (line 310) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/EdgeWeightedDirectedCycle.java
  class EdgeWeightedDirectedCycle (line 39) | public class EdgeWeightedDirectedCycle {
    method EdgeWeightedDirectedCycle (line 50) | public EdgeWeightedDirectedCycle(EdgeWeightedDigraph G) {
    method dfs (line 62) | private void dfs(EdgeWeightedDigraph G, int v) {
    method hasCycle (line 100) | public boolean hasCycle() {
    method cycle (line 110) | public Iterable<DirectedEdge> cycle() {
    method check (line 116) | private boolean check() {
    method main (line 155) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/EdgeWeightedGraph.java
  class EdgeWeightedGraph (line 61) | public class EdgeWeightedGraph {
    method EdgeWeightedGraph (line 74) | public EdgeWeightedGraph(int V) {
    method EdgeWeightedGraph (line 92) | public EdgeWeightedGraph(int V, int E) {
    method EdgeWeightedGraph (line 116) | public EdgeWeightedGraph(In in) {
    method EdgeWeightedGraph (line 149) | public EdgeWeightedGraph(EdgeWeightedGraph G) {
    method V (line 170) | public int V() {
    method E (line 179) | public int E() {
    method validateVertex (line 184) | private void validateVertex(int v) {
    method addEdge (line 195) | public void addEdge(Edge e) {
    method adj (line 212) | public Iterable<Edge> adj(int v) {
    method degree (line 224) | public int degree(int v) {
    method edges (line 236) | public Iterable<Edge> edges() {
    method toString (line 261) | public String toString() {
    method toDot (line 296) | public String toDot() {
    method main (line 315) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/EulerianCycle.java
  class EulerianCycle (line 44) | public class EulerianCycle {
    class Edge (line 48) | private static class Edge {
      method Edge (line 53) | public Edge(int v, int w) {
      method other (line 60) | public int other(int vertex) {
    method EulerianCycle (line 72) | public EulerianCycle(Graph graph) {
    method cycle (line 142) | public Iterable<Integer> cycle() {
    method hasEulerianCycle (line 152) | public boolean hasEulerianCycle() {
    method nonIsolatedVertex (line 157) | private static int nonIsolatedVertex(Graph graph) {
    method satisfiesNecessaryAndSufficientConditions (line 175) | private static boolean satisfiesNecessaryAndSufficientConditions(Graph...
    method certifySolution (line 196) | private boolean certifySolution(Graph graph) {
    method unitTest (line 224) | private static void unitTest(Graph graph, String description) {
    method main (line 250) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/EulerianPath.java
  class EulerianPath (line 38) | public class EulerianPath {
    class Edge (line 42) | private static class Edge {
      method Edge (line 47) | public Edge(int v, int w) {
      method other (line 54) | public int other(int vertex) {
    method EulerianPath (line 66) | public EulerianPath(Graph graph) {
    method path (line 145) | public Iterable<Integer> path() {
    method hasEulerianPath (line 155) | public boolean hasEulerianPath() {
    method nonIsolatedVertex (line 161) | private static int nonIsolatedVertex(Graph graph) {
    method satisfiesNecessaryAndSufficientConditions (line 180) | private static boolean satisfiesNecessaryAndSufficientConditions(Graph...
    method certifySolution (line 201) | private boolean certifySolution(Graph graph) {
    method unitTest (line 222) | private static void unitTest(Graph graph, String description) {
    method main (line 248) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/FFT.java
  class FFT (line 89) | public class FFT {
    method FFT (line 94) | private FFT() { }
    method fft (line 103) | public static Complex[] fft(Complex[] x) {
    method ifft (line 149) | public static Complex[] ifft(Complex[] x) {
    method cconvolve (line 184) | public static Complex[] cconvolve(Complex[] x, Complex[] y) {
    method convolve (line 217) | public static Complex[] convolve(Complex[] x, Complex[] y) {
    method show (line 234) | private static void show(Complex[] x, String title) {
    method main (line 253) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/FarthestPair.java
  class FarthestPair (line 41) | public class FarthestPair {
    method FarthestPair (line 54) | public FarthestPair(Point2D[] points) {
    method either (line 122) | public Point2D either() {
    method other (line 132) | public Point2D other() {
    method distance (line 144) | public double distance() {
    method main (line 157) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/FenwickTree.java
  class FenwickTree (line 42) | public class FenwickTree {
    method FenwickTree (line 46) | public FenwickTree(int size) {
    method rsq (line 59) | public int rsq(int ind) {
    method rsq (line 82) | public int rsq(int a, int b) {
    method update (line 97) | public void update(int ind, int value) {
    method size (line 106) | public int size() {
    method main (line 131) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/FibonacciMinPQ.java
  class FibonacciMinPQ (line 34) | public class FibonacciMinPQ<Key> implements Iterable<Key> {
    class Node (line 42) | private class Node {
    method FibonacciMinPQ (line 54) | public FibonacciMinPQ(Comparator<Key> C) {
    method FibonacciMinPQ (line 62) | public FibonacciMinPQ() {
    method FibonacciMinPQ (line 71) | public FibonacciMinPQ(Key[] a) {
    method FibonacciMinPQ (line 82) | public FibonacciMinPQ(Comparator<Key> C, Key[] a) {
    method isEmpty (line 92) | public boolean isEmpty() {
    method size (line 101) | public int size() {
    method insert (line 110) | public void insert(Key key) {
    method minKey (line 125) | public Key minKey() {
    method delMin (line 136) | public Key delMin() {
    method union (line 159) | public FibonacciMinPQ<Key> union(FibonacciMinPQ<Key> that) {
    method greater (line 171) | private boolean greater(Key n, Key m) {
    method link (line 178) | private void link(Node root1, Node root2) {
    method consolidate (line 188) | private void consolidate() {
    method insert (line 225) | private Node insert(Node x, Node head) {
    method cut (line 239) | private Node cut(Node x, Node head) {
    method meld (line 256) | private Node meld(Node x, Node y) {
    method iterator (line 279) | public Iterator<Key> iterator() {
    class MyIterator (line 283) | private class MyIterator implements Iterator<Key> {
      method MyIterator (line 288) | public MyIterator() {
      method insertAll (line 293) | private void insertAll(Node head) {
      method remove (line 303) | public void remove() {
      method hasNext (line 307) | public boolean hasNext() {
      method next (line 312) | public Key next() {
    class MyComparator (line 323) | private class MyComparator implements Comparator<Key> {
      method compare (line 324) | @Override

FILE: src/main/java/edu/princeton/cs/algs4/FileIndex.java
  class FileIndex (line 43) | public class FileIndex {
    method FileIndex (line 46) | private FileIndex() { }
    method main (line 48) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/FlowEdge.java
  class FlowEdge (line 27) | public class FlowEdge {
    method FlowEdge (line 46) | public FlowEdge(int v, int w, double capacity) {
    method FlowEdge (line 69) | public FlowEdge(int v, int w, double capacity, double flow) {
    method FlowEdge (line 85) | public FlowEdge(FlowEdge e) {
    method from (line 96) | public int from() {
    method to (line 104) | public int to() {
    method capacity (line 112) | public double capacity() {
    method flow (line 120) | public double flow() {
    method other (line 133) | public int other(int vertex) {
    method residualCapacityTo (line 149) | public double residualCapacityTo(int vertex) {
    method addResidualFlowTo (line 167) | public void addResidualFlowTo(int vertex, double delta) {
    method toString (line 189) | public String toString() {
    method main (line 199) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/FlowNetwork.java
  class FlowNetwork (line 36) | public class FlowNetwork {
    method FlowNetwork (line 48) | public FlowNetwork(int V) {
    method FlowNetwork (line 65) | public FlowNetwork(int V, int E) {
    method FlowNetwork (line 86) | public FlowNetwork(In in) {
    method V (line 105) | public int V() {
    method E (line 113) | public int E() {
    method validateVertex (line 118) | private void validateVertex(int v) {
    method addEdge (line 129) | public void addEdge(FlowEdge e) {
    method adj (line 146) | public Iterable<FlowEdge> adj(int v) {
    method edges (line 152) | public Iterable<FlowEdge> edges() {
    method toString (line 169) | public String toString() {
    method main (line 187) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/FloydWarshall.java
  class FloydWarshall (line 50) | public class FloydWarshall {
    method FloydWarshall (line 61) | public FloydWarshall(AdjMatrixEdgeWeightedDigraph G) {
    method hasNegativeCycle (line 111) | public boolean hasNegativeCycle() {
    method negativeCycle (line 120) | public Iterable<DirectedEdge> negativeCycle() {
    method hasPath (line 146) | public boolean hasPath(int s, int t) {
    method dist (line 161) | public double dist(int s, int t) {
    method path (line 178) | public Iterable<DirectedEdge> path(int s, int t) {
    method check (line 192) | private boolean check(AdjMatrixEdgeWeightedDigraph G) {
    method validateVertex (line 212) | private void validateVertex(int v) {
    method main (line 223) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/FordFulkerson.java
  class FordFulkerson (line 40) | public class FordFulkerson {
    method FordFulkerson (line 60) | public FordFulkerson(FlowNetwork G, int s, int t) {
    method value (line 94) | public double value()  {
    method inCut (line 106) | public boolean inCut(int v)  {
    method validate (line 112) | private void validate(int v)  {
    method hasAugmentingPath (line 122) | private boolean hasAugmentingPath(FlowNetwork G, int s, int t) {
    method excess (line 154) | private double excess(FlowNetwork G, int v) {
    method isFeasible (line 164) | private boolean isFeasible(FlowNetwork G, int s, int t) {
    method check (line 200) | private boolean check(FlowNetwork G, int s, int t) {
    method main (line 241) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/FrequencyCounter.java
  class FrequencyCounter (line 41) | public class FrequencyCounter {
    method FrequencyCounter (line 44) | private FrequencyCounter() { }
    method main (line 55) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/GREP.java
  class GREP (line 41) | public class GREP {
    method GREP (line 44) | private GREP() { }
    method main (line 55) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/GabowSCC.java
  class GabowSCC (line 55) | public class GabowSCC {
    method GabowSCC (line 70) | public GabowSCC(Digraph digraph) {
    method dfs (line 87) | private void dfs(Digraph digraph, int v) {
    method count (line 116) | public int count() {
    method stronglyConnected (line 129) | public boolean stronglyConnected(int v, int w) {
    method id (line 141) | public int id(int v) {
    method check (line 147) | private boolean check(Digraph digraph) {
    method validateVertex (line 159) | private void validateVertex(int v) {
    method main (line 170) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/GaussJordanElimination.java
  class GaussJordanElimination (line 67) | public class GaussJordanElimination {
    method GaussJordanElimination (line 82) | public GaussJordanElimination(double[][] A, double[] b) {
    method solve (line 103) | private void solve() {
    method swap (line 133) | private void swap(int row1, int row2) {
    method pivot (line 141) | private void pivot(int p, int q) {
    method primal (line 167) | public double[] primal() {
    method dual (line 185) | public double[] dual() {
    method isFeasible (line 204) | public boolean isFeasible() {
    method show (line 209) | private void show() {
    method certifySolution (line 225) | private boolean certifySolution(double[][] A, double[] b) {
    method test (line 272) | private static void test(String name, double[][] A, double[] b) {
    method test1 (line 297) | private static void test1() {
    method test2 (line 308) | private static void test2() {
    method test3 (line 320) | private static void test3() {
    method test4 (line 333) | private static void test4() {
    method test5 (line 347) | private static void test5() {
    method test6 (line 358) | private static void test6() {
    method main (line 373) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/GaussianElimination.java
  class GaussianElimination (line 64) | public class GaussianElimination {
    method GaussianElimination (line 81) | public GaussianElimination(double[][] A, double[] b) {
    method forwardElimination (line 101) | private void forwardElimination() {
    method swap (line 126) | private void swap(int row1, int row2) {
    method pivot (line 133) | private void pivot(int p) {
    method primal (line 148) | public double[] primal() {
    method isFeasible (line 182) | public boolean isFeasible() {
    method certifySolution (line 188) | private boolean certifySolution(double[][] A, double[] b) {
    method test (line 209) | private static void test(String name, double[][] A, double[] b) {
    method test1 (line 229) | private static void test1() {
    method test2 (line 240) | private static void test2() {
    method test3 (line 251) | private static void test3() {
    method test4 (line 264) | private static void test4() {
    method test5 (line 277) | private static void test5() {
    method test6 (line 288) | private static void test6() {
    method test7 (line 299) | private static void test7() {
    method test8 (line 311) | private static void test8() {
    method test9 (line 323) | private static void test9() {
    method main (line 338) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Genome.java
  class Genome (line 31) | public class Genome {
    method Genome (line 34) | private Genome() { }
    method compress (line 41) | public static void compress() {
    method expand (line 60) | public static void expand() {
    method main (line 78) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/GlobalMincut.java
  class GlobalMincut (line 50) | public class GlobalMincut {
    class CutPhase (line 69) | private class CutPhase {
      method CutPhase (line 74) | public CutPhase(double weight, int s, int t) {
    method GlobalMincut (line 89) | public GlobalMincut(EdgeWeightedGraph G) {
    method validate (line 103) | private void validate(EdgeWeightedGraph G) {
    method weight (line 115) | public double weight() {
    method cut (line 132) | public boolean cut(int v) {
    method makeCut (line 146) | private void makeCut(int t, UF uf) {
    method minCut (line 160) | private void minCut(EdgeWeightedGraph G, int a) {
    method minCutPhase (line 190) | private void minCutPhase(EdgeWeightedGraph G, boolean[] marked, CutPha...
    method contractEdge (line 221) | private EdgeWeightedGraph contractEdge(EdgeWeightedGraph G, int s, int...
    method check (line 243) | private boolean check(EdgeWeightedGraph G) {
    method validateVertex (line 267) | private void validateVertex(int v) {
    method main (line 278) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/GrahamScan.java
  class GrahamScan (line 46) | public class GrahamScan {
    method GrahamScan (line 57) | public GrahamScan(Point2D[] points) {
    method hull (line 111) | public Iterable<Point2D> hull() {
    method isConvex (line 118) | private boolean isConvex() {
    method main (line 145) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Graph.java
  class Graph (line 71) | public class Graph {
    method Graph (line 85) | public Graph(int V) {
    method Graph (line 107) | public Graph(In in) {
    method Graph (line 138) | public Graph(Graph graph) {
    method V (line 166) | public int V() {
    method E (line 175) | public int E() {
    method validateVertex (line 180) | private void validateVertex(int v) {
    method addEdge (line 192) | public void addEdge(int v, int w) {
    method adj (line 208) | public Iterable<Integer> adj(int v) {
    method degree (line 220) | public int degree(int v) {
    method toString (line 232) | public String toString() {
    method toDot (line 267) | public String toDot() {
    method main (line 295) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/GraphGenerator.java
  class GraphGenerator (line 26) | public class GraphGenerator {
    class Edge (line 27) | private static final class Edge implements Comparable<Edge> {
      method Edge (line 31) | private Edge(int v, int w) {
      method compareTo (line 42) | public int compareTo(Edge that) {
    method GraphGenerator (line 52) | private GraphGenerator() { }
    method simple (line 62) | public static Graph simple(int V, int E) {
    method simple (line 89) | public static Graph simple(int V, double p) {
    method complete (line 105) | public static Graph complete(int V) {
    method completeBipartite (line 116) | public static Graph completeBipartite(int V1, int V2) {
    method bipartite (line 130) | public static Graph bipartite(int V1, int V2, int E) {
    method bipartite (line 163) | public static Graph bipartite(int V1, int V2, double p) {
    method path (line 183) | public static Graph path(int V) {
    method binaryTree (line 200) | public static Graph binaryTree(int V) {
    method cycle (line 217) | public static Graph cycle(int V) {
    method eulerianCycle (line 239) | public static Graph eulerianCycle(int V, int E) {
    method eulerianPath (line 264) | public static Graph eulerianPath(int V, int E) {
    method wheel (line 285) | public static Graph wheel(int V) {
    method star (line 313) | public static Graph star(int V) {
    method regular (line 338) | public static Graph regular(int V, int k) {
    method tree (line 366) | public static Graph tree(int V) {
    method main (line 409) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/GrayscalePicture.java
  class GrayscalePicture (line 85) | public final class GrayscalePicture implements ActionListener {
    method GrayscalePicture (line 102) | public GrayscalePicture(int width, int height) {
    method GrayscalePicture (line 116) | public GrayscalePicture(GrayscalePicture picture) {
    method GrayscalePicture (line 136) | public GrayscalePicture(String filename) {
    method toGray (line 188) | private static Color toGray(Color color) {
    method getJLabel (line 202) | public JLabel getJLabel() {
    method setOriginUpperLeft (line 211) | public void setOriginUpperLeft() {
    method setOriginLowerLeft (line 218) | public void setOriginLowerLeft() {
    method show (line 225) | public void show() {
    method hide (line 263) | public void hide() {
    method isVisible (line 274) | public boolean isVisible() {
    method height (line 283) | public int height() {
    method width (line 292) | public int width() {
    method validateRowIndex (line 296) | private void validateRowIndex(int row) {
    method validateColumnIndex (line 301) | private void validateColumnIndex(int col) {
    method validateGrayscaleValue (line 306) | private void validateGrayscaleValue(int gray) {
    method get (line 319) | public Color get(int col, int row) {
    method getGrayscale (line 337) | public int getGrayscale(int col, int row) {
    method set (line 353) | public void set(int col, int row, Color color) {
    method setGrayscale (line 370) | public void setGrayscale(int col, int row, int gray) {
    method equals (line 386) | public boolean equals(Object other) {
    method toString (line 406) | public String toString() {
    method hashCode (line 427) | public int hashCode() {
    method save (line 441) | public void save(String filename) {
    method save (line 453) | public void save(File file) {
    method actionPerformed (line 485) | @Override
    method main (line 509) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Heap.java
  class Heap (line 45) | public class Heap {
    method Heap (line 48) | private Heap() { }
    method sort (line 54) | public static void sort(Comparable[] pq) {
    method sink (line 73) | private static void sink(Comparable[] pq, int k, int n) {
    method less (line 87) | private static boolean less(Comparable[] pq, int i, int j) {
    method exch (line 91) | private static void exch(Object[] pq, int i, int j) {
    method show (line 98) | private static void show(Comparable[] a) {
    method main (line 110) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/HexDump.java
  class HexDump (line 45) | public class HexDump {
    method HexDump (line 48) | private HexDump() { }
    method main (line 59) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/HopcroftKarp.java
  class HopcroftKarp (line 56) | public class HopcroftKarp {
    method HopcroftKarp (line 75) | public HopcroftKarp(Graph G) {
    method toString (line 147) | private static String toString(Iterable<Integer> path) {
    method isLevelGraphEdge (line 157) | private boolean isLevelGraphEdge(int v, int w) {
    method isResidualGraphEdge (line 162) | private boolean isResidualGraphEdge(int v, int w) {
    method hasAugmentingPath (line 179) | private boolean hasAugmentingPath(Graph G) {
    method mate (line 233) | public int mate(int v) {
    method isMatched (line 248) | public boolean isMatched(int v) {
    method size (line 258) | public int size() {
    method isPerfect (line 270) | public boolean isPerfect() {
    method inMinVertexCover (line 283) | public boolean inMinVertexCover(int v) {
    method validate (line 289) | private void validate(int v) {
    method certifySolution (line 301) | private boolean certifySolution(Graph G) {
    method main (line 361) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Huffman.java
  class Huffman (line 37) | public class Huffman {
    method Huffman (line 43) | private Huffman() { }
    class Node (line 46) | private static class Node implements Comparable<Node> {
      method Node (line 51) | Node(char ch, int freq, Node left, Node right) {
      method isLeaf (line 59) | private boolean isLeaf() {
      method compareTo (line 65) | public int compareTo(Node that) {
    method compress (line 75) | public static void compress() {
    method buildTrie (line 117) | private static Node buildTrie(int[] freq) {
    method writeTrie (line 137) | private static void writeTrie(Node x) {
    method buildCode (line 149) | private static void buildCode(String[] st, Node x, String s) {
    method expand (line 163) | public static void expand() {
    method readTrie (line 185) | private static Node readTrie() {
    method main (line 201) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/In.java
  class In (line 59) | public final class In {
    method In (line 87) | public In() {
    method In (line 99) | public In(Socket socket) {
    method In (line 118) | public In(URL url) {
    method In (line 138) | public In(File file) {
    method In (line 161) | public In(String name) {
    method In (line 217) | public In(Scanner scanner) {
    method exists (line 227) | public boolean exists()  {
    method isEmpty (line 242) | public boolean isEmpty() {
    method hasNextLine (line 255) | public boolean hasNextLine() {
    method hasNextChar (line 267) | public boolean hasNextChar() {
    method readLine (line 280) | public String readLine() {
    method readChar (line 297) | public char readChar() {
    method readAll (line 318) | public String readAll() {
    method readString (line 335) | public String readString() {
    method readInt (line 353) | public int readInt() {
    method readDouble (line 376) | public double readDouble() {
    method readFloat (line 399) | public float readFloat() {
    method readLong (line 422) | public long readLong() {
    method readShort (line 445) | public short readShort() {
    method readByte (line 470) | public byte readByte() {
    method readBoolean (line 494) | public boolean readBoolean() {
    method readAllStrings (line 516) | public String[] readAllStrings() {
    method readAllLines (line 534) | public String[] readAllLines() {
    method readAllInts (line 549) | public int[] readAllInts() {
    method readAllLongs (line 563) | public long[] readAllLongs() {
    method readAllDoubles (line 577) | public double[] readAllDoubles() {
    method close (line 590) | public void close() {
    method readInts (line 602) | @Deprecated
    method readDoubles (line 615) | @Deprecated
    method readStrings (line 628) | @Deprecated
    method readInts (line 640) | @Deprecated
    method readDoubles (line 652) | @Deprecated
    method readStrings (line 664) | @Deprecated
    method main (line 674) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/IndexBinomialMinPQ.java
  class IndexBinomialMinPQ (line 35) | public class IndexBinomialMinPQ<Key> implements Iterable<Integer> {
    class Node (line 42) | private class Node<Key> {
    method IndexBinomialMinPQ (line 56) | public IndexBinomialMinPQ(int N) {
    method IndexBinomialMinPQ (line 70) | public IndexBinomialMinPQ(int N, Comparator<Key> comparator) {
    method isEmpty (line 82) | public boolean isEmpty() {
    method contains (line 93) | public boolean contains(int i) {
    method size (line 103) | public int size() {
    method insert (line 121) | public void insert(int i, Key key) {
    method minIndex (line 141) | public int minIndex() {
    method minKey (line 159) | public Key minKey() {
    method delMin (line 177) | public int delMin() {
    method keyOf (line 208) | public Key keyOf(int i) {
    method changeKey (line 223) | public void changeKey(int i, Key key) {
    method decreaseKey (line 240) | public void decreaseKey(int i, Key key) {
    method increaseKey (line 259) | public void increaseKey(int i, Key key) {
    method delete (line 275) | public void delete(int i) {
    method greater (line 304) | private boolean greater(Key n, Key m) {
    method exchange (line 311) | private void exchange(Node<Key> x, Node<Key> y) {
    method link (line 319) | private void link(Node<Key> root1, Node<Key> root2) {
    method swim (line 331) | private void swim(int i) {
    method toTheRoot (line 342) | private void toTheRoot(int i) {
    method erase (line 357) | private Node<Key> erase(int i) {
    method eraseMin (line 372) | private Node<Key> eraseMin() {
    method merge (line 394) | private Node<Key> merge(Node<Key> h, Node<Key> x, Node<Key> y) {
    method union (line 406) | private IndexBinomialMinPQ<Key> union(IndexBinomialMinPQ<Key> heap) {
    method IndexBinomialMinPQ (line 435) | private IndexBinomialMinPQ() { comparator = null; }
    method iterator (line 450) | public Iterator<Integer> iterator() {
    class MyIterator (line 454) | private class MyIterator implements Iterator<Integer> {
      method MyIterator (line 459) | public MyIterator() {
      method clone (line 464) | private Node<Key> clone(Node<Key> x, Node<Key> parent) {
      method hasNext (line 476) | public boolean hasNext() {
      method next (line 480) | public Integer next() {
      method remove (line 485) | public void remove() {
    class MyComparator (line 495) | private class MyComparator implements Comparator<Key> {
      method compare (line 496) | @Override

FILE: src/main/java/edu/princeton/cs/algs4/IndexFibonacciMinPQ.java
  class IndexFibonacciMinPQ (line 39) | public class IndexFibonacciMinPQ<Key> implements Iterable<Integer> {
    class Node (line 49) | private class Node<Key> {
    method IndexFibonacciMinPQ (line 64) | public IndexFibonacciMinPQ(int N) {
    method IndexFibonacciMinPQ (line 78) | public IndexFibonacciMinPQ(Comparator<Key> C, int N) {
    method isEmpty (line 91) | public boolean isEmpty() {
    method contains (line 103) | public boolean contains(int i) {
    method size (line 114) | public int size() {
    method insert (line 127) | public void insert(int i, Key key) {
    method minIndex (line 147) | public int minIndex() {
    method minKey (line 159) | public Key minKey() {
    method delMin (line 171) | public int delMin() {
    method keyOf (line 201) | public Key keyOf(int i) {
    method changeKey (line 217) | public void changeKey(int i, Key key) {
    method decreaseKey (line 234) | public void decreaseKey(int i, Key key) {
    method increaseKey (line 256) | public void increaseKey(int i, Key key) {
    method delete (line 272) | public void delete(int i) {
    method greater (line 302) | private boolean greater(Key n, Key m) {
    method link (line 309) | private void link(Node<Key> root1, Node<Key> root2) {
    method cut (line 321) | private void cut(int i) {
    method consolidate (line 339) | private void consolidate() {
    method insert (line 374) | private Node<Key> insert(Node<Key> x, Node<Key> head) {
    method cut (line 388) | private Node<Key> cut(Node<Key> x, Node<Key> head) {
    method meld (line 405) | private Node<Key> meld(Node<Key> x, Node<Key> y) {
    method iterator (line 428) | public Iterator<Integer> iterator() {
    class MyIterator (line 432) | private class MyIterator implements Iterator<Integer> {
      method MyIterator (line 437) | public MyIterator() {
      method remove (line 444) | public void remove() {
      method hasNext (line 448) | public boolean hasNext() {
      method next (line 453) | public Integer next() {
    class MyComparator (line 464) | private class MyComparator implements Comparator<Key> {
      method compare (line 465) | @Override

FILE: src/main/java/edu/princeton/cs/algs4/IndexMaxPQ.java
  class IndexMaxPQ (line 44) | public class IndexMaxPQ<Key extends Comparable<Key>> implements Iterable...
    method IndexMaxPQ (line 58) | public IndexMaxPQ(int maxN) {
    method isEmpty (line 75) | public boolean isEmpty() {
    method contains (line 87) | public boolean contains(int i) {
    method size (line 97) | public int size() {
    method insert (line 110) | public void insert(int i, Key key) {
    method maxIndex (line 126) | public int maxIndex() {
    method maxKey (line 137) | public Key maxKey() {
    method delMax (line 148) | public int delMax() {
    method keyOf (line 169) | public Key keyOf(int i) {
    method changeKey (line 182) | public void changeKey(int i, Key key) {
    method change (line 198) | @Deprecated
    method increaseKey (line 213) | public void increaseKey(int i, Key key) {
    method decreaseKey (line 234) | public void decreaseKey(int i, Key key) {
    method delete (line 252) | public void delete(int i) {
    method validateIndex (line 264) | private void validateIndex(int i) {
    method less (line 272) | private boolean less(int i, int j) {
    method exch (line 276) | private void exch(int i, int j) {
    method swim (line 288) | private void swim(int k) {
    method sink (line 295) | private void sink(int k) {
    method iterator (line 313) | public Iterator<Integer> iterator() {
    class HeapIterator (line 317) | private class HeapIterator implements Iterator<Integer> {
      method HeapIterator (line 323) | public HeapIterator() {
      method hasNext (line 329) | public boolean hasNext()  { return !copy.isEmpty();                 ...
      method remove (line 330) | public void remove()      { throw new UnsupportedOperationException(...
      method next (line 332) | public Integer next() {
    method main (line 343) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/IndexMinPQ.java
  class IndexMinPQ (line 44) | public class IndexMinPQ<Key extends Comparable<Key>> implements Iterable...
    method IndexMinPQ (line 58) | public IndexMinPQ(int maxN) {
    method isEmpty (line 75) | public boolean isEmpty() {
    method contains (line 87) | public boolean contains(int i) {
    method size (line 97) | public int size() {
    method insert (line 110) | public void insert(int i, Key key) {
    method minIndex (line 126) | public int minIndex() {
    method minKey (line 137) | public Key minKey() {
    method delMin (line 147) | public int delMin() {
    method keyOf (line 167) | public Key keyOf(int i) {
    method changeKey (line 181) | public void changeKey(int i, Key key) {
    method change (line 197) | @Deprecated
    method decreaseKey (line 211) | public void decreaseKey(int i, Key key) {
    method increaseKey (line 231) | public void increaseKey(int i, Key key) {
    method delete (line 249) | public void delete(int i) {
    method validateIndex (line 261) | private void validateIndex(int i) {
    method greater (line 269) | private boolean greater(int i, int j) {
    method exch (line 273) | private void exch(int i, int j) {
    method swim (line 285) | private void swim(int k) {
    method sink (line 292) | private void sink(int k) {
    method iterator (line 314) | public Iterator<Integer> iterator() { return new HeapIterator(); }
    class HeapIterator (line 316) | private class HeapIterator implements Iterator<Integer> {
      method HeapIterator (line 322) | public HeapIterator() {
      method hasNext (line 328) | public boolean hasNext()  { return !copy.isEmpty();                 ...
      method remove (line 329) | public void remove()      { throw new UnsupportedOperationException(...
      method next (line 331) | public Integer next() {
    method main (line 343) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/IndexMultiwayMinPQ.java
  class IndexMultiwayMinPQ (line 40) | public class IndexMultiwayMinPQ<Key> implements Iterable<Integer> {
    method IndexMultiwayMinPQ (line 58) | public IndexMultiwayMinPQ(int N, int D) {
    method IndexMultiwayMinPQ (line 79) | public IndexMultiwayMinPQ(int N, Comparator<Key> C, int D) {
    method isEmpty (line 96) | public boolean isEmpty() {
    method contains (line 107) | public boolean contains(int i) {
    method size (line 117) | public int size() {
    method insert (line 129) | public void insert(int i, Key key) {
    method minIndex (line 144) | public int minIndex() {
    method minKey (line 155) | public Key minKey() {
    method delMin (line 166) | public int delMin() {
    method keyOf (line 185) | public Key keyOf(int i) {
    method changeKey (line 200) | public void changeKey(int i, Key key) {
    method decreaseKey (line 218) | public void decreaseKey(int i, Key key) {
    method increaseKey (line 235) | public void increaseKey(int i, Key key) {
    method delete (line 250) | public void delete(int i) {
    method greater (line 266) | private boolean greater(int i, int j) {
    method exch (line 271) | private void exch(int x, int y) {
    method swim (line 285) | private void swim(int i) {
    method sink (line 293) | private void sink(int i) {
    method minChild (line 308) | private int minChild(int i) {
    method iterator (line 330) | public Iterator<Integer> iterator() {
    class MyIterator (line 335) | private class MyIterator implements Iterator<Integer> {
      method MyIterator (line 338) | public MyIterator() {
      method hasNext (line 345) | public boolean hasNext() {
      method next (line 349) | public Integer next() {
      method remove (line 354) | public void remove() {
    class MyComparator (line 364) | private class MyComparator implements Comparator<Key> {
      method compare (line 365) | @Override

FILE: src/main/java/edu/princeton/cs/algs4/InplaceMSD.java
  class InplaceMSD (line 41) | public class InplaceMSD {
    method InplaceMSD (line 46) | private InplaceMSD() { }
    method sort (line 54) | public static void sort(String[] a) {
    method charAt (line 60) | private static int charAt(String s, int d) {
    method sort (line 67) | private static void sort(String[] a, int lo, int hi, int d) {
    method insertion (line 109) | private static void insertion(String[] a, int lo, int hi, int d) {
    method exch (line 116) | private static void exch(String[] a, int i, int j) {
    method less (line 123) | private static boolean less(String v, String w, int d) {
    method main (line 140) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Insertion.java
  class Insertion (line 51) | public class Insertion {
    method Insertion (line 54) | private Insertion() { }
    method sort (line 60) | public static void sort(Comparable[] a) {
    method sort (line 77) | public static void sort(Comparable[] a, int lo, int hi) {
    method sort (line 91) | public static void sort(Object[] a, Comparator comparator) {
    method sort (line 109) | public static void sort(Object[] a, int lo, int hi, Comparator compara...
    method indexSort (line 127) | public static int[] indexSort(Comparable[] a) {
    method less (line 145) | private static boolean less(Comparable v, Comparable w) {
    method less (line 150) | private static boolean less(Object v, Object w, Comparator comparator) {
    method exch (line 155) | private static void exch(Object[] a, int i, int j) {
    method exch (line 162) | private static void exch(int[] a, int i, int j) {
    method isSorted (line 171) | private static boolean isSorted(Comparable[] a) {
    method isSorted (line 176) | private static boolean isSorted(Comparable[] a, int lo, int hi) {
    method isSorted (line 182) | private static boolean isSorted(Object[] a, Comparator comparator) {
    method isSorted (line 187) | private static boolean isSorted(Object[] a, int lo, int hi, Comparator...
    method show (line 194) | private static void show(Comparable[] a) {
    method main (line 206) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/InsertionX.java
  class InsertionX (line 48) | public class InsertionX {
    method InsertionX (line 51) | private InsertionX() { }
    method sort (line 57) | public static void sort(Comparable[] a) {
    method less (line 91) | private static boolean less(Comparable v, Comparable w) {
    method exch (line 96) | private static void exch(Object[] a, int i, int j) {
    method isSorted (line 106) | private static boolean isSorted(Comparable[] a) {
    method show (line 113) | private static void show(Comparable[] a) {
    method main (line 125) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Interval1D.java
  class Interval1D (line 29) | public class Interval1D {
    method Interval1D (line 60) | public Interval1D(double min, double max) {
    method left (line 83) | @Deprecated
    method right (line 93) | @Deprecated
    method min (line 103) | public double min() {
    method max (line 112) | public double max() {
    method intersects (line 123) | public boolean intersects(Interval1D that) {
    method contains (line 136) | public boolean contains(Interval1D that) {
    method contains (line 147) | public boolean contains(double x) {
    method length (line 156) | public double length() {
    method toString (line 165) | public String toString() {
    method equals (line 176) | public boolean equals(Object other) {
    method hashCode (line 189) | public int hashCode() {
    class MinEndpointComparator (line 196) | private static class MinEndpointComparator implements Comparator<Inter...
      method compare (line 197) | public int compare(Interval1D a, Interval1D b) {
    class MaxEndpointComparator (line 207) | private static class MaxEndpointComparator implements Comparator<Inter...
      method compare (line 208) | public int compare(Interval1D a, Interval1D b) {
    class LengthComparator (line 218) | private static class LengthComparator implements Comparator<Interval1D> {
      method compare (line 219) | public int compare(Interval1D a, Interval1D b) {
    method main (line 236) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Interval2D.java
  class Interval2D (line 29) | public class Interval2D {
    method Interval2D (line 38) | public Interval2D(Interval1D x, Interval1D y) {
    method intersects (line 49) | public boolean intersects(Interval2D that) {
    method contains (line 61) | public boolean contains(Interval2D that) {
    method contains (line 70) | public boolean contains(Point2D p) {
    method area (line 78) | public double area() {
    method toString (line 87) | public String toString() {
    method equals (line 96) | public boolean equals(Object other) {
    method hashCode (line 109) | public int hashCode() {
    method draw (line 118) | public void draw() {
    method main (line 129) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Inversions.java
  class Inversions (line 30) | public class Inversions {
    method Inversions (line 33) | private Inversions() { }
    method merge (line 36) | private static long merge(int[] a, int[] aux, int lo, int mid, int hi) {
    method count (line 57) | private static long count(int[] a, int[] b, int[] aux, int lo, int hi) {
    method count (line 77) | public static long count(int[] a) {
    method merge (line 89) | private static <Key extends Comparable<Key>> long merge(Key[] a, Key[]...
    method count (line 110) | private static <Key extends Comparable<Key>> long count(Key[] a, Key[]...
    method count (line 131) | public static <Key extends Comparable<Key>> long count(Key[] a) {
    method less (line 140) | private static <Key extends Comparable<Key>> boolean less(Key v, Key w) {
    method brute (line 145) | private static <Key extends Comparable<Key>> long brute(Key[] a, int l...
    method brute (line 154) | private static long brute(int[] a, int lo, int hi) {
    method main (line 168) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/KMP.java
  class KMP (line 48) | public class KMP {
    method KMP (line 58) | public KMP(String pat) {
    method KMP (line 79) | public KMP(char[] pattern, int R) {
    method search (line 103) | public int search(String txt) {
    method search (line 123) | public int search(char[] text) {
    method main (line 143) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/KWIK.java
  class KWIK (line 52) | public class KWIK {
    method KWIK (line 55) | private KWIK() { }
    method main (line 67) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Knuth.java
  class Knuth (line 65) | public class Knuth {
    method Knuth (line 68) | private Knuth() { }
    method shuffle (line 76) | public static void shuffle(Object[] a) {
    method shuffleAlternate (line 93) | public static void shuffleAlternate(Object[] a) {
    method main (line 110) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/KosarajuSharirSCC.java
  class KosarajuSharirSCC (line 97) | public class KosarajuSharirSCC {
    method KosarajuSharirSCC (line 106) | public KosarajuSharirSCC(Digraph digraph) {
    method dfs (line 126) | private void dfs(Digraph digraph, int v) {
    method count (line 138) | public int count() {
    method stronglyConnected (line 151) | public boolean stronglyConnected(int v, int w) {
    method id (line 163) | public int id(int v) {
    method check (line 169) | private boolean check(Digraph digraph) {
    method validateVertex (line 181) | private void validateVertex(int v) {
    method main (line 192) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/KruskalMST.java
  class KruskalMST (line 73) | public class KruskalMST {
    method KruskalMST (line 83) | public KruskalMST(EdgeWeightedGraph graph) {
    method edges (line 117) | public Iterable<Edge> edges() {
    method weight (line 125) | public double weight() {
    method check (line 130) | private boolean check(EdgeWeightedGraph graph) {
    method main (line 194) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/LSD.java
  class LSD (line 43) | public class LSD {
    method LSD (line 47) | private LSD() { }
    method sort (line 55) | public static void sort(String[] a, int w) {
    method sort (line 88) | public static void sort(int[] a) {
    method main (line 143) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/LZW.java
  class LZW (line 35) | public class LZW {
    method LZW (line 41) | private LZW() { }
    method compress (line 48) | public static void compress() {
    method expand (line 75) | public static void expand() {
    method main (line 106) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/LazyPrimMST.java
  class LazyPrimMST (line 72) | public class LazyPrimMST {
    method LazyPrimMST (line 84) | public LazyPrimMST(EdgeWeightedGraph G) {
    method prim (line 96) | private void prim(EdgeWeightedGraph G, int s) {
    method scan (line 111) | private void scan(EdgeWeightedGraph G, int v) {
    method edges (line 123) | public Iterable<Edge> edges() {
    method weight (line 131) | public double weight() {
    method check (line 136) | private boolean check(EdgeWeightedGraph G) {
    method main (line 200) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/LinearProbingHashST.java
  class LinearProbingHashST (line 43) | public class LinearProbingHashST<Key, Value> {
    method LinearProbingHashST (line 57) | public LinearProbingHashST() {
    method LinearProbingHashST (line 66) | public LinearProbingHashST(int capacity) {
    method size (line 78) | public int size() {
    method isEmpty (line 88) | public boolean isEmpty() {
    method contains (line 100) | public boolean contains(Key key) {
    method hashTextbook (line 106) | private int hashTextbook(Key key) {
    method hash (line 112) | private int hash(Key key) {
    method resize (line 119) | private void resize(int capacity) {
    method put (line 141) | public void put(Key key, Value val) {
    method get (line 171) | public Value get(Key key) {
    method delete (line 186) | public void delete(Key key) {
    method keys (line 228) | public Iterable<Key> keys() {
    method check (line 237) | private boolean check() {
    method main (line 262) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/LinearProgramming.java
  class LinearProgramming (line 45) | public class LinearProgramming {
    method LinearProgramming (line 65) | public LinearProgramming(double[][] A, double[] b, double[] c) {
    method solve (line 93) | private void solve() {
    method bland (line 113) | private int bland() {
    method dantzig (line 120) | private int dantzig() {
    method minRatioRule (line 131) | private int minRatioRule(int q) {
    method pivot (line 143) | private void pivot(int p, int q) {
    method value (line 166) | public double value() {
    method primal (line 175) | public double[] primal() {
    method dual (line 187) | public double[] dual() {
    method isPrimalFeasible (line 198) | private boolean isPrimalFeasible(double[][] A, double[] b) {
    method isDualFeasible (line 225) | private boolean isDualFeasible(double[][] A, double[] c) {
    method isOptimal (line 252) | private boolean isOptimal(double[] b, double[] c) {
    method check (line 272) | private boolean check(double[][]A, double[] b, double[] c) {
    method show (line 277) | private void show() {
    method test (line 294) | private static void test(double[][] A, double[] b, double[] c) {
    method test1 (line 313) | private static void test1() {
    method test2 (line 328) | private static void test2() {
    method test3 (line 340) | private static void test3() {
    method test4 (line 351) | private static void test4() {
    method main (line 368) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/LinearRegression.java
  class LinearRegression (line 28) | public class LinearRegression {
    method LinearRegression (line 40) | public LinearRegression(double[] x, double[] y) {
    method intercept (line 87) | public double intercept() {
    method slope (line 96) | public double slope() {
    method R2 (line 106) | public double R2() {
    method interceptStdErr (line 115) | public double interceptStdErr() {
    method slopeStdErr (line 124) | public double slopeStdErr() {
    method predict (line 136) | public double predict(double x) {
    method toString (line 147) | public String toString() {

FILE: src/main/java/edu/princeton/cs/algs4/LinkedBag.java
  class LinkedBag (line 51) | public class LinkedBag<Item> implements Iterable<Item> {
    class Node (line 56) | private class Node {
    method LinkedBag (line 64) | public LinkedBag() {
    method isEmpty (line 73) | public boolean isEmpty() {
    method size (line 81) | public int size() {
    method add (line 89) | public void add(Item item) {
    method iterator (line 101) | public Iterator<Item> iterator()  {
    class LinkedIterator (line 106) | private class LinkedIterator implements Iterator<Item> {
      method LinkedIterator (line 110) | public LinkedIterator() {
      method hasNext (line 115) | public boolean hasNext() {
      method next (line 120) | public Item next() {
    method main (line 133) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/LinkedQueue.java
  class LinkedQueue (line 38) | public class LinkedQueue<Item> implements Iterable<Item> {
    class Node (line 44) | private class Node {
    method LinkedQueue (line 52) | public LinkedQueue() {
    method isEmpty (line 63) | public boolean isEmpty() {
    method size (line 71) | public int size() {
    method peek (line 80) | public Item peek() {
    method enqueue (line 89) | public void enqueue(Item item) {
    method dequeue (line 105) | public Item dequeue() {
    method toString (line 119) | public String toString() {
    method check (line 127) | private boolean check() {
    method iterator (line 169) | public Iterator<Item> iterator()  {
    class LinkedIterator (line 174) | private class LinkedIterator implements Iterator<Item> {
      method hasNext (line 177) | public boolean hasNext() {
      method next (line 181) | public Item next() {
    method main (line 195) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/LinkedStack.java
  class LinkedStack (line 43) | public class LinkedStack<Item> implements Iterable<Item> {
    class Node (line 48) | private class Node {
    method LinkedStack (line 56) | public LinkedStack() {
    method isEmpty (line 66) | public boolean isEmpty() {
    method size (line 74) | public int size() {
    method push (line 82) | public void push(Item item) {
    method pop (line 96) | public Item pop() {
    method peek (line 111) | public Item peek() {
    method toString (line 120) | public String toString() {
    method iterator (line 131) | public Iterator<Item> iterator() {
    class LinkedIterator (line 136) | private class LinkedIterator implements Iterator<Item> {
      method hasNext (line 139) | public boolean hasNext() {
      method next (line 143) | public Item next() {
    method check (line 153) | private boolean check() {
    method main (line 186) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/LongestCommonSubstring.java
  class LongestCommonSubstring (line 36) | public class LongestCommonSubstring {
    method LongestCommonSubstring (line 39) | private LongestCommonSubstring() { }
    method lcp (line 42) | private static String lcp(String s, int p, String t, int q) {
    method compare (line 52) | private static int compare(String s, int p, String t, int q) {
    method lcs (line 72) | public static String lcs(String s, String t) {
    method main (line 98) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/LongestRepeatedSubstring.java
  class LongestRepeatedSubstring (line 46) | public class LongestRepeatedSubstring {
    method LongestRepeatedSubstring (line 49) | private LongestRepeatedSubstring() { }
    method lrs (line 66) | public static String lrs(String text) {
    method main (line 85) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/LookupCSV.java
  class LookupCSV (line 47) | public class LookupCSV {
    method LookupCSV (line 50) | private LookupCSV() { }
    method main (line 52) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/LookupIndex.java
  class LookupIndex (line 51) | public class LookupIndex {
    method LookupIndex (line 54) | private LookupIndex() { }
    method main (line 56) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/MSD.java
  class MSD (line 41) | public class MSD {
    method MSD (line 48) | private MSD() { }
    method sort (line 55) | public static void sort(String[] a) {
    method charAt (line 62) | private static int charAt(String s, int d) {
    method sort (line 69) | private static void sort(String[] a, int lo, int hi, int d, String[] a...
    method insertion (line 106) | private static void insertion(String[] a, int lo, int hi, int d) {
    method exch (line 113) | private static void exch(String[] a, int i, int j) {
    method less (line 120) | private static boolean less(String v, String w, int d) {
    method sort (line 136) | public static void sort(int[] a) {
    method sort (line 143) | private static void sort(int[] a, int lo, int hi, int d, int[] aux) {
    method insertion (line 204) | private static void insertion(int[] a, int lo, int hi) {
    method exch (line 211) | private static void exch(int[] a, int i, int j) {
    method main (line 225) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/MaxPQ.java
  class MaxPQ (line 54) | public class MaxPQ<Key> implements Iterable<Key> {
    method MaxPQ (line 64) | public MaxPQ(int initCapacity) {
    method MaxPQ (line 72) | public MaxPQ() {
    method MaxPQ (line 83) | public MaxPQ(int initCapacity, Comparator<Key> comparator) {
    method MaxPQ (line 94) | public MaxPQ(Comparator<Key> comparator) {
    method MaxPQ (line 104) | public MaxPQ(Key[] keys) {
    method isEmpty (line 122) | public boolean isEmpty() {
    method size (line 131) | public int size() {
    method max (line 141) | public Key max() {
    method resize (line 147) | private void resize(int capacity) {
    method insert (line 162) | public void insert(Key x) {
    method delMax (line 179) | public Key delMax() {
    method swim (line 195) | private void swim(int k) {
    method sink (line 202) | private void sink(int k) {
    method less (line 215) | private boolean less(int i, int j) {
    method exch (line 224) | private void exch(int i, int j) {
    method isMaxHeap (line 231) | private boolean isMaxHeap() {
    method isMaxHeapOrdered (line 243) | private boolean isMaxHeapOrdered(int k) {
    method iterator (line 264) | public Iterator<Key> iterator() {
    class HeapIterator (line 268) | private class HeapIterator implements Iterator<Key> {
      method HeapIterator (line 275) | public HeapIterator() {
      method hasNext (line 282) | public boolean hasNext()  { return !copy.isEmpty();                 ...
      method remove (line 283) | public void remove()      { throw new UnsupportedOperationException(...
      method next (line 285) | public Key next() {
    method main (line 296) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Merge.java
  class Merge (line 47) | public class Merge {
    method Merge (line 50) | private Merge() { }
    method merge (line 53) | private static void merge(Comparable[] a, Comparable[] aux, int lo, in...
    method sort (line 77) | private static void sort(Comparable[] a, Comparable[] aux, int lo, int...
    method sort (line 89) | public static void sort(Comparable[] a) {
    method less (line 101) | private static boolean less(Comparable v, Comparable w) {
    method isSorted (line 108) | private static boolean isSorted(Comparable[] a) {
    method isSorted (line 112) | private static boolean isSorted(Comparable[] a, int lo, int hi) {
    method merge (line 123) | private static void merge(Comparable[] a, int[] index, int[] aux, int ...
    method indexSort (line 146) | public static int[] indexSort(Comparable[] a) {
    method sort (line 158) | private static void sort(Comparable[] a, int[] index, int[] aux, int l...
    method show (line 167) | private static void show(Comparable[] a) {
    method main (line 179) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/MergeBU.java
  class MergeBU (line 47) | public class MergeBU {
    method MergeBU (line 50) | private MergeBU() { }
    method merge (line 53) | private static void merge(Comparable[] a, Comparable[] aux, int lo, in...
    method sort (line 75) | public static void sort(Comparable[] a) {
    method less (line 93) | private static boolean less(Comparable v, Comparable w) {
    method isSorted (line 101) | private static boolean isSorted(Comparable[] a) {
    method show (line 108) | private static void show(Comparable[] a) {
    method main (line 120) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/MergeX.java
  class MergeX (line 47) | public class MergeX {
    method MergeX (line 51) | private MergeX() { }
    method merge (line 53) | private static void merge(Comparable[] src, Comparable[] dst, int lo, ...
    method sort (line 71) | private static void sort(Comparable[] src, Comparable[] dst, int lo, i...
    method sort (line 99) | public static void sort(Comparable[] a) {
    method insertionSort (line 106) | private static void insertionSort(Comparable[] a, int lo, int hi) {
    method exch (line 118) | private static void exch(Object[] a, int i, int j) {
    method less (line 125) | private static boolean less(Comparable a, Comparable b) {
    method less (line 130) | private static boolean less(Object a, Object b, Comparator comparator) {
    method sort (line 145) | public static void sort(Object[] a, Comparator comparator) {
    method merge (line 151) | private static void merge(Object[] src, Object[] dst, int lo, int mid,...
    method sort (line 170) | private static void sort(Object[] src, Object[] dst, int lo, int hi, C...
    method insertionSort (line 190) | private static void insertionSort(Object[] a, int lo, int hi, Comparat...
    method isSorted (line 200) | private static boolean isSorted(Comparable[] a) {
    method isSorted (line 204) | private static boolean isSorted(Comparable[] a, int lo, int hi) {
    method isSorted (line 210) | private static boolean isSorted(Object[] a, Comparator comparator) {
    method isSorted (line 214) | private static boolean isSorted(Object[] a, int lo, int hi, Comparator...
    method show (line 221) | private static void show(Object[] a) {
    method main (line 234) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/MinPQ.java
  class MinPQ (line 52) | public class MinPQ<Key> implements Iterable<Key> {
    method MinPQ (line 62) | public MinPQ(int initCapacity) {
    method MinPQ (line 70) | public MinPQ() {
    method MinPQ (line 81) | public MinPQ(int initCapacity, Comparator<Key> comparator) {
    method MinPQ (line 92) | public MinPQ(Comparator<Key> comparator) {
    method MinPQ (line 103) | public MinPQ(Key[] keys) {
    method isEmpty (line 119) | public boolean isEmpty() {
    method size (line 128) | public int size() {
    method min (line 138) | public Key min() {
    method resize (line 144) | private void resize(int capacity) {
    method insert (line 158) | public void insert(Key x) {
    method delMin (line 174) | public Key delMin() {
    method swim (line 190) | private void swim(int k) {
    method sink (line 197) | private void sink(int k) {
    method greater (line 210) | private boolean greater(int i, int j) {
    method exch (line 219) | private void exch(int i, int j) {
    method isMinHeap (line 226) | private boolean isMinHeap() {
    method isMinHeapOrdered (line 238) | private boolean isMinHeapOrdered(int k) {
    method iterator (line 256) | public Iterator<Key> iterator() {
    class HeapIterator (line 260) | private class HeapIterator implements Iterator<Key> {
      method HeapIterator (line 266) | public HeapIterator() {
      method hasNext (line 273) | public boolean hasNext()  { return !copy.isEmpty();                 ...
      method remove (line 274) | public void remove()      { throw new UnsupportedOperationException(...
      method next (line 276) | public Key next() {
    method main (line 287) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Multiway.java
  class Multiway (line 42) | public class Multiway {
    method Multiway (line 45) | private Multiway() { }
    method merge (line 48) | private static void merge(In[] streams) {
    method main (line 74) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/MultiwayMinPQ.java
  class MultiwayMinPQ (line 33) | public class MultiwayMinPQ<Key> implements Iterable<Key> {
    method MultiwayMinPQ (line 48) | public MultiwayMinPQ(int d) {
    method MultiwayMinPQ (line 64) | public MultiwayMinPQ(Comparator<Key> comparator, int d) {
    method MultiwayMinPQ (line 80) | public MultiwayMinPQ(Key[] a, int d) {
    method MultiwayMinPQ (line 98) | public MultiwayMinPQ(Comparator<Key> comparator, Key[] a, int d) {
    method isEmpty (line 112) | public boolean isEmpty() {
    method size (line 121) | public int size() {
    method insert (line 130) | public void insert(Key key) {
    method minKey (line 145) | public Key minKey() {
    method delMin (line 156) | public Key delMin() {
    method greater (line 175) | private boolean greater(int x, int y) {
    method exch (line 183) | private void exch(int x, int y) {
    method getN (line 191) | private int getN(int order) {
    method swim (line 200) | private void swim(int i) {
    method sink (line 208) | private void sink(int i) {
    method minChild (line 224) | private int minChild(int i) {
    method resize (line 240) | private void resize(int N) {
    method iterator (line 262) | public Iterator<Key> iterator() {
    class MyIterator (line 267) | private class MyIterator implements Iterator<Key> {
      method MyIterator (line 270) | public MyIterator() {
      method hasNext (line 279) | public boolean hasNext() {
      method next (line 283) | public Key next() {
      method remove (line 288) | public void remove() {
    class MyComparator (line 298) | private class MyComparator implements Comparator<Key> {
      method compare (line 299) | @Override

FILE: src/main/java/edu/princeton/cs/algs4/NFA.java
  class NFA (line 57) | public class NFA {
    method NFA (line 68) | public NFA(String regexp) {
    method recognizes (line 110) | public boolean recognizes(String txt) {
    method main (line 149) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/NonrecursiveDFS.java
  class NonrecursiveDFS (line 63) | public class NonrecursiveDFS {
    method NonrecursiveDFS (line 71) | public NonrecursiveDFS(Graph graph, int s) {
    method marked (line 113) | public boolean marked(int v) {
    method validateVertex (line 119) | private void validateVertex(int v) {
    method main (line 130) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/NonrecursiveDirectedDFS.java
  class NonrecursiveDirectedDFS (line 46) | public class NonrecursiveDirectedDFS {
    method NonrecursiveDirectedDFS (line 56) | public NonrecursiveDirectedDFS(Digraph digraph, int s) {
    method marked (line 97) | public boolean marked(int v) {
    method validateVertex (line 103) | private void validateVertex(int v) {
    method main (line 114) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Out.java
  class Out (line 35) | public class Out {
    method Out (line 50) | public Out(OutputStream os) {
    method Out (line 58) | public Out() {
    method Out (line 69) | public Out(Socket socket) {
    method Out (line 91) | public Out(String filename) {
    method close (line 113) | public void close() {
    method println (line 120) | public void println() {
    method println (line 129) | public void println(Object x) {
    method println (line 138) | public void println(boolean x) {
    method println (line 147) | public void println(char x) {
    method println (line 156) | public void println(double x) {
    method println (line 165) | public void println(float x) {
    method println (line 174) | public void println(int x) {
    method println (line 183) | public void println(long x) {
    method println (line 194) | public void println(byte x) {
    method print (line 203) | public void print() {
    method print (line 212) | public void print(Object x) {
    method print (line 222) | public void print(boolean x) {
    method print (line 232) | public void print(char x) {
    method print (line 242) | public void print(double x) {
    method print (line 252) | public void print(float x) {
    method print (line 262) | public void print(int x) {
    method print (line 272) | public void print(long x) {
    method print (line 282) | public void print(byte x) {
    method printf (line 294) | public void printf(String format, Object... args) {
    method printf (line 307) | public void printf(Locale locale, String format, Object... args) {
    method main (line 318) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Particle.java
  class Particle (line 29) | public class Particle {
    method Particle (line 51) | public Particle(double rx, double ry, double vx, double vy, double rad...
    method Particle (line 70) | public Particle() {
    method move (line 86) | public void move(double dt) {
    method draw (line 94) | public void draw() {
    method count (line 109) | public int count() {
    method timeToHit (line 122) | public double timeToHit(Particle that) {
    method timeToHitVerticalWall (line 155) | public double timeToHitVerticalWall() {
    method timeToHitHorizontalWall (line 170) | public double timeToHitHorizontalWall() {
    method bounceOff (line 183) | public void bounceOff(Particle that) {
    method bounceOffVerticalWall (line 214) | public void bounceOffVerticalWall() {
    method bounceOffHorizontalWall (line 224) | public void bounceOffHorizontalWall() {
    method kineticEnergy (line 236) | public double kineticEnergy() {

FILE: src/main/java/edu/princeton/cs/algs4/PatriciaSET.java
  class PatriciaSET (line 93) | public class PatriciaSET implements Iterable<String> {
    class Node (line 100) | private class Node {
      method Node (line 105) | public Node(String key, int b) {
    method PatriciaSET (line 117) | public PatriciaSET() {
    method add (line 130) | public void add(String key) {
    method contains (line 171) | public boolean contains(String key) {
    method delete (line 190) | public void delete(String key) {
    method isEmpty (line 238) | boolean isEmpty() {
    method size (line 246) | int size() {
    method iterator (line 256) | public Iterator<String> iterator() {
    method collect (line 263) | private void collect(Node x, int b, Queue<String> queue) {
    method toString (line 276) | public String toString() {
    method safeBitTest (line 298) | private static boolean safeBitTest(String key, int b) {
    method bitTest (line 304) | private static int bitTest(String key, int b) {
    method safeCharAt (line 313) | private static int safeCharAt(String key, int i) {
    method firstDifferingBit (line 333) | private static int firstDifferingBit(String k1, String k2) {
    method main (line 358) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/PatriciaST.java
  class PatriciaST (line 96) | public class PatriciaST<Value> {
    class Node (line 103) | private class Node {
      method Node (line 109) | public Node(String key, Value val, int b) {
    method PatriciaST (line 122) | public PatriciaST() {
    method put (line 139) | public void put(String key, Value val) {
    method get (line 182) | public Value get(String key) {
    method delete (line 203) | public void delete(String key) {
    method contains (line 255) | public boolean contains(String key) {
    method isEmpty (line 264) | boolean isEmpty() {
    method size (line 272) | int size() {
    method keys (line 283) | public Iterable<String> keys() {
    method keys (line 290) | private void keys(Node x, int b, Queue<String> queue) {
    method safeBitTest (line 313) | private static boolean safeBitTest(String key, int b) {
    method bitTest (line 319) | private static int bitTest(String key, int b) {
    method safeCharAt (line 328) | private static int safeCharAt(String key, int i) {
    method firstDifferingBit (line 348) | private static int firstDifferingBit(String k1, String k2) {
    method main (line 373) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Picture.java
  class Picture (line 237) | public final class Picture implements ActionListener {
    method Picture (line 255) | public Picture(int width, int height) {
    method Picture (line 270) | public Picture(Picture picture) {
    method Picture (line 293) | public Picture(String filename) {
    method Picture (line 355) | public Picture(File file) {
    method createGUI (line 378) | @SuppressWarnings("deprecation")
    method getJLabel (line 416) | public JLabel getJLabel() {
    method setOriginUpperLeft (line 425) | public void setOriginUpperLeft() {
    method setOriginLowerLeft (line 432) | public void setOriginLowerLeft() {
    method show (line 442) | @SuppressWarnings("deprecation")
    method hide (line 464) | public void hide() {
    method isVisible (line 475) | public boolean isVisible() {
    method height (line 484) | public int height() {
    method width (line 493) | public int width() {
    method validateRowIndex (line 497) | private void validateRowIndex(int row) {
    method validateColumnIndex (line 502) | private void validateColumnIndex(int col) {
    method get (line 515) | public Color get(int col, int row) {
    method getARGB (line 532) | public int getARGB(int col, int row) {
    method set (line 548) | public void set(int col, int row, Color color) {
    method setARGB (line 564) | public void setARGB(int col, int row, int argb) {
    method equals (line 579) | public boolean equals(Object other) {
    method toString (line 600) | public String toString() {
    method hashCode (line 621) | public int hashCode() {
    method setTitle (line 630) | public void setTitle(String title) {
    method hasAlpha (line 636) | private boolean hasAlpha() {
    method save (line 662) | public void save(String filename) {
    method save (line 681) | public void save(File file) {
    method actionPerformed (line 711) | @Override
    method main (line 735) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/PictureDump.java
  class PictureDump (line 35) | public class PictureDump {
    method PictureDump (line 38) | private PictureDump() { }
    method main (line 48) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Point2D.java
  class Point2D (line 31) | public final class Point2D implements Comparable<Point2D> {
    method Point2D (line 59) | public Point2D(double x, double y) {
    method x (line 75) | public double x() {
    method y (line 83) | public double y() {
    method r (line 91) | public double r() {
    method theta (line 99) | public double theta() {
    method angleTo (line 107) | private double angleTo(Point2D that) {
    method ccw (line 120) | public static int ccw(Point2D a, Point2D b, Point2D c) {
    method area2 (line 134) | public static double area2(Point2D a, Point2D b, Point2D c) {
    method distanceTo (line 143) | public double distanceTo(Point2D that) {
    method distanceSquaredTo (line 154) | public double distanceSquaredTo(Point2D that) {
    method compareTo (line 172) | public int compareTo(Point2D that) {
    method polarOrder (line 185) | public Comparator<Point2D> polarOrder() {
    method atan2Order (line 194) | public Comparator<Point2D> atan2Order() {
    method distanceToOrder (line 203) | public Comparator<Point2D> distanceToOrder() {
    class XOrder (line 208) | private static class XOrder implements Comparator<Point2D> {
      method compare (line 209) | public int compare(Point2D p, Point2D q) {
    class YOrder (line 215) | private static class YOrder implements Comparator<Point2D> {
      method compare (line 216) | public int compare(Point2D p, Point2D q) {
    class ROrder (line 222) | private static class ROrder implements Comparator<Point2D> {
      method compare (line 223) | public int compare(Point2D p, Point2D q) {
    class Atan2Order (line 230) | private class Atan2Order implements Comparator<Point2D> {
      method compare (line 231) | public int compare(Point2D q1, Point2D q2) {
    class PolarOrder (line 239) | private class PolarOrder implements Comparator<Point2D> {
      method compare (line 240) | public int compare(Point2D q1, Point2D q2) {
    class DistanceToOrder (line 260) | private class DistanceToOrder implements Comparator<Point2D> {
      method compare (line 261) | public int compare(Point2D p, Point2D q) {
    method equals (line 276) | @Override
    method toString (line 289) | @Override
    method hashCode (line 298) | @Override
    method draw (line 308) | public void draw() {
    method drawTo (line 316) | public void drawTo(Point2D that) {
    method main (line 326) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Polynomial.java
  class Polynomial (line 42) | public class Polynomial {
    method Polynomial (line 52) | public Polynomial(int a, int b) {
    method reduce (line 63) | private void reduce() {
    method degree (line 77) | public int degree() {
    method plus (line 87) | public Polynomial plus(Polynomial that) {
    method minus (line 102) | public Polynomial minus(Polynomial that) {
    method times (line 118) | public Polynomial times(Polynomial that) {
    method compose (line 136) | public Polynomial compose(Polynomial that) {
    method equals (line 153) | @Override
    method differentiate (line 170) | public Polynomial differentiate() {
    method evaluate (line 185) | public int evaluate(int x) {
    method compareTo (line 202) | public int compareTo(Polynomial that) {
    method toString (line 217) | @Override
    method main (line 238) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/PrimMST.java
  class PrimMST (line 75) | public class PrimMST {
    method PrimMST (line 87) | public PrimMST(EdgeWeightedGraph graph) {
    method prim (line 103) | private void prim(EdgeWeightedGraph graph, int s) {
    method scan (line 113) | private void scan(EdgeWeightedGraph graph, int v) {
    method edges (line 132) | public Iterable<Edge> edges() {
    method weight (line 147) | public double weight() {
    method check (line 156) | private boolean check(EdgeWeightedGraph graph) {
    method main (line 219) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Queue.java
  class Queue (line 42) | public class Queue<Item> implements Iterable<Item> {
    class Node (line 48) | private static class Node<Item> {
    method Queue (line 56) | public Queue() {
    method isEmpty (line 67) | public boolean isEmpty() {
    method size (line 76) | public int size() {
    method peek (line 86) | public Item peek() {
    method enqueue (line 96) | public void enqueue(Item item) {
    method dequeue (line 112) | public Item dequeue() {
    method toString (line 126) | public String toString() {
    method iterator (line 140) | public Iterator<Item> iterator()  {
    class LinkedIterator (line 145) | private class LinkedIterator implements Iterator<Item> {
      method LinkedIterator (line 148) | public LinkedIterator(Node<Item> first) {
      method hasNext (line 152) | public boolean hasNext() {
      method next (line 156) | public Item next() {
    method main (line 170) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Quick.java
  class Quick (line 42) | public class Quick {
    method Quick (line 45) | private Quick() { }
    method sort (line 51) | public static void sort(Comparable[] a) {
    method sort (line 58) | private static void sort(Comparable[] a, int lo, int hi) {
    method partition (line 68) | private static int partition(Comparable[] a, int lo, int hi) {
    method select (line 107) | public static Comparable select(Comparable[] a, int k) {
    method less (line 129) | private static boolean less(Comparable v, Comparable w) {
    method exch (line 135) | private static void exch(Object[] a, int i, int j) {
    method isSorted (line 145) | private static boolean isSorted(Comparable[] a) {
    method isSorted (line 149) | private static boolean isSorted(Comparable[] a, int lo, int hi) {
    method show (line 157) | private static void show(Comparable[] a) {
    method main (line 171) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Quick3string.java
  class Quick3string (line 42) | public class Quick3string {
    method Quick3string (line 46) | private Quick3string() { }
    method sort (line 53) | public static void sort(String[] a) {
    method charAt (line 60) | private static int charAt(String s, int d) {
    method sort (line 68) | private static void sort(String[] a, int lo, int hi, int d) {
    method insertion (line 93) | private static void insertion(String[] a, int lo, int hi, int d) {
    method exch (line 100) | private static void exch(String[] a, int i, int j) {
    method less (line 114) | private static boolean less(String v, String w, int d) {
    method isSorted (line 124) | private static boolean isSorted(String[] a) {
    method main (line 138) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Quick3way.java
  class Quick3way (line 37) | public class Quick3way {
    method Quick3way (line 40) | private Quick3way() { }
    method sort (line 46) | public static void sort(Comparable[] a) {
    method sort (line 53) | private static void sort(Comparable[] a, int lo, int hi) {
    method less (line 78) | private static boolean less(Comparable v, Comparable w) {
    method exch (line 83) | private static void exch(Object[] a, int i, int j) {
    method isSorted (line 93) | private static boolean isSorted(Comparable[] a) {
    method isSorted (line 97) | private static boolean isSorted(Comparable[] a, int lo, int hi) {
    method show (line 106) | private static void show(Comparable[] a) {
    method main (line 118) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/QuickBentleyMcIlroy.java
  class QuickBentleyMcIlroy (line 32) | public class QuickBentleyMcIlroy {
    method QuickBentleyMcIlroy (line 41) | private QuickBentleyMcIlroy() { }
    method sort (line 47) | public static void sort(Comparable[] a) {
    method sort (line 51) | private static void sort(Comparable[] a, int lo, int hi) {
    method insertionSort (line 110) | private static void insertionSort(Comparable[] a, int lo, int hi) {
    method median3 (line 118) | private static int median3(Comparable[] a, int i, int j, int k) {
    method less (line 129) | private static boolean less(Comparable v, Comparable w) {
    method eq (line 135) | private static boolean eq(Comparable v, Comparable w) {
    method exch (line 141) | private static void exch(Object[] a, int i, int j) {
    method isSorted (line 151) | private static boolean isSorted(Comparable[] a) {
    method show (line 158) | private static void show(Comparable[] a) {
    method main (line 171) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/QuickFindUF.java
  class QuickFindUF (line 65) | public class QuickFindUF {
    method QuickFindUF (line 77) | public QuickFindUF(int n) {
    method count (line 89) | public int count() {
    method find (line 100) | public int find(int p) {
    method validate (line 106) | private void validate(int p) {
    method connected (line 124) | @Deprecated
    method union (line 140) | public void union(int p, int q) {
    method main (line 163) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/QuickUnionUF.java
  class QuickUnionUF (line 64) | public class QuickUnionUF {
    method QuickUnionUF (line 76) | public QuickUnionUF(int n) {
    method count (line 89) | public int count() {
    method find (line 100) | public int find(int p) {
    method validate (line 108) | private void validate(int p) {
    method connected (line 126) | @Deprecated
    method union (line 140) | public void union(int p, int q) {
    method main (line 157) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/QuickX.java
  class QuickX (line 28) | public class QuickX {
    method QuickX (line 34) | private QuickX() { }
    method sort (line 40) | public static void sort(Comparable[] a) {
    method sort (line 47) | private static void sort(Comparable[] a, int lo, int hi) {
    method partition (line 64) | private static int partition(Comparable[] a, int lo, int hi) {
    method median3 (line 98) | private static int median3(Comparable[] a, int i, int j, int k) {
    method less (line 109) | private static boolean less(Comparable v, Comparable w) {
    method exch (line 114) | private static void exch(Object[] a, int i, int j) {
    method isSorted (line 124) | private static boolean isSorted(Comparable[] a) {
    method show (line 131) | private static void show(Comparable[] a) {
    method main (line 144) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/RabinKarp.java
  class RabinKarp (line 49) | public class RabinKarp {
    method RabinKarp (line 63) | public RabinKarp(char[] pattern, int R) {
    method RabinKarp (line 74) | public RabinKarp(String pat) {
    method hash (line 88) | private long hash(String key, int m) {
    method check (line 96) | private boolean check(String txt, int i) {
    method search (line 116) | public int search(String txt) {
    method longRandomPrime (line 143) | private static long longRandomPrime() {
    method main (line 155) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/RandomSeq.java
  class RandomSeq (line 29) | public class RandomSeq {
    method RandomSeq (line 32) | private RandomSeq() { }
    method main (line 41) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/RectHV.java
  class RectHV (line 25) | public final class RectHV {
    method RectHV (line 42) | public RectHV(double xmin, double ymin, double xmax, double ymax) {
    method xmin (line 66) | public double xmin() {
    method xmax (line 75) | public double xmax() {
    method ymin (line 84) | public double ymin() {
    method ymax (line 93) | public double ymax() {
    method width (line 102) | public double width() {
    method height (line 111) | public double height() {
    method intersects (line 125) | public boolean intersects(RectHV that) {
    method contains (line 137) | public boolean contains(Point2D p) {
    method distanceTo (line 149) | public double distanceTo(Point2D p) {
    method distanceSquaredTo (line 161) | public double distanceSquaredTo(Point2D p) {
    method equals (line 177) | @Override
    method hashCode (line 194) | @Override
    method toString (line 209) | @Override
    method draw (line 217) | public void draw() {

FILE: src/main/java/edu/princeton/cs/algs4/RedBlackBST.java
  class RedBlackBST (line 79) | public class RedBlackBST<Key extends Comparable<Key>, Value> {
    class Node (line 87) | private class Node {
      method Node (line 94) | public Node(Key key, Value val, boolean color, int size) {
    method RedBlackBST (line 105) | public RedBlackBST() {
    method isRed (line 112) | private boolean isRed(Node x) {
    method size (line 118) | private int size(Node x) {
    method size (line 128) | public int size() {
    method isEmpty (line 136) | public boolean isEmpty() {
    method get (line 152) | public Value get(Key key) {
    method get (line 158) | private Value get(Node x, Key key) {
    method contains (line 175) | public boolean contains(Key key) {
    method put (line 193) | public void put(Key key, Value val) {
    method put (line 206) | private Node put(Node h, Key key, Value val) {
    method deleteMin (line 231) | public void deleteMin() {
    method deleteMin (line 244) | private Node deleteMin(Node h) {
    method deleteMax (line 260) | public void deleteMax() {
    method deleteMax (line 273) | private Node deleteMax(Node h) {
    method delete (line 295) | public void delete(Key key) {
    method delete (line 309) | private Node delete(Node h, Key key) {
    method rotateRight (line 342) | private Node rotateRight(Node h) {
    method rotateLeft (line 356) | private Node rotateLeft(Node h) {
    method flipColors (line 370) | private void flipColors(Node h) {
    method moveRedLeft (line 382) | private Node moveRedLeft(Node h) {
    method moveRedRight (line 397) | private Node moveRedRight(Node h) {
    method balance (line 409) | private Node balance(Node h) {
    method height (line 429) | public int height() {
    method height (line 432) | private int height(Node x) {
    method min (line 446) | public Key min() {
    method min (line 452) | private Node min(Node x) {
    method max (line 463) | public Key max() {
    method max (line 469) | private Node max(Node x) {
    method floor (line 483) | public Key floor(Key key) {
    method floor (line 492) | private Node floor(Node x, Key key) {
    method ceiling (line 509) | public Key ceiling(Key key) {
    method ceiling (line 518) | private Node ceiling(Node x, Key key) {
    method select (line 539) | public Key select(int rank) {
    method select (line 548) | private Key select(Node x, int rank) {
    method rank (line 562) | public int rank(Key key) {
    method rank (line 568) | private int rank(Key key, Node x) {
    method keys (line 586) | public Iterable<Key> keys() {
    method keys (line 602) | public Iterable<Key> keys(Key lo, Key hi) {
    method keys (line 614) | private void keys(Node x, Queue<Key> queue, Key lo, Key hi) {
    method size (line 633) | public int size(Key lo, Key hi) {
    method check (line 646) | private boolean check() {
    method isBST (line 657) | private boolean isBST() {
    method isBST (line 664) | private boolean isBST(Node x, Key min, Key max) {
    method isSizeConsistent (line 672) | private boolean isSizeConsistent() { return isSizeConsistent(root); }
    method isSizeConsistent (line 673) | private boolean isSizeConsistent(Node x) {
    method isRankConsistent (line 680) | private boolean isRankConsistent() {
    method is23 (line 690) | private boolean is23() { return is23(root); }
    method is23 (line 691) | private boolean is23(Node x) {
    method isBalanced (line 700) | private boolean isBalanced() {
    method isBalanced (line 711) | private boolean isBalanced(Node x, int black) {
    method main (line 723) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/ResizingArrayBag.java
  class ResizingArrayBag (line 32) | public class ResizingArrayBag<Item> implements Iterable<Item> {
    method ResizingArrayBag (line 42) | public ResizingArrayBag() {
    method isEmpty (line 51) | public boolean isEmpty() {
    method size (line 59) | public int size() {
    method resize (line 64) | private void resize(int capacity) {
    method add (line 76) | public void add(Item item) {
    method iterator (line 86) | public Iterator<Item> iterator() {
    class ArrayIterator (line 91) | private class ArrayIterator implements Iterator<Item> {
      method hasNext (line 94) | public boolean hasNext() {
      method next (line 98) | public Item next() {
    method main (line 109) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/ResizingArrayQueue.java
  class ResizingArrayQueue (line 39) | public class ResizingArrayQueue<Item> implements Iterable<Item> {
    method ResizingArrayQueue (line 52) | public ResizingArrayQueue() {
    method isEmpty (line 63) | public boolean isEmpty() {
    method size (line 71) | public int size() {
    method resize (line 76) | private void resize(int capacity) {
    method enqueue (line 91) | public void enqueue(Item item) {
    method dequeue (line 104) | public Item dequeue() {
    method peek (line 121) | public Item peek() {
    method iterator (line 131) | public Iterator<Item> iterator() {
    class ArrayIterator (line 136) | private class ArrayIterator implements Iterator<Item> {
      method hasNext (line 139) | public boolean hasNext() {
      method next (line 143) | public Item next() {
    method main (line 156) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/ResizingArrayStack.java
  class ResizingArrayStack (line 42) | public class ResizingArrayStack<Item> implements Iterable<Item> {
    method ResizingArrayStack (line 54) | public ResizingArrayStack() {
    method isEmpty (line 63) | public boolean isEmpty() {
    method size (line 71) | public int size() {
    method resize (line 77) | private void resize(int capacity) {
    method push (line 97) | public void push(Item item) {
    method pop (line 107) | public Item pop() {
    method peek (line 123) | public Item peek() {
    method iterator (line 132) | public Iterator<Item> iterator() {
    class ReverseArrayIterator (line 137) | private class ReverseArrayIterator implements Iterator<Item> {
      method ReverseArrayIterator (line 140) | public ReverseArrayIterator() {
      method hasNext (line 144) | public boolean hasNext() {
      method next (line 148) | public Item next() {
    method main (line 160) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/RunLength.java
  class RunLength (line 39) | public class RunLength {
    method RunLength (line 44) | private RunLength() { }
    method expand (line 51) | public static void expand() {
    method compress (line 67) | public static void compress() {
    method main (line 97) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/SET.java
  class SET (line 52) | public class SET<Key extends Comparable<Key>> implements Iterable<Key> {
    method SET (line 58) | public SET() {
    method SET (line 67) | public SET(SET<Key> x) {
    method add (line 77) | public void add(Key key) {
    method contains (line 91) | public boolean contains(Key key) {
    method delete (line 103) | public void delete(Key key) {
    method remove (line 115) | public void remove(Key key) {
    method size (line 125) | public int size() {
    method isEmpty (line 135) | public boolean isEmpty() {
    method iterator (line 146) | public Iterator<Key> iterator() {
    method max (line 156) | public Key max() {
    method min (line 167) | public Key min() {
    method ceiling (line 181) | public Key ceiling(Key key) {
    method floor (line 196) | public Key floor(Key key) {
    method union (line 210) | public SET<Key> union(SET<Key> that) {
    method intersects (line 229) | public SET<Key> intersects(SET<Key> that) {
    method equals (line 257) | @Override
    method hashCode (line 272) | @Override
    method toString (line 283) | @Override
    method main (line 294) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/ST.java
  class ST (line 57) | public class ST<Key extends Comparable<Key>, Value> implements Iterable<...
    method ST (line 64) | public ST() {
    method get (line 77) | public Value get(Key key) {
    method put (line 92) | public void put(Key key, Value val) {
    method delete (line 106) | public void delete(Key key) {
    method remove (line 119) | public void remove(Key key) {
    method contains (line 132) | public boolean contains(Key key) {
    method size (line 142) | public int size() {
    method isEmpty (line 151) | public boolean isEmpty() {
    method keys (line 164) | public Iterable<Key> keys() {
    method iterator (line 179) | @Deprecated
    method min (line 190) | public Key min() {
    method max (line 201) | public Key max() {
    method ceiling (line 214) | public Key ceiling(Key key) {
    method floor (line 229) | public Key floor(Key key) {
    method main (line 241) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/SegmentTree.java
  class SegmentTree (line 34) | public class SegmentTree {
    method SegmentTree (line 45) | public SegmentTree(int[] array) {
    method size (line 54) | public int size() {
    method build (line 59) | private void build(int v, int from, int size) {
    method rsq (line 87) | public int rsq(int from, int to) {
    method rsq (line 91) | private int rsq(int v, int from, int to) {
    method rMinQ (line 123) | public int rMinQ(int from, int to) {
    method rMinQ (line 127) | private int rMinQ(int v, int from, int to) {
    method update (line 165) | public void update(int from, int to, int value) {
    method update (line 169) | private void update(int v, int from, int to, int value) {
    method propagate (line 202) | private void propagate(int v) {
    method change (line 213) | private void change(Node n, int value) {
    method contains (line 222) | private boolean contains(int from1, int to1, int from2, int to2) {
    method intersects (line 227) | private boolean intersects(int from1, int to1, int from2, int to2) {
    class Node (line 233) | static class Node {
      method size (line 241) | int size() {
    method main (line 268) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Selection.java
  class Selection (line 45) | public class Selection {
    method Selection (line 48) | private Selection() { }
    method sort (line 54) | public static void sort(Comparable[] a) {
    method sort (line 72) | public static void sort(Object[] a, Comparator comparator) {
    method less (line 91) | private static boolean less(Comparable v, Comparable w) {
    method less (line 96) | private static boolean less(Comparator comparator, Object v, Object w) {
    method exch (line 102) | private static void exch(Object[] a, int i, int j) {
    method isSorted (line 114) | private static boolean isSorted(Comparable[] a) {
    method isSorted (line 119) | private static boolean isSorted(Comparable[] a, int lo, int hi) {
    method isSorted (line 126) | private static boolean isSorted(Object[] a, Comparator comparator) {
    method isSorted (line 131) | private static boolean isSorted(Object[] a, Comparator comparator, int...
    method show (line 140) | private static void show(Comparable[] a) {
    method main (line 152) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/SeparateChainingHashST.java
  class SeparateChainingHashST (line 43) | public class SeparateChainingHashST<Key, Value> {
    method SeparateChainingHashST (line 54) | public SeparateChainingHashST() {
    method SeparateChainingHashST (line 62) | public SeparateChainingHashST(int m) {
    method resize (line 71) | private void resize(int chains) {
    method hashTextbook (line 84) | private int hashTextbook(Key key) {
    method hash (line 90) | private int hash(Key key) {
    method size (line 101) | public int size() {
    method isEmpty (line 111) | public boolean isEmpty() {
    method contains (line 123) | public boolean contains(Key key) {
    method get (line 136) | public Value get(Key key) {
    method put (line 152) | public void put(Key key, Value val) {
    method delete (line 174) | public void delete(Key key) {
    method keys (line 186) | public Iterable<Key> keys() {
    method main (line 201) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/SequentialSearchST.java
  class SequentialSearchST (line 61) | public class SequentialSearchST<Key, Value> {
    class Node (line 66) | private class Node {
      method Node (line 71) | public Node(Key key, Value val, Node next)  {
    method SequentialSearchST (line 81) | public SequentialSearchST() {
    method size (line 89) | public int size() {
    method isEmpty (line 99) | public boolean isEmpty() {
    method contains (line 111) | public boolean contains(Key key) {
    method get (line 124) | public Value get(Key key) {
    method put (line 143) | public void put(Key key, Value val) {
    method delete (line 167) | public void delete(Key key) {
    method delete (line 174) | private Node delete(Node x, Key key) {
    method keys (line 192) | public Iterable<Key> keys()  {
    method main (line 205) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Shell.java
  class Shell (line 45) | public class Shell {
    method Shell (line 48) | private Shell() { }
    method sort (line 54) | public static void sort(Comparable[] a) {
    method less (line 81) | private static boolean less(Comparable v, Comparable w) {
    method exch (line 86) | private static void exch(Object[] a, int i, int j) {
    method isSorted (line 96) | private static boolean isSorted(Comparable[] a) {
    method isHsorted (line 103) | private static boolean isHsorted(Comparable[] a, int h) {
    method show (line 110) | private static void show(Comparable[] a) {
    method main (line 122) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/SparseVector.java
  class SparseVector (line 32) | public class SparseVector {
    method SparseVector (line 40) | public SparseVector(int d) {
    method put (line 52) | public void put(int i, double value) {
    method get (line 65) | public double get(int i) {
    method nnz (line 76) | public int nnz() {
    method size (line 86) | @Deprecated
    method dimension (line 96) | public int dimension() {
    method dot (line 107) | public double dot(SparseVector that) {
    method dot (line 131) | public double dot(double[] that) {
    method magnitude (line 144) | public double magnitude() {
    method norm (line 155) | @Deprecated
    method scale (line 166) | public SparseVector scale(double alpha) {
    method plus (line 179) | public SparseVector plus(SparseVector that) {
    method toString (line 192) | public String toString() {
    method main (line 206) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Stack.java
  class Stack (line 50) | public class Stack<Item> implements Iterable<Item> {
    class Node (line 55) | private static class Node<Item> {
    method Stack (line 63) | public Stack() {
    method isEmpty (line 73) | public boolean isEmpty() {
    method size (line 82) | public int size() {
    method push (line 91) | public void push(Item item) {
    method pop (line 105) | public Item pop() {
    method peek (line 120) | public Item peek() {
    method toString (line 130) | public String toString() {
    method iterator (line 145) | public Iterator<Item> iterator() {
    class LinkedIterator (line 150) | private class LinkedIterator implements Iterator<Item> {
      method LinkedIterator (line 153) | public LinkedIterator(Node<Item> first) {
      method hasNext (line 158) | public boolean hasNext() {
      method next (line 163) | public Item next() {
    method main (line 177) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/StaticSETofInts.java
  class StaticSETofInts (line 29) | public class StaticSETofInts {
    method StaticSETofInts (line 37) | public StaticSETofInts(int[] keys) {
    method contains (line 58) | public boolean contains(int key) {
    method rank (line 69) | public int rank(int key) {

FILE: src/main/java/edu/princeton/cs/algs4/StdArrayIO.java
  class StdArrayIO (line 65) | public class StdArrayIO {
    method StdArrayIO (line 68) | private StdArrayIO() { }
    method readDouble1D (line 75) | public static double[] readDouble1D() {
    method print (line 89) | public static void print(double[] a) {
    method readDouble2D (line 103) | public static double[][] readDouble2D() {
    method print (line 120) | public static void print(double[][] a) {
    method readInt1D (line 138) | public static int[] readInt1D() {
    method print (line 152) | public static void print(int[] a) {
    method readInt2D (line 166) | public static int[][] readInt2D() {
    method print (line 183) | public static void print(int[][] a) {
    method readBoolean1D (line 200) | public static boolean[] readBoolean1D() {
    method print (line 214) | public static void print(boolean[] a) {
    method readBoolean2D (line 229) | public static boolean[][] readBoolean2D() {
    method print (line 246) | public static void print(boolean[][] a) {
    method main (line 264) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/StdAudio.java
  class StdAudio (line 213) | public final class StdAudio {
    method StdAudio (line 244) | private StdAudio() {
    method init (line 254) | private static void init() {
    method getAudioInputStreamFromFile (line 277) | private static AudioInputStream getAudioInputStreamFromFile(String fil...
    method drain (line 320) | public static void drain() {
    method play (line 346) | public static void play(double sample) {
    method play (line 379) | public static void play(double[] samples) {
    method play (line 395) | public static void play(String filename) {
    method read (line 440) | public static double[] read(String filename) {
    method save (line 504) | public static void save(String filename, double[] samples) {
    method stopInBackground (line 561) | public static synchronized void stopInBackground() {
    method playInBackground (line 578) | public static synchronized void playInBackground(final String filename) {
    class BackgroundRunnable (line 584) | private static class BackgroundRunnable implements Runnable {
      method BackgroundRunnable (line 588) | public BackgroundRunnable(String filename) {
      method run (line 595) | public void run() {
      method stop (line 625) | public void stop() {
    method loopInBackground (line 641) | @Deprecated
    method startRecording (line 676) | public static void startRecording() {
    method stopRecording (line 690) | public static double[] stopRecording() {
    class QueueOfDoubles (line 706) | private static class QueueOfDoubles {
      method QueueOfDoubles (line 712) | public QueueOfDoubles() {
      method resize (line 718) | private void resize(int capacity) {
      method enqueue (line 727) | public void enqueue(double item) {
      method size (line 734) | public int size() {
      method toArray (line 739) | public double[] toArray() {
    method main (line 754) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/StdAudioStereo.java
  class StdAudioStereo (line 232) | public final class StdAudioStereo {
    method StdAudioStereo (line 267) | private StdAudioStereo() {
    method init (line 277) | private static void init() {
    method getAudioInputStreamFromFile (line 300) | private static AudioInputStream getAudioInputStreamFromFile(String fil...
    method drain (line 343) | public static void drain() {
    method play (line 372) | public static void play(double sampleLeft, double sampleRight) {
    method play (line 415) | public static void play(double sample) {
    method play (line 427) | public static void play(double[] samples) {
    method play (line 445) | public static void play(double[] samplesLeft, double[] samplesRight) {
    method play (line 462) | public static void play(String filename) {
    method readChannel (line 502) | private static double[] readChannel(String filename, boolean channel) {
    method readLeft (line 554) | public static double[] readLeft(String filename) {
    method readRight (line 571) | public static double[] readRight(String filename) {
    method read (line 588) | public static double[] read(String filename) {
    method save (line 628) | private static void save(String filename, byte[] data, AudioFormat for...
    method save (line 675) | public static void save(String filename, double[] samples) {
    method save (line 720) | public static void save(String filename, double[] samplesLeft, double[...
    method stopInBackground (line 755) | public static synchronized void stopInBackground() {
    method playInBackground (line 770) | public static synchronized void playInBackground(final String filename) {
    class BackgroundRunnable (line 776) | private static class BackgroundRunnable implements Runnable {
      method BackgroundRunnable (line 780) | public BackgroundRunnable(String filename) {
      method run (line 787) | public void run() {
      method stop (line 817) | public void stop() {
    method loopInBackground (line 833) | @Deprecated
    method startRecording (line 872) | public static void startRecording() {
    method stopRecording (line 888) | public static void stopRecording() {
    method getRecordingLeft (line 905) | public static double[] getRecordingLeft() {
    method getRecordingRight (line 926) | public static double[] getRecordingRight() {
    method getRecordingMono (line 948) | public static double[] getRecordingMono() {
    class QueueOfDoubles (line 970) | private static class QueueOfDoubles {
      method QueueOfDoubles (line 976) | public QueueOfDoubles() {
      method resize (line 982) | private void resize(int capacity) {
      method enqueue (line 991) | public void enqueue(double item) {
      method size (line 998) | public int size() {
      method toArray (line 1003) | public double[] toArray() {
    method main (line 1018) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/StdDraw.java
  class StdDraw (line 505) | public final class StdDraw implements ActionListener, MouseListener, Mou...
    method StdDraw (line 725) | private StdDraw() { }
    method setVisible (line 740) | public static void setVisible(boolean isVisible) {
    method setCanvasSize (line 752) | public static void setCanvasSize() {
    method setCanvasSize (line 768) | public static void setCanvasSize(int canvasWidth, int canvasHeight) {
    method initCanvas (line 778) | private static void initCanvas() {
    method initGUI (line 804) | private static void initGUI() {
    method createMenuBar (line 832) | private static JMenuBar createMenuBar() {
    method close (line 852) | public static void close() {
    method validate (line 861) | private static void validate(double x, String name) {
    method validateNonnegative (line 867) | private static void validateNonnegative(double x, String name) {
    method validateNotNull (line 872) | private static void validateNotNull(Object x, String name) {
    method setTitle (line 887) | public static void setTitle(String title) {
    method setXscale (line 900) | public static void setXscale() {
    method setYscale (line 907) | public static void setYscale() {
    method setScale (line 915) | public static void setScale() {
    method setXscale (line 928) | public static void setXscale(double min, double max) {
    method setYscale (line 947) | public static void setYscale(double min, double max) {
    method setScale (line 966) | public static void setScale(double min, double max) {
    method scaleX (line 980) | private static double  scaleX(double x) { return width  * (x - xmin) /...
    method scaleY (line 981) | private static double  scaleY(double y) { return height * (ymax - y) /...
    method factorX (line 982) | private static double factorX(double w) { return w * width  / Math.abs...
    method factorY (line 983) | private static double factorY(double h) { return h * height / Math.abs...
    method userX (line 984) | private static double   userX(double x) { return xmin + x * (xmax - xm...
    method userY (line 985) | private static double   userY(double y) { return ymax - y * (ymax - ym...
    method clear (line 991) | public static void clear() {
    method clear (line 1002) | public static void clear(Color color) {
    method getPenRadius (line 1020) | public static double getPenRadius() {
    method setPenRadius (line 1030) | public static void setPenRadius() {
    method setPenRadius (line 1043) | public static void setPenRadius(double radius) {
    method getPenColor (line 1059) | public static Color getPenColor() {
    method getBackgroundColor (line 1068) | public static Color getBackgroundColor() {
    method setPenColor (line 1075) | public static void setPenColor() {
    method setPenColor (line 1089) | public static void setPenColor(Color color) {
    method setPenColor (line 1104) | public static void setPenColor(int red, int green, int blue) {
    method getFont (line 1116) | public static Font getFont() {
    method setFont (line 1123) | public static void setFont() {
    method setFont (line 1133) | public static void setFont(Font font) {
    method line (line 1153) | public static void line(double x0, double y0, double x1, double y1) {
    method pixel (line 1171) | private static void pixel(double x, double y) {
    method point (line 1186) | public static void point(double x, double y) {
    method circle (line 1213) | public static void circle(double x, double y, double radius) {
    method filledCircle (line 1237) | public static void filledCircle(double x, double y, double radius) {
    method ellipse (line 1265) | public static void ellipse(double x, double y, double semiMajorAxis, d...
    method filledEllipse (line 1294) | public static void filledEllipse(double x, double y, double semiMajorA...
    method arc (line 1325) | public static void arc(double x, double y, double radius, double angle...
    method square (line 1352) | public static void square(double x, double y, double halfLength) {
    method filledSquare (line 1376) | public static void filledSquare(double x, double y, double halfLength) {
    method rectangle (line 1402) | public static void rectangle(double x, double y, double halfWidth, dou...
    method filledRectangle (line 1429) | public static void filledRectangle(double x, double y, double halfWidt...
    method polygon (line 1460) | public static void polygon(double[] x, double[] y) {
    method filledPolygon (line 1494) | public static void filledPolygon(double[] x, double[] y) {
    method getImage (line 1520) | private static Image getImage(String filename) {
    method picture (line 1614) | public static void picture(double x, double y, String filename) {
    method picture (line 1646) | public static void picture(double x, double y, String filename, double...
    method picture (line 1685) | public static void picture(double x, double y, String filename, double...
    method picture (line 1726) | public static void picture(double x, double y, String filename, double...
    method text (line 1767) | public static void text(double x, double y, String text) {
    method text (line 1792) | public static void text(double x, double y, String text, double degree...
    method textLeft (line 1814) | public static void textLeft(double x, double y, String text) {
    method textRight (line 1837) | public static void textRight(double x, double y, String text) {
    method show (line 1860) | @Deprecated
    method pause (line 1873) | public static void pause(int t) {
    method show (line 1887) | public static void show() {
    method draw (line 1899) | private static void draw() {
    method enableDoubleBuffering (line 1909) | public static void enableDoubleBuffering() {
    method disableDoubleBuffering (line 1919) | public static void disableDoubleBuffering() {
    method save (line 1940) | public static void save(String filename) {
    method actionPerformed (line 1973) | @Override
    method isMousePressed (line 1999) | public static boolean isMousePressed() {
    method mousePressed (line 2011) | @Deprecated
    method mouseX (line 2023) | public static double mouseX() {
    method mouseY (line 2034) | public static double mouseY() {
    method mouseClicked (line 2044) | @Override
    method mouseEntered (line 2052) | @Override
    method mouseExited (line 2060) | @Override
    method mousePressed (line 2068) | @Override
    method mouseReleased (line 2080) | @Override
    method mouseDragged (line 2090) | @Override
    method mouseMoved (line 2101) | @Override
    method hasNextKeyTyped (line 2120) | public static boolean hasNextKeyTyped() {
    method nextKeyTyped (line 2138) | public static char nextKeyTyped() {
    method isKeyPressed (line 2160) | public static boolean isKeyPressed(int keycode) {
    method keyTyped (line 2170) | @Override
    method keyPressed (line 2180) | @Override
    method keyReleased (line 2190) | @Override
    class RetinaImageIcon (line 2202) | private static class RetinaImageIcon extends ImageIcon {
      method RetinaImageIcon (line 2204) | public RetinaImageIcon(Image image) {
      method getIconWidth (line 2208) | public int getIconWidth() {
      method getIconHeight (line 2217) | public int getIconHeight() {
      method paintIcon (line 2221) | public synchronized void paintIcon(Component c, Graphics g, int x, i...
    method main (line 2238) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/StdIn.java
  class StdIn (line 213) | public final class StdIn {
    method StdIn (line 238) | private StdIn() { }
    method isEmpty (line 251) | public static boolean isEmpty() {
    method hasNextLine (line 264) | public static boolean hasNextLine() {
    method hasNextChar (line 276) | public static boolean hasNextChar() {
    method readLine (line 290) | public static String readLine() {
    method readChar (line 307) | public static char readChar() {
    method readAll (line 328) | public static String readAll() {
    method readString (line 345) | public static String readString() {
    method readInt (line 362) | public static int readInt() {
    method readDouble (line 385) | public static double readDouble() {
    method readFloat (line 407) | public static float readFloat() {
    method readLong (line 429) | public static long readLong() {
    method readShort (line 451) | public static short readShort() {
    method readByte (line 473) | public static byte readByte() {
    method readBoolean (line 498) | public static boolean readBoolean() {
    method readAllStrings (line 520) | public static String[] readAllStrings() {
    method readAllLines (line 538) | public static String[] readAllLines() {
    method readAllInts (line 552) | public static int[] readAllInts() {
    method readAllLongs (line 566) | public static long[] readAllLongs() {
    method readAllDoubles (line 580) | public static double[] readAllDoubles() {
    method resync (line 598) | private static void resync() {
    method setScanner (line 602) | private static void setScanner(Scanner scanner) {
    method readInts (line 614) | @Deprecated
    method readDoubles (line 626) | @Deprecated
    method readStrings (line 636) | @Deprecated
    method main (line 647) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/StdOut.java
  class StdOut (line 67) | public final class StdOut {
    method StdOut (line 84) | private StdOut() { }
    method println (line 89) | public static void println() {
    method println (line 98) | public static void println(Object x) {
    method println (line 107) | public static void println(boolean x) {
    method println (line 116) | public static void println(char x) {
    method println (line 125) | public static void println(double x) {
    method println (line 134) | public static void println(float x) {
    method println (line 143) | public static void println(int x) {
    method println (line 152) | public static void println(long x) {
    method println (line 161) | public static void println(short x) {
    method println (line 172) | public static void println(byte x) {
    method print (line 179) | public static void print() {
    method print (line 188) | public static void print(Object x) {
    method print (line 198) | public static void print(boolean x) {
    method print (line 208) | public static void print(char x) {
    method print (line 218) | public static void print(double x) {
    method print (line 228) | public static void print(float x) {
    method print (line 238) | public static void print(int x) {
    method print (line 248) | public static void print(long x) {
    method print (line 258) | public static void print(short x) {
    method print (line 268) | public static void print(byte x) {
    method printf (line 281) | public static void printf(String format, Object... args) {
    method printf (line 294) | public static void printf(Locale locale, String format, Object... args) {
    method main (line 304) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/StdPicture.java
  class StdPicture (line 175) | public final class StdPicture {
    method StdPicture (line 184) | private StdPicture() { }
    method init (line 195) | public static void init(int width, int height) {
    method read (line 216) | public static void read(String filename) {
    method isVisible (line 245) | public static boolean isVisible() {
    method show (line 252) | public static void show() {
    method hide (line 259) | public static void hide() {
    method pause (line 268) | public static void pause(int t) {
    method height (line 283) | public static int height() {
    method width (line 292) | public static int width() {
    method getAlpha (line 304) | public static int getAlpha(int col, int row) {
    method getRed (line 317) | public static int getRed(int col, int row) {
    method getGreen (line 330) | public static int getGreen(int col, int row) {
    method getBlue (line 343) | public static int getBlue(int col, int row) {
    method getARGB (line 356) | public static int getARGB(int col, int row) {
    method setRGB (line 374) | public static void setRGB(int col, int row, int r, int g, int b) {
    method setARGB (line 397) | public static void setARGB(int col, int row, int a, int r, int g, int ...
    method setARGB (line 433) | public static void setARGB(int col, int row, int argb) {
    method setTitle (line 443) | public static void setTitle(String title) {
    method save (line 460) | public static void save(String filename) {
    method validateComponent (line 464) | private static void validateComponent(int val, String name) {
    method main (line 477) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/StdRandom.java
  class StdRandom (line 82) | public final class StdRandom {
    method StdRandom (line 95) | private StdRandom() { }
    method setSeed (line 105) | public static void setSeed(long s) {
    method getSeed (line 115) | public static long getSeed() {
    method uniform (line 125) | @Deprecated
    method uniformDouble (line 135) | public static double uniformDouble() {
    method uniform (line 147) | @Deprecated
    method uniformInt (line 159) | public static int uniformInt(int n) {
    method uniform (line 172) | @Deprecated
    method uniformLong (line 184) | public static long uniformLong(long n) {
    method random (line 215) | @Deprecated
    method uniform (line 230) | @Deprecated
    method uniformInt (line 244) | public static int uniformInt(int a, int b) {
    method uniform (line 260) | @Deprecated
    method uniformDouble (line 273) | public static double uniformDouble(double a, double b) {
    method bernoulli (line 289) | public static boolean bernoulli(double p) {
    method bernoulli (line 302) | public static boolean bernoulli() {
    method gaussian (line 312) | public static double gaussian() {
    method gaussian (line 335) | public static double gaussian(double mu, double sigma) {
    method geometric (line 351) | public static int geometric(double p) {
    method poisson (line 369) | public static int poisson(double lambda) {
    method pareto (line 391) | public static double pareto() {
    method pareto (line 404) | public static double pareto(double alpha) {
    method cauchy (line 415) | public static double cauchy() {
    method discrete (line 429) | public static int discrete(double[] probabilities) {
    method discrete (line 464) | public static int discrete(int[] frequencies) {
    method exponential (line 499) | public static double exponential(double lambda) {
    method exp (line 515) | @Deprecated
    method shuffle (line 526) | public static void shuffle(Object[] a) {
    method shuffle (line 543) | public static void shuffle(double[] a) {
    method shuffle (line 560) | public static void shuffle(int[] a) {
    method shuffle (line 577) | public static void shuffle(char[] a) {
    method shuffle (line 598) | public static void shuffle(Object[] a, int lo, int hi) {
    method shuffle (line 619) | public static void shuffle(double[] a, int lo, int hi) {
    method shuffle (line 640) | public static void shuffle(int[] a, int lo, int hi) {
    method permutation (line 660) | public static int[] permutation(int n) {
    method permutation (line 679) | public static int[] permutation(int n, int k) {
    method validateNotNull (line 697) | private static void validateNotNull(Object x) {
    method validateSubarrayIndices (line 704) | private static void validateSubarrayIndices(int lo, int hi, int length) {
    method main (line 715) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/StdStats.java
  class StdStats (line 49) | public final class StdStats {
    method StdStats (line 51) | private StdStats() { }
    method max (line 60) | public static double max(double[] a) {
    method max (line 82) | public static double max(double[] a, int lo, int hi) {
    method max (line 101) | public static int max(int[] a) {
    method min (line 118) | public static double min(double[] a) {
    method min (line 140) | public static double min(double[] a, int lo, int hi) {
    method min (line 159) | public static int min(int[] a) {
    method mean (line 176) | public static double mean(double[] a) {
    method mean (line 195) | public static double mean(double[] a, int lo, int hi) {
    method mean (line 213) | public static double mean(int[] a) {
    method var (line 228) | public static double var(double[] a) {
    method var (line 251) | public static double var(double[] a, int lo, int hi) {
    method var (line 273) | public static double var(int[] a) {
    method varp (line 291) | public static double varp(double[] a) {
    method varp (line 313) | public static double varp(double[] a, int lo, int hi) {
    method stddev (line 335) | public static double stddev(double[] a) {
    method stddev (line 347) | public static double stddev(int[] a) {
    method stddev (line 363) | public static double stddev(double[] a, int lo, int hi) {
    method stddevp (line 378) | public static double stddevp(double[] a) {
    method stddevp (line 394) | public static double stddevp(double[] a, int lo, int hi) {
    method sum (line 408) | private static double sum(double[] a) {
    method sum (line 428) | private static double sum(double[] a, int lo, int hi) {
    method sum (line 446) | private static int sum(int[] a) {
    method plotPoints (line 461) | public static void plotPoints(double[] a) {
    method plotLines (line 479) | public static void plotLines(double[] a) {
    method plotBars (line 496) | public static void plotBars(double[] a) {
    method validateNotNull (line 507) | private static void validateNotNull(Object x) {
    method validateSubarrayIndices (line 513) | private static void validateSubarrayIndices(int lo, int hi, int length) {
    method main (line 525) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Stopwatch.java
  class Stopwatch (line 45) | public class Stopwatch {
    method Stopwatch (line 52) | public Stopwatch() {
    method elapsedTime (line 62) | public double elapsedTime() {
    method main (line 79) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/StopwatchCPU.java
  class StopwatchCPU (line 32) | public class StopwatchCPU {
    method StopwatchCPU (line 41) | public StopwatchCPU() {
    method elapsedTime (line 51) | public double elapsedTime() {
    method main (line 67) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/SuffixArray.java
  class SuffixArray (line 63) | public class SuffixArray {
    method SuffixArray (line 70) | public SuffixArray(String text) {
    class Suffix (line 78) | private static class Suffix implements Comparable<Suffix> {
      method Suffix (line 82) | private Suffix(String text, int index) {
      method length (line 86) | private int length() {
      method charAt (line 89) | private char charAt(int i) {
      method compareTo (line 93) | public int compareTo(Suffix that) {
      method toString (line 103) | public String toString() {
    method length (line 112) | public int length() {
    method index (line 124) | public int index(int i) {
    method lcp (line 138) | public int lcp(int i) {
    method lcpSuffix (line 144) | private static int lcpSuffix(Suffix s, Suffix t) {
    method select (line 158) | public String select(int i) {
    method rank (line 170) | public int rank(String query) {
    method compare (line 183) | private static int compare(String query, Suffix suffix) {
    method main (line 197) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/SuffixArrayX.java
  class SuffixArrayX (line 63) | public class SuffixArrayX {
    method SuffixArrayX (line 74) | public SuffixArrayX(String text) {
    method sort (line 86) | private void sort(int lo, int hi, int d) {
    method insertion (line 111) | private void insertion(int lo, int hi, int d) {
    method less (line 118) | private boolean less(int i, int j, int d) {
    method exch (line 132) | private void exch(int i, int j) {
    method length (line 142) | public int length() {
    method index (line 154) | public int index(int i) {
    method lcp (line 167) | public int lcp(int i) {
    method lcp (line 173) | private int lcp(int i, int j) {
    method select (line 190) | public String select(int i) {
    method rank (line 202) | public int rank(String query) {
    method compare (line 215) | private int compare(String query, int i) {
    method main (line 235) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/SymbolDigraph.java
  class SymbolDigraph (line 43) | public class SymbolDigraph {
    method SymbolDigraph (line 56) | public SymbolDigraph(String filename, String delimiter) {
    method contains (line 95) | public boolean contains(String s) {
    method index (line 105) | @Deprecated
    method indexOf (line 115) | public int indexOf(String s) {
    method name (line 126) | @Deprecated
    method nameOf (line 138) | public String nameOf(int v) {
    method G (line 150) | @Deprecated
    method digraph (line 161) | public Digraph digraph() {
    method validateVertex (line 166) | private void validateVertex(int v) {
    method main (line 177) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/SymbolGraph.java
  class SymbolGraph (line 68) | public class SymbolGraph {
    method SymbolGraph (line 81) | public SymbolGraph(String filename, String delimiter) {
    method contains (line 121) | public boolean contains(String s) {
    method index (line 131) | @Deprecated
    method indexOf (line 142) | public int indexOf(String s) {
    method name (line 153) | @Deprecated
    method nameOf (line 165) | public String nameOf(int v) {
    method G (line 176) | @Deprecated
    method graph (line 186) | public Graph graph() {
    method validateVertex (line 191) | private void validateVertex(int v) {
    method main (line 203) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/TST.java
  class TST (line 63) | public class TST<Value> {
    class Node (line 67) | private static class Node<Value> {
    method TST (line 76) | public TST() {
    method size (line 83) | public int size() {
    method contains (line 94) | public boolean contains(String key) {
    method get (line 108) | public Value get(String key) {
    method get (line 119) | private Node<Value> get(Node<Value> x, String key, int d) {
    method put (line 137) | public void put(String key, Value val) {
    method put (line 146) | private Node<Value> put(Node<Value> x, String key, Value val, int d) {
    method longestPrefixOf (line 167) | public String longestPrefixOf(String query) {
    method keys (line 194) | public Iterable<String> keys() {
    method keysWithPrefix (line 207) | public Iterable<String> keysWithPrefix(String prefix) {
    method collect (line 220) | private void collect(Node<Value> x, StringBuilder prefix, Queue<String...
    method keysThatMatch (line 237) | public Iterable<String> keysThatMatch(String pattern) {
    method collect (line 243) | private void collect(Node<Value> x, StringBuilder prefix, int i, Strin...
    method main (line 263) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/TarjanSCC.java
  class TarjanSCC (line 56) | public class TarjanSCC {
    method TarjanSCC (line 71) | public TarjanSCC(Digraph digraph) {
    method dfs (line 84) | private void dfs(Digraph digraph, int v) {
    method count (line 111) | public int count() {
    method stronglyConnected (line 125) | public boolean stronglyConnected(int v, int w) {
    method id (line 137) | public int id(int v) {
    method check (line 143) | private boolean check(Digraph digraph) {
    method validateVertex (line 155) | private void validateVertex(int v) {
    method main (line 166) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/ThreeSum.java
  class ThreeSum (line 44) | public class ThreeSum {
    method ThreeSum (line 47) | private ThreeSum() { }
    method printAll (line 55) | public static void printAll(int[] a) {
    method count (line 76) | public static int count(int[] a) {
    method main (line 98) | public static void main(String[] args)  {

FILE: src/main/java/edu/princeton/cs/algs4/ThreeSumFast.java
  class ThreeSumFast (line 60) | public class ThreeSumFast {
    method ThreeSumFast (line 63) | private ThreeSumFast() { }
    method containsDuplicates (line 66) | private static boolean containsDuplicates(int[] a) {
    method printAll (line 79) | public static void printAll(int[] a) {
    method count (line 99) | public static int count(int[] a) {
    method main (line 120) | public static void main(String[] args)  {

FILE: src/main/java/edu/princeton/cs/algs4/TopM.java
  class TopM (line 35) | public class TopM {
    method TopM (line 38) | private TopM() { }
    method main (line 47) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Topological.java
  class Topological (line 59) | public class Topological {
    method Topological (line 68) | public Topological(Digraph digraph) {
    method Topological (line 85) | public Topological(EdgeWeightedDigraph digraph) {
    method order (line 100) | public Iterable<Integer> order() {
    method hasOrder (line 109) | public boolean hasOrder() {
    method isDAG (line 119) | @Deprecated
    method rank (line 133) | public int rank(int v) {
    method validateVertex (line 140) | private void validateVertex(int v) {
    method main (line 151) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/TopologicalX.java
  class TopologicalX (line 40) | public class TopologicalX {
    method TopologicalX (line 49) | public TopologicalX(Digraph digraph) {
    method TopologicalX (line 90) | public TopologicalX(EdgeWeightedDigraph digraph) {
    method order (line 134) | public Iterable<Integer> order() {
    method hasOrder (line 143) | public boolean hasOrder() {
    method rank (line 156) | public int rank(int v) {
    method check (line 163) | private boolean check(Digraph digraph) {
    method check (line 206) | private boolean check(EdgeWeightedDigraph digraph) {
    method validateVertex (line 250) | private void validateVertex(int v) {
    method main (line 261) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/Transaction.java
  class Transaction (line 26) | public class Transaction implements Comparable<Transaction> {
    method Transaction (line 42) | public Transaction(String who, Date when, double amount) {
    method Transaction (line 58) | public Transaction(String transaction) {
    method who (line 72) | public String who() {
    method when (line 81) | public Date when() {
    method amount (line 90) | public double amount() {
    method toString (line 99) | @Override
    method compareTo (line 112) | public int compareTo(Transaction that) {
    method equals (line 122) | @Override
    method hashCode (line 138) | public int hashCode() {
    class WhoOrder (line 150) | public static class WhoOrder implements Comparator<Transaction> {
      method compare (line 152) | @Override
    class WhenOrder (line 161) | public static class WhenOrder implements Comparator<Transaction> {
      method compare (line 163) | @Override
    class HowMuchOrder (line 172) | public static class HowMuchOrder implements Comparator<Transaction> {
      method compare (line 174) | @Override
    method main (line 186) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/TransitiveClosure.java
  class TransitiveClosure (line 58) | public class TransitiveClosure {
    method TransitiveClosure (line 65) | public TransitiveClosure(Digraph digraph) {
    method reachable (line 80) | public boolean reachable(int v, int w) {
    method validateVertex (line 87) | private void validateVertex(int v) {
    method main (line 98) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/TrieSET.java
  class TrieSET (line 39) | public class TrieSET implements Iterable<String> {
    class Node (line 46) | private static class Node {
    method TrieSET (line 54) | public TrieSET() {
    method contains (line 64) | public boolean contains(String key) {
    method get (line 71) | private Node get(Node x, String key, int d) {
    method add (line 83) | public void add(String key) {
    method add (line 88) | private Node add(Node x, String key, int d) {
    method size (line 105) | public int size() {
    method isEmpty (line 113) | public boolean isEmpty() {
    method iterator (line 123) | public Iterator<String> iterator() {
    method keysWithPrefix (line 133) | public Iterable<String> keysWithPrefix(String prefix) {
    method collect (line 140) | private void collect(Node x, StringBuilder prefix, Queue<String> resul...
    method keysThatMatch (line 157) | public Iterable<String> keysThatMatch(String pattern) {
    method collect (line 164) | private void collect(Node x, StringBuilder prefix, String pattern, Que...
    method longestPrefixOf (line 194) | public String longestPrefixOf(String query) {
    method longestPrefixOf (line 205) | private int longestPrefixOf(Node x, String query, int d, int length) {
    method delete (line 218) | public void delete(String key) {
    method delete (line 223) | private Node delete(Node x, String key, int d) {
    method main (line 248) | public static void main(String[] args) {

FILE: src/main/java/edu/princeton/cs/algs4/TrieST.java
  class TrieST (line 50) | public class TrieST<Value> {
    class Node (line 58) | private static class Node {
    method TrieST (line 66) | public TrieST() {
    method get (line 77) | public Value get(String key) {
    method contains (line 91) | public boolean contains(String key) {
    method get (line 96) | private Node get(Node x, String key, int d) {
    method put (line 111) | public void put(String key, Value val) {
    method put (line 117) | private Node put(Node x, String key, Value val, int d) {
    method size (line 133) | public int size() {
    method isEmpty (line 141) | public boolean isEmpty() {
    method keys (line 151) | public Iterable<String
Condensed preview — 208 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (2,132K chars).
[
  {
    "path": ".gitignore",
    "chars": 588,
    "preview": "# OS generated files\n.DS_Store\nThumbs.db\n*~\n# Thumbnails\n._*\n\n### Java ###\n*.class\n\n# Package Files #\n*.jar\n*.war\n*.ear\n"
  },
  {
    "path": "LICENSE",
    "chars": 35141,
    "preview": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free "
  },
  {
    "path": "README-MAVEN.txt",
    "chars": 3382,
    "preview": "This file provides brief instructions on how to add this repository to\na Maven build, from Eclipse, NetBeans, IntelliJ, "
  },
  {
    "path": "README.md",
    "chars": 3409,
    "preview": "## Overview\n\n<IMG SRC=\"http://algs4.cs.princeton.edu/cover.png\"  align=right hspace=25 width=100 alt = \"Algorithms 4/e t"
  },
  {
    "path": "USING-MAVEN.md",
    "chars": 3774,
    "preview": "This file provides brief instructions on how to add this repository to\na Maven build, from Eclipse, NetBeans, IntelliJ, "
  },
  {
    "path": "build.gradle",
    "chars": 1895,
    "preview": "buildscript {\n  repositories {\n        jcenter()\n   }\n}\n\nplugins {\n    id \"com.jfrog.bintray\" version \"1.7\"\n}\n\ngroup = '"
  },
  {
    "path": "pom.xml",
    "chars": 2428,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/AVLTreeST.java",
    "chars": 27305,
    "preview": "/******************************************************************************\n *  Compilation:  javac AVLTreeST.java\n "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Accumulator.java",
    "chars": 4972,
    "preview": "/******************************************************************************\n *  Compilation:  javac Accumulator.java"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/AcyclicLP.java",
    "chars": 7703,
    "preview": "/******************************************************************************\n *  Compilation:  javac AcyclicLP.java\n "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/AcyclicSP.java",
    "chars": 7483,
    "preview": "/******************************************************************************\n *  Compilation:  javac AcyclicSP.java\n "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/AdjMatrixEdgeWeightedDigraph.java",
    "chars": 7465,
    "preview": "/******************************************************************************\n *  Compilation:  javac AdjMatrixEdgeWei"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/AllowFilter.java",
    "chars": 3530,
    "preview": "/******************************************************************************\n *  Compilation:  javac AllowFilter.java"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Allowlist.java",
    "chars": 3278,
    "preview": "/******************************************************************************\n *  Compilation:  javac Allowlist.java\n "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Alphabet.java",
    "chars": 9075,
    "preview": "/******************************************************************************\n *  Compilation:  javac Alphabet.java\n *"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/AmericanFlag.java",
    "chars": 10269,
    "preview": "/******************************************************************************\n *  Compilation:  javac AmericanFlag.jav"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/AmericanFlagX.java",
    "chars": 6854,
    "preview": "/******************************************************************************\n *  Compilation:  javac AmericanFlagX.ja"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Arbitrage.java",
    "chars": 4519,
    "preview": "/******************************************************************************\n *  Compilation:  javac Arbitrage.java\n "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/AssignmentProblem.java",
    "chars": 11547,
    "preview": "/******************************************************************************\n *  Compilation:  javac AssignmentProble"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Average.java",
    "chars": 2824,
    "preview": "/******************************************************************************\n *  Compilation:  javac Average.java\n * "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/BST.java",
    "chars": 21244,
    "preview": "/******************************************************************************\n *  Compilation:  javac BST.java\n *  Exe"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/BTree.java",
    "chars": 10942,
    "preview": "/******************************************************************************\n *  Compilation:  javac BTree.java\n *  E"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Bag.java",
    "chars": 4984,
    "preview": "/******************************************************************************\n *  Compilation:  javac Bag.java\n *  Exe"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/BellmanFordSP.java",
    "chars": 13456,
    "preview": "/******************************************************************************\n *  Compilation:  javac BellmanFordSP.ja"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/BinaryDump.java",
    "chars": 3444,
    "preview": "/******************************************************************************\n *  Compilation:  javac BinaryDump.java\n"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/BinaryIn.java",
    "chars": 13279,
    "preview": "/******************************************************************************\n *  Compilation:  javac BinaryIn.java\n *"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/BinaryInsertion.java",
    "chars": 5345,
    "preview": "/******************************************************************************\n *  Compilation:  javac BinaryInsertion."
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/BinaryOut.java",
    "chars": 12040,
    "preview": "/******************************************************************************\n *  Compilation:  javac BinaryOut.java\n "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/BinarySearch.java",
    "chars": 4673,
    "preview": "/******************************************************************************\n *  Compilation:  javac BinarySearch.jav"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/BinarySearchST.java",
    "chars": 15849,
    "preview": "/******************************************************************************\n *  Compilation:  javac BinarySearchST.j"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/BinaryStdIn.java",
    "chars": 10980,
    "preview": "/******************************************************************************\n *  Compilation:  javac BinaryStdIn.java"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/BinaryStdOut.java",
    "chars": 10061,
    "preview": "/******************************************************************************\n *  Compilation:  javac BinaryStdOut.jav"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/BinomialMinPQ.java",
    "chars": 9919,
    "preview": "/******************************************************************************\n *  Compilation: javac BinomialMinPQ.jav"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Bipartite.java",
    "chars": 8379,
    "preview": "/******************************************************************************\n *  Compilation:  javac Bipartite.java\n "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/BipartiteMatching.java",
    "chars": 14201,
    "preview": "/******************************************************************************\n *  Compilation:  javac BipartiteMatchin"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/BipartiteX.java",
    "chars": 8960,
    "preview": "/******************************************************************************\n *  Compilation:  javac BipartiteX.java\n"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/BlockFilter.java",
    "chars": 3547,
    "preview": "/******************************************************************************\n *  Compilation:  javac BlockFilter.java"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/BoruvkaMST.java",
    "chars": 8314,
    "preview": "/******************************************************************************\n *  Compilation:  javac BoruvkaMST.java\n"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/BoyerMoore.java",
    "chars": 6800,
    "preview": "/******************************************************************************\n *  Compilation:  javac BoyerMoore.java\n"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/BreadthFirstDirectedPaths.java",
    "chars": 9264,
    "preview": "/******************************************************************************\n *  Compilation:  javac BreadthFirstDire"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/BreadthFirstPaths.java",
    "chars": 11387,
    "preview": "/******************************************************************************\n *  Compilation:  javac BreadthFirstPath"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/CC.java",
    "chars": 8850,
    "preview": "/******************************************************************************\n *  Compilation:  javac CC.java\n *  Exec"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/CPM.java",
    "chars": 4399,
    "preview": "/******************************************************************************\n *  Compilation:  javac CPM.java\n *  Exe"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Cat.java",
    "chars": 2951,
    "preview": "/******************************************************************************\n *  Compilation:  javac Cat.java\n *  Exe"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/ClosestPair.java",
    "chars": 8857,
    "preview": "/******************************************************************************\n *  Compilation:  javac ClosestPair.java"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/CollisionSystem.java",
    "chars": 9356,
    "preview": "/******************************************************************************\n *  Compilation:  javac CollisionSystem."
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Complex.java",
    "chars": 9383,
    "preview": "/******************************************************************************\n *  Compilation:  javac Complex.java\n * "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Count.java",
    "chars": 3323,
    "preview": "/******************************************************************************\n *  Compilation:  javac Count.java\n *  E"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Counter.java",
    "chars": 4272,
    "preview": "/******************************************************************************\n *  Compilation:  javac Counter.java\n * "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Cycle.java",
    "chars": 6615,
    "preview": "/******************************************************************************\n *  Compilation:  javac Cycle.java\n *  E"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Date.java",
    "chars": 7507,
    "preview": "/******************************************************************************\n *  Compilation:  javac Date.java\n *  Ex"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/DeDup.java",
    "chars": 2994,
    "preview": "/******************************************************************************\n *  Compilation:  javac DeDup.java\n *  E"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/DegreesOfSeparation.java",
    "chars": 5490,
    "preview": "/******************************************************************************\n *  Compilation:  javac DegreesOfSeparat"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/DepthFirstDirectedPaths.java",
    "chars": 6156,
    "preview": "/******************************************************************************\n *  Compilation:  javac DepthFirstDirect"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/DepthFirstOrder.java",
    "chars": 8715,
    "preview": "/******************************************************************************\n *  Compilation:  javac DepthFirstOrder."
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/DepthFirstPaths.java",
    "chars": 5836,
    "preview": "/******************************************************************************\n *  Compilation:  javac DepthFirstPaths."
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/DepthFirstSearch.java",
    "chars": 5094,
    "preview": "/******************************************************************************\n *  Compilation:  javac DepthFirstSearch"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Digraph.java",
    "chars": 12132,
    "preview": "/******************************************************************************\n *  Compilation:  javac Digraph.java\n * "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/DigraphGenerator.java",
    "chars": 21518,
    "preview": "/******************************************************************************\n *  Compilation:  javac DigraphGenerator"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/DijkstraAllPairsSP.java",
    "chars": 6580,
    "preview": "/******************************************************************************\n *  Compilation:  javac DijkstraAllPairs"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/DijkstraSP.java",
    "chars": 10478,
    "preview": "/******************************************************************************\n *  Compilation:  javac DijkstraSP.java\n"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/DijkstraUndirectedSP.java",
    "chars": 10730,
    "preview": "/******************************************************************************\n *  Compilation:  javac DijkstraUndirect"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/DirectedCycle.java",
    "chars": 6132,
    "preview": "/******************************************************************************\n *  Compilation:  javac DirectedCycle.ja"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/DirectedCycleX.java",
    "chars": 6480,
    "preview": "/******************************************************************************\n *  Compilation:  javac DirectedCycleX.j"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/DirectedDFS.java",
    "chars": 6906,
    "preview": "/******************************************************************************\n *  Compilation:  javac DirectedDFS.java"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/DirectedEdge.java",
    "chars": 3981,
    "preview": "/******************************************************************************\n *  Compilation:  javac DirectedEdge.jav"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/DirectedEulerianCycle.java",
    "chars": 9865,
    "preview": "/******************************************************************************\n *  Compilation:  javac DirectedEulerian"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/DirectedEulerianPath.java",
    "chars": 9869,
    "preview": "/******************************************************************************\n *  Compilation:  javac DirectedEulerian"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/DoublingRatio.java",
    "chars": 3406,
    "preview": "/******************************************************************************\n *  Compilation:  javac DoublingRatio.ja"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/DoublingTest.java",
    "chars": 3174,
    "preview": "/******************************************************************************\n *  Compilation:  javac DoublingTest.jav"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Draw.java",
    "chars": 66878,
    "preview": "/******************************************************************************\n *  Compilation:  javac Draw.java\n *  Ex"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/DrawListener.java",
    "chars": 4084,
    "preview": "/******************************************************************************\n *  Compilation:  javac DrawListener.jav"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Edge.java",
    "chars": 4854,
    "preview": "/******************************************************************************\n *  Compilation:  javac Edge.java\n *  Ex"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/EdgeWeightedDigraph.java",
    "chars": 12852,
    "preview": "/******************************************************************************\n *  Compilation:  javac EdgeWeightedDigr"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/EdgeWeightedDirectedCycle.java",
    "chars": 7846,
    "preview": "/******************************************************************************\n *  Compilation:  javac EdgeWeightedDire"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/EdgeWeightedGraph.java",
    "chars": 12665,
    "preview": "/******************************************************************************\n *  Compilation:  javac EdgeWeightedGrap"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/EulerianCycle.java",
    "chars": 10936,
    "preview": "/******************************************************************************\n *  Compilation:  javac EulerianCycle.ja"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/EulerianPath.java",
    "chars": 10515,
    "preview": "/******************************************************************************\n *  Compilation:  javac EulerianPath.jav"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/FFT.java",
    "chars": 9785,
    "preview": "/******************************************************************************\n *  Compilation:  javac FFT.java\n *  Exe"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/FarthestPair.java",
    "chars": 7394,
    "preview": "/******************************************************************************\n *  Compilation:  javac FarthestPair.jav"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/FenwickTree.java",
    "chars": 6969,
    "preview": "/******************************************************************************\n *  Compilation:  javac FenwickTree.java"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/FibonacciMinPQ.java",
    "chars": 9373,
    "preview": "/******************************************************************************\n *  Compilation: javac FibonacciMinPQ.ja"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/FileIndex.java",
    "chars": 3612,
    "preview": "/******************************************************************************\n *  Compilation:  javac FileIndex.java\n "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/FlowEdge.java",
    "chars": 9092,
    "preview": "/******************************************************************************\n *  Compilation:  javac FlowEdge.java\n *"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/FlowNetwork.java",
    "chars": 7758,
    "preview": "/******************************************************************************\n *  Compilation:  javac FlowNetwork.java"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/FloydWarshall.java",
    "chars": 11787,
    "preview": "/******************************************************************************\n *  Compilation:  javac FloydWarshall.ja"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/FordFulkerson.java",
    "chars": 10667,
    "preview": "/******************************************************************************\n *  Compilation:  javac FordFulkerson.ja"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/FrequencyCounter.java",
    "chars": 4147,
    "preview": "/******************************************************************************\n *  Compilation:  javac FrequencyCounter"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/GREP.java",
    "chars": 3063,
    "preview": "/******************************************************************************\n *  Compilation:  javac GREP.java\n *  Ex"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/GabowSCC.java",
    "chars": 7804,
    "preview": "/******************************************************************************\n *  Compilation:  javac GabowSCC.java\n *"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/GaussJordanElimination.java",
    "chars": 13723,
    "preview": "/******************************************************************************\n *  Compilation:  javac GaussJordanElimi"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/GaussianElimination.java",
    "chars": 11914,
    "preview": "/******************************************************************************\n *  Compilation:  javac GaussianEliminat"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Genome.java",
    "chars": 3872,
    "preview": "/******************************************************************************\n *  Compilation:  javac Genome.java\n *  "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/GlobalMincut.java",
    "chars": 11665,
    "preview": "/******************************************************************************\n *  Compilation:  javac GlobalMincut.jav"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/GrahamScan.java",
    "chars": 6463,
    "preview": "/******************************************************************************\n *  Compilation:  javac GrahamScan.java\n"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Graph.java",
    "chars": 11307,
    "preview": "/******************************************************************************\n *  Compilation:  javac Graph.java\n *  E"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/GraphGenerator.java",
    "chars": 17747,
    "preview": "/******************************************************************************\n *  Compilation:  javac GraphGenerator.j"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/GrayscalePicture.java",
    "chars": 21105,
    "preview": "/******************************************************************************\n *  Compilation:  javac GrayscalePicture"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Heap.java",
    "chars": 4716,
    "preview": "/******************************************************************************\n *  Compilation:  javac Heap.java\n *  Ex"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/HexDump.java",
    "chars": 3643,
    "preview": "/******************************************************************************\n *  Compilation:  javac HexDump.java\n * "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/HopcroftKarp.java",
    "chars": 16398,
    "preview": "/******************************************************************************\n *  Compilation:  javac HopcroftKarp.jav"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Huffman.java",
    "chars": 7631,
    "preview": "/******************************************************************************\n *  Compilation:  javac Huffman.java\n * "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/In.java",
    "chars": 30497,
    "preview": "/******************************************************************************\n *  Compilation:  javac In.java\n *  Exec"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/IndexBinomialMinPQ.java",
    "chars": 17578,
    "preview": "/******************************************************************************\n *  Compilation: javac IndexBinomialMinP"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/IndexFibonacciMinPQ.java",
    "chars": 15682,
    "preview": "/******************************************************************************\n *  Compilation: javac IndexFibonacciMin"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/IndexMaxPQ.java",
    "chars": 14921,
    "preview": "/******************************************************************************\n *  Compilation:  javac IndexMaxPQ.java\n"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/IndexMinPQ.java",
    "chars": 14463,
    "preview": "/******************************************************************************\n *  Compilation:  javac IndexMinPQ.java\n"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/IndexMultiwayMinPQ.java",
    "chars": 13281,
    "preview": "/******************************************************************************\n *  Compilation: javac IndexMultiwayMinP"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/InplaceMSD.java",
    "chars": 5491,
    "preview": "/******************************************************************************\n *  Compilation: javac InplaceMSD.java\n "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Insertion.java",
    "chars": 8250,
    "preview": "/******************************************************************************\n *  Compilation:  javac Insertion.java\n "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/InsertionX.java",
    "chars": 5191,
    "preview": "/******************************************************************************\n *  Compilation:  javac InsertionX.java\n"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Interval1D.java",
    "chars": 9499,
    "preview": "/******************************************************************************\n *  Compilation:  javac Interval1D.java\n"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Interval2D.java",
    "chars": 6363,
    "preview": "/******************************************************************************\n *  Compilation:  javac Interval2D.java\n"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Inversions.java",
    "chars": 7480,
    "preview": "/******************************************************************************\n *  Compilation:  javac Inversions.java\n"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/KMP.java",
    "chars": 6582,
    "preview": "/******************************************************************************\n *  Compilation:  javac KMP.java\n *  Exe"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/KWIK.java",
    "chars": 4510,
    "preview": "/******************************************************************************\n *  Compilation:  javac KWIK.java\n *  Ex"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Knuth.java",
    "chars": 4901,
    "preview": "/******************************************************************************\n *  Compilation:  javac Knuth.java\n *  E"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/KosarajuSharirSCC.java",
    "chars": 8770,
    "preview": "/******************************************************************************\n *  Compilation:  javac KosarajuSharirSC"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/KruskalMST.java",
    "chars": 7763,
    "preview": "/******************************************************************************\n *  Compilation:  javac KruskalMST.java\n"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/LSD.java",
    "chars": 5836,
    "preview": "/******************************************************************************\n *  Compilation:  javac LSD.java\n *  Exe"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/LZW.java",
    "chars": 5385,
    "preview": "/******************************************************************************\n *  Compilation:  javac LZW.java\n *  Exe"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/LazyPrimMST.java",
    "chars": 8335,
    "preview": "/******************************************************************************\n *  Compilation:  javac LazyPrimMST.java"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/LinearProbingHashST.java",
    "chars": 10351,
    "preview": "/******************************************************************************\n *  Compilation:  javac LinearProbingHas"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/LinearProgramming.java",
    "chars": 13717,
    "preview": "/******************************************************************************\n *  Compilation:  javac LinearProgrammin"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/LinearRegression.java",
    "chars": 6372,
    "preview": "/******************************************************************************\n *  Compilation:  javac LinearRegression"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/LinkedBag.java",
    "chars": 4815,
    "preview": "/******************************************************************************\n *  Compilation:  javac LinkedBag.java\n "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/LinkedQueue.java",
    "chars": 7503,
    "preview": "/******************************************************************************\n *  Compilation:  javac LinkedQueue.java"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/LinkedStack.java",
    "chars": 7021,
    "preview": "/******************************************************************************\n *  Compilation:  javac LinkedStack.java"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/LongestCommonSubstring.java",
    "chars": 5124,
    "preview": "/******************************************************************************\n *  Compilation:  javac LongestCommonSub"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/LongestRepeatedSubstring.java",
    "chars": 4100,
    "preview": "/******************************************************************************\n *  Compilation:  javac LongestRepeatedS"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/LookupCSV.java",
    "chars": 4136,
    "preview": "/******************************************************************************\n *  Compilation:  javac LookupCSV.java\n "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/LookupIndex.java",
    "chars": 4079,
    "preview": "/******************************************************************************\n *  Compilation:  javac LookupIndex.java"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/MSD.java",
    "chars": 8076,
    "preview": "/******************************************************************************\n *  Compilation: javac MSD.java\n *  Exec"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/MaxPQ.java",
    "chars": 10774,
    "preview": "/******************************************************************************\n *  Compilation:  javac MaxPQ.java\n *  E"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Merge.java",
    "chars": 7504,
    "preview": "/******************************************************************************\n *  Compilation:  javac Merge.java\n *  E"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/MergeBU.java",
    "chars": 5332,
    "preview": "/******************************************************************************\n *  Compilation:  javac MergeBU.java\n * "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/MergeX.java",
    "chars": 9264,
    "preview": "/******************************************************************************\n *  Compilation:  javac MergeX.java\n *  "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/MinPQ.java",
    "chars": 10573,
    "preview": "/******************************************************************************\n *  Compilation:  javac MinPQ.java\n *  E"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Multiway.java",
    "chars": 3793,
    "preview": "/******************************************************************************\n *  Compilation:  javac Multiway.java\n *"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/MultiwayMinPQ.java",
    "chars": 9346,
    "preview": "/******************************************************************************\n *  Compilation: javac MultiwayMinPQ.jav"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/NFA.java",
    "chars": 6670,
    "preview": "/******************************************************************************\n *  Compilation:  javac NFA.java\n *  Exe"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/NonrecursiveDFS.java",
    "chars": 5845,
    "preview": "/******************************************************************************\n *  Compilation:  javac NonrecursiveDFS."
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/NonrecursiveDirectedDFS.java",
    "chars": 5649,
    "preview": "/******************************************************************************\n *  Compilation:  javac NonrecursiveDire"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Out.java",
    "chars": 9686,
    "preview": "/******************************************************************************\n *  Compilation:  javac Out.java\n *  Exe"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Particle.java",
    "chars": 9885,
    "preview": "/******************************************************************************\n *  Compilation:  javac Particle.java\n *"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/PatriciaSET.java",
    "chars": 18762,
    "preview": "/******************************************************************************\n *  Compilation:  javac PatriciaSET.java"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/PatriciaST.java",
    "chars": 20074,
    "preview": "/******************************************************************************\n *  Compilation:  javac PatriciaST.java\n"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Picture.java",
    "chars": 29496,
    "preview": "/******************************************************************************\n *  Compilation:  javac Picture.java\n * "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/PictureDump.java",
    "chars": 3282,
    "preview": "/******************************************************************************\n *  Compilation:  javac PictureDump.java"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Point2D.java",
    "chars": 12739,
    "preview": "/******************************************************************************\n *  Compilation:  javac Point2D.java\n * "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Polynomial.java",
    "chars": 10575,
    "preview": "/******************************************************************************\n *  Compilation:  javac Polynomial.java\n"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/PrimMST.java",
    "chars": 8808,
    "preview": "/******************************************************************************\n *  Compilation:  javac PrimMST.java\n * "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Queue.java",
    "chars": 6521,
    "preview": "/******************************************************************************\n *  Compilation:  javac Queue.java\n *  E"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Quick.java",
    "chars": 6954,
    "preview": "/******************************************************************************\n *  Compilation:  javac Quick.java\n *  E"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Quick3string.java",
    "chars": 5534,
    "preview": "/******************************************************************************\n *  Compilation:  javac Quick3string.jav"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Quick3way.java",
    "chars": 4873,
    "preview": "/******************************************************************************\n *  Compilation:  javac Quick3way.java\n "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/QuickBentleyMcIlroy.java",
    "chars": 6907,
    "preview": "/******************************************************************************\n *  Compilation:  javac QuickBentleyMcIl"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/QuickFindUF.java",
    "chars": 7387,
    "preview": "/******************************************************************************\n *  Compilation:  javac QuickFindUF.java"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/QuickUnionUF.java",
    "chars": 7213,
    "preview": "/******************************************************************************\n *  Compilation:  javac QuickUnionUF.jav"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/QuickX.java",
    "chars": 5901,
    "preview": "/******************************************************************************\n *  Compilation:  javac QuickX.java\n *  "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/RabinKarp.java",
    "chars": 6503,
    "preview": "/******************************************************************************\n *  Compilation:  javac RabinKarp.java\n "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/RandomSeq.java",
    "chars": 3201,
    "preview": "/******************************************************************************\n *  Compilation:  javac RandomSeq.java\n "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/RectHV.java",
    "chars": 8777,
    "preview": "/******************************************************************************\n *  Compilation:  javac RectHV.java\n *  "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/RedBlackBST.java",
    "chars": 27882,
    "preview": "/******************************************************************************\n *  Compilation:  javac RedBlackBST.java"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/ResizingArrayBag.java",
    "chars": 4632,
    "preview": "/******************************************************************************\n *  Compilation:  javac ResizingArrayBag"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/ResizingArrayQueue.java",
    "chars": 6574,
    "preview": "/******************************************************************************\n *  Compilation:  javac ResizingArrayQue"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/ResizingArrayStack.java",
    "chars": 6301,
    "preview": "/******************************************************************************\n *  Compilation:  javac ResizingArraySta"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/RunLength.java",
    "chars": 4413,
    "preview": "/******************************************************************************\n *  Compilation:  javac RunLength.java\n "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/SET.java",
    "chars": 12648,
    "preview": "/******************************************************************************\n *  Compilation:  javac SET.java\n *  Exe"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/ST.java",
    "chars": 10464,
    "preview": "/******************************************************************************\n *  Compilation:  javac ST.java\n *  Exec"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/SegmentTree.java",
    "chars": 11570,
    "preview": "/******************************************************************************\n *  Compilation:  javac SegmentTree.java"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Selection.java",
    "chars": 6072,
    "preview": "/******************************************************************************\n *  Compilation:  javac Selection.java\n "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/SeparateChainingHashST.java",
    "chars": 8731,
    "preview": "/******************************************************************************\n *  Compilation:  javac SeparateChaining"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/SequentialSearchST.java",
    "chars": 8156,
    "preview": "/******************************************************************************\n *  Compilation:  javac SequentialSearch"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Shell.java",
    "chars": 5070,
    "preview": "/******************************************************************************\n *  Compilation:  javac Shell.java\n *  E"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/SparseVector.java",
    "chars": 8165,
    "preview": "/******************************************************************************\n *  Compilation:  javac SparseVector.jav"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Stack.java",
    "chars": 6708,
    "preview": "/******************************************************************************\n *  Compilation:  javac Stack.java\n *  E"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/StaticSETofInts.java",
    "chars": 3736,
    "preview": "/******************************************************************************\n *  Compilation:  javac StaticSetOfInts."
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/StdArrayIO.java",
    "chars": 8515,
    "preview": "/******************************************************************************\n *  Compilation:  javac StdArrayIO.java\n"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/StdAudio.java",
    "chars": 31191,
    "preview": "/******************************************************************************\n *  Compilation:  javac StdAudio.java\n *"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/StdAudioStereo.java",
    "chars": 44215,
    "preview": "/******************************************************************************\n *  Compilation:  javac StdAudioStereo.j"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/StdDraw.java",
    "chars": 87639,
    "preview": "/******************************************************************************\n *  Compilation:  javac StdDraw.java\n * "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/StdIn.java",
    "chars": 27490,
    "preview": "/******************************************************************************\n *  Compilation:  javac StdIn.java\n *  E"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/StdOut.java",
    "chars": 9693,
    "preview": "/******************************************************************************\n *  Compilation:  javac StdOut.java\n *  "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/StdPicture.java",
    "chars": 19305,
    "preview": "/******************************************************************************\n *  Compilation:  javac StdPicture.java\n"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/StdRandom.java",
    "chars": 27641,
    "preview": "/******************************************************************************\n *  Compilation:  javac StdRandom.java\n "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/StdStats.java",
    "chars": 18436,
    "preview": "/******************************************************************************\n *  Compilation:  javac StdStats.java\n *"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Stopwatch.java",
    "chars": 4291,
    "preview": "/******************************************************************************\n *  Compilation:  javac Stopwatch.java\n "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/StopwatchCPU.java",
    "chars": 4070,
    "preview": "/******************************************************************************\n *  Compilation:  javac StopwatchCPU.jav"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/SuffixArray.java",
    "chars": 9318,
    "preview": "/******************************************************************************\n *  Compilation:  javac SuffixArray.java"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/SuffixArrayX.java",
    "chars": 10844,
    "preview": "/******************************************************************************\n *  Compilation:  javac SuffixArrayX.jav"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/SymbolDigraph.java",
    "chars": 7658,
    "preview": "/******************************************************************************\n *  Compilation:  javac SymbolDigraph.ja"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/SymbolGraph.java",
    "chars": 8664,
    "preview": "/******************************************************************************\n *  Compilation:  javac SymbolGraph.java"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/TST.java",
    "chars": 11978,
    "preview": "/******************************************************************************\n *  Compilation:  javac TST.java\n *  Exe"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/TarjanSCC.java",
    "chars": 7641,
    "preview": "/******************************************************************************\n *  Compilation:  javac TarjanSCC.java\n "
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/ThreeSum.java",
    "chars": 4702,
    "preview": "/******************************************************************************\n *  Compilation:  javac ThreeSum.java\n *"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/ThreeSumFast.java",
    "chars": 5378,
    "preview": "/******************************************************************************\n *  Compilation:  javac ThreeSumFast.jav"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/TopM.java",
    "chars": 3721,
    "preview": "/******************************************************************************\n *  Compilation:  javac TopM.java\n *  Ex"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/Topological.java",
    "chars": 6766,
    "preview": "/******************************************************************************\n *  Compilation:  javac Topological.java"
  },
  {
    "path": "src/main/java/edu/princeton/cs/algs4/TopologicalX.java",
    "chars": 11717,
    "preview": "/******************************************************************************\n *  Compilation:  javac TopologicalX.jav"
  }
]

// ... and 8 more files (download for full content)

About this extraction

This page contains the full source code of the kevin-wayne/algs4 GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 208 files (2.0 MB), approximately 517.5k tokens, and a symbol index with 2767 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!