Listnode list new listnode listdata 42 listnext new

Info icon This preview shows pages 15–20. Sign up to view the full content.

View Full Document Right Arrow Icon
ListNode list = new ListNode(); list.data = 42; list.next = new ListNode(); list.next.data = -3; list.next.next = new ListNode(); list.next.next.data = 17; list.next.next.next = null; System.out.println(list.data + " " + list.next.data + " " + list.next.next.data); // 42 -3 17 } } data next 42 data next -3 data next 17 null list
Image of page 15

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
16 List node w/ constructor public class ListNode { int data; ListNode next; public ListNode(int data) { this.data = data; this.next = null; } public ListNode(int data, ListNode next) { this.data = data; this.next = next; } } Exercise: Modify the previous client to use these constructors.
Image of page 16
17 Linked node problem 1 What set of statements turns this picture: Into this? data next 10 data next 20 list data next 10 data next 20 list data next 30
Image of page 17

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
18 Linked node problem 2 What set of statements turns this picture: Into this? data next 10 data next 20 list data next 30 data next 10 list data next 20
Image of page 18
19 Linked node problem 3 What set of statements turns this picture: Into this? data next 10 data next 20 list1 data next 30 data next 40 list2 data next 10 data next 30 list1 data next 40 list2 data next 20
Image of page 19

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
20 Linked node problem 4 What set of statements turns this picture: Into this? data next 10 data next 990 list ... data next 10 data next 990 list ... data next 100 0
Image of page 20
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern