Question: QUESTION 6 Correct Answer: 4 Marks Given an array arr, the code below implements Sparse Table for finding the minimum value in a range 1

QUESTION 6
Correct Answer: 4 Marks
Given an array arr, the code below implements Sparse Table for finding the minimum value in a range 1,r in O(1) time. Which of the following statements is true about the Table array after the Sparse Table has been built?
CC++ Code
class SparseTable:
def q, init q,(self, arr):
)
self. log=[0]**(n+1)
for i in range (2,n+1) :
self.log [i]= self.log [i??2]+1
self.table for i in range(self.log [n]+1 for j in range (n)
for i in range(n :
self.table[i][0]= arr[i]
for j in range , self.log [n]+1 :
for i in range (0,n-(1j)+1) :
self.table , self.table [i+(1(j-1))][j-1]
def query(self, I,r :
k= self.log r-I+1
return min(self.table [1][k], self.table st=
 QUESTION 6 Correct Answer: 4 Marks Given an array arr, the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!