Algorithms & Data Structures - 2015



Algorithms & Data Structures - 2015

  • Hash Tables
    Many applications require a dynamic set that support only the dictionary operations such as insert, search, and delete.
    A hash table is an effective data structure for implementing dictionaries. Although searching for an element in a hash table can take as long as searching for an element in a linked list - O(n) time in the worst case - in practice, hashing performs extremely well.
    Under reasonable assumptions, the average time to search for an element in a hash table is O(1).
    A hash table generalizes the simpler notion of an ordinary array.
    Directly addressing into an ordinary array makes effective use of our ability to examine an arbitrary position in an array in O(1) time.
    When the number of keys actually stored is small relative to the total number of possible keys, hash table becomes an effective alternative to directly addressing an array, since a hash table typically uses an array of size proportional to the number of keys actually stored. Instead of using the keys as an array index directly, the array index is computed from the key.
    Implementing hash table involves couple of ideas such as chaining as a way to handle collisions in which more than one key map to the same array index and open addressing which is another way to deal with collisions, and perfect hashing which gives us O(1) worst-case search time.
    Check an example for Hash Table from K&R.
    More on hashing Hash Map Sample codes
    Comparison: Hash Table vs Tree
    Examples of application: 1. De-duplication
    • Removing duplicates from a stream of objects such as linear scan through a huge file or object arriving in real time (packets).
    • Keep track of unique objects.
      • reports unique visitors to web site
      • avoid duplicates in search results
    • How?
      When a new object x arrives, lookup x in hash table. If not found, insert x into hash table.
    Examples of application: 2. The 2-sum problem
    • Input: unsorted array of n integers. Target sum t with any two numbers in the array.
    • Goal: Determine whether or not there are two numbers x, y in the array with x+y = t.
    Examples of application: 3. Historical applications
    • symbol tables in compilers
    • blocking network traffic
    • search algorithms (e.g., game tree exploration)
    Bloom filters


  • Heap
    In a heap, the records are stored in an array so that each key is guaranteed to be larger than its two children keys. So, no node in a heap-ordered tree has a key larger than the key at the root.
    The basic operations are:
    • insert - adding a new object to the heap, O(log(n))
    • extract - extracting max (or min) value, O(log(n))
    • heapify - n batched inserts, O(n)
    • delete - O(log(n))
    heap sort

  • Spatial Data Structures
    A spatial data structure is one that organized geometry in two- and three- dimensional hierarchical structures. So, the structure is nested and of recursive nature.

  • Read full article from Algorithms & Data Structures - 2015


    No comments:

    Post a Comment

    Labels

    Algorithm (219) Lucene (130) LeetCode (97) Database (36) Data Structure (33) text mining (28) Solr (27) java (27) Mathematical Algorithm (26) Difficult Algorithm (25) Logic Thinking (23) Puzzles (23) Bit Algorithms (22) Math (21) List (20) Dynamic Programming (19) Linux (19) Tree (18) Machine Learning (15) EPI (11) Queue (11) Smart Algorithm (11) Operating System (9) Java Basic (8) Recursive Algorithm (8) Stack (8) Eclipse (7) Scala (7) Tika (7) J2EE (6) Monitoring (6) Trie (6) Concurrency (5) Geometry Algorithm (5) Greedy Algorithm (5) Mahout (5) MySQL (5) xpost (5) C (4) Interview (4) Vi (4) regular expression (4) to-do (4) C++ (3) Chrome (3) Divide and Conquer (3) Graph Algorithm (3) Permutation (3) Powershell (3) Random (3) Segment Tree (3) UIMA (3) Union-Find (3) Video (3) Virtualization (3) Windows (3) XML (3) Advanced Data Structure (2) Android (2) Bash (2) Classic Algorithm (2) Debugging (2) Design Pattern (2) Google (2) Hadoop (2) Java Collections (2) Markov Chains (2) Probabilities (2) Shell (2) Site (2) Web Development (2) Workplace (2) angularjs (2) .Net (1) Amazon Interview (1) Android Studio (1) Array (1) Boilerpipe (1) Book Notes (1) ChromeOS (1) Chromebook (1) Codility (1) Desgin (1) Design (1) Divide and Conqure (1) GAE (1) Google Interview (1) Great Stuff (1) Hash (1) High Tech Companies (1) Improving (1) LifeTips (1) Maven (1) Network (1) Performance (1) Programming (1) Resources (1) Sampling (1) Sed (1) Smart Thinking (1) Sort (1) Spark (1) Stanford NLP (1) System Design (1) Trove (1) VIP (1) tools (1)

    Popular Posts