Skip to content

Updated Sorting README #173

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

Merged
merged 6 commits into from
Dec 12, 2017
Merged
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
18 changes: 9 additions & 9 deletions Competitive Coding/Graphs/Shortest Path/dijsktra/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Edsger W.Dijkstra
Dijkstra thought about the shortest path problem when working at the Mathematical Center in Amsterdam in 1956 as a programmer to demonstrate capabilities of a new computer called ARMAC. His objective was to choose both a problem as well as an answer (that would be produced by computer) that non-computing people could understand. He designed the shortest path algorithm and later implemented it for ARMAC for a slightly simplified transportation map of 64 cities in the Netherlands (64, so that 6 bits would be sufficient to encode the city number).
A year later, he came across another problem from hardware engineers working on the institute's next computer: minimize the amount of wire needed to connect the pins on the back panel of the machine. As a solution, he re-discovered the algorithm known as Prim's minimal spanning tree algorithm (known earlier to Jarník, and also rediscovered by Prim).
Dijkstra published the algorithm in 1959, two years after Prim and 29 years after Jarník.


**Algorithm**

Let the node at which we are starting be called the initial node. Let the distance of node Y be the distance from the initial node to Y. Dijkstra's algorithm will assign some initial distance values and will try to improve them step by step.

Assign to every node a tentative distance value: set it to zero for our initial node and to infinity for all other nodes.
Expand All @@ -29,7 +29,7 @@ Otherwise, select the unvisited node that is marked with the smallest tentative

---------------------------------------------------

##Related Problems
## Related Problems
The functionality of Dijkstra's original algorithm can be extended with a variety of modifications. For example, sometimes it is desirable to present solutions which are less than mathematically optimal. To obtain a ranked list of less-than-optimal solutions, the optimal solution is first calculated. A single edge appearing in the optimal solution is removed from the graph, and the optimum solution to this new graph is calculated. Each edge of the original solution is suppressed in turn and a new shortest-path calculated. The secondary solutions are then ranked and presented after the first optimal solution.

Dijkstra's algorithm is usually the working principle behind link-state routing protocols, OSPF and IS-IS being the most common ones.
Expand All @@ -47,16 +47,16 @@ Fast marching method can be viewed as a continuous version of Dijkstra's algorit

----------------------------------------------------------

##Applications
## Applications

1. **Flight Agenda** -- A travel agent requests software for making an agenda of flights for clients. The agent has access to a data base with all airports and flights. Besides the flight number, origin airport and destination, the flights have departure and arrival time. Specifically the agent wants to determine the earliest arrival time for the destination given an origin airport and start time

2. **Telephone Network** -- In a telephone network the lines have bandwidth, BW. We want to route the phone call via the highest BW.


----------------------------------------------
**Source**

[Wikipedia](https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm)

[Dijkstra](http://www.csl.mtu.edu/cs2321/www/newLectures/30_More_Dijkstra.htm)
26 changes: 23 additions & 3 deletions Competitive Coding/Sorting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,35 @@ __Properties__
* Best case performance O(n log n)
* Average case performance depends on gap sequence

####Radix Sorting
From [Wikipedia](https://en.wikipedia.org/wiki/Radix_sort): radix sort is a non-comparative integer sorting algorithm that sorts data with integer keys by grouping keys by the individual digits which share the same significant position and value. A positional notation is required, but because integers can represent strings of characters (e.g., names or dates) and specially formatted floating point numbers, radix sort is not limited to integers. Radix sort dates back as far as 1887 to the work of Herman Hollerith on tabulating machines.
###### View the algorithm in [action](https://www.toptal.com/developers/sorting-algorithms/shell-sort)

### Heap
![](https://upload.wikimedia.org/wikipedia/commons/4/4d/Heapsort-example.gif)

From [Wikipedia](https://en.wikipedia.org/wiki/Heapsort): Heapsort is a comparison-based sorting algorithm. Heapsort can be thought of as an improved selection sort: like that algorithm, it divides its input into a sorted and an unsorted region, and it iteratively shrinks the unsorted region by extracting the largest element and moving that to the sorted region. The improvement consists of the use of a heap data structure rather than a linear-time search to find the maximum.

__Properties__
* Worst case performance O(n log n)
* Best case performance O(n log n)
* Average case performance O(n log n)

###### View the algorithm in [action](https://www.toptal.com/developers/sorting-algorithms/heap-sort)

### Radix
From [Wikipedia](https://en.wikipedia.org/wiki/Radix_sort): Radix sort is a non-comparative integer sorting algorithm that sorts data with integer keys by grouping keys by the individual digits which share the same significant position and value. A positional notation is required, but because integers can represent strings of characters (e.g., names or dates) and specially formatted floating point numbers, radix sort is not limited to integers. Radix sort dates back as far as 1887 to the work of Herman Hollerith on tabulating machines.

__Properties__
* Worst case performance O(wn)
* Best case performance O(w + N)
* Average case performance depends on gap sequence

###### View the algorithm in [action](https://www.toptal.com/developers/sorting-algorithms/shell-sort)
### Counting
From [Wikipedia](https://en.wikipedia.org/wiki/Counting_sort): Counting sort is an algorithm for sorting a collection of objects according to keys that are small integers; that is, it is an integer sorting algorithm. It operates by counting the number of objects that have each distinct key value(k: max key value), and using arithmetic on those counts to determine the positions of each key value in the output sequence.

__Properties__
* Worst case performance O(n + k)
* Best case performance O(n + k)
* Average case performance O(n + k)

### Time-Compexity Graphs

Expand Down
1 change: 1 addition & 0 deletions Sun.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pi=3.1415926535897931
1 change: 1 addition & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import Sun