My teacher has just teach me about complexity of algorithm and he has gave me some homework. I have solve almost all except for this ex:
Consider a robot arm that is fixed at one end. The arm contains two elbows at each of which it is possible to rotate the arm 90 degrees up and down in a vertical plane. How would you mathematically model the possible movements of the end of the arm? Describe an algorithm to move the end of the robot arm from one permissible position to another.
I have to make an algorithm from this requirement? Please give me some cue. ==

Thank you for giving me the cue. I guess that is complexity is O(1) because it always has two elements regardless of input or out. Is it right?

Since all you need is to calculate the out position from the two elements and no for-loop are required, it's O(1)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.