Skip to content

Conversation

@alka-tripathi
Copy link

  1. add(int data)

Purpose: Add an element at the end of the queue.

Behavior:

If the queue is full (isOverflow() returns true), it prints a message and does not add the element.

Otherwise, increments rear and stores the new element in the array.

Time Complexity: O(1)

  1. remove()

Purpose: Remove the element from the front of the queue.

Behavior:

If the queue is empty (isEmpty() returns true), it prints a message and returns -1.

Otherwise, it removes the front element, shifts all remaining elements one step forward, and decrements rear.

Time Complexity: O(n) — due to shifting elements.

  1. peek()

Purpose: Get the element at the front of the queue without removing it.

Behavior:

If the queue is empty, prints a message and returns -1.

Otherwise, returns the first element of the array.

Time Complexity: O(1)

  1. isEmpty()

Purpose: Check whether the queue has any elements.

Behavior:

Returns true if rear == -1 (no elements in the queue), otherwise false.

Use Case: Helps prevent errors when removing or peeking from an empty queue.

  1. isOverflow()

Purpose: Check whether the queue is full.

Behavior:

Returns true if rear == size - 1 (no more space to add elements), otherwise false.

Use Case: Helps prevent adding elements beyond the array size.

#5959 #queue #165

@codecov-commenter
Copy link

codecov-commenter commented Oct 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.83%. Comparing base (6b7d201) to head (527f1f7).

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #6682   +/-   ##
=========================================
  Coverage     77.82%   77.83%           
  Complexity     6392     6392           
=========================================
  Files           732      732           
  Lines         21320    21320           
  Branches       4182     4182           
=========================================
+ Hits          16592    16594    +2     
+ Misses         4059     4058    -1     
+ Partials        669      668    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@DenizAltunkapan
Copy link
Member

@alka-tripathi Please fix the failing workflows so I can start the review.

@github-actions
Copy link

github-actions bot commented Nov 3, 2025

This pull request has been automatically closed because its workflows or checks failed and it has been inactive for more than 14 days. Please fix the workflows and reopen if you'd like to continue. Merging from main/master alone does not count as activity.

@github-actions github-actions bot closed this Nov 3, 2025
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.

3 participants