deletetop

py

School

Texas A&M University, Commerce *

*We aren’t endorsed by this school

Course

241

Subject

Computer Science

Date

Nov 24, 2024

Type

py

Pages

1

Uploaded by ElderRockAnteater16

Report
#Deletion in Linked List from the beginning class Node: def __init__(self, x): self.val = x self.next = None class LinkedList: def __init__(self, node: Node = None): self.head = node def deleteAtBeginning(self): if self.head is not None: self.head = self.head.next else: print("Linked List is empty. Nothing to delete") def printList(self): temp = self.head while temp: print(temp.val, end=" ->") temp = temp.next print("None") node1 = Node(1) node1.next = Node(2) node1.next.next = Node(3) node1.next.next.next = Node(4) node1.next.next.next.next = Node(5) linkedlist = LinkedList(node1) linkedlist.deleteAtBeginning() linkedlist.printList()
Discover more documents: Sign up today!
Unlock a world of knowledge! Explore tailored content for a richer learning experience. Here's what you'll get:
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help