An ISortable object must have a .sort() method. e.g. DoublyLinkedList(LinkedList).
"15 Sorting Algorithms in 6 Minutes"
- # of comparisons
- # of array accesses
... Big-O Cheat Sheet
- "Array Sorting Algorithms"
- Time Complexity: Best, Average, Worst
- Space Complexity: Worst
I don't have K12 students.
It's important to learn OOP. There really is a push back from OOP-over-abstraction to functional with interfaces by convention with e.g. Go,. As a multi-paradigm language built on C (not C++ (OOP which predates Java)), programs can be written in many styles with Python.
There is - some might argue negligible - overhead to each function call. Is there a good way to do compile-time interface checking with Python? Why not?
zope.interface is probably the most popular way to do 'actual' interfaces in Python.
Pyramid framework has zope.interface interfaces.
- IResponse
- IRequest (a 'marker' interface)
An OOP exercise:
# Namespacing
def area_of_a_rectangle()
def perimeter_of_a_rectangle()
def shape__rectangle__area()
def shape__square__area()
# Inheritance, Interfaces, Parameters
class Shape()
def __init__(*args, **kwargs): # *
def area()
def perimeter()
def height/width/[depth]()
# physical units
# class Number(float):
# def __init__(value, unit=)
class Square()
class Rectangle()
class Triangle()
Sorting, [multiple] database indexes (import sqlite), and tree-balancing may be appropriate to teach or mention together or in an optimal sequence.
- OOP
sorted() is implemented with/as a Timsort (and expects an interface (is it __cmp__, __gt__, __lt__, AND __eq__?)).