Linear Data Structures 2.3

# Linear Data Structures 2.3 - CSE 2011 Prof. J. Elder - 64 -...

This preview shows pages 1–5. Sign up to view the full content.

Last Updated: 12-01-17 9:52 AM CSE 2011 Prof. J. Elder - 61 - Insertion Algorithm Algorithm addAfter( v, z ): w ç v.getNext() z. setPrev( v ) {link z to its predecessor} z. setNext( w ) {link z to its successor} w . setPrev( z ) {link z’s successor back to z} v. setNext( z ) {link v to its new successor, z} size ç size + 1

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

View Full Document
Last Updated: 12-01-17 9:52 AM CSE 2011 Prof. J. Elder - 62 - End of Lecture 4 Jan 12, 2012
Last Updated: 12-01-17 9:52 AM CSE 2011 Prof. J. Elder - 63 - Deletion remove (v) removes node v from the list. A B C D v A B C D v A B C

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

View Full Document
Last Updated: 12-01-17 9:52 AM
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSE 2011 Prof. J. Elder - 64 - Deletion Algorithm Algorithm remove( v ): u ç v.getPrev() {node before v} w v.getNext() {node after v} w. setPrev( u ) {link out v} u. setNext( w ) v. setPrev( null ) {null out fields of v} v. setNext( null ) size ç size - 1 Last Updated: 12-01-17 9:52 AM CSE 2011 Prof. J. Elder - 65 - Running Time • Insertion and Deletion of any given node takes O(1) time. • However, depending upon the application, finding the insertion location or the node to delete may take longer!...
View Full Document

## This note was uploaded on 02/14/2012 for the course CSE 2011Z taught by Professor Elder during the Fall '11 term at York University.

### Page1 / 5

Linear Data Structures 2.3 - CSE 2011 Prof. J. Elder - 64 -...

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

View Full Document
Ask a homework question - tutors are online