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

Make me friendly #42

Open
wants to merge 7 commits into
base: make-me-friendly
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.idea
Thumbs.db
desktop.ini
*.pyo
*.pyc
8 changes: 8 additions & 0 deletions bubble_sort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# https://www.geeksforgeeks.org/python-program-for-bubble-sort/

def bubbleSort(arr):
n = len(arr)
for i in range(n):
for j in range(0, n-i-1):
if arr[j] > arr[j+1] :
arr[j], arr[j+1] = arr[j+1], arr[j]
21 changes: 21 additions & 0 deletions heap_sort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# https://www.geeksforgeeks.org/heap-sort/

def heapify(arr, n, i):
largest = i
l = 2 * i + 1
r = 2 * i + 2
if l < n and arr[i] < arr[l]:
largest = l
if r < n and arr[largest] < arr[r]:
largest = r
if largest != i:
arr[i],arr[largest] = arr[largest],arr[i]
heapify(arr, n, largest)

def heapSort(arr):
n = len(arr)
for i in range(n, -1, -1):
heapify(arr, n, i)
for i in range(n-1, 0, -1):
arr[i], arr[0] = arr[0], arr[i]
heapify(arr, i, 0)
10 changes: 10 additions & 0 deletions run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from bubble_sort import bubbleSort
from heap_sort import heapSort

bubble_sorted = [1,4,2,56,134,7,2]
bubbleSort(bubble_sorted)
print(bubble_sorted)

heap_sorted = [25,66,2,7,91,2,3,11,7]
heapSort(heap_sorted)
print(heap_sorted)
2 changes: 1 addition & 1 deletion sample.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

В строке ниже будет конфликт, потому что в разных ветках были изменения, и git не может решить без нас, какие из них важнее

Это исправленное содержимое ветки master <- Здесь будет конфликт
Это исправленное содержимое ветки make-me-friendly <- Здесь будет конфликт

При этом, git достаточно умен для того, чтобы объединить изменения из разных веток в одном файле, если они не соприкасаются номерами измененных строк