Show Menu

Tech Interview Cheat Sheet (DRAFT) by

Notes of technical interview

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Basic System Design

Presen­tation Layer
User interface, caching, valida­tion, single page or multi page
Business Layer
Logic/­wor­kflows, reuse common logic
Data Layer
Entity objects that pass data, database type. SQL vs NoSQL
Also consider security of applic­ation.

System Design - Deployment Consid­era­tions

Consider the following guidelines for deploy­ment:
• Consider using non-di­str­ibuted deployment to maximize perfor­mance.
• Consider using distri­buted deployment to achieve better scalab­ility and to allow each layer
to be secured separa­tely.

Map Reduce

The MapReduce algorithm contains two important tasks, namely Map and Reduce.
The Map task takes a set of data and converts it into another set of data, where individual elements are broken down into tuples (key-value pairs).
The Reduce task takes the output from the Map as an input and combines those data tuples (key-value pairs) into a smaller set of tuples.


Language used for relational databases
Scaled vertically by increasing power (more common), scaled horizo­ntally by partit­ioning
Tables and columns, rows, Have constr­ained logical relati­onships
Must exhibit ACID properties
MS-SQL, Oracle, Access, Ingress
Language used for non relational dbs
Scales better horizo­ntally using master­-slave archit­ecture
Multiple formats: Column, Key-Value, Document, Graph
Adheres to CAP
MongoDB, DynamoDB, CouchDB
Use SQL when:
data is small
Concep­tually modeled as tabular
consis­tency is critical
Use NoSQL when:
Graph or hierar­chial data
Data sets which are both large and mutate signif­icantly
Businesses growing extremely fast but lacking data schemata
ACID - Atomicity, Consis­tency, Isolation, Durability
CAP - Consis­tency, Availa­bity, Partition tolerance


Insertion Sort
¼ n^2
½ n^2
use for small or partia­lly­-sorted arrays
Merge Sort
½ n lg n
n lg n
n lg n
n log n guarantee; stable
Quick Sort
n lg n
2 n ln n
½ n^2
n log n probab­ilistic guarantee; fastest in practice
Quick Sort works better for small arrays
Merge Sort works better for linked lists and is consistent for any size of data

C# String Methods

Compare two strings
Returns the index position of first occurrence of character
deletes all the characters from beginning to specified index position.
replaces the specified character with another
str1.R­epl­ace­(‘old’, ‘new’);
his method returns substring.
str1.S­ubs­tri­ng(1, 7);

Substr­ing­(Int32, Int32) //start, length

C# List Methods

Uses a binary search algorithm to locate a specific element in the sorted List<T> or a portion of it.
Converts the elements in the current List<T> to another type, and returns a list containing the converted elements.
Returns the zero-based index of the first occurrence of a value in the List<T> or in a portion of it.
Sorts the elements or a portion of the elements in the List<T>
Reverses the order of the elements in the List<T> or a portion of it.
Sort is QuickSort

Search Basics

Breadth First Search
An algorithm that searches a tree (or graph) by searching levels of the tree first, starting at the root.
Moves left to right on level, tracking children. Then moves to next level
Depth First Search
An algorithm that searches a tree (or graph) by searching depth of the tree first, starting at the root.
It traverses left down a tree until it cannot go further
traverses back up trying the right child of nodes on that branch, and if possible left from the right children
When finished examining a branch it moves to the node right of the root then tries to go left on all it's children until it reaches the bottom.
When to use BFS:
Optimal for searching a tree that is wider than it is deep
Uses a queue to store inform­ation about the tree while it traverses a tree so uses more memory than DFS
When to use DFS
Optimal for searching a tree that is deeper than it is wide.
Uses a stack to push nodes onto.