title: Determining if a list of numbers is in heap order, Python 3.2
body: <p>I just discovered heap (in real life and in Python) and now I'm trying to determine if a certain list of random numbers is in heap order.<br>
  Problem is I'm not sure myself if I actually understand "heap" in practice even though I believe the definition provided makes sense.</p>
  
  <p>I found some practice problems that should help you write heap psuedo code.
  This is the problem and below it is my attempt at solving it:</p>
  
  <p>Write a function that checks whether a list of numbers is a heap or not: </p>
  
  <p>Given a list, it returns True if the numbers are in a heap order, and False if the numbers are not and have the programme return and print the answer.</p>
  
  <p>Example:</p>
  
  <ul>
  <li>returns True:
  the following list is in heap order: [0,1, 10, 2, 3, 11, 12, 4, 5, 19, 15]</li>
  <li>returns False
  the following list is not in heap order: [0, 1, 10, 2, 15, 11, 12, 4, 5, 19, 3]</li>
  </ul>
  
  <p>Then there were 2 lists with a bunch of random numbers from 1 - 100 thrown in there, and some repeat. </p>
  
  <pre><code>    def heap_or(A):
        n = len(A)
        for i in range(n):
          start = (len(A) - 2) / 2
          while start &gt;= 0:
            siftDown(A, start, len(A) - 1)
            start -= 1:
               return 'True'
          else:
               return 'False'
  
      def siftDown(A, start, end):
      root = start
      while root * 2 + 1 &lt;= end:
          number = root * 2 + 1
          if number + 1 &lt;= end and A[number] &lt; A[number + 1]:
              number += 1
          if number &lt;= end and A[root] &lt; A[number]:
              A[root], A[number] = A[number], A[root]
              root = number
          else:
              return
  
       print 
  </code></pre>
  
  <p>Can somebody please give me a hand?  Because I'm not really sure if I'm defining heap correctly the code is giving me a hard time as well!</p>