Giter Club home page Giter Club logo

sparse-array's Introduction

Sparse Array

This project provides an implementation of a sparse array using a linked list data structure. It is designed to represent arrays with huge indices but mostly consisting of zeros in a more efficient way.

Getting Started

To use this project, simply clone the repository and compile the SparseArray.cpp file using your preferred C++ compiler. The program will prompt you to enter the size of the array and its elements. You can then perform various operations on the sparse array, such as setting and getting positions, printing the array, and adding arrays.

Usage

Here are some examples of how to use this program:

// Create a new sparse array
SparseArray arr;

// Set values at specific positions
arr.set_value(0, 5);
arr.set_value(2, 10);
arr.set_value(4, 15);

// Get values at specific positions
cout << arr.get(0) << endl; // Output: 5
cout << arr.get(1) << endl; // Output: 0

// Print the entire array
arr.print_array(); // Output: [5, 0, 10, 0, 15]

// Add two arrays together
SparseArray arr2;
arr2.set_value(1, 20);
arr2.set_value(3, 25);

SparseArray result = arr.add_arrays(arr2);
result.print_array(); // Output: [5, 20, 10, 25, 15]

sparse-array's People

Contributors

mhrasmy 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.