diff --git a/apps/website/contents/algorithms/binary.md b/apps/website/contents/algorithms/binary.md index 2fb55290..b9a2ec01 100644 --- a/apps/website/contents/algorithms/binary.md +++ b/apps/website/contents/algorithms/binary.md @@ -21,7 +21,7 @@ toc_max_heading_level: 2 ## Introduction -Knowledge of binary number system and bit manipulation is less important in coding interviews as most Software Engineers do not have to deal with bits, which is more commonly used when dealing with lower level systems and programming languages. They are still asked sometimes, so you should at least still know how to convert a number from decimal form into binary form, and vice versa, in your chosen programming language. +Knowledge of binary number system and bit manipulation is less important in coding interviews as most Software Engineers do not have to deal with bits, which is more commonly used when dealing with lower level systems and programming languages. They are still asked sometimes, so you should at least still know how to convert a number from decimal form into binary form (and vice versa) in your chosen programming language. ## Learning resources diff --git a/apps/website/contents/algorithms/graph.md b/apps/website/contents/algorithms/graph.md index 6e6590de..5da3ec59 100644 --- a/apps/website/contents/algorithms/graph.md +++ b/apps/website/contents/algorithms/graph.md @@ -26,7 +26,7 @@ A graph is a structure containing a set of objects (nodes or vertices) where the Graphs are commonly used to model relationship between unordered entities, such as - Friendship between people - Each node is a person and edges between nodes represent that these two people are friends. -- Distances between locations - Each node is a location and the edge between nodes represent that these locations are connected. The value of the edge represent the distance. +- Distances between locations - Each node is a location and the edge between nodes represent that these locations are connected. The value of the edge represents the distance. Be familiar with the various graph representations, graph search algorithms and their time and space complexities. @@ -48,7 +48,7 @@ You can be given a list of edges and you have to build your own graph from the e - Adjacency list - Hash table of hash tables -Using a hash table of hash table would be the simplest approach during algorithm interviews. It will be rare that you have to use adjacency matrix or list for graph questions during interviews. +Using a hash table of hash tables would be the simplest approach during algorithm interviews. It will be rare that you have to use an adjacency matrix or list for graph questions during interviews. In algorithm interviews, graphs are commonly given in the input as 2D matrices where cells are the nodes and each cell can traverse to its adjacent cells (up/down/left/right). Hence it is important that you be familiar with traversing a 2D matrix. When traversing the matrix, always ensure that your current position is within the boundary of the matrix and has not been visited before. @@ -78,7 +78,7 @@ In algorithm interviews, graphs are commonly given in the input as 2D matrices w - **Common** - Breadth-first Search, Depth-first Search - **Uncommon** - Topological Sort, Dijkstra's algorithm -- **Almost never** - Bellman-Ford algorithm, Floyd-Warshall algorithm, Prim's algorithm, Kruskal's algorithm. Your interviewer likely don't know them either. +- **Almost never** - Bellman-Ford algorithm, Floyd-Warshall algorithm, Prim's algorithm, Kruskal's algorithm. Your interviewer likely doesn't know them either. ### Depth-first search @@ -161,7 +161,7 @@ For additional tips on BFS and DFS, you can refer to this [LeetCode post](https: A topological sort or topological ordering of a directed graph is a linear ordering of its vertices such that for every directed edge uv from vertex u to vertex v, u comes before v in the ordering. Precisely, a topological sort is a graph traversal in which each node v is visited only after all its dependencies are visited. -Topological sorting is most commonly used for job scheduling a sequence of jobs or tasks which has dependencies on other jobs/tasks. The jobs are represented by vertices, and there is an edge from x to y if job x must be completed before job y can be started. +Topological sorting is most commonly used for scheduling a sequence of jobs or tasks which has dependencies on other jobs/tasks. The jobs are represented by vertices, and there is an edge from x to y if job x must be completed before job y can be started. Another example is taking courses in university where courses have pre-requisites. diff --git a/apps/website/contents/algorithms/heap.md b/apps/website/contents/algorithms/heap.md index 8a199460..9b6f09a9 100644 --- a/apps/website/contents/algorithms/heap.md +++ b/apps/website/contents/algorithms/heap.md @@ -23,8 +23,8 @@ toc_max_heading_level: 2 A heap is a specialized tree-based data structure which is a complete tree that satisfies the heap property. -- Max heap - In a max heap the value of a node must be greatest among the node values in its entire subtree. The same property must be recursively true for all nodes in the tree. -- Min heap - In a min heap the value of a node must be smallest among the node values in its entire subtree. The same property must be recursively true for all nodes in the tree. +- Max heap - In a max heap, the value of a node must be greatest among the node values in its entire subtree. The same property must be recursively true for all nodes in the tree. +- Min heap - In a min heap, the value of a node must be smallest among the node values in its entire subtree. The same property must be recursively true for all nodes in the tree. In the context of algorithm interviews, heaps and priority queues can be treated as the same data structure. A heap is a useful data structure when it is necessary to repeatedly remove the object with the highest (or lowest) priority, or when insertions need to be interspersed with removals of the root node. diff --git a/apps/website/contents/algorithms/math.md b/apps/website/contents/algorithms/math.md index 780c8cef..68351465 100644 --- a/apps/website/contents/algorithms/math.md +++ b/apps/website/contents/algorithms/math.md @@ -29,6 +29,13 @@ Math is a foundational aspect of Computer Science and every programmer and compu - Check for and handle overflow/underflow if you are using a typed language like Java and C++. At the very least, mention that overflow/underflow is possible and ask whether you need to handle it. - Consider negative numbers and floating point numbers. This may sound obvious, but under interview pressure, many obvious cases go unnoticed. +## Corner cases + +- Division by 0 +- Multiplication by 1 +- Negative numbers +- Floats + ## Common formulas | | Formula | @@ -53,13 +60,6 @@ When dealing with floating point numbers, take note of rounding mistakes. Consid If the question asks you to implement an operator such as power, square root or division and want it to be faster than O(n), some sort of doubling (fast exponentiation) or halving (binary search) is usually the approach to go. Examples: [Pow(x, n)](https://leetcode.com/problems/powx-n/), [Sqrt(x)](https://leetcode.com/problems/sqrtx/) -## Corner cases - -- Division by 0 -- Multiplication by 1 -- Negative numbers -- Floats - ## Essential questions _These are essential questions to practice if you're studying for this topic._ diff --git a/apps/website/contents/algorithms/queue.md b/apps/website/contents/algorithms/queue.md index a83258b2..63d64287 100644 --- a/apps/website/contents/algorithms/queue.md +++ b/apps/website/contents/algorithms/queue.md @@ -55,7 +55,7 @@ Breadth-first search is commonly implemented using queues. ## Things to look out for during interviews -Most languages don't have a built in Queue class which to be used, and candidates often use arrays (JavaScript) or lists (Python) as a queue. However, note that the enqueue operation in such a scenario will be O(n) because it requires shifting of all other elements by one. In such cases, you can flag this to the interviewer and say that you assume that there's a queue data structure to use which has an efficient enqueue operation. +Most languages don't have a built-in Queue class which can be used, and candidates often use arrays (JavaScript) or lists (Python) as a queue. However, note that the enqueue operation in such a scenario will be O(n) because it requires shifting of all other elements by one. In such cases, you can flag this to the interviewer and say that you assume that there's a queue data structure to use which has an efficient enqueue operation. ## Corner cases diff --git a/apps/website/contents/algorithms/tree.md b/apps/website/contents/algorithms/tree.md index de37a76c..5b10cbc0 100644 --- a/apps/website/contents/algorithms/tree.md +++ b/apps/website/contents/algorithms/tree.md @@ -57,7 +57,7 @@ Trees are commonly used to represent hierarchical data, e.g. file systems, JSON, ### Binary tree -Binary means two, so nodes in a binary trees have a maximum of two children. +Binary means two, so nodes in a binary tree have a maximum of two children. **Binary tree terms** @@ -119,7 +119,7 @@ Be familiar with the following routines because many tree questions make use of - Whether a value is in the tree - Calculate height of the tree - Binary search tree - - Determine if is binary search tree + - Determine if it is a binary search tree - Get maximum value - Get minimum value diff --git a/apps/website/contents/algorithms/trie.md b/apps/website/contents/algorithms/trie.md index 156755c8..72b4fb15 100644 --- a/apps/website/contents/algorithms/trie.md +++ b/apps/website/contents/algorithms/trie.md @@ -37,11 +37,11 @@ Be familiar with implementing from scratch, a `Trie` class and its `add`, `remov `m` is the length of the string used in the operation. -| Operation | Big-O | Note | -| --------- | ----- | ---- | -| Search | O(m) | | -| Insert | O(m) | | -| Remove | O(m) | | +| Operation | Big-O | +| --------- | ----- | +| Search | O(m) | +| Insert | O(m) | +| Remove | O(m) | ## Corner cases