CP114 Lecture Notes - Lecture 10: Gie, Linked List, Thrice

46 views4 pages
School
Course
Professor

Document Summary

Data structures: lecture (cid:1005)(cid:1004) (cid:894)li(cid:374)ked recursio(cid:374) a(cid:374)d writi(cid:374)g (cid:373)ethods(cid:895) Postconditions: returns identical - true if this list contains the same values as rs in the same order, otherwise returns false (boolean) identical = false n = len(self) # lists must be the same length to be identical. if len(rs) == n: i = 0. # compare each element, stop when the elements are not the same. # or the end of the list is reached. while i < n and self[i] == rs[i]: i += 1 if i == n: identical = true return identical. Both array a(cid:374)d li(cid:374)ked list gi(cid:448)e the sa(cid:373)e a(cid:374)s(cid:449)er si(cid:374)ce (cid:449)e"re usi(cid:374)g the high-level functions. But a linked list is more inefficient compared to the array based list. Since the code makes us have to start from the beginning of the list every time. When i is 0 (and the node values are 7), for each list there is a call to __getitem__(0).

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