Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create quicksort.py #2707

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#### Name: [Mohammed Aman](https://giithub.com/beastaman)

- Place: Hyderabad, Telangana, India
- Bio: Frontend Developer | ReactJs Developer | Tech Enthusiast
- GitHub: [beastaman](https://github.com/beastaman)

#### Name: [3mYouOL](https://github.com/3mYouOL)

- Place: Iloilo, Philippines
Expand Down
40 changes: 40 additions & 0 deletions profiles/mohd_aman.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<div align="center">

[![Typing SVG](https://readme-typing-svg.herokuapp.com?font=Fira+Code&pause=1000&color=4700F7&background=00FFD200&center=true&vCenter=true&width=435&lines=Hi%2C+Beast+Aman+Here...)](https://git.io/typing-svg)
# I'm a Front End Web Developer <img src="https://media.giphy.com/media/hvRJCLFzcasrR4ia7z/giphy.gif" width="35" />

</div>

<br />

### <img src="https://media.giphy.com/media/WUlplcMpOCEmTGBtBW/giphy.gif" width="30"> &nbsp; Introduction:

- 🌱 I’m currently working as Frontend Developer
- 🤔 I’m looking for help with other content creators
- 📫 How to reach me: ✨ _[my web][website]_ ✨
- ⚡ Fun fact: I love to play guitar and cook

### 🧏‍♂️ &nbsp; Connect with me:

[![Facebook](https://img.shields.io/badge/Facebook-%231877F2.svg?style=for-the-badge&logo=Facebook&logoColor=white)][facebook]
[![Instagram](https://img.shields.io/badge/Instagram-%23E4405F.svg?style=for-the-badge&logo=Instagram&logoColor=white)][instagram]
[![dev](https://img.shields.io/badge/Dev-%23000000.svg?style=for-the-badge&logo=Dev&logoColor=white)][dev]
[![medium](https://img.shields.io/badge/Medium-%23000000.svg?style=for-the-badge&logo=Medium&logoColor=white)][medium]
[![CodePen](https://img.shields.io/badge/Codepen-000000?style=for-the-badge&logo=codepen&logoColor=white)][codepen]

### 🖥 &nbsp; Skills & Tools:

![HTML5](https://img.shields.io/badge/html5-%23E34F26.svg?style=for-the-badge&logo=html5&logoColor=white)
![CSS3](https://img.shields.io/badge/css3-%231572B6.svg?style=for-the-badge&logo=css3&logoColor=white)
![JavaScript](https://img.shields.io/badge/javascript-%23323330.svg?style=for-the-badge&logo=javascript&logoColor=%23F7DF1E)
![PHP](https://img.shields.io/badge/php-%23777BB4.svg?style=for-the-badge&logo=php&logoColor=white)
![React](https://img.shields.io/badge/react-%2320232a.svg?style=for-the-badge&logo=react&logoColor=%2361DAFB)
![NodeJS](https://img.shields.io/badge/node.js-6DA55F?style=for-the-badge&logo=node.js&logoColor=white)


[website]: https://beastaman.github.io/myweb
[instagram]: https://www.instagram.com/mohd_aman_25/
[facebook]: https://www.facebook.com/mohammedaman.nawaz.77
[medium]: https://www.medium.com/mohammedamannawaz
[codepen]: https://codepen.io/itsaman25
[dev]: https://dev.to/beastaman25
39 changes: 39 additions & 0 deletions scripts/mergesort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
def merge_sort(arr):
if len(arr) > 1:
mid = len(arr) // 2 # Find the middle of the array
left_half = arr[:mid] # Divide the array into two halves
right_half = arr[mid:]

# Recursive call on each half
merge_sort(left_half)
merge_sort(right_half)

i = j = k = 0

# Copy data to temporary arrays left_half and right_half
while i < len(left_half) and j < len(right_half):
if left_half[i] < right_half[j]:
arr[k] = left_half[i]
i += 1
else:
arr[k] = right_half[j]
j += 1
k += 1

# Check if any element was left
while i < len(left_half):
arr[k] = left_half[i]
i += 1
k += 1

while j < len(right_half):
arr[k] = right_half[j]
j += 1
k += 1

# Example usage:
if __name__ == "__main__":
arr = [12, 11, 13, 5, 6, 7]
print("Unsorted array:", arr)
merge_sort(arr)
print("Sorted array:", arr)
15 changes: 15 additions & 0 deletions scripts/quicksort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
def quicksort(arr):
if len(arr) <= 1:
return arr

pivot = arr[len(arr) // 2]
left = [x for x in arr if x < pivot]
middle = [x for x in arr if x == pivot]
right = [x for x in arr if x > pivot]

return quicksort(left) + middle + quicksort(right)

# Example usage:
my_list = [3, 6, 8, 10, 1, 2, 1]
sorted_list = quicksort(my_list)
print("Sorted array:", sorted_list)