Skip to content

Commit 8b9ca96

Browse files
authored
Merge branch 'kelvins:main' into Abhiharsh-IN-Hacktoberfest
2 parents 445cb5f + a39bcb3 commit 8b9ca96

File tree

4 files changed

+180
-14
lines changed

4 files changed

+180
-14
lines changed

CONTRIBUTING.md

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,58 @@
11
# Contributing
22

3-
You can contribute in 3 ways: creating issues, opening pull requests, and reviewing pull requests.
4-
## Creating Issues
3+
Thanks for your interest in contributing! We appreciate your support, and we welcome contributions from the community.
54

6-
Feel free to create an issue if you encounter any problems, have any suggestions, or would like a specific new algorithm or language to be included. Open a new PR directly in cases of minor corrections or inclusion of algorithms already listed in a language not yet implemented.
5+
Before you start contributing, please take a moment to review this document to understand the process and guidelines for contributing to our project.
76

8-
Before creating the issue, check for similar issues and remember to detail the problem encountered or proposed suggestion.
7+
## Code of Conduct
98

10-
## Opening Pull Requests
9+
We have adopted a [Code of Conduct](./CODE-OF-CONDUCT.md) that we expect all community members to follow. Please make sure to review and adhere to it in all interactions within our community.
1110

12-
It is also possible to contribute by opening a Pull Request (PR) with a solution to a problem or including a new algorithm.
11+
## How Can I Contribute?
1312

14-
When opening a PR, remember to include a relevant description of the changes made and add a link in the project's README if new algorithms are incorporated.
13+
There are various ways to contribute:
1514

16-
## Reviewing Pull Requests
15+
- Reporting Issues: If you encounter a bug or have a feature request, please open an issue on GitHub.
16+
- Code Contributions: If you are a developer, you can help us by submitting pull requests.
17+
- Documentation: Improvements to our documentation are always welcome.
1718

18-
Another way to contribute to the project is by reviewing open PRs. If you have mastery of an algorithm, data structure, or even a specific programming language, feel free to help review the open PRs.
19+
## Reporting Issues
1920

20-
When reviewing, remember to be cordial/polite and, if possible, manually test the change or correction before approving the PR.
21+
If you encounter an issue or have a feature request, please follow these steps:
22+
23+
1. Check if the issue or feature request already exists.
24+
2. If it doesn't exist, please open a new issue, providing a clear and detailed description of the problem or request.
25+
3. Use a descriptive title, provide steps to reproduce the issue, and specify your environment.
26+
27+
## Development Guidelines
28+
29+
Before you start working on a contribution, please keep in mind the following guidelines:
30+
31+
- Adhere to our [Code of Conduct](./CODE-OF-CONDUCT.md).
32+
- Respect and follow existing project coding standards.
33+
- Write clear and concise commit messages.
34+
- Test your changes thoroughly.
35+
- Make your code clean and readable.
36+
- Document your code as necessary.
37+
38+
## Submitting Pull Requests
39+
40+
To submit a pull request, please follow these steps:
41+
42+
1. Fork the repository.
43+
2. Create a new branch for your contribution: `git checkout -b feature/my-contribution`.
44+
3. Make your changes and commit them.
45+
4. Ensure that your code is properly tested.
46+
5. Create a pull request against our main branch.
47+
6. Clearly describe your changes, why they are necessary, and how to test them.
48+
7. Be responsive to feedback and participate in the review process.
49+
50+
## Review Process
51+
52+
All contributions will be reviewed by project maintainers. We may provide feedback or request additional changes. Your contribution will be merged once it meets our standards.
53+
54+
## Getting Help
55+
56+
If you need assistance or have any questions, you can reach out to us. We are here to help you with your contributions.
57+
58+
We look forward to your contributions and thank you for your time and effort!

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2220,8 +2220,8 @@ In order to achieve greater coverage and encourage more people to contribute to
22202220
</a>
22212221
</td>
22222222
<td> <!-- C++ -->
2223-
<a href="./CONTRIBUTING.md">
2224-
<img align="center" height="25" src="./logos/github.svg" />
2223+
<a href="./src/cpp/Stack.cpp">
2224+
<img align="center" height="25" src="./logos/cplusplus.svg" />
22252225
</a>
22262226
</td>
22272227
<td> <!-- Java -->
@@ -2288,8 +2288,8 @@ In order to achieve greater coverage and encourage more people to contribute to
22882288
</a>
22892289
</td>
22902290
<td> <!-- Python -->
2291-
<a href="./CONTRIBUTING.md">
2292-
<img align="center" height="25" src="./logos/github.svg" />
2291+
<a href="./src/python/dynamic_stack.py">
2292+
<img align="center" height="25" src="./logos/python.svg" />
22932293
</a>
22942294
</td>
22952295
<td> <!-- Go -->

src/cpp/Stack.cpp

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#include <iostream>
2+
3+
// MAX is a macro to define all stack instances size
4+
#define MAX 10
5+
6+
// Stack: Last In - First Out (LIFO)
7+
8+
class Stack {
9+
private:
10+
int array[MAX];
11+
int index = 0;
12+
13+
public:
14+
Stack(){}
15+
16+
void push(int element) {
17+
if (this->index >= MAX) {
18+
throw std::logic_error("Stack is full!");
19+
}
20+
this->array[index] = element;
21+
index++;
22+
}
23+
24+
bool isEmpty() {
25+
if (!this->index) {
26+
return true;
27+
}
28+
return false;
29+
}
30+
31+
int pop() {
32+
if (this->isEmpty()) {
33+
throw std::logic_error("Stack is empty!");
34+
}
35+
index--;
36+
int value = this->array[this->index];
37+
this->array[this->index] = 0;
38+
return value;
39+
}
40+
41+
void print() {
42+
std::cout << "[ ";
43+
for (int i = 0; i < this->index; i++) {
44+
std::cout << this->array[i] << " ";
45+
}
46+
std::cout << "]" << std::endl;
47+
}
48+
};
49+
50+
int main() {
51+
// Create a pointier to a new Stack instance
52+
Stack* stack = new Stack();
53+
54+
std::cout << "Push(1, 2, 4)" << std::endl;
55+
stack->push(1);
56+
stack->push(2);
57+
stack->push(4);
58+
stack->print();
59+
60+
std::cout << "Pop()" << std::endl;
61+
stack->pop();
62+
stack->print();
63+
64+
stack->pop();
65+
stack->pop();
66+
67+
std::cout << "Empty Stack" << std::endl;
68+
stack->print();
69+
}

src/python/dynamic_stack.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Stack: Last In - First Out (LIFO)
2+
3+
4+
# Define node format: value and a pointier to next
5+
class Node:
6+
def __init__(self, value: int) -> None:
7+
self.value = value
8+
self.next = None
9+
10+
11+
class DynamicStack:
12+
def __init__(self) -> None:
13+
self.__first = None
14+
15+
def isEmpty(self) -> bool:
16+
if not self.__first:
17+
return True
18+
return False
19+
20+
def push(self, value: int):
21+
node = Node(value)
22+
node.next = self.__first
23+
self.__first = node
24+
25+
def pop(self) -> int:
26+
if self.isEmpty():
27+
raise Exception("Stack is empty!")
28+
removedElement = self.__first.value
29+
self.__first = self.__first.next
30+
return removedElement
31+
32+
def show(self) -> None:
33+
node = self.__first
34+
print("[", end=" ")
35+
while node:
36+
print(node.value, end=" ")
37+
node = node.next
38+
print("]")
39+
40+
41+
def main() -> None:
42+
dynamic_stack = DynamicStack()
43+
44+
print(f"Push(1,2,4):")
45+
dynamic_stack.push(1)
46+
dynamic_stack.push(2)
47+
dynamic_stack.push(4)
48+
49+
dynamic_stack.show()
50+
51+
print(f"Remove last: {dynamic_stack.pop()}")
52+
print(f"Remove last: {dynamic_stack.pop()}")
53+
print(f"Remove last: {dynamic_stack.pop()}")
54+
print("Empty stack!")
55+
dynamic_stack.show()
56+
57+
58+
if __name__ == "__main__":
59+
main()

0 commit comments

Comments
 (0)