Skip to main content

Algorithms in a Nutshell

The following are some of the the chapters from Algorithm's in a Nutshell, from which I will produce code in .NET, specifically C#, VB.NET or F#, to clarify the principles for myself.


Chapter 4. Sorting Algorithms

·       Section 4.1. Overview
·       Section 4.2. Insertion Sort
·       Section 4.3. Median Sort
·       Section 4.4. Quicksort
·       Section 4.5. Selection Sort
·       Section 4.6. Heap Sort
·       Section 4.7. Counting Sort
·       Section 4.8. Bucket Sort
·       Section 4.9. Criteria for Choosing a Sorting Algorithm
·       Section 4.10. References

Chapter 5. Searching

·       Section 5.1. Overview
·       Section 5.2. Sequential Search
·       Section 5.3. Binary Search
·       Section 5.4. Hash-based Search
·       Section 5.5. Binary Tree Search

Chapter 6. Graph Algorithms

·       Section 6.1. Overview
·       Section 6.2. Depth-First Search
·       Section 6.3. Breadth-First Search
·       Section 6.4. Single-Source Shortest Path
·       Section 6.5. All Pairs Shortest Path
·       Section 6.6. Minimum Spanning Tree Algorithms
·       Section 6.7. References

Chapter 7. Path Finding in AI

·       Section 7.1. Overview
·       Section 7.2. Depth-First Search
·       Section 7.3. Breadth-First Search
·       Section 7.4. A*Search
·       Section 7.5. Comparison
·       Section 7.6. Minimax
·       Section 7.7. NegMax
·       Section 7.8. AlphaBeta
·       Section 7.9. References

Chapter 8. Network Flow Algorithms

·       Section 8.1. Overview
·       Section 8.2. Maximum Flow
·       Section 8.3. Bipartite Matching
·       Section 8.4. Reflections on Augmenting Paths
·       Section 8.5. Minimum Cost Flow
·       Section 8.6. Transshipment
·       Section 8.7. Transportation
·       Section 8.8. Assignment
·       Section 8.9. Linear Programming
·       Section 8.10. References

Chapter 9. Computational Geometry

·       Section 9.1. Overview
·       Section 9.2. Convex Hull Scan
·       Section 9.3. LineSweep
·       Section 9.4. Nearest Neighbor Queries
·       Section 9.5. Range Queries
·       Section 9.6. References

Comments

Popular posts from this blog

Heap Sort

Heap Sort is interesting because the use of the 'heapify' method that creates a binary tree as a flat array. First, a binary tree, also known as a heap , is created, and then the same function is used to sort the elements. In a heap, the first node in the array at zero (0) is the top node of the binary tree. The next two (2) items are the two (2) subnodes of the top node, and so on.  For each node at a position (positionIndex), its 2 subnodes are in the following positions: int left = 2 * positionIndex + 1; int right = 2 *  positionIndex + 2; The CommonMethods.Swap() function is a reusable class , since swapping values by position is a common action during these example sorts. Class using System; namespace Algorithms {     class HeapSort     {         public int[]  Sort()         {             //creates array             int[] arrayTo...

Hash-based Search

An example of a hash-based search, although using dictionaries.  The code is designed to manage lists of Person objects, with unique Id's as the key value, with a rudimentary hash function to assign to various lists. Salient Characteristic(s) Useful for managing large unsorted lists Divides the items into smaller hash-based buckets (divide and conquer) Generally excellent performance Sensitive to the choice of hash function and data structures chosen Note The Id key is not rigorous enough to guarantee uniqueness, and a better key might need to be selected, e.g., SSN, to prevent the same person being entered twice. Code using System; using System.Collections.Generic; namespace Algorithms {     //Example object to add and find in Hash Search example     public class Person     {         private int _Id;         public int Id          {     ...

Binary Search

This is the basic divide-and-conquer algorithm, requiring a sorted array. This repeatedly halves the remaining positions to search, until the value is found, or it determines that the value cannot be found. As mentioned, it requires a presorted array, or if unsorted, requires it is sorted. The benefits accrue in instances where the array is sorted once, but searched many times. On a hypothetical array of 100 items, a linear search has an average performances of O(n/2), or a search of half the positions, 50, to find the item. By comparison, the average performance of Binary Search is O(log n), which for 100 items translates into 4.6, a radically reduced number of iterations, but with greater requirements for logic and memory. Done in both C#, as an iterative while loop, and F#, as a recursion. C# using System; namespace Algorithms { class BinarySearch { public BinarySearch() { } public int Search(int num, int[] arrayToSearch) ...