Range Minimum Query
Submissions: 1961   Accuracy:


  Difficulty: Medium   Marks: 4

Given an array A[ ] and its size N your task is to complete two functions  a constructST  function which builds the segment tree  and a function RMQ which finds range minimum query in a segment tree .

The task is to complete two functions constructST and RMQ .
The constructST function builds the segment tree and takes two arguments the array A[ ] and the size of the array .
It returns a pointer to the first element of the segment tree array . 
The RMQ function takes 4 arguments the first being the segment tree st constructed, second being the size N and then third and forth arguments are the range of query a and b .The function RMQ returns the min of the elements in the array from index range a and b. There are multiple test cases. For each test case, this method will be called individually.

The function RMQ should return the min element in the array from range a to b .

1<=Q(no of queries)<=10000
Input (To be used only for expected output) 

1 2 3 4
0 2 2 3

1 3

For query 1 ie 0 2 the element in this range are 1 2 3 and the min element is 1  
2. For query 2 ie 2 3 the element in this range are 3 4 and the min element is 3 

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Harshit Sidhwa
Author: Shubham Joshi 1

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.