instead of o(n3) complexity can we print subarray in o(n) or o(n2) complexity
How to print subarray with o(n) or O(n2) complexity
Yes you can. Watch the further videos, it must be taught there
no the video is not there
I thought you were asking for maximum subarray sum.
Yes, generating all the subarrays cannot be done in O(n) time.
There are exactly n(n+1)/2 subarrays, which can be written as A[i…j] for all i and and all j≥i. The algorithm to generate all pairs is immediate (double loop) and cannot be improved.
If you just need to output the pairs (i, j) O(n²) will be the commplexity. And if you need to store all subarrays in full, O(n³); in this case.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
i am unable to ask further doubts why is this so
Your course validity must have expired.
If this is not the case then drop a mail at [email protected]