TIL: Internet Protocol RFC 760, MIT Algorithms Course, and Mathematics for Computer Science
Today I learned about the foundational Internet Protocol specification from 1980, MIT's comprehensive algorithms course, and their mathematics for computer science curriculum.
The principles established in RFC 760 continue to influence modern networking, despite the transition from IPv4 to IPv6 and the addition of numerous extensions and optimizations.
# Breadth-first search for shortest pathsfromcollectionsimportdequedefbfs_shortest_path(graph,start,end):"""
Time Complexity: O(V + E)
Space Complexity: O(V)
"""ifstart==end:return[start]queue=deque([(start,[start])])visited={start}whilequeue:node,path=queue.popleft()forneighboringraph[node]:ifneighbornotinvisited:new_path=path+[neighbor]ifneighbor==end:returnnew_pathqueue.append((neighbor,new_path))visited.add(neighbor)returnNone# No path found
# Probability distributions in algorithm analysisimportrandomdefexpected_comparison_quicksort(n):"""
Expected number of comparisons in quicksort
E[X] = 2(n+1)H_n - 2n where H_n is nth harmonic number
"""harmonic_n=sum(1/iforiinrange(1,n+1))return2*(n+1)*harmonic_n-2*n# Random algorithm exampledefrandomized_quickselect(arr,k):"""
Expected time: O(n)
Worst case: O(n²)
"""iflen(arr)==1:returnarr[0]pivot=random.choice(arr)less=[xforxinarrifx<pivot]equal=[xforxinarrifx==pivot]greater=[xforxinarrifx>pivot]ifk<len(less):returnrandomized_quickselect(less,k)elifk<len(less)+len(equal):returnpivotelse:returnrandomized_quickselect(greater,k-len(less)-len(equal))
These foundational resources provide the mathematical and algorithmic thinking skills essential for advanced computer science work, from protocol design to efficient algorithm implementation.