This is a question I have after listening to a lecture.

def gosperize(curve):
    scaled_curve = scale(sqrt(2)/2)(curve)
    left_curve = rotate(pi/4)(scaled_curve)
    right_curve = translate(0.5,0.5)(rotate(-pi/4)(scaled_curve))

    return connect_rigidly(left_curve, right_curve)

def gosper_curve(level):
    return repeated(gosperize, level)(curve)

def identity(x):
    return x

def repeated(f, n):
    if (n == 0):
       return identity
    return composed(f, repeated(f, n-1))

def rotate(angle):
    def transform(curve):
        def rotated_curve(t):
            pt = curve(t)
            x, y = x_of(pt), y_of(pt)
            cos_a, sin_a = cos(angle), sin(angle)

            return make_point(cos_a*x - sin_a*y, sin_a*x + cos_a*y)
        return rotated_curve
    return transform

def joe_rotate(angle):
    def transform(curve):
        def rotated_curve(t):
            x, y = x_of(curve(t)), y_of(curve(t))
            cos_a, sin_a = cos(angle), sin(angle)

            return make_point(cos_a*x - sin_a*y, sin_a*x + cos_a*y)
        return rotated_curve
    return transform

I think this is all the code that is needed to contextualise my question properly. The lecture was on an abstraction on curves. It was mentioned that for the function gosper_curve,if joe_rotate is used instead of rotate, gosper_curve will turn into a process whose time is linear in the level into one which is exponential in the level. I do not understand how assigning pt=curve(t) could change the time complexity of the function. I would appreciate any help on my order of growth fundamentals.

  • $\begingroup$ Indeed, the difference between joe_rotate and rotate seem bounded by a constant to me. Are you sure that this is the only difference? Are there lecture notes or something else the lecture was based on that explicitly defines these functions such that we can see their exact difference (it seem likely either the lecturer has made a mistake or you made a mistake in transcribing the material, it would be useful to find out what is the case!) $\endgroup$ – Discrete lizard Feb 13 '18 at 13:34
  • $\begingroup$ @Discretelizard yea I'm pretty sure it's the only difference since I copied it exactly from the slides. It seems weird to me, thats why I'm asking for help here. $\endgroup$ – Prashin Jeevaganth Feb 13 '18 at 13:42
  • $\begingroup$ Could you provide a link to those slides? Some more context could make this issue a lot clearer. $\endgroup$ – Discrete lizard Feb 13 '18 at 13:46
  • $\begingroup$ Welcome to Computer Science! Please get rid of the source code and replace it with ideas, pseudo code and arguments of correctness. See here and here for related meta discussions. $\endgroup$ – Raphael Feb 13 '18 at 13:47
  • $\begingroup$ The title you have chosen is not well suited to representing your question. Please take some time to improve it; we have collected some advice here. Thank you! $\endgroup$ – Raphael Feb 13 '18 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.