1 / 50

struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true)

struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; }. root s temp. NULL. ?. ?.

Download Presentation

struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp NULL ? ?

  2. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp NULL abc ?

  3. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp NULL abc ? ?

  4. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp NULL abc abc ?

  5. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp NULL abc abc NULL

  6. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp abc abc NULL

  7. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp dog ? abc NULL

  8. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp dog ? ? abc NULL

  9. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp dog dog ? abc NULL

  10. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp dog dog ? abc NULL

  11. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp dog dog abc NULL

  12. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp dog dog abc NULL

  13. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp dog dog abc NULL

  14. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp hat ? dog abc NULL

  15. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp hat ? ? dog abc NULL

  16. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp hat hat ? dog abc NULL

  17. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next= root; root = temp; } ...... root s temp hat hat ? dog abc NULL

  18. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp hat hat dog abc NULL

  19. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root= temp; } ...... root s temp hat hat dog abc NULL

  20. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp hat hat dog abc NULL

  21. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp xyz ? hat dog abc NULL

  22. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp xyz ? ? hat dog abc NULL

  23. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp xyz xyz ? hat dog abc NULL

  24. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp xyz xyz ? hat dog abc NULL

  25. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next =root; root = temp; } ...... root s temp xyz xyz hat dog abc NULL

  26. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp xyz xyz hat dog abc NULL

  27. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp xyz xyz hat dog abc NULL

  28. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root s temp xyz ? xyz hat dog abc NULL

  29. struct Link { string data; Link * next; }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link; temp->data = s; temp->next = root; root = temp; } ...... root xyz hat dog abc NULL

  30. struct Link { string data; Link * next; Link(string a, Link * b) { data = a; next = b; } }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; temp = new Link(s, root); root = temp; } ...... root xyz hat dog abc NULL

  31. struct Link { string data; Link * next; Link(string a, Link * b) { data = a; next = b; } }; void main() { Link * root = NULL; while (true) { Link * temp; string s; cin >> s; if (cin.fail()) break; root = new Link(s, root); } ...... root xyz hat dog abc NULL

  32. struct Link { string data; Link * next; Link(string a, Link * b) { data = a; next = b; } }; void main() { Link * root = NULL; while (true) { string s; cin >> s; if (cin.fail()) break; root = new Link(s, root); } ...... root xyz hat dog abc NULL

  33. root cout << root->data; xyz hat dog abc NULL

  34. root cout << root->data; cout << root->next->data; xyz hat dog abc NULL

  35. root cout << root->data; cout << root->next->data; cout << root->next->next->data; xyz hat dog abc NULL

  36. root while (something) { cout << root->data; root = root->next; } xyz hat dog abc NULL

  37. root while (something) { cout << root->data; root = root->next; } xyz hat dog abc NULL

  38. root while (something) { cout << root->data; root = root->next; } xyz hat dog abc NULL

  39. root while (something) { cout << root->data; root = root->next; } xyz hat dog abc NULL

  40. root while (something) { cout << root->data; root = root->next; } xyz hat dog abc NULL

  41. root while (something) { cout << root->data; root = root->next; } xyz hat dog abc NULL

  42. root while (something) { cout << root->data; root = root->next; } xyz hat dog abc NULL

  43. root while (something) { cout << root->data; root = root->next; } xyz hat dog abc NULL

  44. root while (something) { cout << root->data; root = root->next; } xyz hat dog abc NULL

  45. root while (something) { cout << root->data; root = root->next; } xyz hat dog abc NULL

  46. root while (something) { cout << root->data; root = root->next; } xyz hat dog abc NULL

  47. root while (something) { cout << root->data; root = root->next; } xyz hat dog abc NULL

  48. root NULL while (something) { cout << root->data; root = root->next; } xyz hat dog abc NULL

  49. root NULL while (root != NULL) { cout << root->data; root = root->next; } xyz hat dog abc NULL

  50. root temp NULL Link * temp; temp = root; while (temp != NULL) { cout << temp->data; temp = temp->next; } xyz hat dog abc NULL

More Related