Karteikarten
Week 4: Sorting & Understanding Python

Karten in diesem Stapel (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
Informationen
- Beschreibung
- Computer Science (FIT1045: Algorithms & Programming Fundamentals in Python) Karteikarten am Week 4: Sorting & Understanding Python, erstellt von Melina Mackey am 02/09/2019.
- Erstellt von
- Melina Mackey
- Aufrufe
- 0
- Verlauf
-
- Erstellt von Melina Mackey · 2 Sep 2019
- Kopiert von Melina Mackey · 2 Sep 2019
- Kopiert von Melina Mackey · 2 Sep 2019
- Bewertung