DSA/README.md

154 lines
6.7 KiB
Markdown
Raw Normal View History

2021-04-24 23:56:27 +00:00
[![.NET](https://github.com/MakeContributions/DSA/actions/workflows/dotnet.yml/badge.svg)](https://github.com/MakeContributions/DSA/actions/workflows/dotnet.yml)
[![C++](https://github.com/MakeContributions/DSA/actions/workflows/cpp.yml/badge.svg)](https://github.com/MakeContributions/DSA/actions/workflows/cpp.yml)
[![Go](https://github.com/MakeContributions/DSA/actions/workflows/go.yml/badge.svg)](https://github.com/MakeContributions/DSA/actions/workflows/go.yml)
[![Node.js CI](https://github.com/MakeContributions/DSA/actions/workflows/node.js.yml/badge.svg)](https://github.com/MakeContributions/DSA/actions/workflows/node.js.yml)
[![Python](https://github.com/MakeContributions/DSA/actions/workflows/python.yml/badge.svg)](https://github.com/MakeContributions/DSA/actions/workflows/python.yml)
[![codespell](https://github.com/MakeContributions/DSA/actions/workflows/codespell.yml/badge.svg)](https://github.com/MakeContributions/DSA/actions/workflows/codespell.yml)
2021-04-24 23:59:57 +00:00
[![CodeQL](https://github.com/MakeContributions/DSA/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/MakeContributions/DSA/actions/workflows/codeql-analysis.yml)
2021-07-17 20:59:51 +00:00
[![Discord](https://img.shields.io/discord/863049619734790185?color=7389D8&logo=discord&logoColor=ffffff&label=&labelColor=6A7EC2)](https://discord.gg/ydWxdqbTyK)
2021-07-09 13:38:09 +00:00
2020-12-17 03:18:20 +00:00
# Data Structures and Algorithm
2021-01-15 13:52:11 +00:00
Data structure and Algorithm (DSA)
## Explanations
- [English](./docs/en)
2022-02-07 15:10:32 +00:00
- [Português](./docs/pt)
- [Turkish](./docs/tr)
2021-05-08 12:54:07 +00:00
- [繁體中文](./docs/zh-tw)
- [日本語](./docs/ja)
2021-01-15 13:52:11 +00:00
## Contribution Guidelines
2021-03-18 19:48:09 +00:00
2021-04-07 18:32:02 +00:00
### 1. Contribution Specifications
2021-03-18 19:48:09 +00:00
2021-04-18 14:40:26 +00:00
The problem being contributed must either be a simple **file** (**Eg.** [`kruskal-algorithm.cpp`](./algorithms/CPlusPlus/Graphs/kruskal-algorithm.cpp), [`linear-search.java`](./algorithms/Java/searching/linear-search.java)) or a more complex **directory** ([`palindrome/`](./algorithms/Rust/strings/palindrome)). This is a unit `problem`.
2021-03-18 19:48:09 +00:00
2021-04-20 12:29:02 +00:00
The directory tree has the following convention of `algorithms/{language}/{category}/{problem}`, where `{language}` represents the language code of the problem (**Eg.** `CPlusPlus` for C++, `CSharp` for C# etc.), `{category}` is the topic or category of the problem being contributed (**Eg.** `strings`, `sorting`, `linked-lists` etc.), and `{problem}` is a conforming name to the problem (**Eg.** `linear-search.cpp`, `palindrome`, `queue-linked-list.cpp` etc.)
2021-03-18 19:48:09 +00:00
A unit `problem` must conform to the following specifications:
2021-03-18 19:48:09 +00:00
- The name should be in lowercase. (**Eg.** `palindrome/`, `binary-search.cpp` etc.).
- Each word must be separated by a **dash** or a **hyphen** (`-`).
2021-03-18 19:48:09 +00:00
**If you have a problem that belongs to a new _topic_ or _category_ than one which are present:**
2021-03-18 19:48:09 +00:00
1. Create a new folder and an index for it inside (a readme, `README.md` file).
2. To each new index file, write the readme with your `problem` in it ([Markdown Documentation](https://guides.github.com/features/mastering-markdown/)).
3. The folder name can also only contain **lowercase characters** and **dashes** or **hyphens** (`-`) (Eg. `strings` `sorting` etc.)
2021-04-07 18:32:02 +00:00
#### Simple (File) Contributions
2021-03-18 19:48:09 +00:00
The file should conform to the `problem` specification, and the extension (**Eg.** `linear-search.java`, `kruskal-algorithm.cpp`, `count-inversions.js` etc.)
2021-04-07 18:32:02 +00:00
#### Project/Folder-based Contributions
2021-03-18 19:48:09 +00:00
The project and folder-based contributions have a bit more stricter contribution contribution specifications.
The folder should conform to the `problem` specification, along with the following specifications
**Folder Structure**
2021-03-18 19:48:09 +00:00
```bash
problem-name\
| - .gitignore
| - README.md
| - Makefile # or the specific specification/requirements/configuration file
| - src\
| - main.ext
```
2021-04-07 18:32:02 +00:00
#### `README.md` Specification / Template
2021-03-18 19:48:09 +00:00
````markdown
2022-08-06 20:21:14 +00:00
# Delete the kth node from the end
2021-03-18 19:48:09 +00:00
2022-08-06 20:21:14 +00:00
Lets K be the total nodes in the linked list.
Observation : The Nth node from the end is (K-N+1)th node from the beginning.
So the problem simplifies down to that we have to find (K-N+1)th node from the beginning.
One way of doing it is to find the length (K) of the linked list in one pass and then in the second pass move (K-N+1) step from the beginning to reach the Nth node from the end.
To do it in one pass. Lets take the first pointer and move N step from the beginning. Now the first pointer is (K-N+1) steps away from the last node, which is the same number of steps the second pointer require to move from the beginning to reach the Nth node from the end.
2021-03-18 19:48:09 +00:00
## Prerequisites
- prerequisite library or package
- [prerequisite library](https://www.example.com/link-to-official-library)
## Instructions
- instructions to run the project
- < Simple and reproducible commands to execute the project >
```bash
2022-08-06 20:21:14 +00:00
javac circular.java
java circular
```
2021-03-18 19:48:09 +00:00
## Test Cases & Output < if exists>
2022-08-06 20:21:14 +00:00
Test Case 1:
Input- 3
1 2 3 4 5 6
Output- 1>2>3>5>6
````
2021-04-07 18:32:02 +00:00
#### `.gitignore` File
2021-03-18 19:48:09 +00:00
```gitignore
# add all output files and build files to be excluded from git tracking
main # executable file also must have the project name
target/ # the build file, for example for rust
2021-01-15 13:52:11 +00:00
```
2021-03-18 19:48:09 +00:00
2021-04-07 18:32:02 +00:00
#### Build File / Specification File / Configuration File
2021-03-18 19:48:09 +00:00
It can be any of the following ones
2021-03-18 19:48:09 +00:00
- **C/C++**: `Makefile`
- **Python**: `requirements.txt`
- **JavaScript**: `package.json` and `package-lock.json`
- **Rust**: `Cargo.toml` and `Cargo.lock`
- **Go**: `go.mod`
2021-04-07 18:32:02 +00:00
#### Source Code File
2021-03-18 19:48:09 +00:00
The source code files, should either be in `src/` folder (**Eg.** `src/main.cpp` or `src/main.js`) or the root folder (**Eg.** `palindrome.go` or `App.java`) where `ext` is the file extension for the specific programming language.
Again, the source codes must conform to a valid file structure convention that the programming language enforces.
2021-04-07 18:32:02 +00:00
### 2. Naming Convention
2021-03-18 19:48:09 +00:00
The programming should keep the naming convention rule of each programming language.
2020-12-23 14:22:49 +00:00
### Other topic
- [First-time contribution](CONTRIBUTING.md)
2021-03-03 22:52:16 +00:00
2021-05-21 12:17:36 +00:00
## Reviewers
| Programming Language | Users |
| -------------------- | ------------------------------------------------- |
| C or C++ | @Arsenic-ATG, @UG-SEP, @aayushjain7, @Ashborn-SM |
2021-10-13 11:11:13 +00:00
| Java | @TawfikYasser, @aayushjain7 |
| C# | @ming-tsai, @Waqar-107 |
2022-02-23 13:20:55 +00:00
| Go | |
| Python | @Arsenic-ATG, @sridhar-5 |
2021-08-09 14:48:37 +00:00
| JavaScript | @ming-tsai |
2021-05-21 12:17:36 +00:00
## Contributors
<a href="https://github.com/MakeContributions/DSA/graphs/contributors">
<img src="https://contrib.rocks/image?repo=MakeContributions/DSA" />
2022-08-06 20:21:14 +00:00
2021-05-21 12:17:36 +00:00
</a>
2021-04-09 16:48:38 +00:00
## Open Graph
2021-04-09 16:48:38 +00:00
<img src="https://opengraph.github.com/3b128f0e88464a82a37f2daefd7d594c6f41a3c22b3bf94c0c030135039b5dd7/MakeContributions/DSA" />
2020-12-23 14:22:49 +00:00
## License
2020-12-23 14:22:49 +00:00
[MIT](./LICENSE)