Queue: A queue is a linear structure that follows a particular order in which operations are performed. The order is First In, First Out (FIFO). ```js class Node{ constructor(data,prev,next){ this.data = data; this.prev = prev; this.next = next; } getData(){ return this.data; } } class Queue{ constructor(){ this.head = null; this.tail = null; this.size = 0; } offer(element){ if(this.head == null){ this.head = new Node(element); this.tail = this.head; }else{ var newNode = new Node(element); newNode.next = this.tail; this.tail.prev = newNode; this.tail = newNode; } this.size++ } size(){ return this.size; } poll(){ var p = this.head; if(p == null){ return null; } this.head = this.head.prev; p.next = null; p.prev = null; this.size--; return p; } } function print(queue){ document.write("Head "); var node = null; while((node = queue.poll())!=null){ document.write(node.getData() + "<-"); } document.write("Tail <br>"); } var queue = new Queue(); queue.offer("A"); queue.offer("B"); queue.offer("C"); queue.offer("D"); print(queue); ``` this one is for those who like challenges. if you understood the code, please leave a comment with the result.
very simple answer. lacked a bit of detail😊
Head A<-B<-C<-D<-Tail