Advertisements
Advertisements
प्रश्न
For the given code segment, write Big O notation for worst case complexity.
for (int i=1; i<=P; i++)
{ Statements }
for (int j=1; j<=P; ++j)
for (int k=1; k<=Q; k++)
{ Statements }
अति संक्षिप्त उत्तर
Advertisements
उत्तर
First loop runs from 1 to P so O(P).
Second loop runs 1 to P so O(P).
Third loop runs from 1 to Q so O(P * Q) is the worst time complexity.
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
2024-2025 (March) Official Board
