Posts

Graph theory

Graph Theory  Introduction:- Graph data structure and traversal Ordering:-  of dependent nodes using topological ordering  Shortest path:- algorithm in weighted and non-weighted graphs Spanning Tree:- algorithms to connect all nodes in a graph  Graphs are excellent tools for modelling complex relationships  Adjacency matrix is most common way of representing Graph Adjacent List and Adjacent Sets are alternative data structures  Traversing of graph 1) Depth-first 2) Breath-first Relationship between entities example :-  Rob drives a Car.      Entities:- {Rob, Car}      Relationship:- {Drives} A graph can be used to represent above relationship where  (V)ertices ->  entities (E)dges -> relationship => G=(V,E) Directed and Undirected Graph Directed (Twitter) :- Rob drives his car => one directional relationship (car cannot drive Rob) => Rob -----> Car Undirected (Facebook):- David and Dave plays fo...

Recursion

There are two ways to approach a problem in computer science  Bottom-up Top-down Bottom-up :- approach a problem from the simple case to difficult case... for example factorial of N   we start a loop from 1 to till N where product=1 product =product*1 product= product*2 product=product*3 and continue till N    Top-down :- approach a problem then sub-problem and then sub problem of subvproblem until the best case .. for example:- factorial of a number where N!-> N * (N-1)! * (N-2)! *... 1 fact(N){ if(n==1) return 1; return n * fact(n-1) } where n=1 is the best case where algorithm will stop executing further.   Recursion:-   Recursive shines when implementing a top-down approach Recursion executes on call-stack where best case will the on the top Recursion natural fits when we need to delve into multiple layers of a problem without knowing how many layers are there. e.g. find sub directories in a directory where depth is unknown  Problems:-...
 Permutation lock:- A permutation is an ordered combination. ( a lock problem) (multiplication priciple) it can have 2 types:-  1) Repetition Allowed :- When  a thing has 3 different types, we have N choices each times. Hence the permutation will be =N*N*N 2) No Repetition :- N factorial / (N-r) factorial Combination:- is counting of selections that we make for N objects whereas permutation is counting the number of arrangements of N objects  care about selections 

Daily git

Image
Git commit log git log --oneline -n 2 where:- -n 2 :- print last 2 commit only  <code> push origin remote branch </code> git log --oneline -n 4 where:- --oneline : to show commit in a single line (otherwise it will print Author,Date etc. details as well as above) Change/Modify/Amend last commit message  git commit --amend Above command will pop up a vi/gui editor depends on your configuration. Edit the message and save (vi command ->  ESC :wq ) After Merge Branches But Preserve/Skip Few Files Lets take a scenario where you want to merge branch A into branch B but both have some common files e.g. Version / Config.xml  with different version or configuration. For example  Dev/ReleaseCandiate/Production branches have different version file so while merging our code from Dev to RC/Prod we would not like to update prod Version file with our local Dev version and there are other N number of scenarios. ...

Java 8 Introduction and Basics

What is Functional Programming ? Why we need Functional Programming ? How Functional Programming is different from Imperative style programming ? What are the key features of Functional Programming ? What is Lambda ?