In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you the "python double-ended linked list example analysis", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "python double-ended linked list example analysis" this article.
1. A node of a double-ended linked list has two pointers, pointing to the previous node and the latter node, respectively.
2. Double-ended linked list is a data structure composed of prev (front-drive pointer) and next (rear-drive pointer).
These two are used to build the relationship between nodes.
Example
Class DoubleNode: def _ _ init__ (self,item): self.item = item self.next = None self.prior = None class HandleDouNode: def create_node_head (self Li): head = DoubleNode (li [0]) for element in li [1:]: node = DoubleNode (element) node.next = head # the pointer of the new node is linked to the original head node head.prior = node # the previous pointer of the original head node is linked to node head = node # the header node points to node return head def create_node_tail (self Li): head = DoubleNode (li [0]) tail = head for element in li [1:]: node = DoubleNode (element) tail.next = node # the next pointer of the original tail node is linked to the node node.prior = tail # node node the previous pointer is connected to the original tail tail = node # modify the tail finger The needle is node return head def print_node (self Head): while head: print (head.item,end=',') head = head.next hdn = HandleDouNode () head = hdn.create_node_tail print (head.item) print (head.next.item) print (head.next.prior.item) "" OUT121 "above are all the contents of the article" sample Analysis of python double-ended linked lists " Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.