zoukankan      html  css  js  c++  java
  • 学习笔记之Problem Solving with Algorithms and Data Structures using Python

    Problem Solving with Algorithms and Data Structures using Python — Problem Solving with Algorithms and Data Structures

    Introduction · python-data-structure-cn

    • https://facert.gitbooks.io/python-data-structure-cn/

    Problem Solving with Algorithms and Data Structures Using Python SECOND EDITION: Bradley N. Miller, David L. Ranum: 9781590282571: Amazon.com: Books

    • https://www.amazon.com/Problem-Solving-Algorithms-Structures-Python/dp/1590282574
    • THIS TEXTBOOK is about computer science. It is also about Python. However, there is much more. The study of algorithms and data structures is central to understanding what computer science is all about. Learning computer science is not unlike learning any other type of difficult subject matter. The only way to be successful is through deliberate and incremental exposure to the fundamental ideas. A beginning computer scientist needs practice so that there is a thorough understanding before continuing on to the more complex parts of the curriculum. In addition, a beginner needs to be given the opportunity to be successful and gain confidence. This textbook is designed to serve as a text for a first course on data structures and algorithms, typically taught as the second course in the computer science curriculum. Even though the second course is considered more advanced than the first course, this book assumes you are beginners at this level. You may still be struggling with some of the basic ideas and skills from a first computer science course and yet be ready to further explore the discipline and continue to practice problem solving. We cover abstract data types and data structures, writing algorithms, and solving problems. We look at a number of data structures and solve classic problems that arise. The tools and techniques that you learn here will be applied over and over as you continue your study of computer science.

    • 1.8.2. Built-in Collection Data Types 
    Table 3: Methods Provided by Lists in Python
    Method NameUseExplanation
    append alist.append(item) Adds a new item to the end of a list
    insert alist.insert(i,item) Inserts an item at the ith position in a list
    pop alist.pop() Removes and returns the last item in a list
    pop alist.pop(i) Removes and returns the ith item in a list
    sort alist.sort() Modifies a list to be sorted
    reverse alist.reverse() Modifies a list to be in reverse order
    del del alist[i] Deletes the item in the ith position
    index alist.index(item) Returns the index of the first occurrence of item
    count alist.count(item) Returns the number of occurrences of item
    remove alist.remove(item) Removes the first occurrence of item
    Table 4: Methods Provided by Strings in Python
    Method NameUseExplanation
    center astring.center(w) Returns a string centered in a field of size w
    count astring.count(item) Returns the number of occurrences of item in the string
    ljust astring.ljust(w) Returns a string left-justified in a field of size w
    lower astring.lower() Returns a string in all lowercase
    rjust astring.rjust(w) Returns a string right-justified in a field of size w
    find astring.find(item) Returns the index of the first occurrence of item
    split astring.split(schar) Splits a string into substrings at schar
    Table 5: Operations on a Set in Python
    Operation NameOperatorExplanation
    membership in Set membership
    length len Returns the cardinality of the set
    | aset otherset Returns a new set with all elements from both sets
    & aset otherset Returns a new set with only those elements common to both sets
    - aset otherset Returns a new set with all items from the first set not in second
    <= aset <= otherset Asks whether all elements of the first set are in the second
    Table 6: Methods Provided by Sets in Python
    Method NameUseExplanation
    union aset.union(otherset) Returns a new set with all elements from both sets
    intersection aset.intersection(otherset) Returns a new set with only those elements common to both sets
    difference aset.difference(otherset) Returns a new set with all items from first set not in second
    issubset aset.issubset(otherset) Asks whether all elements of one set are in the other
    add aset.add(item) Adds item to the set
    remove aset.remove(item) Removes item from the set
    pop aset.pop() Removes an arbitrary element from the set
    clear aset.clear() Removes all elements from the set
    Table 7: Operators Provided by Dictionaries in Python
    OperatorUseExplanation
    [] myDict[k] Returns the value associated with k, otherwise its an error
    in key in adict Returns True if key is in the dictionary, False otherwise
    del del adict[key] Removes the entry from the dictionary
    Table 8: Methods Provided by Dictionaries in Python
    Method NameUseExplanation
    keys adict.keys() Returns the keys of the dictionary in a dict_keys object
    values adict.values() Returns the values of the dictionary in a dict_values object
    items adict.items() Returns the key-value pairs in a dict_items object
    get adict.get(k) Returns the value associated with kNone otherwise
    get adict.get(k,alt) Returns the value associated with kalt otherwise
    • 1.9. Input and Output
      • aName = input('Please enter your name: ')
  • 相关阅读:
    格式化Format使用
    ASP.NET几种清除页面缓存的方法
    repeater中分页aspnetpager是遇到的问题
    利用正则表达式去掉html代码
    ASP.NET母版页中调用内容页的方法和web用户控件调用.aspx页面里的方法
    PHP常用代码大全
    用 JA Transmenu 模块做多级弹出菜单
    简单的 "改变" joomla 后台administrator目录
    数据库设计中的14个技巧
    Joomla模板制作教程(转)
  • 原文地址:https://www.cnblogs.com/pegasus923/p/10454395.html
Copyright © 2011-2022 走看看