type
status
date
slug
summary
tags
category
icon
password
Property
Jul 24, 2023 10:25 AM

Announcement


Where are We in CS61A?



What are Continers Good For?
- Allow us to store related values together
- Can process the values one-by-one or inaggregate
- Allows us to from compound values through data abstraction
- Give rise to a number of ways of storing values
- Lists store values in order,associated with an index
- Dictionaries have no order but associated values with any sort of key
- Trees allow for a hierarchical representation od data
The Many Use of Trees
Trees show up in:
- Efficiently searching data (e.g. Autocomplete)
- Artifficial Intelligence (Game Trees/the minimax algorithm)
- Machine Learning (Decision Trees)
- Computational Biology (Suffix Trees, Phylogenetic Trees)
- Programming Languages (Syntax and Expression Trees)
- Operating Systems (File Structure)

Mutability
- Data abstraction allows us to think about compound values as units, or objects
- But compound values have state that change over time; they are mutable
- So far, we treated all our values as immutable; we only created new objects, never changing them


记住:赋值的行为

Mutation Operations
Add Element
extend 针对的是铺平多个元素
Remove Element
pop 默认删除最后一个元素,也可以指定索引删除,返回删除的元素
remove() 函数用于移除列表中某个值的第一个匹配项,没有返回值


- 作者:Kitety
- 链接:https://www.kitety.com/article/cs-61a-11
- 声明:本文采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。
相关文章