Skip to content

landerrosette/algs4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

This repository contains C++ implementations of the algorithms and clients in the textbook Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

For the original Java source code, visit the official repository.

Algorithms

Fundamentals

Sorting

Symbol Tables

Graphs

Strings

Clients

Fundamentals

Sorting

Symbol Tables

  • Symbol table tests (TestSequentialSearchST, TestBinarySearchST, TestBST, TestRedBlackBST, TestSeparateChainingHashST, TestLinearProbingHashST): main_TestST.cpp.in

Graphs

Strings

Build and Run

  1. Configure the project in the build directory:

    cmake -B build
  2. Build all clients:

    cmake --build build

    Alternatively, you can build only a specific client (e.g., the "Union-find" client):

    cmake --build build --target UF
  3. (Optional) Download sample input files from the book's website: https://algs4.cs.princeton.edu/code/.

  4. From the build directory, run the client. You may redirect the input from a file (possibly one obtained in step 3):

    ./UF < tinyUF.txt

    You may also pipe the output of one client to the input of another:

    ./Huffman - < abra.txt | ./Huffman +

    Some clients expect command-line arguments:

    ./DepthFirstPaths tinyCG.txt 0

    This will run depth-first search on the graph in tinyCG.txt starting from vertex 0.

About

Algorithms, 4th edition textbook code in C++

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published