Skip to content

Commit

Permalink
grammar / consistency fixes for algo sites
Browse files Browse the repository at this point in the history
  • Loading branch information
micsparre committed Aug 2, 2023
1 parent 2666344 commit 7cf1cdb
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion apps/website/contents/algorithms/binary.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions apps/website/contents/algorithms/graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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.

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions apps/website/contents/algorithms/heap.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
14 changes: 7 additions & 7 deletions apps/website/contents/algorithms/math.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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._
Expand Down
2 changes: 1 addition & 1 deletion apps/website/contents/algorithms/queue.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions apps/website/contents/algorithms/tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**

Expand Down Expand Up @@ -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

Expand Down
10 changes: 5 additions & 5 deletions apps/website/contents/algorithms/trie.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 7cf1cdb

Please sign in to comment.