All Algorithms implemented in Dart

Overview

The Algorithms - Dart

Build Status Donate   Gitter chat  

All algorithms implemented in Dart (for education)

These implementations are for learning purposes. They may be less efficient than the implementations in the Dart standard library.

List of Algorithms

See our directory for full list of all algorithms. A few of the algorithms (the most common ones) are explained here.

Search Algorithms

Linear

alt text

From Wikipedia: linear search or sequential search is a method for finding a target value within a list. It sequentially checks each element of the list for the target value until a match is found or until all the elements have been searched. Linear search runs in at the worst linear time and makes at most n comparisons, where n is the length of the list.

Properties

  • Worst case performance O(n)
  • Best case performance O(1)
  • Average case performance O(n)
  • Worst case space complexity O(1) iterative

Binary

alt text

From Wikipedia: Binary search, also known as half-interval search or logarithmic search, is a search algorithm that finds the position of a target value within a sorted array. It compares the target value to the middle element of the array; if they are unequal, the half in which the target cannot lie is eliminated and the search continues on the remaining half until it is successful.

Properties

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

Sort Algorithms

Bubble

alt text

From Wikipedia: Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the list to be sorted, compares each pair of adjacent items and swaps them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted.

Properties

  • Worst case performance O(n^2)
  • Best case performance O(n)
  • Average case performance O(n^2)
View the algorithm in action

Insertion

alt text

From Wikipedia: Insertion sort is a simple sorting algorithm that builds the final sorted array (or list) one item at a time. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort.

Properties

  • Worst case performance O(n^2)
  • Best case performance O(n)
  • Average case performance O(n^2)
View the algorithm in action

Quick

alt text

From Wikipedia: Quicksort (sometimes called partition-exchange sort) is an efficient sorting algorithm, serving as a systematic method for placing the elements of an array in order.

Properties

  • Worst case performance O(n^2)
  • Best case performance O(n log n) or O(n) with three-way partition
  • Average case performance O(n^2)
View the algorithm in action

Selection

alt text

From Wikipedia: The algorithm divides the input list into two parts: the sublist of items already sorted, which is built up from left to right at the front (left) of the list, and the sublist of items remaining to be sorted that occupy the rest of the list. Initially, the sorted sublist is empty and the unsorted sublist is the entire input list. The algorithm proceeds by finding the smallest (or largest, depending on sorting order) element in the unsorted sublist, exchanging (swapping) it with the leftmost unsorted element (putting it in sorted order), and moving the sublist boundaries one element to the right.

Properties

  • Worst case performance O(n^2)
  • Best case performance O(n^2)
  • Average case performance O(n^2)
View the algorithm in action

Merge

alt text

From Wikipedia: Merge sort (also commonly spelled mergesort) is a divide and conquer algorithm that was invented by John von Neumann in 1945. The algorithm dirst divides the list into the smallest unit (1 element), then compares each element with the adjacent list to sort and merge the two adjacent lists. Finally all the elements are sorted and merged. It is an efficient, general-purpose, comparison-based sorting algorithm.

Properties

  • Worst case performance O(n log n)
  • Best case performance O(n log n)
  • Average case performance O(n log n)
View the algorithm in action

Shell

alt text

From Wikipedia: Shellsort is a generalization of insertion sort that allows the exchange of items that are far apart. The idea is to arrange the list of elements so that, starting anywhere, considering every nth element gives a sorted list. Such a list is said to be h-sorted. Equivalently, it can be thought of as h interleaved lists, each individually sorted.

Properties

  • Worst case performance O(nlog2 2n)
  • Best case performance O(n log n)
  • Average case performance depends on gap sequence
View the algorithm in action

Time-Complexity Graphs

Comparing the complexity of sorting algorithms (Bubble Sort, Insertion Sort, Selection Sort)

Complexity Graphs


Community Channel

We're on Gitter! Please join us.

Contribution

Please read our CONTRIBUTING.md.

License

MIT

Comments
  • Create power_of_two.dart

    Create power_of_two.dart

    This pull request is for HacktoberFest 2020 In this I have checked if a number is a power of 2 or not, without using logarithmic operations and by using bit manipulation.

    Welcome to Dart community

    Describe your change:

    • [ ] Add an algorithm?
    • [ ] Fix a bug or typo in an existing algorithm?
    • [ ] Documentation change?

    Checklist:

    • [ ] I have read CONTRIBUTING.md.
    • [ ] This pull request is all my own work -- I have not plagiarized.
    • [ ] I know that pull requests will not be merged if they fail the automated tests.
    • [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
    • [ ] All new Dart files are placed inside an existing directory.
    • [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
    • [ ] If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.
    hacktoberfest-accepted 
    opened by neha-hasija17 8
  • Linked list tests

    Linked list tests

    Welcome to Dart community

    I've changed github action to run all tests from all folders /.dart and subfolders //*.dart. I don't have ideas how to force dart to traverse whole directory tree.

    Also I've encountered some mirror bugs. Most of them is fixed, but I'll have to spend more time on remaining ones.

    Describe your change:

    • [ ] Add an algorithm?
    • [x] Fix a bug or typo in an existing algorithm?
    • [ ] Documentation change?

    Checklist:

    • [x] I have read CONTRIBUTING.md.
    • [x] This pull request is all my own work -- I have not plagiarized.
    • [x] I know that pull requests will not be merged if they fail the automated tests.
    • [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
    • [x] All new Dart files are placed inside an existing directory.
    • [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
    • [ ] If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.
    opened by Parowicz 8
  • Radix sort

    Radix sort

    how can write the bellow code in dart //js code let digitBuckets = Array.from({length: 10}, () => []); //dart code List digitBuckets = List.from({});//confused here

    //how can i write this: Array.from({length: 10}, () => []); //in dart List digitBuckets = ??

    opened by vipuluthaiah 7
  • Create peak_element.dart

    Create peak_element.dart

    This is a program to find the index of the peak element in a given array using binary search approach. A peak element is an element which is greater than both of its neighbors. This Pull Request is for HacktoberFest 2020

    Welcome to Dart community

    Describe your change:

    • [ ] Add an algorithm?
    • [ ] Fix a bug or typo in an existing algorithm?
    • [ ] Documentation change?

    Checklist:

    • [ ] I have read CONTRIBUTING.md.
    • [ ] This pull request is all my own work -- I have not plagiarized.
    • [ ] I know that pull requests will not be merged if they fail the automated tests.
    • [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
    • [ ] All new Dart files are placed inside an existing directory.
    • [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
    • [ ] If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.
    hacktoberfest-accepted tests are needed 
    opened by neha-hasija17 7
  • SimpleLinkedList

    SimpleLinkedList

    Welcome to Dart community

    Describe your change:

    Added in the very basic Singly LinkedList implementation in dart which should be easily understood by the beginners in dart

    • [ ] Add an algorithm?
    • [ ] Fix a bug or typo in an existing algorithm?
    • [ ] Documentation change?

    Checklist:

    • [x] I have read CONTRIBUTING.md.
    • [x] This pull request is all my own work -- I have not plagiarized.
    • [x] I know that pull requests will not be merged if they fail the automated tests.
    • [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
    • [x] All new Dart files are placed inside an existing directory.
    • [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
    • [ ] If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.
    tests are needed 
    opened by akashgkrishnan 7
  • Implementation of singly linked list in Dart

    Implementation of singly linked list in Dart

    Welcome to Dart community

    Describe your change:

    • [x] Add an algorithm?
    • [ ] Fix a bug or typo in an existing algorithm?
    • [ ] Documentation change?

    Checklist:

    • [x] I have read CONTRIBUTING.md.
    • [x] This pull request is all my own work -- I have not plagiarized.
    • [x] I know that pull requests will not be merged if they fail the automated tests.
    • [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
    • [x] All new Dart files are placed inside an existing directory.
    • [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
    • [ ] If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.
    opened by nandikajain 6
  • Create sphenic_number.dart

    Create sphenic_number.dart

    This Pull Request is for HacktoberFest 2020

    Welcome to Dart community

    Describe your change:

    • [ ] Add an algorithm?
    • [ ] Fix a bug or typo in an existing algorithm?
    • [ ] Documentation change?

    Checklist:

    • [ ] I have read CONTRIBUTING.md.
    • [ ] This pull request is all my own work -- I have not plagiarized.
    • [ ] I know that pull requests will not be merged if they fail the automated tests.
    • [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
    • [ ] All new Dart files are placed inside an existing directory.
    • [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
    • [ ] If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.
    hacktoberfest-accepted tests are needed 
    opened by neha-hasija17 6
  • Add GitHub Action dart-package-analyzer.yml

    Add GitHub Action dart-package-analyzer.yml

    @chimon2000 Your review, please?

    Output: https://github.com/TheAlgorithms/Dart/runs/1253813888

    Related to #86, #87, and #88

    Welcome to Dart community

    Describe your change:

    • [ ] Add an algorithm?
    • [ ] Fix a bug or typo in an existing algorithm?
    • [ ] Documentation change?

    Checklist:

    • [ ] I have read CONTRIBUTING.md.
    • [ ] This pull request is all my own work -- I have not plagiarized.
    • [ ] I know that pull requests will not be merged if they fail the automated tests.
    • [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
    • [ ] All new Dart files are placed inside an existing directory.
    • [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
    • [ ] If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.
    opened by cclauss 6
  • Gather code coverage

    Gather code coverage

    Welcome to Dart community

    @cclauss i've fixed your pull request according to #100 Right now I'm saving coverage in *.lcov format. You have ideas how to proceed?

    Describe your change:

    • [ ] Add an algorithm?
    • [ ] Fix a bug or typo in an existing algorithm?
    • [ ] Documentation change?

    Checklist:

    • [x] I have read CONTRIBUTING.md.
    • [x] This pull request is all my own work -- I have not plagiarized.
    • [x] I know that pull requests will not be merged if they fail the automated tests.
    • [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
    • [x] All new Dart files are placed inside an existing directory.
    • [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
    • [ ] If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.
    opened by Parowicz 5
  • Evaluate Boolean Expressions

    Evaluate Boolean Expressions

    This program is for the evaluation of the Boolean expression where a string consists of only 0, 1, A, B, C where A = AND B = OR C = XOR The evaluation is done from left to right. The length of string will be odd. It will always be a valid string. This pull request is for Hacktober Fest 2020.

    Welcome to Dart community

    Describe your change:

    • [ ] Add an algorithm?
    • [ ] Fix a bug or typo in an existing algorithm?
    • [ ] Documentation change?

    Checklist:

    • [ ] I have read CONTRIBUTING.md.
    • [ ] This pull request is all my own work -- I have not plagiarized.
    • [ ] I know that pull requests will not be merged if they fail the automated tests.
    • [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
    • [ ] All new Dart files are placed inside an existing directory.
    • [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
    • [ ] If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.
    hacktoberfest-accepted tests are needed 
    opened by RimjhimGupta 4
  • Create magic_number.dart

    Create magic_number.dart

    This Pull request is for HacktoberFest 2020

    Welcome to Dart community

    Describe your change:

    • [ ] Add an algorithm?
    • [ ] Fix a bug or typo in an existing algorithm?
    • [ ] Documentation change?

    Checklist:

    • [ ] I have read CONTRIBUTING.md.
    • [ ] This pull request is all my own work -- I have not plagiarized.
    • [ ] I know that pull requests will not be merged if they fail the automated tests.
    • [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
    • [ ] All new Dart files are placed inside an existing directory.
    • [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
    • [ ] If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.
    hacktoberfest-accepted 
    opened by neha-hasija17 4
  • dijkstra added

    dijkstra added

    Welcome to Dart community

    Describe your change:

    • [x] Add an algorithm?
    • [ ] Fix a bug or typo in an existing algorithm?
    • [ ] Documentation change?

    Checklist:

    • [x] I have read CONTRIBUTING.md.
    • [x] This pull request is all my own work -- I have not plagiarized.
    • [x] I know that pull requests will not be merged if they fail the automated tests.
    • [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
    • [x] All new Dart files are placed inside an existing directory.
    • [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
    • [ ] If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.
    opened by hzonuz 0
  • Fixes: 200

    Fixes: 200

    Welcome to Dart community

    Describe your change:

    • [ ] Add an algorithm?
    • [x] Fix a bug or typo in an existing algorithm?
    • [ ] Documentation change?

    Checklist:

    • [ ] I have read CONTRIBUTING.md.
    • [ ] This pull request is all my own work -- I have not plagiarized.
    • [ ] I know that pull requests will not be merged if they fail the automated tests.
    • [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
    • [ ] All new Dart files are placed inside an existing directory.
    • [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
    • [ ] If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.
    opened by skdotv 0
  • `Fixes: #196`

    `Fixes: #196`

    Welcome to Dart community

    Describe your change:

    • [ ] Add an algorithm?
    • [ ] Fix a bug or typo in an existing algorithm?
    • [ ] Documentation change?

    Checklist:

    • [ ] I have read CONTRIBUTING.md.
    • [ ] This pull request is all my own work -- I have not plagiarized.
    • [ ] I know that pull requests will not be merged if they fail the automated tests.
    • [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
    • [ ] All new Dart files are placed inside an existing directory.
    • [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
    • [ ] If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.
    opened by skdotv 0
  • Issue #194: fixed

    Issue #194: fixed

    Welcome to Dart community

    Describe your change:

    • [ ] Add an algorithm?
    • [x] Fix a bug or typo in an existing algorithm?
    • [ ] Documentation change?

    Checklist:

    • [ ] I have read CONTRIBUTING.md.
    • [ ] This pull request is all my own work -- I have not plagiarized.
    • [ ] I know that pull requests will not be merged if they fail the automated tests.
    • [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
    • [ ] All new Dart files are placed inside an existing directory.
    • [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
    • [ ] If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.
    opened by skdotv 0
Owner
The Algorithms
Open Source resource for learning Data Structures & Algorithms and their implementation in any Programming Language
The Algorithms
Algorithm Toolbox is an Android app for C++, Python and DART algorithms. It shows the codes as well as its explanation with various examples.

AlgoKing Algorithm Toolbox is an Android app for C++, Python and DART algorithms. It shows the codes as well as its explanation with various examples.

Hash Studios 5 Sep 13, 2022
Machine learning algorithms in Dart programming language

Machine learning algorithms for Dart developers What is the ml_algo for? The main purpose of the library is to give native Dart implementation of mach

Ilya Gyrdymov 134 Jan 4, 2023
A simple DLNA DMC library implemented by Dart.

DLNA-Dart A simple DLNA DMC library implemented by Dart. It is tiny and only the basic network video casting function is supported. Structure Flutter

Ning 68 Jan 4, 2023
A Flutter project that implemented getx package and firebase services.

Get X Firebase A Flutter Package that implemented firebase services with getx package. It's free, open source, complete, rapid development package for

Faisal Ramdan 19 Nov 26, 2022
A test for a position as a mobile engineer at the company Phi. (I did not participate in the selection process, I implemented the application for study purposes only)

Phi Bank Aplicativo desenvolvido baseado num teste para o cargo de desenvolvedor mobile na empresa Phi. (Não participei do processo seletivo, implemen

null 1 Dec 1, 2021
AuthPass - Password Manager based on Flutter for all platforms. Keepass 2.x (kdbx 3.x) compatible.

AuthPass.app - Open Source Password Manager for mobile and desktop AuthPass - Password Manager based on Flutter for all platforms. Keepass 2.x (kdbx 3

AuthPass 1.5k Jan 5, 2023
a project for learning all Flutter Widgets , sync from flutter.dev the officia website.

Flutter Widgets Catalog (WIP) 计划 1、使用Flutter开发一个全平台的Flutter Widgets Catalog APP,并且开源。在这个APP中可以通过图形化的方式查看所有Widgets的介绍,示例,视频教程。 2、所有文档内容由前一天从flutter.dev

ezshine 32 Aug 3, 2022
Simple and modern news app that incorporates REST API (newsapi.org), all built entirely with Flutter.

A simple news app with a minimalistic and clean UI that incorporates the newsapi.org api all built entirely with Flutter. Be sure to leave a star ??

Carlton Aikins 73 Dec 1, 2022
Build a generative, customized admin for all platforms. Nice to use and nice to extend.

flutter admin kit Build a generative, customized admin for all platforms. Nice to use and nice to extend. Feature highlights: Declarative routing via

smartnuance 31 Nov 26, 2022
A simple easy to use Flutter DApp , which keeps a track of all your day to day transactions by using Ethereum blockchain in the background which in turn increases your credit score.

Sahayog A simple easy to use Flutter DApp , which keeps a track of all your day to day transactions by using Ethereum blockchain in the background whi

Utkarsh Agarwal 15 May 21, 2022
A public repo that contains all the projects built in live coding events.

JEToP Live Coding A public repo that contains all the projects built in live coding events. Star this repo to not miss it. Built with ❤️ by JEToP's IT

JEToP - Junior Enterprise Torino Politecnico 13 Nov 30, 2022
Your grades across all your devices.

Gradely 2 A Grade Calculator App, that syncs all your Grades across all your devices, built with Flutter and with the amazing backend Appwrite. Screen

Elias Schneider 16 Dec 8, 2022
This is the graduation project and it's all about a mobile app to organize events.

eventy A new Flutter project. This is the Graduation Project i work with my team @aboonasser & @Tameem99 Getting Started This project is a starting po

mohammad alfayez 2 Dec 15, 2021
Latest and easy-to-read news, all in your pocket 📱

Observer-flutter About Flutter app for getting live news in different categories Tools used Inshorts News API v2 This API's documentation Get the App

null 3 Jul 13, 2022
'Efficacy' is a an Android app that keeps users updated on all events and happenings in and around the NITS campus. Note that the one in this repo is a slightly altered version of the original.

Efficacy : The proposed Android app for all clubs, events and happenings at NIT Silchar Get the release APK Some interesting features of this app incl

Gaurav Bhattacharjee 2 Aug 29, 2021
The Quack Project on every Emory student phone, organizing the calendars of users & eliminating all frustrations with on-campus dining.

Bestagons Micro-Charter Code Name: Quack Mission Statement: Bestagons are a 6-person team dedicated to developing the experience and skills necessary

null 4 Dec 20, 2021
The ultimate baby monitor! This mobile app helps new parents keep track of all their newborn baby's needs, milestones, and reminders in one place!

New Parent The ultimate baby monitor! This mobile app helps new parents keep track of all their newborn baby's needs, milestones, and reminders in one

ACM Projects 6 Jun 22, 2022
DoneIt is a sample note app 📝 Flutter application 📱 built to demonstrate use of Clean Architecture tools. Dedicated to all Flutter Developers with ❤️.

DoneIt ?? DoneIt is a sample note app ?? Flutter application ?? built to demonstrate use of Clean Architecture tools. Dedicated to all Flutter Develop

Shubham Chhimpa 175 Dec 24, 2022