GithubHelp home page GithubHelp logo

azamzow / set-map-demo Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 4 KB

This program emonstrates working with Sets and Maps in java utilizing a Hast set/map, a Tree set/map, and a Linked set/map.

Java 100.00%

set-map-demo's Introduction

Set Map Demo Project

Description

This program demonstrates working with Sets and Maps in java. It utilizes the following:

  1. Hast set: extends AbstractSet and implements the Set interface. It creates a collection that uses a hash table for storage.
  2. Hash map: offers 0(1) lookup and insertion. If you iterate through the keys, though, the ordering of the keys is essentially arbitrary. It is implemented by an array of linked lists.
  3. Tree set: is basically implementation of a self-balancing binary search tree like Red-Black Tree.
  4. Tree map: offers O(log N) lookup and insertion. Keys are ordered, so if you need to iterate through the keys in sorted order, you can. This means that keys must implement the Comparable interface. TreeMap is implemented by a Red-Black Tree.
  5. Linked set: is a linear data structure. Unlike arrays, linked set elements are not stored at contiguous location; the elements are linked using pointers.
  6. Linked map: offers 0(1) lookup and insertion. Keys are ordered by their insertion order. It is implemented by doubly-linked buckets

To Run

Using terminal on Mac:

$ cd Set-Map-Demo
$ javac SetMapDemo.java
$ java SetMapDemo

Output

An Example output is shown below,

Hash  set: [as, looks, nothing, is, it, easy]

Tree set: [as, easy, is, it, looks, nothing]

Linked set: [nothing, is, as, easy, it, looks]

6 distinct words detected:

Hash map: {as=2, looks=1, nothing=1, is=1, it=1, easy=1}

Tree map: {as=2, easy=1, is=1, it=1, looks=1, nothing=1}

Linked map: {nothing=1, is=1, as=2, easy=1, it=1, looks=1}

set-map-demo's People

Contributors

azamzow avatar

Watchers

James Cloos avatar

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.