dsa_kit 0.0.4 copy "dsa_kit: ^0.0.4" to clipboard
dsa_kit: ^0.0.4 copied to clipboard

A scalable DSA utilities kit for Dart. Includes Heaps, DeQueues, and more.

dsa_kit #

Pub Version License: MIT Dart

A scalable Data Structures & Algorithms toolkit for Dart, designed to make competitive programming, interview preparation, and algorithmic problem-solving more accessible in the Dart ecosystem.

๐ŸŽฏ Why dsa_kit? #

Coming from Python or Java, you might miss the convenience of heapq or Collections.PriorityQueue. Dart's core libraries are excellent, but they don't include specialized data structures that are essential for algorithmic problem-solving.

dsa_kit bridges this gap by providing:

  • ๐Ÿ—๏ธ Production-ready implementations following SOLID principles
  • ๐Ÿงช Thoroughly tested components with comprehensive test coverage
  • ๐Ÿ“š Learning-friendly code with clear documentation and examples
  • โšก Performance-optimized algorithms suitable for competitive programming
  • ๐ŸŽ“ Interview-ready utilities that you can confidently use and explain

๐Ÿš€ Quick Start #

Add dsa_kit to your pubspec.yaml:

dependencies:
  dsa_kit: ^0.0.1

Run:

dart pub get

๐Ÿ“– Usage #

Heaps #

Perfect for priority queues, finding k-th largest/smallest elements, and heap sort implementations.

import 'package:dsa_kit/dsa_kit.dart';

void main() {
  // Min Heap - smallest element first
  var minHeap = MinHeap<int>();
  minHeap.push(10);
  minHeap.push(5);
  minHeap.push(15);
  
  print(minHeap.peek()); // Output: 5
  print(minHeap.pop());  // Output: 5
  
  // Max Heap - largest element first  
  var maxHeap = MaxHeap<String>();
  maxHeap.push("apple");
  maxHeap.push("zebra");
  maxHeap.push("banana");
  
  print(maxHeap.peek()); // Output: zebra
  print(maxHeap.pop());  // Output: zebra
  
  // Works with custom objects too!
  var taskHeap = MinHeap<Task>();
  taskHeap.push(Task("Low priority", 3));
  taskHeap.push(Task("High priority", 1));
  taskHeap.push(Task("Medium priority", 2));
  
  while (!taskHeap.isEmpty) {
    print(taskHeap.pop().name); // Outputs in priority order
  }
}

Deque #

Efficient for adding/removing elements from both ends. Perfect for sliding windows, BFS/DFS, and scheduling tasks.

import 'package:dsa_kit/dsa_kit.dart';

void main() {
  final deque = Deque<int>();

  // Append values to the right (end)
  deque.appendRight(1);
  deque.appendRight(2);
  deque.appendRight(3);
  print(deque.prettyPrint()); // Output: [1, 2, 3]

  // Append values to the left (front)
  deque.appendLeft(0);
  deque.appendLeft(-1);
  print(deque.prettyPrint()); // Output: [-1, 0, 1, 2, 3]

  // Peek values without removing
  print(deque.peekLeft());   // Output: -1
  print(deque.peekRight());  // Output: 3

  // Pop values from both ends
  print(deque.popLeft());   // Output: -1
  print(deque.popRight());  // Output: 3
  print(deque.prettyPrint()); // Output: [0, 1, 2]

  // Clear the deque
  deque.clear();
  print(deque.prettyPrint()); // Output: []
}

๐Ÿงช Testing #

Run tests:

dart test

๐Ÿ“‹ Planned Features:

  • Trie - For string searching and prefix operations
  • Union-Find (Disjoint Set) - For dynamic connectivity problems
  • Graph Utilities - BFS, DFS, shortest path algorithms
  • Segment Trees - For range queries and updates
  • Dynamic Programming Helpers - Memoization utilities and common DP patterns
  • Advanced Trees - AVL, Red-Black trees
  • String Algorithms - KMP, Rabin-Karp implementations

๐Ÿ“ Changelog #

See CHANGELOG.md for detailed version history.

๐Ÿ“„ License #

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ‘จโ€๐Ÿ’ป Author #

Vishwa Karthik
Software Engineer passionate about algorithms and clean code

  • ๐ŸŒ Domain: in.vishwakarthik
  • ๐Ÿ“ฆ Package: dsa_kit

0
likes
140
points
329
downloads

Publisher

verified publishervishwakarthik.in

Weekly Downloads

A scalable DSA utilities kit for Dart. Includes Heaps, DeQueues, and more.

Repository (GitHub)
View/report issues

Topics

#dsa-kit #built-in-methods

Documentation

API reference

License

MIT (license)

More

Packages that depend on dsa_kit