Consider the following code segment 1 Total 0 2 forx 0 xSolu
Solution
1)O(Total)
--In this element we are setting total to Zero(=0)
--so that we are initialised with 0
--we are setting the value into zero because avoiding default values
2)O(mNum)
--first ou might say that upper bound is O(mNum)
--so we drop constants so it is in the form of O(mNum) mathematically
--so X initially setting value is 0
--so X will run from 0 to nNum iterations
--so each iteration X is incremented by 1
3)O(mNum*mNum)
--so previous loop and this loopis mNum iterations
--so this is nested loop
--so this loop is mNum*mNum
--thus O(mNum) so the Y is 0 to mNum action is to mNum actions
--once Y value is equals to mNum skips to upper loop of 2) position
4)O(Total+1)
--in this step Total initial value is 0
--so the value is incremented by 1
--so that Total vlaue is incremented upto mNum
--once the mNum is reached in Y nested loop
--it will skips to X loop until the loop ending stage.
