C Lang, Gorshenin, 2015

View Fullscreen

Reference cards (cheat sheets) collection.

Main algorithms to use.

Basic algorithms :

  • Sorting – Merge Sort, Insertion Sort, Quick Sort, Number of inversions
  • Matrix Multiplication (just know the algo if not implement it)
  • Prime Sieving
  • Modular Math including multiplication and division
  • Euclidean Algorithm for GCD, Modular Inverse, Fast Exponentiation
  • Fibonacci number with matrix multiplication
  • Probability distribution and expected value
  • Stats – Mean, Median, Variance, Bayes theorem

Linear data structures and algorithms:

  • Arrays
  • Linked List
  • Stack
  • Queues

Algorithmic techniques:

  • Divide and Conquer – Binary Search, Maximum Subarray
  • Greedy Algorithms – Activity Selection, Huffman encoding
  • Dynamic Programming – Matrix Chain Multiplication, Knapsack,
  • Linear Programming – Variable Maximisation, Linear time sorting
  • String Algorithms – Manacher, LCS, Edit Distance

Typical non-linear data structures:

  • Trees – Binary Tree, General Tree, Lowest Common Ancestor
  • Binary Search Tree – Inorder Traversal, Level order traversal, finding kth largest element, diameter, depth, number of nodes, etc.
  • Heaps – Array Implementation, Heapify, Heap Sort
  • Union Find
  • Hash Table – Linear Probing, Open addressing, Collision avoidance


  • Adjacency List, Adjacency Matrix, Weighted Edge Graphs
  • Basic Traversal algos – Breadth First Search, Depth First Search, etc
  • Shortest Path Finding Algorithm – Dijkstra, Floyd Warshal, Bellman Ford
  • Minimum Spanning Tree – Kruskal’s Algo, Prim’s Algo

Advance Tree and Graph :

  • Balanced Trees – AVL, Red-Black
  • Heavy Light Decomposition, B+ Trees, Quad Tree
  • Advance Graph – Min Cut, Max Flow
  • Maximum Matching – Hall’s Marriage
  • Hamiltonian Cycle
  • Edge Graphs / Line Graphs
  • Strongly Connected Components
  • Dominant Sub-Graph, Vertex Cover, Travelling Salesman – Approx algos

Advance String Algorithms :

  • Knuth Morris Pratt Algorithm
  • Rabin Karp Algorithm
  • Tries and Compressed Tries
  • Prefix Trees, Suffix Trees, Suffix Automation – Ukkonen Algorithm

Advance Math:

  • Fast Fourier Tranformation
  • Primality Testing
  • Computational Geometry – Closest point pair, Voronoi diagram, Convex Hull

General Advance topics :

  • Iterating through all combination / permutation
  • Bit manipulation

Reference cards (cheat sheets) collection.

Java may not be the newest programming language around, but it is still one of the most popular. This is an Object Oriented Programming (OOP) language, which has become a mainstay in most enterprise and home projects.
Here are a few good design principles you should follow:

1. DRY
DRY stands for Don’t Repeat Yourself, which is pretty self explanatory. This means that you shouldn’t be duplicating your code in a program. If a code fragment is appearing in two places, then you would do well to turn it into a method instead of writing the entire fragment again. Lack of duplication helps in easy maintenance of the code.

2. Encapsulation

Whether your project gets bought over or whether you work on it yourself, your code will always change. So, it is good to encapsulate the part of the code that you think will be changed. This makes you code easy to maintain and test.

3. Design Principle

Here you should try and follow an open closed design principle. This means that you classes, functions or methods should be Open so that new functionality can be added easily. The Open Closed Design Principle focuses on this aspect and makes it possible to avoid unauthorised changes to already tested and working code.

4. Single Responsibility Principle (SRP)

According to this principle, a class should be handling a single functionality. In addition, there should be more than one reason for a developer to change a class from what it currently does. For example, if you have multiple functionalities in a class in Java then you might face problems when you are coupling this fake Java.

5. Dependency

The framework that you use already provides you dependence, which means that looking for it a additionally will be a waste of time. You can also use byte code instrumentation as well. Some Aspect Oriented Programming (AOP) framework already does this. Lastly, you can also make the use of proxies.

6. Composition over Inheritance

According to many programmers, composition is more important than inheritance. They say that you should be focusing on the composition of your program than on employing a flexible inheritance structure. This is because composition allows you to change the behaviour of a class at runtime. Interface on the other hand allows you to use polymorphism, providing the flexibility to replace something with better implementation.

7. Liskov Substitution Principle (LSP)

This principle states that you must be able to subtypes for super types. This means that any methods or functions in your program that are making the use of super class types, then they should also be able to work with the sub class. It is in close relation to SRP and the Interface Segregation Principle.

8. Interface Segregation principle (ISP)

This principle tells you to ensure that clients do not implement any interface that it doesn’t use. In Java, an interface has the disadvantage from the design point of view, to implement all methods before the classes can use it;

9. Programming for Interface

A programmer should always be programming for the interface and not for the implementation that will give them flexibility in code. Make use of interface types on variables and return types on methods. In addition, argument types should also be use.

10. Delegate

Delegate the tasks of your program to specific to classes. An example of this would be the equals () and hashCode() method.