GithubHelp home page GithubHelp logo

williamfiset / deprecated-data-structures Goto Github PK

View Code? Open in Web Editor NEW
2.8K 144.0 1.3K 176.04 MB

A collection of powerful data structures

License: MIT License

Java 100.00%
java heap binarytree fenwick linkedlist priority-queue queue segmenttree stack suffixarray

deprecated-data-structures's Introduction

No Maintenance Intended

⛔️ DEPRECATED ⛔️

Project status

This data-structures repository is deprecated. It is no longer being actively maintained or watched. The data structures in this repository was moved to the Algorithms repo in mid 2019. Please submit pull requests and issues to the Algorithms repo.

License

This repository is released under the MIT license. In short, this means you are free to use this software in any personal, open-source or commercial projects. Attribution is optional but appreciated.

deprecated-data-structures's People

Contributors

ashiqursuperfly avatar braj065 avatar finnlidbetter avatar janclarin avatar mehranus avatar micahstairs avatar navedrizvi avatar williamfiset avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deprecated-data-structures's Issues

Tests for IList

Recently added a new interface IList which the dynamic array and the linked list implement. Tests should be created for the new methods like clear, remove, removeAt, etc..

Small Error in LinkedList Code

Hi William,

I'm learning data structures through your Udemy course. I think there's error in the isEmpty() method. Shouldn't it be:

void isEmpty() {
return size == 0;
}

Best Regards,
Kevin

Map not properly removing items

My map implementation is having trouble removing some elements once they are added. I suspect that has to do with hash collisions or rehashing the table.

extra path compression

unionFind class method find has extra step. It does compression even if it is not needed.

while (p != root) { int next = id[p]; id[p] = root; p = next; }
can be modified to the following to bypass unnecessary step

while (id[p] != root) { int next = id[p]; id[p] = root; p = next; }

Refactoring part in adding process in Separate chaning feature

https://github.com/williamfiset/data-structures/blob/b63739f38cbc405d5d2ebcbae2ce02f37bde35fe/com/williamfiset/datastructures/hashtable/HashTableSeparateChaining.java#L152

I think improvement is needed in the bucketInsertEntry () method, because by going through this situation according to the bucket value being null in 152 rows, the same condition may appear as return null in the bucketSeekEntry method, accordingly we understand that there is no addition in that index according to the bucketIndex-given in the condition of correctness of the condition in 152 rows. Therefore, I think there is no need for additional checking, so it should not be logged into the bucketSeekEntry () method, we can do such a refactoring by considering these (I sampled the change over your codes):

private V bucketInsertEntry (int bucketIndex, Entry <K, V> entry) {

    LinkedList <Entry <K, V >> bucket = table [bucketIndex];

    if (bucket == null) {
        table [bucketIndex] = bucket = new LinkedList<>();
        bucket.add (entry);
        if (++ size> threshold) resizeTable ();
        return null; // Use null to indicate that there was no previous entry
    }

    Entry <K, V> existentEntry = bucketSeekEntry (bucketIndex, entry.key);
    if (!existentEntry == null) {
      V oldVal = existentEntry.value;
      existentEntry.value = entry.value;
      return oldVal;
    }
     
    return null;
  } 

Add Judy array implementation

Wikipedia makes the Judy array appear to be the holy grail of all data structures. I'm curious to see how well a solid implementation actually performs compared to hash tables, skip lists, balanced trees and etc...

Suffix array improvements

To polish off the suffix array data structure we still need to:

  • Add tests
  • Automate detecting alphabet shift size
  • Finish nlogn construction
  • Refactor SA classes.

reverse method in dynamic intArray

The reverse method in the dynamic integer array doesn't seem to work as intended. The for loop doesn't print all elements of the array as it loops only half of the array when printing the contents.

[UnionFind] No need to update sz of the merged component?

Hi William,

Thank you for creating such great course and it tremendously helped me to understand algorithms and data structure.
I have a question about your implementation of the UnionFind DS but it looks like the questions at the Udemy Q&A section haven't been answered for some time, so I figured I would have a better chance of reaching you here.

In the UnionFind source code, you are merging the smaller component into the bigger one and updating the sz of the bigger component, but the sz of the smaller component is not being updated. Is it not necessary to update it to be zero since it doesn't have any element belonging to it?

// Unify the components/sets containing elements 'p' and 'q'
  public void unify(int p, int q) {

    int root1 = find(p);
    int root2 = find(q);

    // These elements are already in the same group!
    if (root1 == root2) return;

    // Merge smaller component/set into the larger one.
    if (sz[root1] < sz[root2]) {
      sz[root2] += sz[root1];
      id[root1] = root2;
    } else {
      sz[root1] += sz[root2];
      id[root2] = root1;
    }

    // Since the roots found are different we know that the
    // number of components/sets has decreased by one
    numComponents--;
  }
}

Thank you again for the great course.
Many of us owe a great deal.

Heapify PQ

I misunderstood what heapify was suppose to do and how it is supposed to be implemented. This needs to be redone

Binary Search Tree - Remove count

The binary search tree remove method decrements the number of elements in a tree before actually removing an item (if it exists at all).

Trie Memory leak

The Trie's .clear() method should recursively delete all child nodes, this will help the garbage collector do its job.

Windows illegal characters

Gradle fails to build on Windows due to strange characters in the TreePrinter class. simple fix is to replace these character but that would break the nice formatting.

Windows 10 Home Single Language
Version 1803
When I try gradle build, it gives the following errors:

C:\Users\New_User\Desktop\Java Getting started\Data Structures\data-structures>gradle build
Starting a Gradle Daemon (subsequent builds will be faster)

Task :compileJava
C:\Users\New_User\Desktop\Java Getting started\Data Structures\data-structures\com\williamfiset\datastructures\utils\TreePrinter.java:92: error: unmappable character (0x90) for encoding windows-1252
System.out.print(j % 2 == 0 ? "Γöî" : "Γö?");
^
C:\Users\New_User\Desktop\Java Getting started\Data Structures\data-structures\com\williamfiset\datastructures\utils\TreePrinter.java:76: error: unclosed character literal

          c = (line.get(j) != null) ? 'Γö┤' : 'Γöÿ';
                                      ^

C:\Users\New_User\Desktop\Java Getting started\Data Structures\data-structures\com\williamfiset\datastructures\utils\TreePrinter.java:76: error: illegal character: '\u201d'
c = (line.get(j) != null) ? 'Γö┤' : 'Γöÿ';
^
C:\Users\New_User\Desktop\Java Getting started\Data Structures\data-structures\com\williamfiset\datastructures\utils\TreePrinter.java:76: error: illegal character: '\u00b4'
c = (line.get(j) != null) ? 'Γö┤' : 'Γöÿ';
^
C:\Users\New_User\Desktop\Java Getting started\Data Structures\data-structures\com\williamfiset\datastructures\utils\TreePrinter.java:76: error: unclosed character literal
c = (line.get(j) != null) ? 'Γö┤' : 'Γöÿ';
^
C:\Users\New_User\Desktop\Java Getting started\Data Structures\data-structures\com\williamfiset\datastructures\utils\TreePrinter.java:76: error: unclosed character literal
c = (line.get(j) != null) ? 'Γö┤' : 'Γöÿ';
^
C:\Users\New_User\Desktop\Java Getting started\Data Structures\data-structures\com\williamfiset\datastructures\utils\TreePrinter.java:76: error: illegal character: '\u201d'
c = (line.get(j) != null) ? 'Γö┤' : 'Γöÿ';
^
C:\Users\New_User\Desktop\Java Getting started\Data Structures\data-structures\com\williamfiset\datastructures\utils\TreePrinter.java:76: error: illegal character: '\u02dc'
c = (line.get(j) != null) ? 'Γö┤' : 'Γöÿ';
^
C:\Users\New_User\Desktop\Java Getting started\Data Structures\data-structures\com\williamfiset\datastructures\utils\TreePrinter.java:76: error: unclosed character literal
c = (line.get(j) != null) ? 'Γö┤' : 'Γöÿ';
^
C:\Users\New_User\Desktop\Java Getting started\Data Structures\data-structures\com\williamfiset\datastructures\utils\TreePrinter.java:78: error: unclosed character literal
if (j < line.size() && line.get(j) != null) c = 'Γöö';
^
C:\Users\New_User\Desktop\Java Getting started\Data Structures\data-structures\com\williamfiset\datastructures\utils\TreePrinter.java:78: error: illegal character: '\u201d'
if (j < line.size() && line.get(j) != null) c = 'Γöö';
C:\Users\New_User\Desktop\Java Getting started\Data Structures\data-structures\com\williamfiset\datastructures\utils\TreePrinter.java:78: error: illegal character: '\u201d'
if (j < line.size() && line.get(j) != null) c = 'Γöö';
C:\Users\New_User\Desktop\Java Getting started\Data Structures\data-structures\com\williamfiset\datastructures\utils\TreePrinter.java:78: error: unclosed character literal
if (j < line.size() && line.get(j) != null) c = 'Γöö';
12 errors

Task :compileJava FAILED
FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':compileJava'.

Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
  • Get more help at https://help.gradle.org
    BUILD FAILED in 14s
    1 actionable task: 1 executed

Missing data structures

  • AVL tree
  • B-Tree
  • Binary tree
  • Bloom filter
  • D-Heap
  • Dynamic Array
  • Fenwick Tree
    • Point updates and range sum queries
    • Range updates and point queries
    • Range updates and range queries
  • Fibonacci heap
  • Graph
    • Adjacency matrix
    • Adjacency list
  • Hashtable
    • Separate chaining with linked list
    • Open addressing linear probing
    • Open addressing quadratic probing
    • Open addressing double hashing probing
  • Judy array
  • K-d Tree
  • Link-cut tree
  • Linked-list
  • Binary heap
  • QuadTree (optional)
  • Queue
    • Link list implementation
    • Array implementation
  • Red-Black tree
  • Segment tree
    • Array based implementation with lazy propagation
    • Pointer based with lazy propagation
    • With coordinate compression
  • Set
  • Skip list
  • Splay Tree
  • Stack
    • Pointer based implementation
    • Array based implementation
  • SuffixArray
    • O(n2log(n)) implementation
    • O(nlog2(n)) implementation
    • O(nlog(n)) implementation
    • O(n) implementation
  • Treap
  • Trie
  • Unionfind (with path compression)
  • Van Emde Boas tree

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.