Link to home
Start Free TrialLog in
Avatar of Guru Ji
Guru JiFlag for Canada

asked on

some java questions recursion and order of an equation

i just have a question which was in one of my exams
I am looking for answers please help Thanks !

Given the following algorithm in pseudo code, and the knowledge that for problem size 100 the "while loop" executes 100 times and the "for loop" 2 x 106 times.

1)
2) while (condition)
2.1)
2.2)
3) for (condition)
      3.1)
      3.2)
      3.3)
      3.4)
4)
5)

a)  What is the runtime equation of this algorithm?

b)  What is the order of this algorithm?


QUES 2 -----------------------------------

Part- a ) Given the following code, convert this into a non-recursive method.

private void Insert_End (node ptr, Data data){
    if (ptr.next != null) {
        Insert_End(ptr.next, data);
      else
        ptr.next = Create_Node(ptr.data);
    }
}

Part-b ) - What is the runtime equation of the recursive and non-recursive code?




ASKER CERTIFIED SOLUTION
Avatar of alainbryden
alainbryden
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Guru Ji

ASKER

it is one of my past exams which I have it, so I just typed it in exactly...

Can you please write me the non-recursive method of the last question...

and please tell me what would be the run time equation will be ?

Thanks
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial