Linear Data Structures 2.3

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

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
Last Updated: 12-01-17 9:52 AM CSE 2011 Prof. J. Elder - 62 - End of Lecture 4 Jan 12, 2012
Background image of page 2
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
Background image of page 3

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

View Full DocumentRight Arrow Icon
Last Updated: 12-01-17 9:52 AM
Background image of page 4
Background image of page 5
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 Right Arrow Icon
Ask a homework question - tutors are online