Skip to content

Commit

Permalink
fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilk committed Apr 8, 2017
1 parent 28f00aa commit 029e4fd
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/algo/1todo
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Prim's
Kruskall
topological sort(all types)
detect cycle in (un)directed graph
detect oddcycle (of each componenent)
detect odd cycle (of each component)
Hamiltonian cycle
Hachers graph
vertex cover
Expand Down
6 changes: 3 additions & 3 deletions src/algo/dp/DPIntroduction.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
According to Wikipedia, Dynamic programming (also known as dynamic optimization) is a method for solving a complex problem by
breaking it down into a collection of simpler subproblems, solving each of those subproblems just once,
and storing their solutions – ideally, using a memory-based data structure.
For example, in order computer Nth fibonacci number or to find shortest path, we can use DP and get result in
For example, in order computer Nth Fibonacci number or to find shortest path, we can use DP and get result in
much easier and optimized way.
DP techniques help us to solve exponential problems in Polynomoil time.
DP techniques help us to solve exponential problems in polynomial time.
<br>
Notes From MIT(6.006)->
DP => careful brute force
DP => guessing + recursion + memoization
DP => shortest path in some DAG
Time complexity => # subproblems x time/subproblem (treating recursion calls as O(1))

These are five interdependant steps to DP
These are five interdependent steps to DP
1) define subproblems
2) guess ( part of subproblems)
3) relate subproblem solutions
Expand Down
4 changes: 2 additions & 2 deletions src/algo/graph/BellmanFord.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
* Created by sherxon on 1/7/17.
*/
/**
* This Bellman Ford shortest path algorithm. It works with negative edges and and if there negative cycle
* This Bellman Ford shortest path algorithm. It works with negative edges and if there negative cycle
* the algorithm reports. Time complexity is O(V*E) if E is V^2 , we can say that O(V^3).
* This is slower than Dijkstra shortest path algorithm which works for only non-negative edges in O(VLogV)
* with fibonacci heap.
* with Fibonacci heap.
* */
public class BellmanFord {
WeightedGraph graph;
Expand Down
2 changes: 1 addition & 1 deletion src/algo/graph/Dijsktra.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* This is the algorithm to find shortest Path in weighted and non-negative edged graph. Graph can be directed
* or undirected. This is not optimized version as shortestPath() method searches vertex with minimal weight
* every time. To optimize fibonacci heap can be used. This algorithm finds shortest path from source vertex
* every time. To optimize Fibonacci heap can be used. This algorithm finds shortest path from source vertex
* to all other reachable vertexes. Time complexity is O(VE)
* */
public class Dijsktra {
Expand Down
2 changes: 1 addition & 1 deletion src/algo/numerals/FermatPrimality.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* the value n is called a Fermat liar because it incorrectly implies that p is prime.
* If np–1 Mod p ≠ 1, n is called a Fermat witness because it proves that p is
* not prime
* We can use many test to remove fermats lier. For example, if p passes the test 10 times, there is a 1/210 ≈ 0.00098 probability
* We can use many test to remove Fermat liar. For example, if p passes the test 10 times, there is a 1/210 ≈ 0.00098 probability
* that p is not prime
*/
public class FermatPrimality {
Expand Down
4 changes: 2 additions & 2 deletions src/algo/string/Trie.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

/**
* This is prefix truee, which consumes alot memory but very fast.
* This is prefix tree, which consumes a lot memory but very fast.
*/
public class Trie {

Expand Down Expand Up @@ -75,7 +75,7 @@ public TrieNode(char c) {


/*
This is recursive, one-class aproach, but it has small bug that I could not find it in 2 hours.
This is recursive, one-class approach, but it has small bug that I could not find it in 2 hours.
public class Trie {
int[] a= new int[26];
Expand Down
2 changes: 1 addition & 1 deletion src/interviewquestions/Easy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ Here are few examples.
[1,3,5,6], 0 → 0

64)**Palindrome Number**
Determine if given interger is palindrome, dont use extra space
Determine if given integer is palindrome, don't use extra space

65)**Lowest Common Ancestor of a Binary Search Tree**
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.
Expand Down
2 changes: 1 addition & 1 deletion src/interviewquestions/Medium.txt
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ Given a binary array, find the maximum number of consecutive 1s in this array if
Example 1:
Input: [1,0,1,1,0]
Output: 4
Explanation: Flip the first zero will get the the maximum number of consecutive 1s.
Explanation: Flip the first zero will get the maximum number of consecutive 1s.
After flipping, the maximum number of consecutive 1s is 4.
Note:
The input array will only contain 0 and 1.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
public class DeleteNodeSingleLinkedList {
/**
* Case: We have only list node which is not last element. To remove this node, we can chnage its value
* Case: We have only list node which is not last element. To remove this node, we can change its value
* and set pointer to next of next.
*/
public void deleteNode(ListNode x) {
Expand Down
2 changes: 1 addition & 1 deletion src/interviewquestions/easy/ImplementstrSt.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
public class ImplementstrSt {
/**
* There are two solutions for this problem. One is using RabinKarp Algorithm and the second one is using
* Java's index of algorithm i.e searching starting point of needle from haystack and comparing neeedle.
* Java's index of algorithm i.e. searching starting point of needle from haystack and comparing needle.
* Time complexity in both algorithms is average O(n+m) and in the worst case O(mn);
*/

Expand Down
2 changes: 1 addition & 1 deletion src/interviewquestions/easy/RansomNote.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public class RansomNote {

/**
* The idea is to create an array with length of 26 (english letters) and store each frequency of each letter.
* The idea is to create an array with length of 26 (English letters) and store each frequency of each letter.
* and remove ransom note letters from array. if certain character count in array is 0, that means ransom note has a
* character that is not included on magazine.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/interviewquestions/hard/PostOrderTraversalTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ void postOrderIt(TreeNode root, List<Integer> list){
2.3. push the right child of popped item to stack.
reverse the ouput.
reverse the output.
* */
4 changes: 2 additions & 2 deletions src/interviewquestions/medium/Searcha2DMatrixII.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ boolean searchMatrix(int[][] a, int target) {

/**
* We start search the matrix from top right corner, initialize the current position to top right corner,
* if the target is greater than the value in current position, then the target can not be in entire row
* if the target is greater than the value in current position, then the target cannot be in entire row
* of current position because the row is sorted, if the target is less than the value in current position,
* then the target can not in the entire column because the column is sorted too. We can rule out one row or
* then the target cannot be in the entire column because the column is sorted too. We can rule out one row or
* one column each time,
* so the time complexity is O(m+n).
*/
Expand Down
4 changes: 2 additions & 2 deletions src/timus/GenealogicalTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ public void addVertex(Integer v){
V newV= new V(v);
vertices.putIfAbsent(v, newV);
}
public void addEdge(Integer from, Integer to, int weigth){
public void addEdge(Integer from, Integer to, int weight){
V fromV=vertices.get(from);
V toV=vertices.get(to);
E e= new E(fromV, toV, weigth);
E e= new E(fromV, toV, weight);
fromV.edges.add(e); // directed graph
}

Expand Down
4 changes: 2 additions & 2 deletions src/timus/SegmentTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
public class SegmentTree {
public static void main(String[] args) {
int[] a=new int[]{-1, 2, 4, 0};
int treeSize=a.length*2-1;// if power of two, just multiply by two and substract one
// else find nextpower of two and multiple by 2 and sabstruct one;
int treeSize=a.length*2-1;// if power of two, just multiply by two and subtract one
// else find next power of two and multiple by 2 and subtract one;
int[] tree= new int[treeSize];
for (int i = 0; i < treeSize; i++) {
tree[i]=Integer.MAX_VALUE; // to build min segment tree
Expand Down

0 comments on commit 029e4fd

Please sign in to comment.