- Upvotes Received
- 0
- Posts with Upvotes
- 0
- Upvoting Members
- 0
- Downvotes Received
- 2
- Posts with Downvotes
- 2
- Downvoting Members
- 1
Re:
search(l, key): if len(l) == 0: return False elif l[0] == key: return True else: return search(l[1:], key) I was just wondering if there is any way that i can get rid of "elif" statement. The function is suppose to return False if the key is not in the list … |
|
[ICODE]def selsort(l): if len(l)<=1: return l else: for i in range(len(l)): selsort(l[1:]) [/ICODE] Hey guys, this is what I have so far. I have trouble understanding recursion. Anyone know how to use it to do selection sort? |
|
how would you sort a class object? say..you have a card class, and in the card class, you can have the suits and face value of a card. how would you sort the cards by face values? (smallest to biggest?) thanks |
|
does anybody know how to make bubble sort work in progressively smaller sizes and determine if a list is sorted on it's first try? i've got the basic bubble sort algorithm down. i just can't figure out the rest of it (my basic bubble sort code below) [code] def bubbleSort(list1): … |
|
i'm having problems with a binary search in a list... [code] def binarySearch(list1,faces): first = 0 last = len(list1) - 1 while first <= last: mid = (first + last) / 2 if faces == list1[mid]: return mid elif faces < list1[mid]: last = mid - 1 else: first = … |
|
Hi, I have a question about lists and tables... So far, i've managed to take a list and make a table like so: 23 764 12 54 83 2 543 890 1235 453 98 the list being [23, 764, 12, 54, 83, 2, 543, 890, 1235, 453, 98]. i need … |