Skip to content

Commit e29d933

Browse files
committed
restructured code
1 parent 8c6a018 commit e29d933

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+189
-111
lines changed

README.md

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Code Logbook
2+
This repository contains solutions for standard programming problems structured by the algorithmic techniques or datastructures
3+
used to solve them
4+
5+
## Algorithm Techniques
6+
In mathematics and computer science, an algorithmic technique is a general approach for implementing a process or computation
7+
8+
9+
### Brute Force
10+
Brute Force search or exhaustive search, also known as generate and test, is a very general problem-solving technique and algorithmic paradigm that consists of systematically enumerating all possible candidates
11+
for the solution and checking whether each candidate satisfies the problem's statement. An example of a brute force technique is backtracking.Backtracking is an algorithm where we
12+
traverse all the possible paths to find the correct solution.
13+
14+
### Divide and Conquer
15+
The divide and conquer technique decomposes complex problems recursively into smaller sub-problems.
16+
Each sub-problem is then solved and these partial solutions are recombined to determine the overall solution.
17+
This technique is often used for searching and sorting.
18+
19+
### Dynamic Programming
20+
Dynamic programming is a systematic technique in which a complex problem is decomposed recursively into smaller, overlapping sub-problems for solution.
21+
Dynamic programming stores the results of the overlapping sub-problems locally using an optimization technique called memoization
22+
23+
24+
### Greedy
25+
A greedy approach begins by evaluating one possible outcome from the set of possible outcomes, and then searches locally for an improvement on that outcome.
26+
When a local improvement is found, it will repeat the process and again search locally for additional improvements near this local optimum.
27+
A greedy technique is generally simple to implement, and these series of decisions can be used to find local optimums depending on where the search began.
28+
However, greedy techniques may not identify the global optimum across the entire set of possible outcomes.
29+
30+
31+
### Graph Traversal
32+
Graph traversal is a technique for finding solutions to problems that can be represented as graphs.
33+
This approach is broad, and includes depth-first search, breadth-first search, tree traversal, and many specific variations that may include local optimizations and excluding search spaces that can be determined to be non-optimum or not possible.
34+
These techniques may be used to solve a variety of problems including shortest path and constraint satisfaction problems.
35+
36+
## Datastructures
37+
38+
39+
### HashMaps
40+
41+
### Heap
42+
43+
### List
44+
45+
### Stack
46+
47+
### Tree
48+
49+

src/main/java/algorithms/backtracking/FindLongestPathInMatrix.java src/main/java/algorithm/bruteforce/FindLongestPathInMatrix.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package algorithms.backtracking;
1+
package algorithm.bruteforce;
22

33
import java.util.ArrayList;
44
import java.util.List;

src/main/java/algorithms/backtracking/FindStringInDictionary.java src/main/java/algorithm/bruteforce/FindStringInDictionary.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
package algorithms.backtracking;
1+
package algorithm.bruteforce;
22

33
import java.util.ArrayList;
4-
import java.util.Arrays;
54
import java.util.List;
65
import java.util.Stack;
76

src/main/java/algorithms/backtracking/ResolveWildcardCharacter.java src/main/java/algorithm/bruteforce/ResolveWildcardCharacter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package algorithms.backtracking;
1+
package algorithm.bruteforce;
22

33
import java.util.ArrayList;
44
import java.util.List;

src/main/java/algorithms/divideandconquer/LargestAndSmallestNumber.java src/main/java/algorithm/divideandconquer/LargestAndSmallestNumber.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
package algorithms.divideandconquer;
1+
package algorithm.divideandconquer;
22

33
/**
44
* Created by aysen on 10/16/16.
55
*/
66

77

8-
import javafx.util.Pair;
8+
9+
import algorithm.mathematicaloptimizations.lists.Pair;
910

1011
import java.util.List;
1112

src/main/java/algorithms/dp/FibonacciSeries.java src/main/java/algorithm/dp/FibonacciSeries.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package algorithms.dp;
1+
package algorithm.dp;
22

33

44
public class FibonacciSeries {

src/main/java/algorithms/dp/LongestCommonSubsequence.java src/main/java/algorithm/dp/LongestCommonSubsequence.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package algorithms.dp;
1+
package algorithm.dp;
22

33
public class LongestCommonSubsequence {
44

src/main/java/algorithms/dp/LowestTravelCost.java src/main/java/algorithm/dp/LowestTravelCost.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package algorithms.dp;
1+
package algorithm.dp;
22

33
import java.util.*;
44
import java.util.stream.Collectors;

src/main/java/algorithms/dp/MaxSubMatrix.java src/main/java/algorithm/dp/MaxSubMatrix.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package algorithms.dp;
1+
package algorithm.dp;
22

33
import java.util.Arrays;
44

src/main/java/algorithms/dp/MinimumCoins.java src/main/java/algorithm/dp/MinimumCoins.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package algorithms.dp;
1+
package algorithm.dp;
22

33
import java.util.Collections;
44
import java.util.List;

src/main/java/algorithms/dp/MinimumPerfectSquares.java src/main/java/algorithm/dp/MinimumPerfectSquares.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package algorithms.dp;
1+
package algorithm.dp;
22

33
public class MinimumPerfectSquares {
44
/**

src/main/java/algorithms/dp/PrintStringInDictionary.java src/main/java/algorithm/dp/PrintStringInDictionary.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package algorithms.dp;
1+
package algorithm.dp;
22

33
public class PrintStringInDictionary {
44

src/main/java/algorithms/dp/StockPriceProblem.java src/main/java/algorithm/dp/StockPriceProblem.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package algorithms.dp;
1+
package algorithm.dp;
22

33
public class StockPriceProblem {
44

src/main/java/datastructure/graphs/Edge.java src/main/java/algorithm/graphtraversal/Edge.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package datastructure.graphs;
1+
package algorithm.graphtraversal;
22

33
/**
44
* Created by aysen on 10/18/16.

src/main/java/datastructure/graphs/EdgeWeightedGraph.java src/main/java/algorithm/graphtraversal/EdgeWeightedGraph.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package datastructure.graphs;
1+
package algorithm.graphtraversal;
22

33
import java.util.HashMap;
44
import java.util.Map;

src/main/java/datastructure/graphs/Vertex.java src/main/java/algorithm/graphtraversal/Vertex.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
package datastructure.graphs;
1+
package algorithm.graphtraversal;
22

33
import java.util.ArrayDeque;
4-
import java.util.HashSet;
54
import java.util.Queue;
6-
import java.util.Set;
75

86
/**
97
* Created by aysen on 10/18/16.

src/main/java/datastructure/graphs/problems/DetectCylesInAGraph.java src/main/java/algorithm/graphtraversal/problems/DetectCylesInAGraph.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package datastructure.graphs.problems;
1+
package algorithm.graphtraversal.problems;
22

3-
import datastructure.graphs.Edge;
4-
import datastructure.graphs.EdgeWeightedGraph;
3+
import algorithm.graphtraversal.Edge;
4+
import algorithm.graphtraversal.EdgeWeightedGraph;
55

66
import java.util.ArrayList;
77
import java.util.List;

src/main/java/datastructure/graphs/problems/MaximumLengthBetweenCities.java src/main/java/algorithm/graphtraversal/problems/MaximumLengthBetweenCities.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package datastructure.graphs.problems;
1+
package algorithm.graphtraversal.problems;
22

3-
import datastructure.graphs.EdgeWeightedGraph;
4-
import datastructure.graphs.Vertex;
3+
import algorithm.graphtraversal.EdgeWeightedGraph;
4+
import algorithm.graphtraversal.Vertex;
55

66
import java.util.HashMap;
77
import java.util.Map;

src/main/java/datastructure/graphs/problems/ShortestPathInDAG.java src/main/java/algorithm/graphtraversal/problems/ShortestPathInDAG.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package datastructure.graphs.problems;
1+
package algorithm.graphtraversal.problems;
22

3-
import datastructure.graphs.EdgeWeightedGraph;
4-
import datastructure.graphs.Vertex;
3+
import algorithm.graphtraversal.EdgeWeightedGraph;
4+
import algorithm.graphtraversal.Vertex;
55

66
import java.util.HashMap;
77
import java.util.Map;

src/main/java/datastructure/graphs/problems/TopologicalSort.java src/main/java/algorithm/graphtraversal/problems/TopologicalSort.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
package datastructure.graphs.problems;
1+
package algorithm.graphtraversal.problems;
22

3-
import datastructure.graphs.Edge;
4-
import datastructure.graphs.EdgeWeightedGraph;
5-
import datastructure.graphs.Vertex;
3+
import algorithm.graphtraversal.Edge;
4+
import algorithm.graphtraversal.EdgeWeightedGraph;
5+
import algorithm.graphtraversal.Vertex;
66

77
import java.util.*;
8-
import java.util.stream.Collectors;
98

109
public class TopologicalSort {
1110

src/main/java/datastructure/graphs/traversals/BreadthFirstTraversal.java src/main/java/algorithm/graphtraversal/traversals/BreadthFirstTraversal.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package datastructure.graphs.traversals;
1+
package algorithm.graphtraversal.traversals;
22

3-
import datastructure.graphs.Edge;
4-
import datastructure.graphs.EdgeWeightedGraph;
5-
import datastructure.graphs.Vertex;
3+
import algorithm.graphtraversal.Edge;
4+
import algorithm.graphtraversal.EdgeWeightedGraph;
5+
import algorithm.graphtraversal.Vertex;
66

77
import java.util.*;
88
import java.util.stream.Collectors;

src/main/java/datastructure/graphs/traversals/DepthFirstTraversal.java src/main/java/algorithm/graphtraversal/traversals/DepthFirstTraversal.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package datastructure.graphs.traversals;
1+
package algorithm.graphtraversal.traversals;
22

3-
import datastructure.graphs.Edge;
4-
import datastructure.graphs.EdgeWeightedGraph;
3+
import algorithm.graphtraversal.Edge;
4+
import algorithm.graphtraversal.EdgeWeightedGraph;
55

66
import java.util.HashSet;
77
import java.util.List;

src/main/java/datastructure/trees/BinarySearchTree.java src/main/java/algorithm/graphtraversal/trees/BinarySearchTree.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
package datastructure.trees;
1+
package algorithm.graphtraversal.trees;
22

3-
import javax.swing.tree.TreeNode;
4-
import java.util.ArrayList;
5-
import java.util.List;
63
import java.util.Optional;
74

85
/**

src/main/java/datastructure/trees/BinaryTreeNode.java src/main/java/algorithm/graphtraversal/trees/BinaryTreeNode.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package datastructure.trees;
1+
package algorithm.graphtraversal.trees;
22

33
/**
44
* Created by aysen on 10/2/16.

src/main/java/datastructure/trees/TreeNode.java src/main/java/algorithm/graphtraversal/trees/TreeNode.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package datastructure.trees;
1+
package algorithm.graphtraversal.trees;
22

33
import java.util.ArrayList;
44
import java.util.List;

src/main/java/datastructure/trees/TreeTraversals.java src/main/java/algorithm/graphtraversal/trees/TreeTraversals.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package datastructure.trees;
1+
package algorithm.graphtraversal.trees;
22

33
import java.util.ArrayDeque;
44
import java.util.ArrayList;

src/main/java/datastructure/trees/problems/TreeProblems.java src/main/java/algorithm/graphtraversal/trees/problems/TreeProblems.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
package datastructure.trees.problems;
1+
package algorithm.graphtraversal.trees.problems;
22

3-
import datastructure.trees.BinaryTreeNode;
3+
import algorithm.graphtraversal.trees.BinaryTreeNode;
44

55
import java.util.ArrayDeque;
66
import java.util.ArrayList;

src/main/java/algorithms/greedy/MinimumSpanningTree.java src/main/java/algorithm/greedy/MinimumSpanningTree.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package algorithms.greedy;
1+
package algorithm.greedy;
22

3-
import datastructure.graphs.Edge;
4-
import datastructure.graphs.EdgeWeightedGraph;
3+
import algorithm.graphtraversal.Edge;
4+
import algorithm.graphtraversal.EdgeWeightedGraph;
55

66
public class MinimumSpanningTree {
77

src/main/java/algorithms/greedy/ShortestPathInGraph.java src/main/java/algorithm/greedy/ShortestPathInGraph.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
package algorithms.greedy;
1+
package algorithm.greedy;
22

3-
import datastructure.graphs.EdgeWeightedGraph;
3+
import algorithm.graphtraversal.EdgeWeightedGraph;
44

55
import java.util.HashMap;
66
import java.util.Map;

src/main/java/datastructure/heap/BinaryMaxHeap.java src/main/java/algorithm/mathematicaloptimizations/BinaryMaxHeap.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package datastructure.heap;
1+
package algorithm.mathematicaloptimizations;
22

33
import java.util.ArrayList;
44
import java.util.List;

src/main/java/datastructure/heap/BinaryMinHeap.java src/main/java/algorithm/mathematicaloptimizations/BinaryMinHeap.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package datastructure.heap;
1+
package algorithm.mathematicaloptimizations;
22

33
import java.util.ArrayList;
44
import java.util.List;

src/main/java/datastructure/hashing/problems/HashProblems.java src/main/java/algorithm/mathematicaloptimizations/HashProblems.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package datastructure.hashing.problems;
1+
package algorithm.mathematicaloptimizations;
22

3-
import datastructure.trees.BinaryTreeNode;
4-
import javafx.util.Pair;
3+
import algorithm.mathematicaloptimizations.lists.Pair;
4+
import algorithm.graphtraversal.trees.BinaryTreeNode;
55

66
import java.util.*;
77

src/main/java/datastructure/heap/Heap.java src/main/java/algorithm/mathematicaloptimizations/Heap.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package datastructure.heap;
1+
package algorithm.mathematicaloptimizations;
22

33
/**
44
* Created by aysen on 10/28/16.

src/main/java/datastructure/heap/problems/HeapProblems.java src/main/java/algorithm/mathematicaloptimizations/heap/problems/HeapProblems.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package datastructure.heap.problems;
1+
package algorithm.mathematicaloptimizations.heap.problems;
22

3-
import datastructure.heap.BinaryMaxHeap;
4-
import datastructure.heap.BinaryMinHeap;
5-
import datastructure.heap.Heap;
3+
import algorithm.mathematicaloptimizations.BinaryMaxHeap;
4+
import algorithm.mathematicaloptimizations.BinaryMinHeap;
5+
import algorithm.mathematicaloptimizations.Heap;
66

77
import java.util.List;
88
import java.util.stream.Collectors;

src/main/java/datastructure/lists/LinkedList.java src/main/java/algorithm/mathematicaloptimizations/lists/LinkedList.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package datastructure.lists;
1+
package algorithm.mathematicaloptimizations.lists;
22

33
import java.util.Collection;
44
import java.util.Iterator;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package algorithm.mathematicaloptimizations.lists;
2+
3+
import java.util.Objects;
4+
5+
public class Pair<U, V> {
6+
7+
/**
8+
* The first element of this <code>Pair</code>
9+
*/
10+
private U key;
11+
12+
/**
13+
* The second element of this <code>Pair</code>
14+
*/
15+
private V value;
16+
17+
/**
18+
* Constructs a new <code>Pair</code> with the given values.
19+
*
20+
* @param key the key
21+
* @param value the value
22+
*/
23+
public Pair(U key, V value) {
24+
25+
this.key = key;
26+
this.value = value;
27+
}
28+
29+
public U getKey() {
30+
return key;
31+
}
32+
33+
public V getValue() {
34+
return value;
35+
}
36+
37+
@Override
38+
public boolean equals(Object o) {
39+
if (this == o) return true;
40+
if (o == null || getClass() != o.getClass()) return false;
41+
Pair<?, ?> pair = (Pair<?, ?>) o;
42+
return Objects.equals(key, pair.key) && Objects.equals(value, pair.value);
43+
}
44+
45+
@Override
46+
public int hashCode() {
47+
return Objects.hash(key, value);
48+
}
49+
}
50+

src/main/java/datastructure/lists/problems/ListProblems.java src/main/java/algorithm/mathematicaloptimizations/lists/problems/ListProblems.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package datastructure.lists.problems;
1+
package algorithm.mathematicaloptimizations.lists.problems;
22

33
/**
44
* Created by aysen on 10/27/16.

src/main/java/datastructure/lists/problems/MergeSortedLinkedLists.java src/main/java/algorithm/mathematicaloptimizations/lists/problems/MergeSortedLinkedLists.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package datastructure.lists.problems;
1+
package algorithm.mathematicaloptimizations.lists.problems;
22

33
import java.util.LinkedList;
44
import java.util.List;

0 commit comments

Comments
 (0)