Linked Lists. Outline. COMP9024: Data Structures and Algorithms. Algorithms versus Heuristics. Data Structures and Algorithms. Abstract Data Types

Similar documents
Using Recursion. Linear Recursion ( 4.1.1) Recall the Recursion Pattern ( 2.5) A Simple Example of Linear Recursion

Using Recursion Goodrich, Tamassia. Using Recursion 1

Data Structures and Algorithms " Recursion!

CSC 344 Algorithms and Complexity. What is Recursion?

Recursion. The Recursion Pattern. Recursion 3/16/14

RECURSION (CH 5) A pattern for solving algorithm design problems

PDF created with pdffactory Pro trial version Recursion

Linked Lists. Singly Linked Lists (3.2) CSE 2011 Winter /01/2011

Recursion Chapter 3.5

Lecture 3 Linear Data Structures: Arrays, Array Lists, Stacks, Queues and Linked Lists

Data Structures and Algorithms " Arrays and Linked Lists!

csci 210: Data Structures Linked lists Summary Arrays vs. Lists Arrays vs. Linked Lists a[0] a[1] a[2]... null Today READING: Arrays

csci 210: Data Structures Linked lists

Lecture 3 Linear Data Structures

Computer Science 210: Data Structures. Linked lists

Data structure and algorithm in Python

Arrays. Array Definition

CPSC 35 Midterm Exam

CSED233: Data Structures (2018F) Lecture3: Arrays and Linked Lists

DHANALAKSHMI COLLEGE OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING EC6301 OBJECT ORIENTED PROGRAMMING AND DATA STRUCTURES

Lists. Outline. COMP9024: Data Structures and Algorithms. Lists. Array List ADT. Array-Based Implementation. Array lists Node lists Iterators

Arrays & Linked Lists

NCS 301 DATA STRUCTURE USING C

ADTs, Arrays, Linked Lists

COMP 250 Winter generic types, doubly linked lists Jan. 28, 2016

Welcome to CSL 201 Data Structures

Algorithm Design and Recursion. Search and Sort Algorithms

csci 210: Data Structures Stacks and Queues in Solution Searching

CS115 INTRODUCTION TO COMPUTER SCIENCE 1. Additional Notes Module 5

DATA STRUCTURE UNIT I

Programming II (CS300)

ADTs, Arrays, and Linked-Lists

ITI Introduction to Computing II

Data Structures (CS301) LAB

9/26/2018 Data Structure & Algorithm. Assignment04: 3 parts Quiz: recursion, insertionsort, trees Basic concept: Linked-List Priority queues Heaps

8/19/2014. Most algorithms transform input objects into output objects The running time of an algorithm typically grows with input size

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR

Linked lists. Insert Delete Lookup Doubly-linked lists. Lecture 6: Linked Lists

PROGRAMMING IN HASKELL. CS Chapter 6 - Recursive Functions

Algorithms 4. Odd or even Algorithm 5. Greatest among three numbers Algorithm 6. Simple Calculator Algorithm

Stacks (5.1) Abstract Data Types (ADTs) CSE 2011 Winter 2011

FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- OCTOBER, 2012 DATA STRUCTURE

Announcements. Project 5 is on the street. Second part is essay questions for CoS teaming requirements.

Recursion (Rosen, 6 th edition, Section 4.3, 4.4)

1/18/12. Chapter 5: Stacks, Queues and Deques. Stacks. Outline and Reading. Nancy Amato Parasol Lab, Dept. CSE, Texas A&M University

Information Science 2

University of Palestine. Final Exam 2 nd semester 2014/2015 Total Grade: 50

Dynamic Data Structures

COMP 250. Lecture 6. doubly linked lists. Sept. 20/21, 2017

+ Abstract Data Types

Spring 2008 Data Structures (CS301) LAB

Computer Science 62. Bruce/Mawhorter Fall 16. Midterm Examination. October 5, Question Points Score TOTAL 52 SOLUTIONS. Your name (Please print)

COMP 250 Midterm #2 March 11 th 2013

Announcements. Prelude (2) Prelude (1) Data Structures and Information Systems Part 1: Data Structures. Lecture 6: Lists.

Lecture 6: Recursion RECURSION

Discrete Mathematics Introduction

Insertions and removals follow the Fist-In First-Out rule: Insertions: at the rear of the queue Removals: at the front of the queue

doubly linked lists Java LinkedList

CS32 Discussion Week 3

Computer Science Foundation Exam. Dec. 19, 2003 COMPUTER SCIENCE I. Section I A. No Calculators! KEY

[2:3] Linked Lists, Stacks, Queues

CH ALGORITHM ANALYSIS CH6. STACKS, QUEUES, AND DEQUES

Linear Structures. Linear Structure. Implementations. Array details. List details. Operations 2/10/2013

Programming II (CS300)

Chapter 1: Number and Operations

Solutions to Assessment

ECE 2400 Computer Systems Programming Fall 2018 Topic 2: C Recursion

Singly (Simply) Linked Lists

Classic Data Structures Introduction UNIT I

Lists and Sequences. 1/22/ :32 PM Sequences 1

Cantor s Diagonal Argument for Different Levels of Infinity

Definitions. You can represent a point by a dot and name it by a capital letter.

Priority Queue Sorting

DDS Dynamic Search Trees

Recursion. Chapter 7. Copyright 2012 by Pearson Education, Inc. All rights reserved

Revision Statement while return growth rate asymptotic notation complexity Compare algorithms Linear search Binary search Preconditions: sorted,

Linked Lists. Chapter 4

CA341 - Comparative Programming Languages

CS2210 Data Structures and Algorithms

Programming II (CS300)

Programming II (CS300)

// Pointer to the first thing in the list

10/1/2018 Data Structure & Algorithm. Circularly Linked List Doubly Linked List Priority queues Heaps

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May

Functional programming with Common Lisp

Module 10. Recursion. Adapted from Absolute Java, Rose Williams, Binghamton University

Linked Lists. .. and other linked structures. Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

17CS33:Data Structures Using C QUESTION BANK

This lecture. Iterators ( 5.4) Maps. Maps. The Map ADT ( 8.1) Comparison to java.util.map

Chapter 13. Recursion. Copyright 2016 Pearson, Inc. All rights reserved.

Linear Structures. Linear Structure. Implementations. Array details. List details. Operations 4/18/2013

About this exam review

5 Phases of Software Life Cycle

CSC 172 Data Structures and Algorithms. Lecture #8 Spring 2018

Come to the PASS workshop with your mock exam complete. During the workshop you can work with other students to review your work.

1 Deletion in singly linked lists (cont d) 1 Other Functions. 1 Doubly Linked Lists. 1 Circular lists. 1 Linked lists vs. arrays

Recursion: Recursion: repeated curses

! Determine if a number is odd or even. ! Determine if a number/character is in a range. - 1 to 10 (inclusive) - between a and z (inclusive)

Principles of Programming Languages Topic: Scope and Memory Professor Louis Steinberg Fall 2004

CSCI-1200 Data Structures Spring 2018 Lecture 7 Order Notation & Basic Recursion

Transcription:

COMP9024: Data Structures and Algorithms Week Three: Linked Lists and Recursion Outline Singly Linked Lists Doubly Linked Lists Recursions Hui Wu Session 1, 2014 http://www.cse.unsw.edu.au/~cs9024 1 2 Data Structures and Algorithms Algorithms versus Heuristics Data structures A data structure is a way of storing data in a computer so that it can be used efficiently. Algorithms An algorithm is a finite sequence of well-defined instructions for solving a problem and guaranteed to terminate in a finite time. An algorithm does not necessarily need to be executable in a computer, but can be converted into a program. Heuristics A heuristic is a finite sequence of well-defined instructions for partially solving a hard problem and guaranteed to terminate in a finite time. A heuristic is not always guaranteed to find a solution while an algorithm is. Descriptions of algorithms We will use Java-like pseudo code mixed with English to describe algorithms. 3 4 Abstract Data Types An Abstract Data Type (ADT) is a specification of a set of data and the set of operations that can be performed on the data. Such a data type is abstract in the sense that it is independent of various concrete implementations. The definition can be mathematical, or it can be programmed as an interface. We need to implement an ADT by using a class to make it usable. Linked Lists 5 6 1

Singly Linked List The Node Class for List Nodes A singly linked list is a concrete data structure consisting of a sequence of nodes Each node stores element link to the next node elem next node /** Node of a singly linked list of strings. */ public class Node private String element; // we assume elements are character strings private Node next; /** Creates a node with the given element and next node. */ public Node(String s, Node n) element = s; next = n; /** Returns the element of this node. */ public String getelement() return element; /** Returns the next node of this node. */ public Node getnext() return next; // Modifier methods: /** Sets the element of this node. */ public void setelement(string newelem) element = newelem; A B C D 7 /** Sets the next node of this node. */ public void setnext(node newnext) next = newnext; 8 The Class for a Singly Linked List Inserting at the Head (1/2) /** Singly linked list.*/ public class SLinkedList protected Node head; // head node of the list protected long size; // number of nodes in the list /** Default constructor that creates an empty list */ public SLinkedList() head = null; size = 0; //... update and search methods would go here... 1. Allocate a new node 2. Insert the new element 3. Have the new node point to old head 4. Update head to point to the new node 9 10 Inserting at the Head (2/2) Removing at the Head (1/2) Algorithm addfirst(v) v.setnext(head); // make v point to the old head node head = v; // make head point to the new node size =size+1; // increment the node count 1. Update head to point to next node in the list 2. Allow garbage collector to reclaim the former first node 11 12 2

Removing at the Head (2/2) Inserting at the Tail (1/2) Algorithm removefirst() if ( head = null ) Indicate an error: the list is empty; t = head ; /* make head point to the next node (or null) */ head = head.getnext(); t.setnext(null); //null out the next pointer of the removed node size = size - 1; //decrement the node count 1. Allocate a new node 2. Insert the new element 3. Have the new node point to null 4. Have the old last node point to new node 5. Update tail to point to new node 13 14 Inserting at the Tail (2/2) Removing at the Tail (1/2) Algorithm addlast(v) v.setnext(null); //make the new node v point to null object tail.setnext(v); //make the old tail node point to the new node tail = v ; //make tail point to the new node size = size +1; //increment the node count Removing the tail node of a singly linked list cannot be done in constant time. We need to traverse the whole linked list to remove the tail node, which takes O(n) time, where n is the number of nodes in the linked list. 15 16 Removing at the Tail (2/2) Doubly Linked List Algorithm removelast() if ( size = 0 ) Indicate an error: the list is empty; if ( size = 1 ) // only one node head = null; // at least two nodes t = head; /* make t point to the head */ while ( t.getnext!= null ) /* find the last node */ s = t; t = t.getnext(); s.setnext(null); //null out the next pointer of the last node size = size - 1; //decrement the node count 17 A doubly linked list is a concrete data structure consisting of a sequence of nodes. Each node stores: element link to the previous node link to the next node Special and nodes prev elem nodes/positions elements next node 18 3

The Node Class of Doubly Linked List Inserting at the Head (1/2) /** Node of a doubly linked list of strings */ public class DNode protected String element; // String element stored by a node protected DNode next, prev; // Pointers to next and previous nodes /** Constructor that creates a node with given fields */ public DNode(String e, DNode p, DNode n) element = e; prev = p; next = n; /** Returns the element of this node */ public String getelement() return element; /** Returns the previous node of this node */ public DNode getprev() return prev; /** Returns the next node of this node */ public DNode getnext() return next; /** Sets the element of this node */ public void setelement(string newelem) element = newelem; /** Sets the previous node of this node */ public void setprev(dnode newprev) prev = newprev; /** Sets the next node of this node */ public void setnext(dnode newnext) next = newnext; 19 Rome Seattle New York (a) Before the insertion Sydney Rome Seattle New York (b) After the insertion 20 Inserting at the Head (2/2) Inserting in the Middle (1/2) Algorithm addfirst(v) w =.getnext(); // make w point to the first node v.setnext(w); // make v point to the old first node v.setprev(); // make v point to the w.setprev(v); // make the old first node point to v.setnext(v); // make point to v size = size+1; // increment the node count Rome Seattle New York (a) Before the insertion 21 Rome Seattle Sydney New York (b) After the insertion 22 Inserting in the Middle (2/2) Removing at the Tail (1/2) Algorithm addafter(v,z) w=v.getnext(); // make w point to the node after v z.setprev(v); // link z to its predecessor, v z.setnext(w); // link z to its successor, w w.setprev(z); // link w to its new predecessor, z v.setnext(z); // link v to its new successor, z size = size+1; // increment the node count Rome Seattle Sydney New York (a) Before the deletion Rome Seattle Sydney 23 (b) After the deletion 24 4

Removing at the Tail (2/2) Removing in the Middle (1/2) Algorithm removelast(): if ( size = 0 ) Indicate an error: this list is empty; v =.getprev() // make v point to the last node u = v.getprev(); // u points to the node before the last node.setprev(u); u.setnext(); v.setprev(null); v.setnext(null); size = size -1; Rome Seattle Sydney New York (a) Before the deletion Rome Seattle New York (b) After the deletion 25 26 Removing in the Middle (2/2) Algorithm remove(v): u = v.getprev() // make u point to the node before v w = v.getnext(); // w points to the node after v w.setprev(u); // link out v u.setnext(w); v.setprev(null); // null out the pointers of v v.setnext(null); size = size -1; // decrement the node count Programming with Recursion 27 28 The Recursion Pattern Content of a Recursive Method Recursion: when a method s itself Classic example--the factorial function: n! = 1 2 3 (n-1) n Recursive definition: 1 f ( n) n f ( n 1) if n 0 As a Java method: // recursive factorial function public static int recursivefactorial(int n) if (n == 0) return 1; // basis case return n * recursivefactorial(n- 1); // recursive case Base case(s) Values of the input variables for which we perform no recursive s are ed base cases (there should be at least one base case). Every possible chain of recursive s must eventually reach a base case. Recursive s Calls to the current method. Each recursive should be defined so that it makes progress towards a base case. 29 30 5

Visualizing Recursion Example English Rulers Recursion trace A box for each recursive An arrow from each er to ee An arrow from each ee to er showing return value Example recursion trace: return 4 * 6 = 24 final answer recursivefactorial ( 4 ) return 3 * 2 = 6 recursivefactorial ( 3 ) return 2 * 1 = 2 recursivefactorial ( 2 ) return 1 * 1 = 1 recursivefactorial ( 1 ) Define a recursive way to print the ticks and numbers like an English ruler: return 1 recursivefactorial ( 0 ) 31 32 A Recursive Method for Drawing Ticks on an English Ruler Visualizing the DrawTicks Method // draw a tick with no label public static void drawonetick(int ticklength) drawonetick(ticklength, - 1); // draw one tick public static void drawonetick(int ticklength, int ticklabel) for (int i = 0; i < ticklength; i++) System.out.print("-"); if (ticklabel >= 0) System.out.print(" " + ticklabel); System.out.print("\n"); public static void drawticks(int ticklength) // draw ticks of given length if (ticklength > 0) // stop when length drops to 0 drawticks(ticklength- 1); // recursively draw left ticks drawonetick(ticklength); // draw center tick drawticks(ticklength- 1); // recursively draw right ticks public static void drawruler(int ninches, int majorlength) // draw ruler drawonetick(majorlength, 0); // draw tick 0 and its label for (int i = 1; i <= ninches; i++) drawticks(majorlength- 1); // draw ticks for this inch drawonetick(majorlength, i); // draw tick i and its label 33 An interval with a central tick length L >1 is composed of the following: an interval with a central tick length L-1, a single tick of length L, an interval with a central tick length L-1. drawticks ( 3 ) drawticks ( 2 ) drawticks ( 2 ) drawticks ( 1 ) drawticks ( 0 ) drawonetick ( 1 ) drawonetick ( 2 ) drawticks ( 1 ) drawonetick ( 3 ) drawticks ( 0 ) drawticks ( 0 ) drawonetick ( 1 ) drawticks ( 0 ) ( previous pattern repeats ) Output 34 Re the Recursion Pattern Using Recursion Recursion: when a method s itself Classic example--the factorial function: n! = 1 2 3 (n-1) n Recursive definition: 1 f ( n) n f ( n 1) if n 0 As a Java method: // recursive factorial function public static int recursivefactorial(int n) if (n == 0) return 1; // basis case return n * recursivefactorial(n- 1); // recursive case 35 36 6

Linear Recursion Test for base cases. Begin by testing for a set of base cases (there should be at least one). Every possible chain of recursive s must eventually reach a base case, and the handling of each base case should not use recursion. Recur once. Perform a single recursive. (This recursive step may involve a test that decides which of several possible recursive s to make, but it should ultimately choose to make just one of these s each time we perform this step.) Define each possible recursive so that it makes progress towards a base case. A Simple Example of Linear Recursion Algorithm LinearSum(A, n) Input : A integer array A and an integer n such that A has at least n elements Output : The sum of the first n integers in A if ( n = 1) return A[0]; return LinearSum(A, n - 1) + A[n - 1]; Example recursion trace: LinearSum ( A, 5 ) return 15 + A [ 4 ] = 15 + 5 = 20 LinearSum ( A, 4 ) LinearSum ( A, 3 ) LinearSum ( A, 2 ) LinearSum ( A, 1 ) return 13 + A [ 3 ] = 13 + 2 = 15 return 7 + A [ 2 ] = 7 + 6 = 13 return 4 + A [ 1 ] = 4 + 3 = 7 return A [ 0 ] = 4 37 38 Reversing an Array Defining Arguments for Recursion Algorithm ReverseArray(A, i, j) Input : An array A and nonnegative integer indices i and j Output : The reversal of the elements in A starting at index i and ending at j if (i < j ) swap A[i] and A[j]; ReverseArray(A, i + 1, j - 1); In creating recursive methods, it is important to define the methods in ways that facilitate recursion. This sometimes requires we define additional parameters that are passed to the method. For example, we defined the array reversal method as ReverseArray(A, i, j), not ReverseArray(A). 39 40 Computing Powers Recursive Squaring The power function, p(x,n)=x n, can be defined recursively: 1 p( x, n) x p( x, n 1) if n 0 This leads to an power function that runs in O(n) time (for we make n recursive s). We can do better than this, however. We can derive a more efficient linearly recursive algorithm by using repeated squaring: 1 2 p( x, n) x p( x,( n 1) / 2) 2 p( x, n / 2) For example, 2 4 = 2 (4/2)2 = (2 4/2 ) 2 = (2 2 ) 2 = 4 2 = 16 2 5 = 2 1+(4/2)2 = 2(2 4/2 ) 2 = 2(2 2 ) 2 = 2(4 2 ) = 32 2 6 = 2 (6/ 2)2 = (2 6/2 ) 2 = (2 3 ) 2 = 8 2 = 64 2 7 = 2 1+(6/2)2 = 2(2 6/2 ) 2 = 2(2 3 ) 2 = 2(8 2 ) = 128. if x 0 if x 0 is odd if x 0 is even 41 42 7

A Recursive Squaring Method Analyzing the Recursive Squaring Method Algorithm Power(x, n) Input : A number x and integer n = 0 Output : The value x n if (n = 0) return 1; if (n is odd ) y = Power(x, (n - 1)/ 2); return x*y*y; y = Power(x, n/ 2); return y*y; 43 Algorithm Power(x, n) Input : A number x and integer n = 0 Output : The value x n if (n = 0) return 1; if (n is odd ) y = Power(x, (n - 1)/ 2); return x*y*y; y = Power(x, n/ 2); return y*y; Each time we make a recursive we halve the value of n; hence, we make log n recursive s. That is, this method runs in O(log n) time. It is important that we used a variable twice here rather than ing the method twice. 44 Tail Recursion Binary Recursion Tail recursion occurs when a linearly recursive method makes its recursive as its last step. The array reversal method is an example. Such methods can be easily converted to nonrecursive methods (which saves on some resources). Example: Algorithm IterativeReverseArray(A, i, j ) Input : An array A and nonnegative integer indices i and j Output : The reversal of the elements in A starting at index i and ending at j while ( i < j ) swap A[i] and A[j]; i = i + 1; j = j 1; Binary recursion occurs whenever there are two recursive s for each non-base case. Example: the DrawTicks method for drawing ticks on an English ruler. 45 46 A Binary Recursive Method for Drawing Ticks Another Binary Recursive Method // draw a tick with no label public static void drawonetick(int ticklength) drawonetick(ticklength, - 1); // draw one tick public static void drawonetick(int ticklength, int ticklabel) for (int i = 0; i < ticklength; i++) System.out.print("-"); if (ticklabel >= 0) System.out.print(" " + ticklabel); System.out.print("\n"); public static void drawticks(int ticklength) // draw ticks of given length if (ticklength > 0) // stop when length drops to 0 drawticks(ticklength- 1); // recursively draw left ticks drawonetick(ticklength); // draw center tick drawticks(ticklength- 1); // recursively draw right ticks public static void drawruler(int ninches, int majorlength) // draw ruler drawonetick(majorlength, 0); // draw tick 0 and its label for (int i = 1; i <= ninches; i++) drawticks(majorlength- 1); // draw ticks for this inch drawonetick(majorlength, i); // draw tick i and its label Note the two recursive s Problem: add all the numbers in an integer array A: Algorithm BinarySum(A, i, n) Input : An array A and integers i and n Output : The sum of the n integers in A starting at index i if (n = 1) return A[i]; return BinarySum(A, i, n/ 2) + BinarySum(A, i + n/ 2, n/ 2); Example trace: 0, 1 0, 2 1, 1 0, 4 2, 1 2, 2 3, 1 0, 8 4, 1 4, 2 5, 1 4, 4 6, 1 6, 2 7, 1 47 48 8

Computing Fibanacci Numbers Fibonacci numbers are defined recursively: F 0 = 0 F 1 = 1 F i = F i-1 + F i-2 for i > 1. As a recursive algorithm (first attempt): Algorithm BinaryFib(k) Input : Nonnegative integer k Output : The kth Fibonacci number F k if ( k = 1) return k; return BinaryFib(k - 1) + BinaryFib(k - 2); Analyzing the Binary Recursion Fibonacci Algorithm Let n k denote number of recursive s made by BinaryFib(k). Then n 0 = 1 n 1 = 1 n 2 = n 1 + n 0 + 1 = 1 + 1 + 1 = 3 n 3 = n 2 + n 1 + 1 = 3 + 1 + 1 = 5 n 4 = n 3 + n 2 + 1 = 5 + 3 + 1 = 9 n 5 = n 4 + n 3 + 1 = 9 + 5 + 1 = 15 n 6 = n 5 + n 4 + 1 = 15 + 9 + 1 = 25 n 7 = n 6 + n 5 + 1 = 25 + 15 + 1 = 41 n 8 = n 7 + n 6 + 1 = 41 + 25 + 1 = 67. Note that the value at least doubles for every other value of n k. That is, n k > 2 k/2. It is exponential! 49 50 A Better Fibonacci Algorithm Multiple Recursion Use linear recursion instead: Algorithm LinearFibonacci(k): Input : A nonnegative integer k Output : Pair of Fibonacci numbers (F k, F k-1 ) if ( k = 1) return (k, 0); (i, j) = LinearFibonacci(k - 1); return (i +j, i); Runs in O(k) time. Motivating example: summation puzzles pot + pan = bib dog + cat = pig boy + girl = baby Multiple recursion: makes potentially many recursive s (not just one or two). 51 52 Algorithm for Multiple Recursion Visualizing PuzzleSolve Algorithm PuzzleSolve(k,S,U) Input: An integer k, sequence S, and set U (the universe of elements to test) Output: An enumeration of all k-length extensions to S using elements in U without repetitions for all e in U do Remove e from U; // e is now being used Add e to the end of S; if (k = 1) Test whether S is a configuration that solves the puzzle; if ( S solves the puzzle ) return Solution found: S; PuzzleSolve(k - 1, S,U); Add e back to U; // e is now unused Remove e from the end of S; 53 Initial PuzzleSolve ( 3,(), a, b, c ) PuzzleSolve ( 2, a, b, c ) PuzzleSolve ( 2, b, a, c ) PuzzleSolve ( 2, c, a, b ) PuzzleSolve ( 1, ab, c ) PuzzleSolve ( 1, ba, c ) PuzzleSolve ( 1, ca, b ) abc bac cab PuzzleSolve ( 1, ac, b ) PuzzleSolve ( 1, bc, a ) PuzzleSolve ( 1, cb, a ) acb bca cba 54 9

References 1. Chapter 3, Data Structures and Algorithms by Goodrich and Tamassia. 2. Garbage Collection by Bill Venners (http://www.artima.com/insidejvm/ed2/gc.html). 55 10