06-07_LinkedLists - Linked Lists Click to edit Master...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
Click to edit Master subtitle style © 2009 Dr. Tim Linked Lists Dr. Tim Margush University of Akron © 2009
Background image of page 1

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

View Full DocumentRight Arrow Icon
© 2009 Dr. Tim Goals Describe a linked data structure Perform basic operations on a linked data structure using a Node class Implement the List ADT using a linked data structure Compare the advantages of linked to array-based implementations of a list
Background image of page 2
© 2009 Dr. Tim Backing Store Every List implementation requires a backing store A data structure containing elements of the List An array is one possible backing store Arrays store data references physically contiguous memory locations A linked structure is another
Background image of page 3

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

View Full DocumentRight Arrow Icon
© 2009 Dr. Tim Array vs. Linked Structure References to List elements can be stored In physical sequential order (array) In random locations (linked) Must be able to locate the first and next items list[0], list[1], … head, current.next The first element is special
Background image of page 4
© 2009 Dr. Tim Links Links specify the location of something Links can be integers, or references Object t; t is a link (reference) to an Object int loc; loc is an array subscript used to locate an Object (or primitive value)
Background image of page 5

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

View Full DocumentRight Arrow Icon
© 2009 Dr. Tim Nodes Nodes support linked structures by bundling data with one or more links to other elements of the collection A linked list uses Nodes with a data value and one or more links (references) to other Nodes class Node<E>{ private E data; private Node<E> next; }
Background image of page 6
© 2009 Dr. Tim Inner Classes An inner class is defined inside another class A private inner class is only accessible by the outer (enclosing) class public class LList<E> implements ListInterface<E>{ private class Node{ private E data; private Node next; } private Node head;
Background image of page 7

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

View Full DocumentRight Arrow Icon
© 2009 Dr. Tim Inner Classes Methods in both the inner and outer class have complete access to all members of each other, including private members public class LList<E> implements ListInterface<E>{ private class Node{ private Node() { //access private outer member if ( head == null) … } } //access private constructor private Node head = new Node() ;
Background image of page 8
© 2009 Dr. Tim Visualization of a Linked List null Node head;
Background image of page 9

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

View Full DocumentRight Arrow Icon
© 2009 Dr. Tim
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/22/2011 for the course CS 463 taught by Professor Dr. tim margush during the Fall '09 term at The University of Akron.

Page1 / 33

06-07_LinkedLists - Linked Lists Click to edit Master...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online