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

A scalable DSA utilities kit for Dart. Includes MinHeap, MaxHeap, 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
  }
}

class Task implements Comparable<Task> {
  final String name;
  final int priority;
  
  Task(this.name, this.priority);
  
  @override
  int compareTo(Task other) => priority.compareTo(other.priority);
}

Common Use Cases #

Finding K Largest Elements:

List<int> findKLargest(List<int> nums, int k) {
  var minHeap = MinHeap<int>();
  
  for (var num in nums) {
    minHeap.push(num);
    if (minHeap.length > k) {
      minHeap.pop();
    }
  }
  
  return minHeap.toList();
}

๐Ÿ—๏ธ Architecture #

The package follows SOLID principles with a clean, extensible architecture:

lib/
โ”œโ”€โ”€ dsa_kit.dart           // Main export file
โ””โ”€โ”€ heaps/
    โ”œโ”€โ”€ heap_base.dart     // Abstract base class
    โ”œโ”€โ”€ min_heap.dart      // Concrete MinHeap implementation
    โ””โ”€โ”€ max_heap.dart      // Concrete MaxHeap implementation

All data structures implement intuitive interfaces and are designed for easy extension and modification.

๐Ÿงช 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
0
points
329
downloads

Publisher

verified publishervishwakarthik.in

Weekly Downloads

A scalable DSA utilities kit for Dart. Includes MinHeap, MaxHeap, and more.

Repository (GitHub)
View/report issues

Topics

#dsa #built-in-methods

License

unknown (license)

More

Packages that depend on dsa_kit