Difference between revisions of "PythonSearchAssignment.py"
From WLCS
(Created page with "<syntaxhighlight lang="Python"> nums = [604, 565, 449, 69, 869, 965, 506, 145, 913, 874, 987, 315, 967, 543, 675, 571, 388, 167, 259, 331, 47, 863, 970, 890, 312, 109, 360, 993, ...") |
|||
Line 1: | Line 1: | ||
<syntaxhighlight lang="Python"> | <syntaxhighlight lang="Python"> | ||
− | nums = [604, 565, 449, 69, 869, 965, 506, 145, 913, 874, 987, 315, 967, 543, 675, 571, 388, 167, 259, 331, 47, 863, 970, 890, 312, 109, 360, 993, 176, 490, 34, 637, 712, 721, 552, 914, 425, 551, 274, 346, 516, 922, 823, 540, 12, 53, 689, 159, 388, 285, 95, 554, 932, 755, 560, 676, 152, 912, 816, 82, 974, 518, 502, 765, 191, 176, 613, 627, 233, 995, 864, 316, 151, 169, 264, 367, 928, 841, 330, 368, 457, 843, 688, 599, 959, 67, 393, 253, 675, 46, 595, 864, 44, 425, 573, 994, 271, 781, 638, 138] | + | nums = [604, 565, 449, 69, 869, 965, 506, 145, 913, 874, 987, 315, 967, 543, \ |
+ | 675, 571, 388, 167, 259, 331, 47, 863, 970, 890, 312, 109, 360, 993, \ | ||
+ | 176, 490, 34, 637, 712, 721, 552, 914, 425, 551, 274, 346, 516, 922, \ | ||
+ | 823, 540, 12, 53, 689, 159, 388, 285, 95, 554, 932, 755, 560, 676, 152, \ | ||
+ | 912, 816, 82, 974, 518, 502, 765, 191, 176, 613, 627, 233, 995, 864, \ | ||
+ | 316, 151, 169, 264, 367, 928, 841, 330, 368, 457, 843, 688, 599, 959, \ | ||
+ | 67, 393, 253, 675, 46, 595, 864, 44, 425, 573, 994, 271, 781, 638, 138] | ||
#Prompt user for a search key | #Prompt user for a search key |
Latest revision as of 08:19, 13 September 2013
nums = [604, 565, 449, 69, 869, 965, 506, 145, 913, 874, 987, 315, 967, 543, \
675, 571, 388, 167, 259, 331, 47, 863, 970, 890, 312, 109, 360, 993, \
176, 490, 34, 637, 712, 721, 552, 914, 425, 551, 274, 346, 516, 922, \
823, 540, 12, 53, 689, 159, 388, 285, 95, 554, 932, 755, 560, 676, 152, \
912, 816, 82, 974, 518, 502, 765, 191, 176, 613, 627, 233, 995, 864, \
316, 151, 169, 264, 367, 928, 841, 330, 368, 457, 843, 688, 599, 959, \
67, 393, 253, 675, 46, 595, 864, 44, 425, 573, 994, 271, 781, 638, 138]
#Prompt user for a search key
#Implement linear search here
nums.sort() #Sorts the list for binary search
#Prompt user for a search key
#Implement binary search here