In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, I would like to share with you how to use Python to emulate the C language to achieve linear table sequential storage structure of the relevant knowledge points, detailed content, clear logic, I believe that most people are too aware of this knowledge, so share this article for your reference, I hope you can learn something after reading this article, let's take a look at it.
Code:
#! / usr/bin/env python#-*-coding: utf-8-*-_ _ author__ = 'MrHero' class Node (object): the storage structure of the linear table is similar to the chain storage structure of the C language def _ init__ (self) Data=None): self.data = data self.next = None class LKList (object): "specific operation of the linear table"def _ _ init__ (self):"is equivalent to initializing the linear table, that is, creating a header node with an empty header node. The created table with position number 0 is: header node [0]-> node [1]-> node [2]-> node [3]-> node [4]: return: "self.L = Node (None) self.L.next = None self.length = 0 def is_empty (self):" determine the length of the new table: return: " "return self.length = = 0 def get_length (self):" get the length of the new table of the line: return: "return self.length def insert (self I Elem): "" at the location I disposal insert element elem: param I: specified location: param elem: inserted element elem: return: "" j = 0 p = self.L while j < iMui 1 and p is not None: # look up iMui 1 node j + = 1 p = p.next if p is None: # No logic found The node raise IndexError ("Index is out of range!") with the order of iMur1 Else: # find the node with logical bit order tmp = Node (elem) tmp.next = p.next p.next = tmp self.length + = 1 def delete (self) I): "" delete the element of the specified node: param I: specified node: return: deleted specified node element value "" if self.is_empty (): raise IndexError ("The list is empty!") Elif 0 < I
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.