RAM
- The role of the computer
- For storing binary data and computing
- A measure of computer memory size unit:
- bit (bit):
- Byte: 8bit
- kb: 1024 bytes
- mb:1024kb
- Question: How computer to calculate 1 + 2?
- It must open up memory space in the computer's memory
- Only the corresponding value stored in the memory
- The concept of variables
- a = 10 meaning representation in a computer (memory map)
- After a good memory space opened up, every piece of memory space will have two default properties
- The size of the memory space: computer memory size unit
- Memory address space: hexadecimal value
- Address effect: for positioning (tracking) the specified memory, can obtain the data stored in the memory
- Variable represents the essence of memory address space, usually a variable is intended to represent the memory address corresponding to the memory space
- A = appreciated that the memory 10 (reference point)
- Quote: Variable
- Point: If a certain variable / address of a reference stored in a memory, it means that the variable pointing to the memory address of the memory space corresponding to.
- The size of the memory space occupied by different data
Order table
- Elements of the container / data structure is stored in sequential, the structure of sequence table can be divided into two forms: a single data type (numpy) and multiple data types (list).
- python lists and tuples belong to multiple data types order table
- Single data type sequence table memory map (memory continuously open)
- Multiple Data Types FIG sequence table memory (RAM discontinuous open)
- Malpractice order of the table: the order table structure needs to know in advance the size of the data to apply continuous storage space, time and needs to be expanded during the relocation of data.
No data with respect to the order of the relocation table, list structure may take advantage of computer memory, dynamic memory management for flexible and augmented: list.
- List (Linked list) is a common basic data structures, a linear table, as sequence table but not continuously stored data, but each node information (data storing means) stored in the next node ( That address)
. Is_empty (): the list is empty
. Length (): chain length
. Travel (): traverse the entire list
. Add (item): Adding the head of the list elements
. Append (item): the tail of the list to add elements
. Insert (pos, item): add elements specified location
. Remove (item): Delete Node
. Search (item): Find node if there is
# Each class the Node (): DEF __init __ (Self, Item): self.item = Item self.next = None # list class Link (): # create an empty list DEF __init __ (Self): self._head = None # head of the chain add data DEF the Add (Self, Item): # instantiated Node = the Node (Item) when # note is not empty, how to add node.next = self._head self._head = Node # display lists def travel (Self): CUR = self._head the while CUR: Print (cur.item) CUR = cur.next # chain length DEF length (Self): COUNT = 0 CUR = self._head the while CUR: COUNT + = . 1 CUR = cur.next return COUNT DEF isEmpty (Self) : return self._head == None # Add the tail of the list DEF the append (Self, Item): the Node = the Node (Item) # list is empty IF self.isEmpty (): self._head =node return # 链表不为空 cur=self._head pre=None while cur: pre=cur cur=cur.next pre.next=node # 查找 def search(self,item): flag=False cur=self._head while cur: if cur.item==item: flag=True break CUR = cur.next return In Flag # inserted DEF INSERT (Self, POS, Item): # insertion position error length = self.length () IF POS < . 1 or POS> length: Print ( ' POS Error ' ) return the else : Node = the Node (Item) # inserted assumed a start value. 1 CUR = self._head pre = None for I in Range (POS- . 1 ): Pre = CUR CUR = cur.next pre.next = the Node node.next = CUR # Delete to delete the first element encountered DEF the Remove (Self, Item): CUR = self._head pre = None # delete is the first node IF cur.item == Item: self._head = self._head.next return # delete a node is not the first the while CUR: IF cur.item == Item: pre.next =cur.next break else: pre=cur cur=cur.next #链表图 link=Link() link.append(1) link.append(2) link.append(3) # link.travel() # print(link.length()) # print(link.isEmpty()) # print(link.search(4)) # link.insert(2,1) link.remove(1) link.travel()