title: Time Complexity: Nested 'if-then-else'
body: <p>I've written a recursive program in <strong>Scheme</strong>, and I'm having trouble getting the time complexity of it. I believe it goes out to be O(log(n)), but I am definitely no expert on this time complexity. Can you help me try and work out the complexity of this?</p>
  
  <p>Here's my pseudo-code:</p>
  
  <pre><code>function A {
  
  for (int i = 0; i &lt; length.list(); i++)
  {
      if (list is null)
          output absolute value of result
  
      if (s2 &lt; s1)
          recall function A, adding item to s2 value.
      else
          recall function A, adding item to s1 value.
  }
  
  }
  </code></pre>
  
  <p>Here's the actual code in Scheme:</p>
  
  <pre><code>(define min-split (lambda (L s1 s2 mini)
             (cond 
  
               ((null? L)
                (if (&gt; 0 mini)
  
                    (min-split L s1 s2 (- mini (+ mini mini)))
  
                    mini
                    )
                  mini
                )
  
               ((&gt; s2 s1) 
                   (min-split (cdr L) (+ s1 (car L)) s2 (- (+ (car L) s1) s2)) 
                   )
               (else 
                   (min-split (cdr L) s1 (+ s2 (car L)) (- (+ (car L) s2) s1))
                        )
                    )
                  )
  )
  </code></pre>
  
  <p>Thanks!</p>