Tuesday 12 March 2013

DLL insert



void DLL::insert(int data){
  if(_head == _curr){
    _head = new Node(data, (Node*)0, _head);
    _curr->_prev = _head;
  }
  else {
    _curr->_prev = new Node(data, _curr->_prev, _curr);
    _curr->_prev->_prev->_next = _curr->_prev;
  }
}

No comments:

Post a Comment