Get Time
Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings
View: Flat (newest first)  | Threaded  | Tree
Previous Thread  |  Next Thread
WRong Algorithm for <O(n),O(log n)> segment tree for RMQ | Reply
the query() fumction does return M[node] = p2 or M[node] = p1 which is wrong since it distorts the original tree...i have checked it ....u shud simply return p2 or p1(if other is -1 returned)or p1 if A[p1] < A[p2] else p2 for A[p2] < A[p1]....However if u persists with ur current code u have to reinitialize the tree after each query therby O(n^2)....Please look into this..