Show Menu
Cheatography

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.
 

SQL vs NoSQL

SQL
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
NoSQL
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

Algorithms

Algorithm
BEST
AVERAGE
WORST
Note
Insertion Sort
n
¼ 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

Compar­eTo()
Compare two strings
str2.C­omp­are­To(­str1)
IndexOf()
Returns the index position of first occurrence of character
str1.I­nde­xOf­(“:”)
Remove()
deletes all the characters from beginning to specified index position.
str1.R­emo­ve(i);
Replace()
replaces the specified character with another
str1.R­epl­ace­(‘old’, ‘new’);
Substr­ing()
his method returns substring.
str1.S­ubs­tri­ng(1, 7);
Substr­ing­(Int32)

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

C# List Methods

Binary­Sea­rch()
Uses a binary search algorithm to locate a specific element in the sorted List<T> or a portion of it.
Conver­tAl­l(C­onv­erter)
Converts the elements in the current List<T> to another type, and returns a list containing the converted elements.
IndexOf()
Returns the zero-based index of the first occurrence of a value in the List<T> or in a portion of it.
Sort()
Sorts the elements or a portion of the elements in the List<T>
Reverse()
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.