diff --git a/Competitive Coding/Graphs/Shortest Path/dijsktra/README.md b/Competitive Coding/Graphs/Shortest Path/dijsktra/README.md index 13bc946ff..33a53180f 100644 --- a/Competitive Coding/Graphs/Shortest Path/dijsktra/README.md +++ b/Competitive Coding/Graphs/Shortest Path/dijsktra/README.md @@ -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. @@ -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. @@ -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) diff --git a/Competitive Coding/Sorting/README.md b/Competitive Coding/Sorting/README.md index 96b0cce5e..101d71ca0 100644 --- a/Competitive Coding/Sorting/README.md +++ b/Competitive Coding/Sorting/README.md @@ -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 diff --git a/Sun.py b/Sun.py new file mode 100644 index 000000000..60b2c3b8d --- /dev/null +++ b/Sun.py @@ -0,0 +1 @@ +pi=3.1415926535897931 diff --git a/__init__.py b/__init__.py new file mode 100644 index 000000000..0e357ea5f --- /dev/null +++ b/__init__.py @@ -0,0 +1 @@ +import Sun