Giter Club home page Giter Club logo

ordered-set-data-structure's Introduction

Ordered-set-Data-Structure

Welcome to a custom C++ Set library that provides functionality similar to the C++ Standard Template Library (STL).
This project offers an implementation of a Set data structure designed to store unique integers in ascending order.
You can perform a variety of operations on multiple sets simultaneously, including insert, delete, membership checking, union, intersection, size calculation, difference, symmetric difference, and printing elements in sorted order.
Explore this library to understand how to manage multiple sets efficiently in C++.

Getting Started

  1. Clone the repository:
    git clone "https://github.com/AnkitChoudhaary/Ordered-set-Data-Structure/tree/main"
  2. Compile the Code :
    g++ main.cpp main
  3. Run the program :
    ./main
    

How to Use :

1. Insert

To Insert data into the set, use the Insert Command {P.S.: you can use multiple set} :

1 {set num} {data}

2. Delete

To delete an element from the set, use the Delete command :

2 {set num} {data}

3. Belongs To

Check if an element belongs to the set using the Belongs To command { Output -1 : if set doesn't exist }:

3 {set num} {data}

4. Union

To take the union of two sets, use the Union command {Output stores to set num1}:

4 {set num1} {set num2}

5. Intersection

Find the intersection of two sets with the Intersection command {Output stores to set num1}:

5 {set num1} {set num2}

6. Size

Get the number of elements in a set with the Size command:

6 {set num}

7. Difference

To find the difference between two sets, use the Difference command {Output stores to set num1} :

7 {set num1} {set num2}

8. Symmetric Difference

Calculate the symmetric difference of two sets with the Symmetric Difference command {Output stores to set num1}:

8 {set num1} {set num2}

9. Print

Print all elements of a set in sorted order using the Print command:

9 {set num}

Example

1 1 5        // Insert 5 into Set 1
2 1 5        // Delete 5 from Set 1
3 1 6        // Check if 6 belongs to Set 1
4 1 2        // Take the union of Set 1 and Set 2
5 1 2        // Find the intersection of Set 1 and Set 2
6 1          // Get the size of Set 1
7 1 2        // Find the difference between Set 1 and Set 2
8 1 2        // Calculate the symmetric difference of Set 1 and Set 2
9 1          // Print the elements of Set 1

Time Complexity

Here's an overview of the time complexity of the functions in the custom Set library:

Function Time Complexity
Insert O(log n)
Delete O(log n)
Belongs To O(log n)
Union O(n)
Intersection O(n)
Size O(1)
Difference O(n)
Symmetric Difference O(n)
Print O(n)

P.S.: This is just a simple project to show how all the big projects use simple data structures to get a fascinating Data Structures :).
you may not find this useful.

ordered-set-data-structure's People

Contributors

ankitchoudhaary avatar

Stargazers

 avatar

Watchers

 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.