COSC 3320 | Algorithms Resources
December 18, 2023
Resources | Videos and Readings
- MIT Open Courseware Intro to Algorithms
- MIT Open Courseware Algorithm Design and Analysis
- Neetcode 150
- Book of Proof
- Abdul Bari
- Michael Sambol
- UASCO Competitive Programming Handbook
Leetcode Problems
Divide and Conquer
- Search in Rotated Sorted Array
- Find Peak Element
- Single Element in a Sorted Array
- Koko Eating Bananas
- Median of Two Sorted Arrays
- Balance a Binary Search Tree
- Construct Binary Tree from Preorder and Inorder Traversal
Backtracking
Dynamic Programming
- Longest Common Subsequence
- Edit Distance
- Interleaving String
- Target Sum
- Minimum Falling Path Sum
- Longest Increasing Subsequence
- Wiggle Subsequence
Graphs
MST Prim & Kruskal
class UnionFind:
def __init__(self, n):
self.parents = {}
self.rank = {}
for i in range(1, n + 1):
self.parents[i] = i
self.rank[i] = 0
def find(self, nd):
p = self.parents[nd]
while p != self.parents[p]:
self.parents[p] = self.parents[self.parents[p]]
p = self.parents[p]
return p
def union(self, nd1, nd2):
p1, p2 = self.find(nd1), self.find(nd2)
if p1 == p2:
return False
if self.rank[p1] > self.rank[p2]:
self.parents[p2] = p1
elif self.rank[p2] > self.rank[p1]: