lundi 8 juillet 2019

SORTING INSERTION

This is code I have so far for linked list that takes a value but it doesn't sort it?

do I have to add anything else to it

void OrderedDoublyLinkedList::insertNode(int x) {
  nodeType *temp = new nodeType;

  temp->info = x;
  temp->next = NULL;

  if (first == NULL) {
    first = temp;
    last = temp;
  }
  else {
    last->next = temp;
    last = last->next;
  }
}

Aucun commentaire:

Enregistrer un commentaire