CSC 111 Lecture Notes - Lecture 9: Null Set, Linked List

38 views3 pages

Document Summary

Return numitems: returns the number of items in the list add (item) { Head -> new node head = (cid:374)ew node (cid:894)(cid:858)x(cid:859)(cid:895): head pointer pointing to new node that we created node head data (cid:858)x(cid:859) Data (cid:858)c(cid:859: node that points from c to a to t to null, to add an s, locate end of list, create a new node, set last node pointer to new node. Data items (cid:858)c(cid:859) (cid:858)a(cid:859: set a pointer called curr curr = head; while(curr. getnext( )!=null) { curr = curr. getnext( ); Null: moves the pointer through the list until null is reached. Return curr. getitem( ): remove all operation removeall ( ) { numitems = 0; head = null, makes the head point to null, list is still there it is just non-accessible, (cid:862)gets (cid:396)id(cid:863) of list, remove (location) operation. Curr/prev (cid:858)a(cid:859) curr: makes previous curr then advances curr. (cid:858)t(cid:859) (cid:858)s(cid:859)

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents