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?? DS data-structures linked-list time-complexity queue + – sushmita asked Sep 20, 2018 sushmita 1.2k views answer comment Share Follow See all 12 Comments See all 12 12 Comments reply Show 9 previous comments MiNiPanda commented Oct 22, 2018 reply Follow Share 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 votes 0 votes Shaik Masthan commented Oct 22, 2018 reply Follow Share my view is the answer provided by rahul sharma 5 0 votes 0 votes MiNiPanda commented Oct 22, 2018 i edited by MiNiPanda Oct 22, 2018 reply Follow Share 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 votes 1 votes Please log in or register to add a comment.
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). phaneendrababu answered Sep 20, 2018 phaneendrababu comment Share Follow See all 4 Comments See all 4 4 Comments reply sushmita commented Sep 20, 2018 reply Follow Share 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 votes 0 votes phaneendrababu commented Sep 20, 2018 reply Follow Share Yes,we can also do like that. 0 votes 0 votes Mayankprakash commented Sep 20, 2018 reply Follow Share @sushmita What is the final answer? 0 votes 0 votes sushmita commented Sep 21, 2018 reply Follow Share I DON'T KNOW. THAT'S WHY I HAVE POSTED HERE. 0 votes 0 votes Please log in or register to add a comment.