Please enable JavaScript.
Coggle requires JavaScript to display documents.
IMP TOPICS for COL - Coggle Diagram
IMP TOPICS for COL
Data structures
Hashing
Stacks
Backtracking
Dictionary
Functional
Curring
Map and filter
Tail recursion
SML VS PYTHON
List
Sml
All elements same type
Immutable no assignment of element
Only first accessible in O(1)
Hd and tl
Length find O(N)
Different types of list
Python
Different type allowed
Mutable
Assignment allowed
Random acess
Time O(1)
Access any location in list
Len O(1)
Append only changes doesn't return
So does extend and
Pop return the poped element
PositiveIndices 0 to len-1
Negative index -1to -len
Type is list
Slicing useful
Beware second index
Order of number of elements inslice
Adding only at end
Square bracket
LENGTH
Tuples
Any types mixed
Immutable in both
Single tuple in python
SYNTAXES
CONDITIONALS
SML
KEY DIFFERENCE THAT BOTH ELSE AND IF MUST GIVE THE SAME TYPE OF EXPRSSION IN RETURN
IF THEN ELSE
PYTHON
IF : ELSE:
OPERATORS
REAL SML SAME AS PYTHON EXCEPT NO %
SML
INTS
MOD INSTEAD OF % IN PYTHON
DIV INSTEAD OF // IN PYTHON
LESS THAN EQUAL TO <> SML PYTHON !=
PYTHON EQUALITY TEST == VS = IN SML
BOOLEAN
ANDALSO
AND IN PYTHON
ORELSE
OR IN PYTHON
NOT
STRING
SIZE VS LEN
^ VS +
DEFINE VARIABLES
VAL X = VS X=
LET IN END
Sorting
Stable sorting
Iterative merge sort
Save space
Oscillation between two units of memory
Keep track of where to write where you are present
Use index rather than silcing
Merge lists of 1 size then size 2 until size =lenof original list
But there might be uneven merge
Keep track of the size of the largest sorted group
Keep track where is it located
Keep track where it will go in the next merge operation
Each time we change level we change to where amd from where we move elements
We need a function to pair the groups
We also need a function to merge to pairs
Time and space complexietyb
Keep in mind whether in sml or python
What are the differences and where
REMBER THAT WE CAN WRITE O(N) = CN
Proving correctness
Invariants
Focus on what is need for into work
For that think how it can fail
Is it sufficient
Given loop may require more than one invariant
Raher than fitting everything I one invariant split them
Termination keep in track all the possiblecases
REVISION
INTEGER SQRT
ITERATIVE
RECURSIVE
OOP
DP
FLOATING POINT ARTHMETIC
Parameter passing
Variable scope