---
# System prepended metadata

title: Problem 1
tags: [week7, answer]

---

# Problem 1
###### tags: `week7` `answer`
```python=1
def binarySearch(sd,t):
    n = sd.getSize()
    alist = []
    def bs(s,e):
        nonlocal alist
        nonlocal sd,t
        if e-s == 1:
            alist.append(-1)
            return -1
        if (s+e)%2 == 0:
            m = (s+e)//2
        else:
            m = ((s+e)//2)+1
        mnum = sd.getData(m)
        if t < mnum:
            bs(s,m)
        elif t > mnum:
            bs(m,e)
        elif t == mnum:
            alist.append(m)
            return m
    k = bs(0,n)
    return alist[0]

def postorder(root):
    if (root.left == None):
        if (root.right == None): 
            return root.key
        else:
            return postorder(root.right) + root.key
    else:
        if (root.right == None):
            return postorder(root.left) + root.key
        else:
            return postorder(root.left) + postorder(root.right) + root.key
```