Node Array Based Off of Nick Parlante\'s tutorial from Stanford University


/ Published in: C++
Save to your folder(s)



Copy this code and paste it in your HTML
  1. struct chainLink * buildLIST()
  2. {
  3. chainLink *head[ARRAY_TOP];
  4. makeNULL(head);
  5. head[ARRAY_TOP] = new chainLink;
  6. return head[0];
  7. }
  8. void makeNULL(chainLink **newNode){
  9.  
  10. for(int a = 0; a < ARRAY_TOP; a++){
  11. newNode[a] = new chainLink;
  12. newNode[a]->data = 0;
  13. newNode[a]->next = 0;
  14. }
  15. }
  16. struct chainLink * buildLIST()
  17. {
  18. chainLink *head[ARRAY_TOP];
  19. makeNULL(head);
  20. head[ARRAY_TOP] = new chainLink;
  21. return head[0];
  22. }
  23. void Push(struct chainLink* headRef[ARRAY_TOP], int data){
  24. int key = 1;
  25. chainLink *head[ARRAY_TOP];
  26. makeNULL(head);
  27.  
  28. head[0]->data = data;
  29. head[0]->next = headRef[0];
  30. headRef[0] = head[0];
  31. }
  32. void pushNODES(int index, int number){
  33. chainLink* head[ARRAY_TOP];
  34. makeNULL(head);
  35. head[index] = buildLIST();
  36. Push(head, number);
  37. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.