COMPSCI 61B Lecture Notes - Lecture 4: Infinite Loop, Rotary Valve

42 views6 pages

Document Summary

While functional, naked linked lists like the intlist is hard to use. Users of this class are probably going to need to know references very well and use recursion well. It"s better to make a list easier to work. Instead of intlist class, have an intnode class. Next thing we"re going to do, is create another class called sllist. An sllist is a list of integers which hides the terrible truth of the nakedness within public class sllist { public intnode first; public sllist(int x) { Did not have to specify null, just have to specify an x. Intnode x = new intnode(10, null) vs. sllist y = new sllist(10); Programmer who uses this data structure need not worry about recursion or references. First = new intnode(x, null); public sllist(int x) { first. item; first = newintnode(x, first); /adds x to the front of the list; public void addfirst(int x) {

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