-
-
Notifications
You must be signed in to change notification settings - Fork 775
Added Queues directory and queue.md #223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d00d9ac
Added Queues directory and queue.md
Surani02 7d57b25
Added Queues directory and queue.md
Surani02 8be599c
Added Queues directory and queue.md
Surani02 0384321
Added Queues directory and queue.md
Surani02 79c8256
Added comments to the AnimatedButtons.html
Surani02 3612da8
Added Queues directory and queue.md
Surani02 fb2efc7
Added video explanation link to Kadane's Algorithm.md
Surani02 14cccbe
Added video explanation link to Kadane's Algorithm.md
Surani02 acc2a49
Merge branch 'master' into new-branch
appgurueu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Queue | ||
|
||
## Description: | ||
Surani02 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
A queue is a linear data structure that follows the First-In-First-Out (FIFO) principle. It is often compared to a real-world queue of people waiting in line. The element that is added first is the one that gets removed first. Queues are commonly used for various applications, such as task scheduling, managing requests, and more. | ||
|
||
### Time Complexity: | ||
Surani02 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Enqueue (Insertion): O(1) | ||
Surani02 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Dequeue (Removal): O(1) | ||
Peek (Accessing the front element): O(1) | ||
|
||
### Space Complexity: | ||
O(n), where n is the number of elements in the queue. | ||
|
||
## Applications: | ||
1) Task scheduling | ||
2) Print job management | ||
3) Breadth-first search (BFS) in graph algorithms | ||
4) Simulating real-world scenarios | ||
Surani02 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
5) Handling requests in a web server | ||
|
||
## Queue Operations: | ||
|
||
1) Initialize a Queue: | ||
- Create an empty queue data structure. You can implement a queue using an array, linked list, or other data structures, depending on your specific requirements. | ||
Surani02 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
2) Enqueue (Insertion): | ||
- To add an element to the queue, insert it at the rear (end) of the queue. | ||
Surani02 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
-Increment the rear pointer to point to the newly added element. | ||
Surani02 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
-Ensure the queue remains in the correct order, following the FIFO principle. | ||
Surani02 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
3) Dequeue (Removal): | ||
- To remove an element from the queue, take it from the front. | ||
Surani02 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Increment the front pointer to point to the next element in the queue. | ||
- Make sure to handle the case when the queue becomes empty. | ||
4) Peek (Accessing the Front Element): | ||
- To access the element at the front of the queue without removing it, simply refer to the front element. | ||
- This is useful for checking what's at the front of the queue without altering its contents. | ||
5) Check if Queue is Empty: | ||
Surani02 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- You can determine if the queue is empty by comparing the front and rear pointers. If they are equal, the queue is empty. | ||
6) Check if Queue is Full (if using a fixed-size array): | ||
- In cases where a fixed-size array is used to implement a queue, check if the rear pointer has reached the maximum size of the array to determine if the queue is full. | ||
|
||
## Sourse: | ||
- [Queue Data Structure](https://www.geeksforgeeks.org/queue-data-structure/) | ||
## Video URL: | ||
- [Queue in Data Structure](https://www.youtube.com/watch?v=zp6pBNbUB2U) | ||
- [Implementation of Queue using Arrays](https://www.youtube.com/watch?v=YqrFeU90Coo) | ||
- [Queue Implementation using Linked List in C](https://www.youtube.com/watch?v=RN1wzY_tnYU) | ||
|
||
## Others: | ||
Surani02 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Queues can be implemented using arrays, linked lists, or specialized queue data structures depending on the specific requirements. They are crucial in scenarios where tasks or data need to be processed in a specific order, ensuring fairness and proper management. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.