Flashcards
Week 4: Sorting & Understanding Python

Flashcards do conjunto (10)
- 1Sorting problem

- 2Selection sort

- 3Insertion sort

- 4Selection vs insertion sortSelection sort skips the last item, as it is already sorted
Insertion sort skips the first item, as it is already sorted - 5Python objects and variables- Objects have a type, identity and type-specific content
- Variables are named references to objects
- Assignment operation creates a variable if necessary (if the value exists, it points to it)
- Objects disappear (are deleted) when no longer referenced
- Variables exist until explicitly deleted or frame is discarded (when leaving function) - 6Python functions- Are also objects with an identifier
- References to functions can be passed to other variables
- Function execution has own frame of local variables
- Local variables for parameters are created on call - 7Methods for swapping references1. Creating a temporary variable
2. Using multiple assignment (tuples) - 8List mutability and equality- Lists are objects containing a mutable sequence of references => list values change without being reassigned
- Setting a variable equal to "[…]" expression creates a new list
- However assignment (e.g. lst1 = lst2) assigns reference to existing object
- Same objects are always equal, but equal objects don't always have the same identity - 9Copying a list- Shallow copy (e.g. slicing the original list or using copy from the copy module) is
not guaranteed to work => only copies references and not the object referenced
- Deep copy recursively copies referenced objects, creating an independent copy of original object - 10Augmented assignment with mutable objects
Informações
- Descrição
- Computer Science (FIT1045: Algorithms & Programming Fundamentals in Python) FlashCards sobre Week 4: Sorting & Understanding Python, criado por Melina Mackey em 02-09-2019.
- Criado por
- Melina Mackey
- Visualizações
- 0
- Histórico
-
- Criado por Melina Mackey · 2 set 2019
- Copiado por Melina Mackey · 2 set 2019
- Copiado por Melina Mackey · 2 set 2019
- Avaliação