Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Linked List
Lancelot03
Lancelot03

Posted on • Edited on

     

Linked List

Linked List Creation--

class Node:   # Node Creation    def __init__(self, data):        self.data=data        self.ref=None class LinkedList:   # Connecting the nodes    def __int__(self):        self.head=None    def print_ll(self):  # Printing of the created linhed list        if self.head is None:            print("Linked list is empty")            return        n=self.head        while n:            print(n.data)            n=n.refnode1 =Node(10)   # Given the vazlue in the 1st nodenode2=Node(2)   # Giving the value in the second nodeq1=LinkedList()  # Calling the Linkeglist functionq1.head=node1  # pointing of q1 as a head nodenode1.ref=node2   # storing the addresss of the 2nd node into                     first nodeq1.print_ll()  # printing of q1
Enter fullscreen modeExit fullscreen mode

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

If you like my posts then please follow me on GitHub for more Coding Problems and Projects :-)
  • Joined

More fromLancelot03

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp