Skip to content

Conversation

@saishmungase
Copy link

Description

This PR adds an implementation of a FIFO Queue data structure using two LIFO Stacks, as requested in the data_structures README (High Priority).

  • File Added: Python/data_structures/queue/queue_using_stacks.py
  • Functionality: Implements enqueue, dequeue, peek, is_empty, size using two internal lists (_in_stack, _out_stack) to simulate FIFO behavior.
  • Follows FIFO principle with amortized O(1) dequeue/peek.

Algorithm Description (Included in code comments)

Elements are enqueued onto _in_stack. Dequeue/peek operations transfer elements from _in_stack to _out_stack (reversing them) only when _out_stack is empty, then operate on _out_stack.

Complexity Analysis (Included in code comments)

  • Time Complexity:
    • Enqueue: O(1)
    • Dequeue: O(1) amortized
    • Peek: O(1) amortized
  • Space Complexity: O(n)

Checklist

  • Code follows the project's contributing guidelines (folder structure, naming).
  • Code includes data structure description comment.
  • Code includes time and space complexity analysis.
  • Code is tested (includes doctests).
  • Commit message follows the specified format.
  • This PR adds one specific data structure implementation.

…on list- Time Complexity: Enqueue O(1) avg, Dequeue O(n)- Space Complexity: O(n)
…stacks- Time Complexity: Enqueue O(1), Dequeue O(1) amortized- Space Complexity: O(n)
@github-actions
Copy link

🎉 Welcome to Hacktoberfest 2025, @saishmungase! 🎃

Thank you for your first contribution to our DSA repository! Here's what happens next:

🔍 Automatic Checks

  • Code Validation: Passed
  • 🧪 Compilation Tests: Passed

📋 Next Steps

🎯 Great job! Your code compiled successfully. Maintainers @Karanjot786 and @Pradeepsingh61 will review your PR soon.

🎁 What You Get

  • 🏆 Hacktoberfest Credit: This PR counts toward your 6 PR goal for exclusive T-shirt + Tree!
  • 🌟 Hall of Fame: You'll be featured in our contributors list
  • 📚 Learning: Code review feedback from experienced developers

💡 Tips for Success

  • Follow our Contributing Guidelines
  • Add comments explaining your algorithm
  • Include time/space complexity analysis
  • Test your code before submitting

Welcome to the community! 🚀

@github-actions github-actions bot requested a review from Karanjot786 October 27, 2025 15:35
@github-actions
Copy link

🤖 Automated PR Status

🔍 Code Validation

Passed - File naming and structure look good!

🧪 Compilation Tests

Passed - All code compiles successfully!

📋 Overall Status

🎉 Ready for Review - Your PR has passed all automated checks!
👥 Maintainers have been notified for review.


This comment was generated automatically. Checks will re-run when you push new commits.

@saishmungase
Copy link
Author

Hey @Pradeepsingh61 , @Karanjot786 Can You Please check this PR ?

@saishmungase saishmungase closed this by deleting the head repository Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant