[history from the beginning] No. 298 quarter time history about the black hole.

Source: Internet
Author: User

plot summary:
Dr. Stephen Hawking's "Brief History of Time", mainly about black holes, about black holes, what need to know?

Drama Start:
Star Calendar July 11, 2016 17:02:46, the Milky Way Galaxy Earles the Chinese Empire Jiangnan Line province.

[Engineer Ah Wei] is working with [machine Wei] to study [The history of time about black holes].










Easter eggs: (for stacks, queues, binary tree python implementations, just a preliminary implementation)

<span style= "FONT-SIZE:18PX;"     >#### @usage Data Structure Summary, increasing in # @author mw# @date July 11, 2016 Monday 10:06:56 # @param # @return # # # # # # # # # #栈 class Stack: def __init__ (self, size = +): Self.stack = [] self.size = Size Self.top =-1 def sets Ize (self, size): self.size = size def isEmpty (self): if self.top = = -1:return Tru             E Else:return False def isfull (self): if self.top + 1 = = Self.size:             Return True Else:return False def top (self): if Self.isempty (): Raise Exception ("Stackisempty") Else:return Self.stack[self.top] def push (Self,obj)        : If Self.isfull (): Raise Exception ("StackOverflow") #self. SetSize (self.size*=2); Else:self.stack.append (obj) self.top +=1 def pop (self): if Self.isempty ():            Raise Exception ("Stackisempty") else:self.top-= 1 return Self.stack.pop ()         Def show (self): print (self.stack) def test (self): s = Stack (5) s.push (1)         S.push (2) S.push (3) S.push (4) S.push (5) S.show () S.pop () s.show () S.push (6) s.show () #队列 class Queue:def __init__ (Self,size = +): Self.queue = [] Self.size             = Size Self.front = 0 self.rear = 0 def setSize (self, size): Self.size = size def isEmpty (self): return self.rear = = 0 def isfull (self): if (self.front-self.rear + 1) = = Self.size:return True Else:return False def first (self): if SE                 Lf.isempty (): Raise Exception ("Queueisempty") Else:return Self.queue[self.front] Def last (self):        If Self.isempty (): Raise Exception ("Queueisempty") Else:return self.queue[self.re AR] def add (self,obj): If Self.isfull (): Raise Exception ("Queueoverflow") Else : Self.queue.append (obj) self.rear + = 1 def delete (self): if Self.isempty ( ): Raise Exception ("Queueisempty") Else:self.rear-=1 return Self.queue.pop (0 ) def show (self): print (self.queue) def test (self): q = Queue (3) Q.add (1) Q. Add (2) q.show () Q.delete () q.show () #二叉树, use the queue () class Binarytreenode:def __init__ (Self,dat     A,left,right): Self.left = left self.data = Data Self.right = Right class BinaryTree: def __init__ (self): Self.root = None def maketree (self,data,left,right): Self.root = Binarytre Enode (data,left,right) #Left.root = Right.root = None def isEmpty (self): If Self.root is None:return True Else:return False def preorder (self,r): If R.root is not None:print (R.root.da TA) if R.root.left is not None:self.preOrder (r.root.left) if r.root.right are not             None:self.preOrder (r.root.right) def inorder (self,r): If R.root is not None: If R.root.left is not None:self.inOrder (r.root.left) print (r.root.data) i F r.root.right is not None:self.inOrder (r.root.right) def postorder (SE             LF,R): If R.root is not none:if r.root.left are not None:self.preOrder (r.root.left)         If R.root.right is not None:self.preOrder (r.root.right) print (r.root.data) def levelorder (self, a): Q = Queue () R = a while r are not None:print (r.root.data) if R.ROOT.L EFT is not None:q.add (r.root.left) If r.root.right are not None:q.add (r.root. right) if Q.isempty (): Print ("empty") R = None Els         E:r = Q.delete () def test (self): R = BinaryTree () RA = BinaryTree ()         Ra.maketree (2,none,none) RB = BinaryTree () rb.maketree (3,none,none) r.maketree (1,RA,RB) Print ("Pre-sequence Traversal") R.preorder (r) Print ("middle order Traversal") R.inorder (r) Print ("Post-order traversal") R.postord ER (r) print ("Hierarchical Traversal") R.levelorder (R) def findtree (self, prelist,inlist,postlist): If Len (prelis          T) ==0:return if Len (prelist) ==1:postlist.append (prelist[0]) return     ROOT=PRELIST[0]     n = inlist.index (root) self.findtree (prelist[1:n+1],inlist[:n],postlist) self.findtree (prelist[n+1: ],inlist[n+1:],postlist) postlist.append (Root) #已知前序遍历结果和中序遍历结果, the post-order traversal def test2 (self): Prelist=list (          ' DBACEGF ') midlist=list (' ABCDEFG ') afterlist=[] Self.findtree (prelist,midlist,afterlist)    Print (afterlist) if __name__ = = ' __main__ ': stack = stack ();    Stack.test ();    Queue = Queue ();    Queue.test ();    Btree = BinaryTree ();    Btree.test (); Btree.test2 ();</span>

The end of this section, to know how to funeral, please see tell.

[history from the beginning] No. 298 quarter time history about the black hole.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.