Library / SDK
TheAlgorithms/Dart avatar
TheAlgorithms/Dart

TheAlgorithms/Dart: a directory of teaching code rather than a dependency

All Algorithms implemented in Dart

2,156 stars486 forksDartMIT

At a glance

What is it?
TheAlgorithms/Dart gathers Dart implementations of classic algorithms for reading rather than for production use, and the tables show the difference: eight algorithms get full complexity rows, while shellsort's average case is answered in words.
Who is it for?
This is a reading collection, not a dependency, and it holds to that framing. Use it when you are learning an algorithm in Dart or want a second implementation to compare against your own.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 117 days ago.
What is it written in?
Mainly Dart, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 23, 2026, and from our analysis. They are not legal advice.

Editorial analysis

Thirteen algorithm folders and no usage guide

The repository description is one line, all algorithms implemented in Dart, and the root of the tree matches it literally. Thirteen directories hold code: `array/`, `backtracking/`, `conversions/`, `data_structures/`, `dynamic_programming/`, `graphs/`, `maths/`, `other/`, `project_euler/`, `search/`, `sort/`, `strings/` and `trees/`. Everything else at the root is project plumbing, among them `CONTRIBUTING.md`, `DIRECTORY.md`, `analysis_options.yaml`, `dart_test.yaml`, `pubspec.yaml` and `tests/`. The README frames all of it as teaching material, opening with all algorithms implemented in Dart (for education) and warning that the implementations may be less efficient than the ones in the Dart standard library. Topics carry algorithms, dart, data-structures and hacktoberfest, and hacktoberfest is a contributions event, so the growth channel the project names for itself is contributor submissions. No homepage is configured for the project. The repository is MIT licensed.

No install command exists, so you copy one file

The README has no installation section. There is no dependency line to paste into `pubspec.yaml`, no Dart SDK version to match, and not one import example for any of the thirteen algorithm folders, so the documented route to the code is the repository itself on the master branch. What the page offers as a starting point is `DIRECTORY.md`, which it names as the full list of all algorithms, and the four tooling files that sit beside the algorithm folders:

yaml
analysis_options.yaml
dart_test.yaml
pubspec.yaml
tests/

Those four entries carry no source code, and the README attaches no command to them. If you expected the package manifest to pull something in for you, nothing on the page says that happens. The practical route is therefore short: pick a category, open the file inside it, read it, and copy what you need into a project of your own.

The README explains eight algorithms and defers the rest

Eight algorithms get a full treatment. Linear and binary search sit under Search Algorithms, then bubble, insertion, quick, selection, merge and shell under Sort Algorithms. Each one carries a Properties block listing worst case, best case and average case performance, and the two searches add a worst case space complexity row. Linear search is the only entry whose space figure is qualified, written as O(1) iterative, while binary search records a bare O(1) for the same row. Every sort entry links out to a toptal.com page introduced as View the algorithm in action, and each definition is attributed to a Wikipedia page, down to the merge sort paragraph that credits John von Neumann and the year 1945 for a divide and conquer algorithm. That same paragraph drops a letter while describing the first step, printing the algorithm as it `dirst` divides the list into single elements. Only one chart exists, under Time-Complexity Graphs, and it compares Bubble Sort, Selection Sort and Insertion Sort, the three entries whose average case reads O(n^2), which leaves quicksort, merge sort and shellsort described in prose and never drawn.

Search routines split on whether the input is sorted

The two search entries differ on one condition, and it decides how you may call them. Linear search walks a list element by element, checking each entry for the target until a match or the end of the list, which puts it at most n comparisons, worst O(n), best O(1), average O(n). Binary search compares the target with the middle element, discards the half the target cannot sit in, and repeats on what is left. That discard is only legal because the binary search entry places the target within a sorted array, so the sorting step belongs to the caller, and nothing in the two entries connects them. Binary search reports worst O(log n), best O(1), average O(log n), and its four properties rows read:

code
Worst case performance    O(log n)
Best case performance    O(1)
Average case performance    O(log n)
Worst case space complexity    O(1)

Both entries declare O(1) space for an iterative implementation, so neither reserves memory for the search. What the page never states is what either routine returns when nothing matches, and no failure case is documented for an unsorted list handed to binary search.

Shellsort is the only sort with no average case number

One row in the sort tables is a sentence where every other row is a bound. Shellsort's three rows read `Worst case performance O(nlog2 2n)`, `Best case performance O(n log n)` and `Average case performance depends on gap sequence`. No other sort behaves that way. Bubble gives O(n^2) worst, O(n) best and O(n^2) average. Insertion repeats those same three values. Selection is O(n^2) in all three positions, merge sort is O(n log n) in all three, and quicksort lists O(n^2) for both worst and average. Shell alone answers its average row with depends on gap sequence, and alone writes its worst row as O(nlog2 2n), spelling the exponent inline rather than raising it. A reader chasing performance advice has to know that the gap sequence drives the shell result, and this table declines to say which sequence the Dart file uses. What the page offers is a transcription of published complexity classes, and the transcription is uneven.

Quicksort claims O(n) in a case the root listing never shows

Quicksort carries the only variant mention in the whole Properties set. Its best case row reads O(n log n) or O(n) with three-way partition, which is a claim about one implementation rather than about quicksort in general. Nothing at the repository root names a three-way partition file, the top level stops at `sort/` without further detail, and the only quicksort references in the README are the Wikipedia page and the toptal.com animation. The fastest number on the sheet therefore points at a variant a reader cannot locate without opening files one at a time. The rest of the entry is pessimistic, O(n^2) worst case and O(n^2) average case, which puts quicksort's typical cost on this page at the same level as bubble sort, even though its best case is listed as O(n log n). Read that row as a note about what a Dart implementation might do, not as a measurement of any file inside `sort/`.

Dart config files sit beside a Travis CI badge

Alongside the algorithm folders the tree carries the files a Dart project normally needs: `analysis_options.yaml` for analyzer settings, `dart_test.yaml` for the test runner configuration, `tests/` for the test files and `pubspec.yaml` for the package manifest. What the README does not add is a statement about how any of it runs in automation, and the only build signal in the file is a Travis CI badge aimed at the master branch, `travis-ci.com/TheAlgorithms/Dart.svg?branch=master`. No test command appears anywhere on the page, and no provider other than that badge is named. Community channels are wired the same way, through a donation badge at `www.paypal.me/TheAlgorithms/100`, a Discord invite at `the-algorithms.com/discord/` and a Gitter room at `gitter.im/#TheAlgorithms_community:gitter.im`. The last push was on 2026-06-28, on the default branch called master.

The collection admits it can lose to the standard library

The strongest limitation is admitted outright by the README. The page says these implementations are for learning purposes and may be less efficient than the implementations in the Dart standard library, and nothing later in the file takes that back. The real alternative for any hot path is therefore the standard library, and the difference in approach is plain: the library ships behaviour as maintained runtime code, while this repository ships readable source with a printed complexity class and no measurement behind it. The root listing has no benchmark directory and no profiling harness, so the gap between O(n log n) on paper and real elapsed time stays unquantified for every individual file. Two further costs follow from the layout. Since no dependency line and no version to pin appear anywhere on the page, anything copied out of `sort/` or `search/` becomes code the copying project owns and must maintain, and no upstream change reaches it. Coverage also looks uneven from outside the page: eight algorithms carry explanations, and the other folders are visible only through `DIRECTORY.md`.

Editorial conclusion

This is a reading collection, not a dependency, and it holds to that framing. Use it when you are learning an algorithm in Dart or want a second implementation to compare against your own. Leave it out of any hot path, because the README itself says the code may be less efficient than the Dart standard library, and no file in the tree carries measurements. Before copying a folder, check that the algorithm fits your input size, confirm your data really is sorted before calling binary search, and read the complexity row inside the file rather than trusting the README table.

Frequently asked questions

Can I add TheAlgorithms/Dart to my pubspec.yaml as a dependency?

The README has no installation section, no dependency line and no package name to copy. The repository root does carry a pubspec.yaml beside the algorithm folders, so the documented route is to open the file you need inside the folder you need and copy the code.

Which algorithms does TheAlgorithms/Dart explain, and where is the rest?

Eight get full entries with a Properties block: linear search and binary search, then bubble, insertion, quick, selection, merge and shell sort. The README points to DIRECTORY.md for the full list, which also sits at the repository root.

Why does TheAlgorithms/Dart say its code may be slower than the Dart standard library?

Because the README states that the implementations are for learning purposes and may be less efficient than the implementations in the Dart standard library. That is the only reason the page gives, and the README does not print any measurement that would size the gap.

Does TheAlgorithms/Dart run its tests on every push?

The tree contains dart_test.yaml and a tests/ folder, which is where Dart projects keep test configuration and test files, but the README names no test command and no provider beyond a Travis CI badge aimed at the master branch. The last push on the default branch was on 2026-06-28.

Is the quicksort in TheAlgorithms/Dart the three-way variant?

Its best case row reads O(n log n) or O(n) with three-way partition, but nothing at the repository root names a three-way partition file. The README links the Wikipedia page and a toptal.com animation for quick sort, so open the file in sort/ before relying on that row.

Official sources

  1. Issues
  2. License: MIT
  3. README
  4. TheAlgorithms/Dart on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/thealgorithms-dart.svg)](https://hysenlabs.com/projects/thealgorithms-dart)

Was this useful?