@@ -103,8 +103,8 @@ def print_int_array(the_array: [int]) -> None:
103
103
104
104
def matrix_transposition (the_matrix : [[int ]]) -> [[int ]]:
105
105
"""Returns the transposition of a matrix"""
106
- rows = len (the_matrix )
107
- cols = len (the_matrix [0 ]) # the number of columns remain constant
106
+ rows : int = len (the_matrix )
107
+ cols : int = len (the_matrix [0 ]) # the number of columns remain constant
108
108
109
109
transposed_matrix = [[0 ] * rows for _ in range (cols )]
110
110
@@ -141,10 +141,12 @@ def fact(n: int) -> int:
141
141
142
142
143
143
def binary_search (key : int , the_array : [int ]) -> int :
144
+ """Calls _rank() to binary search the_array"""
144
145
return _rank (key , sorted (the_array ), 0 , len (the_array ) - 1 ) # works best on sorted arrays
145
146
146
147
147
148
def _rank (key : int , the_array : [int ], min_index : int , max_index : int ) -> int :
149
+ """Returns the index of the key if present, -1 if not"""
148
150
if min_index > max_index :
149
151
return - 1
150
152
@@ -221,7 +223,7 @@ def main():
221
223
print ()
222
224
print ("- Recursive Fib" )
223
225
224
- for i in range (4 ):
226
+ for i in range (40 ):
225
227
print (Fibonacci .fib (i ))
226
228
227
229
print ()
0 commit comments