What is the time complexity for finding the node at x position where n is the length of the rope?

Category: QuestionsWhat is the time complexity for finding the node at x position where n is the length of the rope?
Editor">Editor Staff asked 1 month ago

What is the time complexity for finding the node at x position where n is the length of the rope?
 
(a) O (log n)
 
(b) O (n!)
 
(c) O (n^2)
 
(d) O (1)
 
I need to ask this question from Binary Trees in division Binary Trees of Data Structures & Algorithms I
 
This question was addressed to me in a job interview.

1 Answers
Editor">Editor Staff answered 1 month ago

Right option is (a) O (log n)
 
For explanation: In order to find the node at x position in a rope data structure where N is the length of the rope, we start a recursive search from the root node. So the time complexity for worst case is found to be O (log N).