CP114 Lecture Notes - Lecture 7: Linked Data, Data Element, Init

54 views3 pages
School
Course
Professor

Document Summary

A node typically consists of two parts: a data part, which may contain any kind of value at least one pointer, or link, part, which links to another node. A data structure is built by linking together a series of these nodes. How they are linked together determines the type of data structure that is built. We will look at a linked stack data structure to understand such a structure is built. For a linked stack, we need 2 classes. 1 for the node and one for the actual stack. A stack node is very simple: it needs only a _data attribute and a _next attribute. A node is created only when there is a value to add to the stack. There is no use for an empty node. Other than the constructor, the _stacknode class needs no methods as the stack class takes care of manipulating the nodes.

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

Related Questions