Skip to content

Commit

Permalink
modified
Browse files Browse the repository at this point in the history
  • Loading branch information
patilniraj8 committed Sep 30, 2023
1 parent 969f216 commit 9c5ec85
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/sorting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ Heap sort is a comparison-based sorting algorithm that uses a binary heap data s
* In-place Swapping: Rust provides an efficient way to swap two elements in an array with arr.swap(i, j), which makes the algorithm elegant and concise.
* Performance: Rust, being a systems programming language, ensures that the heap sort implementation is efficient and can be optimized further by the Rust compiler.

![Alt text](image-4.png)

__Properties__
* In-place sorting: It sorts the data in place, requiring only a constant amount of additional memory.
* Time complexity: Heap sort has a worst-case time complexity of O(n log n).
Expand Down Expand Up @@ -172,6 +174,8 @@ The idea behind Pancake Sort:

The goal is to move the largest unsorted element to its correct position in each iteration.

![Alt text](image-3.png)

__Properties__
* Worst case : O(n^2)
* Average case : O(n^2)
Expand All @@ -193,6 +197,8 @@ Merge sort is a divide-and-conquer sorting algorithm. It works as follows:
* The sorted halves are merged together using the merge function.
* The merge function takes two sorted arrays (or slices) and returns a new array that contains all the elements from both arrays in sorted order. It does this by iterating through both arrays simultaneously, always choosing the smallest of the two current elements to append to the result.

![Alt text](image-2.png)

__Properties__
* Worst case : O(nlogn)
* Average case : O(nlogn)
Expand All @@ -217,6 +223,8 @@ Here's a step-by-step explanation followed by a Rust implementation:
* Insert the current element in its correct position so that the elements before are all smaller than the current element.
* Repeat the process for each of the elements in the array.

![Alt text](image-1.png)

__Properties__
* Worst case : O(n^2)
* Average case : O(n^2)
Expand Down
Binary file added src/sorting/image-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/sorting/image-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/sorting/image-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/sorting/image-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9c5ec85

Please sign in to comment.