CSCI 103L Lecture Notes - Lecture 18: Linked List

23 views2 pages

Document Summary

Pa2: need maze, where you"ve been before, and predecessor array, null pointer. Int * ptr = null: arrays review. Arrays cannot grow or shrink: linked list. Each piece has a value and a pointer to the next item. Use a struct that has the data and a pointer in it. If(head == null) : head = new item, head->val = v, head->next = null; Must allocate dynamically so they live past the end of the function call. Push_front would add new value to the front. Pop_front, pop_back : remove front or back item: linked lists are a good way to test pointers and dynamic memory (probably on programing midterm, linked list needs 2 classes. Class of item and class of list. List stores the head and has member functions to add items, etc. To make a pointer point at the next value in a linked list: temp = temp->next.

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