in DS
1,198 views
0 votes
0 votes
WHAT IS THE TIME COMPLEXITY TO ENQUEUE AN ELEMENT IF THE QUEUE IS IMPLEMENTED AS A CIRCULAR QUEUE AND WE HAVE GOT ONLY ONE POINTER TO FRONT ELEMENT??
in DS
1.2k views

4 Comments

As per my knowledge, we can't answer O(1)

@Shaik then what is your view on this https://gateoverflow.in/3654/gate2004-it-13?

0
0

my view is the answer provided by rahul sharma 5

0
0
edited by
Okay.. O(n) is when we are taking care of all practical issues. Here nothing of that sort is mentioned so I think theoritically O(1) should be considered otherwise O(n) would be very trivial. But then I respect your opinion :)
1
1

1 Answer

0 votes
0 votes
As we have only one pointer which points to FRONT the time complexity is O(n). If we have a REAR pointer the time complexity is O(1).

4 Comments

no we can also do with front with O(1).

A->B->C->D->E->A is our circular linked list and front points to A.

Now if we want to add F, copy F to A and now insert A between F and B.

our linked list will become-

A->B->C->D->E->F->A
0
0
Yes,we can also do like that.
0
0
@sushmita

What is the final answer?
0
0
I DON'T KNOW. THAT'S WHY I HAVE POSTED HERE.
0
0

Related questions