Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. void insertLast(int key, int data) {
  2.  
  3. //create a link
  4. struct node *link = (struct node*) malloc(sizeof(struct node));
  5. link->key = key;
  6. link->data = data;
  7.  
  8. if(isEmpty()) {
  9. //make it the last link
  10. last = link;
  11. } else {
  12. //make link a new last link
  13. last->next = link;
  14.  
  15. //mark old last node as prev of new link
  16. link->prev = last;
  17. }
  18.  
  19. //point last to new last node
  20. last = link;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement