CSC148H5 Lecture Notes - Lecture 24: University Of Toronto Mississauga, Linked List, Init

24 views3 pages

Document Summary

Csc148h5s - introduction to computer science (winter 2017) Here is a linked list node for the following questions. The empty linked list will be represented as. None. class node: def __init__(self,value): self. value = value self. text = none. Question 1: let"s practice with this linked list node. Show the linked list that is created by the following code. a = node(4) a. next = node(5) = node(6) c = a. next c. next = b a: 4->5->6->none b: 6->none c: 5->6->none. Question 2: explain in plain english the purpose of each of the following functions. def mystery1 (lnk: noe): #purpose? while lnk and lnk. next: lnk. next = lnk. next. next lnk = lnk. next. Mystery1 deletes every node except for the third. Deletes every other node in the linked lists. If odd number of nodes, delete all but last; if even number, delete all nodes. Makes first three nodes be the same as the third node.

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