GoConqr has a new look! Let us know what you think.

Flashcards

Week 4: Sorting & Understanding Python

Melina Mackey Computer Science English 10 cards

Week 4: Sorting & Understanding Python

Cards in this deck (10)

  1. 1Sorting problemSorting problem
  2. 2Selection sortSelection sort
  3. 3Insertion sortInsertion sort
  4. 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
  5. 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)
  6. 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
  7. 7Methods for swapping references1. Creating a temporary variable
    2. Using multiple assignment (tuples)
  8. 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
  9. 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
  10. 10Augmented assignment with mutable objects

Information

Description
Computer Science (FIT1045: Algorithms & Programming Fundamentals in Python) Flashcards on Week 4: Sorting & Understanding Python, created by Melina Mackey on 02/09/2019.
Created by
Melina Mackey
Views
0
History
  • Created by Melina Mackey · Sep 2, 2019
  • Copied by Melina Mackey · Sep 2, 2019
  • Copied by Melina Mackey · Sep 2, 2019
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?