python code

  • Thread starter Thread starter RashiG
  • Start date Start date

RashiG

Guest
Member
Code:

Code:

Code:
var Queue = function() {
  this.first = null;
  this.size = 0;
};
 
var Node = function(data) {
   this.data  = data;
  this.next = null;
};
 
Queue.prototype.enqueue = function(data) {
  var node = new Node(data);
 
  if (!this.first){
    this.first = node;
  } else {
    n = this.first;
    while (n.next) {
      n = n.next;
    }
    n.next = node;
  }
 
  this.size += 1;
  return node;
};
Continue reading...

Continue reading...
 
Top