Explain time and space complexity of two python codes. Which one is the best? (Non- subjective)
Question: These codes gives the sum of even integers in a list without using loop
statement. I would like to know the time complexity and space complexity of
both codes. which is best?

CODE 1:

    
    
    class EvenSum:
         #Initialize the class
    
        def __init__(self):
            self.res = 0
    
        def sumEvenIntegers(self, integerlist):
            if integerlist:
                if not integerlist[0] % 2: 
                    self.res += integerlist[0]
                    del integerlist[0]
                    self.sumEvenIntegers(integerlist)
                else:
                    del integerlist[0]
                    self.sumEvenIntegers(integerlist)
            return self.res
    
    #main method
    if __name__ == "__main__":
    l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    even = EvenSum()
    print even.sumEvenIntegers(l)
    

CODE 2:

    
    
    import numpy as np
    
    def sum_of_all_even_integers(list):
        list_sum = sum(list)  
        bin_arr  = map(lambda x:x%2, list)
        return list_sum - sum(list*bin_arr)
    
    if __name__ == "__main__":
    
        list = np.array([1,2,3,4,5,6,7,8,9,10])
        print sum_of_all_even_integers(list)
    


Answer: According to the [Python wiki](https://wiki.python.org/moin/TimeComplexity),
deleting an item from a list takes linear time proportional to the number of
elements in the list. Since you delete every item in the list, and each
deletion takes linear time, the overall runtime is proportional to the square
of number of items in the list.

In your second code snippet, both `sum` as well as `map` take linear time. So
the overall complexity is linear proportional to the number of elements in the
list. Interestingly, `sum_of_elements` isn't used at all (but it doesn't sum
all even elements either).

