CISC 2200 Lecture Notes - Lecture 4: Linked List, Linear Search, The Algorithm

40 views3 pages

Document Summary

Cout << *ip: << *ip << a = << a << endl; // *ip would be 1000 (address of a) Cout << *ip: << *ip << a = << a << b= << b << endl; //a will stay as 10 int**& pr = ip; // pr will be ip in a sense. We can use a struct for nodes and list types to be together. Putitem: when the list is empty, putitem creates a node and sets the external pointer listdata to it, 1. Set the node"s info to the input data: 3. Set the node"s next pointer to the listdata, the first item in the list: 4. Set listdata to point to the new node (this order matters) Node -> next = listdata; listdata = node; length++: the algorithm is unchanged: linear search through the list to find the desired item. In fact, the implementation is largely unchanged; it just needs to use pointers instead of array indices.

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