/compSci

Basic implementations of common data structures and algorithms for personal edification

Primary LanguageC++

Waxing lyrical about computer science things

This is a set of basic implementations of common CS algorithms and data structures, along with a few applications in exercise form. The material covered here is largely motivated by GeeksForGeeks articles and "Cracking the Coding Interview" book, both of which I highly recommend.

Covered so far (in some form or another)

Algorithms

  • Quicksort
  • Merge sort
  • Radix sort
  • Shortest distance from start node to all nodes in a graph (Dijkstra)
  • BFS (see problems below)
  • Basic DFS to find connected node with given value
  • Edit distance (Levenshtein - rederived this one actually! sans one bug... )
  • Arbitrary precision arithmetic sum (product is the hard/important one though...)
  • Basic linked list operations (reversal, cycle detection; not optimized)

Data structures

  • Max heap
  • Graph (not very well though)
  • Linked list (even worse than graph)
  • Hash map

Classic problems

  • 1/0 Knapsack
  • Coin change
  • Permutations of a string
  • Largest Sum Contiguous Subarray problem (brute force and my own attempt at homegrown Kadane)
  • Remove invalid parentheses in string with fewest number of deletions using BFS (finds multiple solutions)
  • Robot maze
  • Floodfill
  • All valid string with N parenthesis
  • Find contiguous subarray with sum = S
  • Find max j-i in array A such that A[i]<A[j]
  • Check if two strings interleave to give a third
  • Find all subsets of a given set
  • Tower of Hanoi