type
Post
status
Published
date
Jul 24, 2023
slug
cs-61a-11
summary
Study Python Mutable Sequences in CS 61A.
tags
CS61A
CS
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 许可协议,转载请注明出处。
相关文章

.png?table=block&id=e6a0d7df-d54f-4470-a912-e62f7c9728aa&t=e6a0d7df-d54f-4470-a912-e62f7c9728aa&width=1080&cache=v2)


.png?table=block&id=fa81f9ab-c0da-4f4e-a935-0567380c36d0&t=fa81f9ab-c0da-4f4e-a935-0567380c36d0&width=1080&cache=v2)
.png?table=block&id=55df38cd-a361-41ee-a75d-c17615e78d6b&t=55df38cd-a361-41ee-a75d-c17615e78d6b&width=1080&cache=v2)
_(1).jpg?table=block&id=a716c7ee-7105-4a3f-8133-a15129086419&t=a716c7ee-7105-4a3f-8133-a15129086419&width=1080&cache=v2)
.jpg?table=block&id=2e9784d9-1d6e-44fc-9106-f0c576ddcb8f&t=2e9784d9-1d6e-44fc-9106-f0c576ddcb8f&width=1080&cache=v2)

.png?table=block&id=c0772cdb-ee08-49f4-b2f3-c804586bb769&t=c0772cdb-ee08-49f4-b2f3-c804586bb769&width=1080&cache=v2)

.png?table=block&id=b43ea4ae-a57d-4962-80ba-12280979702b&t=b43ea4ae-a57d-4962-80ba-12280979702b&width=1080&cache=v2)
