title: Doubly ended queue
body: <p>*Can an input restricted deque be implemented using a linear queue instead of a circular queue?</p>
  <p>Is this possibly (although not preferred)
  Please verify!!!</p>
  <p>Here is the code(but the time complexity for insertion from front is O(n);*</p>
  <pre><code>    #include &lt;stdio.h&gt;
      #define SIZE 5
      struct QUEUE{
          int queue[SIZE];
          int front,rear;
      }q;
      int isFull(){
          if(q.rear==SIZE-1)return 1;
          return 0;
      }
      int isEmpty(){
          if(q.front==-1 ||q.front&gt;q.rear)return 1;
          return 0;   
      }
      void enqueue_back(){
          if(!isFull()){
              int ele;
              printf(&quot;\nEnter the element you want to enqueue: &quot;);
              scanf(&quot;%d\n&quot;,&amp;ele);
              q.queue[++q.rear]=ele;
          }
          else{
              printf(&quot;\nThe Queue is Full.&quot;);
          }
          if (q.front==-1){
              q.front++;
          }  
      }
      void enqueue_front(){
          if (q.front==-1){
              q.front++;
          } 
          if(!isFull()){
              for (int i=q.rear+1;i&gt;q.front;i--){
                  
                  q.queue[i]=q.queue[i-1];
              }
              int ele;
              printf(&quot;\nEnter the element you want to enqueue: &quot;);
              scanf(&quot;%d\n&quot;,&amp;ele);
              q.queue[q.front]=ele;
              q.rear++;
          }
  else{
              printf(&quot;\nThe Queue is Full.&quot;);
          }
          }
      void dequeue(){
          if(!isEmpty()){
              ++q.front;
          }
          else{
              printf(&quot;\nThe Queue is Empty.&quot;);
          }
      }
  </code></pre>