Category Archives: ACM

ArrayList in Java

ArrayList in Java:

Generics:

 

LinkedList is faster for manipulation but slower for retrieval and ArrayList is slower for manipulation but faster for retrieval

 

Swap without a temp variable

It’s possible with addition:

It’s also possible with multiplication:

 

 

 

Source:
http://www.geeksforgeeks.org/swap-two-numbers-without-using-temporary-variable/

 

AVL Tree

B+ Tree

Floyd Warshall Algorithm

Bellman Ford

It works on negative cycle.

Implemented Code:

Time Complexity:

O([E].[V])

Reference:
http://cyberlingo.blogspot.com/2015/07/bellman-ford-algorithm.html

Dijkstra

output:

Complexity:
O(E+V^2)

We are using here adjacency matrix list