Skip to content

Conversation

@Brijesh03032001
Copy link
Contributor

@Brijesh03032001 Brijesh03032001 commented Oct 26, 2025

📚 Add Comprehensive Queue Data Structure Implementation

🎃 Hacktoberfest 2025 Contribution - Queue Data Structure

🚀 Summary

This PR introduces a comprehensive Queue data structure implementation in R, contributing valuable educational content to TheAlgorithms/R repository with focus on pure data structure concepts.

📁 What's Added

  • /data_structures/Queue/ - New organized folder structure
  • queue_operations.r - Complete Queue implementation (290+ lines)
  • Updated DIRECTORY.md - Proper documentation linking

✨ Key Features

🔧 Queue Operations (queue_operations.r)

  • Core Operations: enqueue(), dequeue(), front(), rear(), size(), isEmpty()
  • Advanced Features: Bounded queues, overflow/underflow protection
  • Bonus Implementation: Priority Queue with custom priorities
  • Error Handling: Comprehensive edge case management
  • Interactive Demo: Step-by-step operation demonstrations
  • Educational Examples: Clear FIFO principle demonstrations

🎯 Priority Queue Implementation

  • Custom Priority Support: Elements ordered by priority values
  • Flexible Comparison: Supports both numeric and custom comparisons
  • Real-world Applications: Task scheduling, event management
  • Complete Interface: All standard queue operations with priority handling

🧠 Educational Impact

  • Beginner-Friendly: Clear documentation and examples
  • Data Structure Focus: Pure implementation without problem-solving complexity
  • Algorithm Understanding: Demonstrates FIFO principles clearly
  • Best Practices: Proper R coding standards and error handling
  • Comprehensive Coverage: Both basic Queue and Priority Queue variants

🔍 Code Quality

  • Lint-Free: No R linting warnings
  • Tested: All functions verified with example outputs
  • Documented: Comprehensive comments and explanations
  • Modular: Clean separation of concerns
  • Standards: Follows repository naming conventions

🎮 Demo Output

# Queue Operations Demo
Queue initialized with max size: unlimited
Enqueued: Task A | Size: 1
Enqueued: Task B | Size: 2
Enqueued: Task C | Size: 3
Queue: [ Task A <- Task B <- Task C ] (front <- rear)
Dequeued: Task A | Size: 2
Front element: Task B
Rear element: Task C

# Priority Queue Demo
Priority Queue initialized
Adding: (Emergency, priority: 1)
Adding: (Normal, priority: 5)
Adding: (Urgent, priority: 2)
Dequeue order: EmergencyUrgentNormal

🏗️ Architecture

  • Reference Classes: Proper OOP implementation in R
  • Memory Efficient: Smart memory management for large queues
  • Extensible: Easy to add more Queue variants
  • Clean Interface: Intuitive method names and consistent behavior

🎓 Learning Outcomes

Students and developers will learn:

  • Queue ADT: Complete understanding of FIFO data structure
  • Priority Queues: Advanced queue concepts with ordering
  • Data Structure Design: Proper implementation patterns in R
  • R Programming: Advanced R concepts and best practices
  • Algorithm Complexity: Understanding O(1) operations

🌟 Hacktoberfest Spirit

This contribution embodies Hacktoberfest values:

  • Quality: Well-tested, documented, and educational code
  • Community: Helps R developers learn data structures
  • Growth: Expands TheAlgorithms repository with valuable content
  • Accessibility: Clear examples for learners at all levels
  • Pure Focus: Educational data structure without problem-solving complexity

🚦 Testing Instructions

# Test Queue operations
Rscript data_structures/Queue/queue_operations.r

📊 Complexity Analysis

  • Enqueue: O(1) - Adding element to rear
  • Dequeue: O(1) - Removing element from front
  • Front/Rear: O(1) - Accessing elements
  • Size/isEmpty: O(1) - Status checking
  • Priority Queue: O(n) for insertion (maintains order)

🎯 Applications Covered

  • CPU Scheduling: Process management queues
  • Print Queues: Document processing order
  • Buffer Management: Data stream handling
  • Level Order Traversal: Tree algorithm foundation
  • Task Management: Priority-based job scheduling

🔄 Queue Variants Included

  1. Basic Queue: Standard FIFO implementation
  2. Bounded Queue: Size-limited with overflow protection
  3. Priority Queue: Element ordering by priority
  4. Interactive Examples: Step-by-step demonstrations

Ready for review! 🚀 This contribution adds significant educational value focusing purely on Queue data structure concepts. Perfect for Hacktoberfest 2025! 🎃

Related: Hacktoberfest 2025, Data Structures, Queue, FIFO, Priority Queue


📋 PR Checklist

  • Code follows repository standards
  • Comprehensive documentation included
  • All functions tested with examples
  • DIRECTORY.md updated appropriately
  • Focus on educational data structure implementation
  • No external dependencies required
  • Proper error handling implemented

- Add comprehensive Queue implementation with all operations (enqueue, dequeue, peek, etc.)
- Include Priority Queue implementation as bonus feature
- Add Rotten Oranges problem solution using BFS with Queue
- Implement step-by-step visualization for better understanding
- Update DIRECTORY.md with Queue section under Data Structures
- Include detailed problem statement, examples, and complexity analysis
- Remove rotten_oranges_bfs.r file (LeetCode Rotten Oranges problem)
- Update DIRECTORY.md to reflect pure Queue data structure only
- Keep only queue_operations.r with comprehensive Queue and PriorityQueue implementations
- Focus on educational data structure implementation without problem-solving examples
@Brijesh03032001 Brijesh03032001 changed the title feat: Add comprehensive Queue data structure with BFS application (Rotten Oranges) feat: Add comprehensive Queue data structure Oct 26, 2025
Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@siriak siriak merged commit ca2677f into TheAlgorithms:master Oct 26, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants