please provide a solution and also how to make a segment tree of matrices
Matrix query doubt
your base element is a matrix!, since its given that matrix size is fixed(2x2) you can represent it with vector of size 4.
now try to solve it (think how to multiply two matrices given as vectors)
after it it’s just cake walk.
please help fixing this code…
Do not return array reference instead take vector and return the vector itself,
also when query is out of range, return identity matrix(not null matrix)
fixed it …but cant figure out why its giving null matrix
When choosing start index as 0, children are 2node+1 and 2node+2.
Also you take input in local a(array) and make tree with global a.
not helping i did change it …giving same all zeros
Rohit please see your mistakes!
- you called buildtree with 2+node+2 instead of 2*node+2,
- your identity matrix was incorrect (1,0,1,0 instead of 1001)
- in query your complete overlap condition was incorrect!