Algorithms CompleteComplete Tips & Secrets for Professionals Algorithms Tips & Secrets for Professionals 200+ pages of professional hints and tricks Disclaimer This is an unocial free book created for educational purposes and is GoalKicker.com not aliated with ocial Algorithms group(s) or company(s). Free Programming Books All trademarks and registered trademarks are the property of their respective owners Contents About ................................................................................................................................................................................... 1 Chapter 1: Getting started with algorithm ....................................................................................................... 2 Section 1.1: A sample algorithmic problem ................................................................................................................. 2 Section 1.2: Getting Started with Simple Fizz Buzz Algorithm in Swift ...................................................................... 2 Chapter 2: Sorting ........................................................................................................................................................ 4 Section 2.1: Stability in Sorting ...................................................................................................................................... 4 Chapter 3: Bubble Sort ............................................................................................................................................... 5 Section 3.1: Bubble Sort ................................................................................................................................................. 5 Section 3.2: Implementation in C & C++ ...................................................................................................................... 5 Section 3.3: Implementation in C# ............................................................................................................................... 6 Section 3.4: Python Implementation ............................................................................................................................ 7 Section 3.5: Implementation in Java ........................................................................................................................... 7 Section 3.6: Implementation in Javascript .................................................................................................................. 8 Chapter 4: Algorithm Complexity ......................................................................................................................... 8 Section 4.1: Big-Theta notation .................................................................................................................................... 9 Section 4.2: Comparison of the asymptotic notations ............................................................................................ 10 Section 4.3: Big-Omega Notation .............................................................................................................................. 10 Chapter 5: Graph ........................................................................................................................................................ 11 Section 5.1: Storing Graphs (Adjacency Matrix) ....................................................................................................... 11 Section 5.2: Introduction To Graph Theory .............................................................................................................. 15 Section 5.3: Storing Graphs (Adjacency List) ........................................................................................................... 18 Section 5.4: Topological Sort ...................................................................................................................................... 20 Section 5.5: Detecting a cycle in a directed graph using Depth First Traversal .................................................. 21 Section 5.6: Thorup's algorithm ................................................................................................................................. 22 Chapter 6: Dynamic Programming .................................................................................................................... 23 Section 6.1: Edit Distance ............................................................................................................................................ 23 Section 6.2: Weighted Job Scheduling Algorithm .................................................................................................... 24 Section 6.3: Longest Common Subsequence ........................................................................................................... 27 Section 6.4: Fibonacci Number .................................................................................................................................. 28 Section 6.5: Longest Common Substring .................................................................................................................. 29 Chapter 7: Kruskal's Algorithm ............................................................................................................................ 29 Section 7.1: Optimal, disjoint-set based implementation ......................................................................................... 29 Section 7.2: Simple, more detailed implementation ................................................................................................ 30 Section 7.3: Simple, disjoint-set based implementation .......................................................................................... 31 Section 7.4: Simple, high level implementation ........................................................................................................ 31 Chapter 8: Greedy Algorithms ............................................................................................................................. 31 Section 8.1: Human Coding ...................................................................................................................................... 31 Section 8.2: Activity Selection Problem ..................................................................................................................... 34 Section 8.3: Change-making problem ...................................................................................................................... 36 Chapter 9: Searching ................................................................................................................................................ 37 Section 9.1: Binary Search .......................................................................................................................................... 37 Section 9.2: Rabin Karp .............................................................................................................................................. 39 Section 9.3: Analysis of Linear search (Worst, Average and Best Cases) ............................................................ 39 Section 9.4: Binary Search: On Sorted Numbers ..................................................................................................... 41 Section 9.5: Linear search .......................................................................................................................................... 42 Chapter 10: Big-O Notation ................................................................................................................................... 42 Section 10.1: A Simple Loop ......................................................................................................................................... 42 Section 10.2: A Nested Loop ....................................................................................................................................... 43 Section 10.3: O(log n) types of Algorithms ............................................................................................................... 44 Section 10.4: An O(log n) example ............................................................................................................................. 45 Chapter 11: Bellman–Ford Algorithm ................................................................................................................ 46 Section 11.1: Single Source Shortest Path Algorithm (Given there is a negative cycle in a graph) ..................... 46 Section 11.2: Detecting Negative Cycle in a Graph ................................................................................................... 50 Section 11.3: Why do we need to relax all the edges at most (V-1) times .............................................................. 52 Chapter 12: Merge Sort ............................................................................................................................................ 54 Section 12.1: Merge Sort Basics .................................................................................................................................. 54 Section 12.2: Merge Sort Implementation in Go ....................................................................................................... 55 Section 12.3: Merge Sort Implementation in C & C# ...............................................................................................
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages216 Page
-
File Size-