Giter VIP home page Giter VIP logo

generic-segment-tree's Introduction

Generic-Segment-Tree

Generic Segment Tree frame work:

SegmentTree class constructor definition:

SegmentTree (T *array, int size_of_array , T nop , T(*merger)(T,T) , T(*lnode_op)(T) )

  • array is main input array on which segment tree has been defined
  • here n stands for size of array
  • nop stands for not possible value, this value is different for different T.
  • merger stands for "segment tree node merging function"
  • lnode_op stands for "leaf node value operation"

Query operation:

T SegmentTree::query(int start_of_range, int end_of_range)

As the argument's name suggest, we give a starting and ending range to query function, It will conclude the appropriate output value T for that range.

Update operation:

void SegmentTree::update(int index,int update_value)

We want to update value for particular index in input array, so we take index as input and new value. This function will update the value at index in input array and also in segment tree.

Header file SegmentTree.hpp and example of it is given in SegmentTreeHeader folder.

TestingHeader folder contains test program for ensuring accuracy and performance benchmark.

Only execute Testing.cpp

  • g++ -std=c++17 -o Testing Testing.cpp
  • ./Testing

generic-segment-tree's People

Contributors

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