Professional Documents
Culture Documents
Python Data Structures Cheat Sheet PDF
Python Data Structures Cheat Sheet PDF
Average
Lists and Tuples in Python Algorithm Best case
case
Worst case Remarks Dictionaries
Selection n exchanges,
Ordered sequence of values indexed by integer numbers. Tuples are immutable ½n2 ½n2 ½n2 It is an unordered set of key value pairs
sort quadratic is the best case
CHEAT SHEET
• To specify size of tuple/list: • Initialize an empty Dict
Insertion Used for small or partial-
• To initialize empty list /tuple: n ¼n2 ½n2 Syntax: myDict = {}
Synatx: len(myListOrTuple) sort sorted arrays
Syntax: Lists: myList = [] • Add an element with key "k" to the Dict
• Remove element in position X of list/tuple: Rarely useful,
Tuples: myTuple = () Bubble Syntax: myDict["k"] = value
n ½n2 ½n2 Insertion sort can be used
• To get an element in position x in list/tuple: Syntax: Lists: del myList[x] sort • Update the element with key "k"