• Leetcode


    1. 多行注释:ctrl + /

    2. enumerae()函数

    将一个可遍历的数据对象组合为一个索引序列,同时列出数据和数据下标,如:

    seq = ['one', 'two', 'three']
    for i, element in enumerate(seq):
      print(i, element)

    0 one

    1 two

    3 three

    3. find shortest string in list, key=len可忽略

    min(list_name, key = len)

    4. 取余数:%,整除(向下取整)://

    5. Tree

    Binary Search Tree作用:speed up our binaryy search as we are able to find items faster

    Tree traversal: traversing means visiting and outputting the value of each node in a particular order

    *3种Depth First Traversals*

    a) In-order: In the case of binary search trees (BST), Inorder traversal gives nodes in non-decreasing order

    Until all nodes are traversed-
    Step 1: recursively traverse left subtree
    Step 2: visit root node
    Step 3: recursively traverse right subtree

    b) Pre-order: Preorder traversal is used to create a copy of the tree. Preorder traversal is also used to get prefix expression on an expression tree

    Until all nodes are traversed-
    Step 1: visit root node
    Step 2: recursively traverse left subtree
    Step 3: recursively traverse right subtree

    c) Post-order: Postorder traversal is used to delete the tree or get the postfix expression of an expression tree

    Until all nodes are traversed-
    Step 1:recursively traverse left subtree
    Step 2: recursively traverse right subtree
    Step 3: visit root node

    Depth First Traversals: 
    (a) Inorder (Left, Root, Right) : 4 2 5 1 3 
    (b) Preorder (Root, Left, Right) : 1 2 4 5 3 
    (c) Postorder (Left, Right, Root) : 4 5 2 3 1

  • 相关阅读:
    推荐一个简洁优雅的博客系统,farbox
    flash从数据流判断图片格式防止xss攻击
    iBatis框架batch处理优化 (转)
    hadoop环境中误删除tmp文件夹的恢复
    Mysql04
    MapReduce中文翻译
    Big Table中文翻译
    GFS中文翻译
    HDFS读写流程
    两个网卡的设置
  • 原文地址:https://www.cnblogs.com/eleni/p/16077827.html
Copyright © 2020-2023  润新知