Friday 24 February 2017

Second Min And Second Max With Update Using Segment Tree


SEGMENT TREE

To perform following operation(<10^5) on given array(<10^5) :

U I V - Update the value present at I with value V

A L R - Find the sum between range L and R

M L R - Find the maximum number between L and R

m L R - Find the minimum number between L and R

S L R - Find second maximum value in between L and R

s L R - Find second mimimum value in between L and R



View Ramesh Chandra's profile on LinkedIn

Ramesh Chandra

Tuesday 21 February 2017

Maximum Coin Sum Set Of Non Adjacent Vertices In Tree


DYNAMIC PROGRAMMING

Given a tree T of N nodes, where each node i has Ci coins attached with it. You have to choose a subset of nodes such that no two adjacent nodes(i.e. nodes connected directly by an edge) are chosen and sum of coins attached with nodes in chosen subset is maximum.



View Ramesh Chandra's profile on LinkedIn

Ramesh Chandra