GATE CSE
First time here? Checkout the FAQ!
x
+4 votes
135 views

A queue is a particular kind of abstract data type. Enqueue and Dequeue makes the queue FIFO data structure. There are several efficient implementations of FIFO queues. An efficient implementation is one which can perform the operations of enququeing and dequeueing in O(1) time. The best choice is :

a] DLL                                    c] SLL

b] Dynamic Array                    d] any one of these

asked in Programming by Boss (6.5k points)  
edited by | 135 views

2 Answers

+4 votes
Best answer
The properties which are required are as follows :

a) Since queue length is not fixed , hence we can use either of the three mentioned data structures for our purpose

b) Also it is required that enqueue and dequeue operations are to be done in O(1) time.This can also be done for all.For linked list , we can maintain two pointers  one pointing to front element from where dequeue will take place and the other pointing to rear element for enqueue operation.Hence just by making a few change of pointers , we are able to enqueue an dequeue using single and double linked list.Also can be done using dynamic array by maintaining index of front and rear elements of the queue.

 

Hence D) should be the correct option.
answered by Veteran (66.3k points)  
edited by
+2 votes

Any one can be used if use two or more pointer in case od single and double pointer..Dynamic array take constant time to detele and insert .

 

answered by Veteran (47.3k points)  
edited by
Plz check my answer.
Got it habib..
i forget to take two pointer.

Related questions



Top Users May 2017
  1. akash.dinkar12

    3548 Points

  2. pawan kumarln

    2126 Points

  3. Bikram

    1922 Points

  4. sh!va

    1682 Points

  5. Arjun

    1622 Points

  6. Devshree Dubey

    1272 Points

  7. Debashish Deka

    1270 Points

  8. Angkit

    1056 Points

  9. LeenSharma

    1028 Points

  10. Arnab Bhadra

    812 Points

Monthly Topper: Rs. 500 gift card
Top Users 2017 May 22 - 28
  1. Bikram

    1008 Points

  2. pawan kumarln

    752 Points

  3. Arnab Bhadra

    726 Points

  4. akash.dinkar12

    428 Points

  5. Arjun

    350 Points


22,896 questions
29,206 answers
65,329 comments
27,708 users