Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fa41b6f

Browse files
rahulkumaransoubh1k
authored andcommitted
Added a README.md in Searching and Sorting directories separately (#112)
* Create README.md * Create README.md
1 parent f460e32 commit fa41b6f

File tree

2 files changed

+124
-0
lines changed

2 files changed

+124
-0
lines changed

‎Competitive Coding/Search/README.md‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## Search Algorithms
2+
3+
### Linear
4+
![alt text](https://camo.githubusercontent.com/c05ad3f2178af2f16ebe2c04eb122e1e0c6a055b/687474703a2f2f7777772e7475746f7269616c73706f696e742e636f6d2f646174615f737472756374757265735f616c676f726974686d732f696d616765732f6c696e6561725f7365617263682e676966)
5+
6+
From [Wikipedia](https://en.wikipedia.org/wiki/Linear_search): linear search or sequential search is a method for finding a target value within a list. It sequentially checks each element of the list for the target value until a match is found or until all the elements have been searched.
7+
Linear search runs in at worst linear time and makes at most n comparisons, where n is the length of the list.
8+
9+
__Properties__
10+
* Worst case performance O(n)
11+
* Best case performance O(1)
12+
* Average case performance O(n)
13+
* Worst case space complexity O(1) iterative
14+
15+
### Binary
16+
![alt text](https://camo.githubusercontent.com/1cd853b57885449a176810b3e967167fb9fbf3b3/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f662f66372f42696e6172795f7365617263685f696e746f5f61727261792e706e67)
17+
18+
From [Wikipedia](https://en.wikipedia.org/wiki/Binary_search_algorithm): Binary search, also known as half-interval search or logarithmic search, is a search algorithm that finds the position of a target value within a sorted array. It compares the target value to the middle element of the array; if they are unequal, the half in which the target cannot lie is eliminated and the search continues on the remaining half until it is successful.
19+
20+
__Properties__
21+
* Worst case performance O(log n)
22+
* Best case performance O(1)
23+
* Average case performance O(log n)
24+
* Worst case space complexity O(1)
25+
26+
### Interpolation
27+
Interpolation search is an improved version of binary search algorithm.
28+
29+
![alt text](https://qph.ec.quoracdn.net/main-qimg-02f1f050de01608b9b1f2f27155d1b17)
30+
31+
Even when the data is sorted, binary search does not take advantage of that to probe the position of desired data.
32+
Position Probing in Interpolation
33+
SearchInterpolation search search a particular item by computing the probe position. Initially probe position is the position of the middle most item of the collection.If middle item is greater than item then probe position is again calculated in the sub-array to the right of the middle item other wise item is search in sub-array to the left of the middle item. This process continues on sub-array as well until the size of subarray reduces to zero.
34+
35+
36+
__Properties__
37+
* Worst case performance O(n)
38+
* Best case performance O(1)
39+
* Average case performance O(log(logn))
40+
* Worst case space cmplexity O(1)

‎Competitive Coding/Sorting/README.md‎

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
## Sort Algorithms
2+
3+
4+
### Bubble
5+
![alt text](https://camo.githubusercontent.com/40b8099e638526dce298f8dc91246173d56e389a/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f7468756d622f382f38332f427562626c65736f72742d6564697465642d636f6c6f722e7376672f32323070782d427562626c65736f72742d6564697465642d636f6c6f722e7376672e706e67)
6+
7+
From [Wikipedia](https://en.wikipedia.org/wiki/Bubble_sort): Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the list to be sorted, compares each pair of adjacent items and swaps them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted.
8+
9+
__Properties__
10+
* Worst case performance O(n^2)
11+
* Best case performance O(n)
12+
* Average case performance O(n^2)
13+
14+
###### View the algorithm in [action](https://www.toptal.com/developers/sorting-algorithms/bubble-sort)
15+
16+
17+
18+
### Insertion
19+
![alt text](https://camo.githubusercontent.com/a7657e625281b63ca552a40c099c9331ce79f6a1/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f372f37652f496e73657274696f6e736f72742d6564697465642e706e67)
20+
21+
From [Wikipedia](https://en.wikipedia.org/wiki/Insertion_sort): Insertion sort is a simple sorting algorithm that builds the final sorted array (or list) one item at a time. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort.
22+
23+
__Properties__
24+
* Worst case performance O(n^2)
25+
* Best case performance O(n)
26+
* Average case performance O(n^2)
27+
28+
###### View the algorithm in [action](https://www.toptal.com/developers/sorting-algorithms/insertion-sort)
29+
30+
31+
### Merge
32+
![alt text](https://camo.githubusercontent.com/64ba2bcbd5c11779657e40a1d03d0ea691f6fa57/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f632f63632f4d657267652d736f72742d6578616d706c652d33303070782e676966)
33+
34+
From [Wikipedia](https://en.wikipedia.org/wiki/Merge_sort): In computer science, merge sort (also commonly spelled mergesort) is an efficient, general-purpose, comparison-based sorting algorithm. Most implementations produce a stable sort, which means that the implementation preserves the input order of equal elements in the sorted output. Mergesort is a divide and conquer algorithm that was invented by John von Neumann in 1945.
35+
36+
__Properties__
37+
* Worst case performance O(n log n)
38+
* Best case performance O(n)
39+
* Average case performance O(n)
40+
41+
42+
###### View the algorithm in [action](https://www.toptal.com/developers/sorting-algorithms/merge-sort)
43+
44+
### Quick
45+
![alt text](https://camo.githubusercontent.com/2499d89bbb30337a5d2d7770cc034b4b71fbfdc6/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f362f36612f536f7274696e675f717569636b736f72745f616e696d2e676966)
46+
47+
From [Wikipedia](https://en.wikipedia.org/wiki/Quicksort): Quicksort (sometimes called partition-exchange sort) is an efficient sorting algorithm, serving as a systematic method for placing the elements of an array in order.
48+
49+
__Properties__
50+
* Worst case performance O(n^2)
51+
* Best case performance O(n log n) or O(n) with three-way partition
52+
* Average case performance O(n log n)
53+
54+
###### View the algorithm in [action](https://www.toptal.com/developers/sorting-algorithms/quick-sort)
55+
56+
### Selection
57+
![alt text](https://camo.githubusercontent.com/3174db3ca6ed6da3159b4bbc18f73359f0ab33ae/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f7468756d622f622f62302f53656c656374696f6e5f736f72745f616e696d6174696f6e2e6769662f32353070782d53656c656374696f6e5f736f72745f616e696d6174696f6e2e676966)
58+
59+
From [Wikipedia](https://en.wikipedia.org/wiki/Selection_sort): The algorithm divides the input list into two parts: the sublist of items already sorted, which is built up from left to right at the front (left) of the list, and the sublist of items remaining to be sorted that occupy the rest of the list. Initially, the sorted sublist is empty and the unsorted sublist is the entire input list. The algorithm proceeds by finding the smallest (or largest, depending on sorting order) element in the unsorted sublist, exchanging (swapping) it with the leftmost unsorted element (putting it in sorted order), and moving the sublist boundaries one element to the right.
60+
61+
__Properties__
62+
* Worst case performance O(n^2)
63+
* Best case performance O(n^2)
64+
* Average case performance O(n^2)
65+
66+
###### View the algorithm in [action](https://www.toptal.com/developers/sorting-algorithms/selection-sort)
67+
68+
### Shell
69+
![alt text](https://camo.githubusercontent.com/e80043bbd0ce86517a91198be315740504c6980e/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f642f64382f536f7274696e675f7368656c6c736f72745f616e696d2e676966)
70+
71+
From [Wikipedia](https://en.wikipedia.org/wiki/Shellsort): Shellsort is a generalization of insertion sort that allows the exchange of items that are far apart. The idea is to arrange the list of elements so that, starting anywherem considereing every nth element gives a sorted list. Such a list is said to be h-sorted. Equivanelty, it can be thought of as h intterleaved lists, each individually sorted.
72+
73+
__Properties__
74+
* Worst case performance O(nlog2 2n)
75+
* Best case performance O(n log n)
76+
* Average case performance depends on gap sequence
77+
78+
###### View the algorithm in [action](https://www.toptal.com/developers/sorting-algorithms/shell-sort)
79+
80+
### Time-Compexity Graphs
81+
82+
Comparing the complexity of sorting algorithms (Bubble Sort, Insertion Sort, Selection Sort)
83+
84+
[Complexity Graphs](https://github.com/prateekiiest/Python/blob/master/sorts/sortinggraphs.png)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /