Topic 24 Sorting and Searching Arrays "There's Nothing in Your Head the Sorting Hat Can't See

Topic 24 Sorting and Searching Arrays "There's Nothing in Your Head the Sorting Hat Can't See

Topic 24 sorting and searching arrays "There's nothing in your head the sorting hat can't see. So try me on and I will tell you where you ought to be." -The Sorting Hat, Harry Potter and the Sorcerer's Stone 1 WNBA Standings Billboard Hot 100 Largest Metropolitan Areas What do these all have in common? They’re lists of data. We can search through these lists to find something we seek. You’re tracking ID numbers of 200 students enrolled in a class. 57653291, 77974202, 48255064, 50207222, 64327022, 124359, 63817496, 58405436, 25849336, 2472481, 75132998, 75157472, 17504896, 44628635, 71803121, 60578923, 39500049, 80927192, 6013783, 1753947, 41600085, 63630375, 27411604, 2266772, 1876442, 70037639, 16791517, 3405289, 38008671, 26822328, 826108, 93585196, 57231458, 80432166, 15898393, 325166, 27182396, 9980623, 52043583, 46417853, 75067816, 93080379, 80006753, 63763649, 70163825, 75992680, 83819701, 41048764, 69114073, 42204250, 81387373, 56124523, 95869383, 41128399, 81794220, 31352781, 72159769, 3180908, 35393222, 21608155, 90427286, 14141847, 9465016, 55643749, 42230760, 71764328, 12688576, 7962189, 42378930, 76296176, 80671990, 46498407, 32040088, 84436740, 79974249, 83114317, 93258187, 90886474, 15092431, 13525665, 28427034, 81774244, 74116912, 67661230, 68114047, 86052223, 41107776, 68254428, 32185835, 77720864, 39574223, 50496301, 71770551, 29904350, 32018874, 17487375, 96645404, 8932932, 68504204, 31471516, 82736372, 50993878, 79981976, 69678695, 73837172, 89450303, 65252607, 63400970, 38338141, 37064007, 692899, 56662000, 33776992, 41824071,15276083, 83279627, 91988800, 56678667, 60166494, 5920219, 36514409, 91794150, 23430314, 92924419, 10987159, 18834841, 19683736, 85098330, 33649023, 68054688, 99470738, 28355571, 43342771, 59546955, 44973645, 80164480, 17362473, 61913631, 93718882, 10426440, 24730250, 7626153, 55752830, 36316758, 82135131, 8991920, 1189936, 3999980, 5085935, 80025899, 37921450, 61990737, 88409230, 10762169, 4863131, 48520540, 71301552, 99393961, 57937674, 37254359, 85368896, 73346077, 32675274, 2453304, 88257335, 95397732, 60620609, 95214574, 17415138, 60348442, 97989270, 54893057, 73070608, 84727623, 95534022, 97461108, 81359424, 79361707, 54451332, 71460551, 5904284, 71341587, 23894936, 80948727, 13731268, 14398208, 24830512, 719995, 28999931, 78135920, 95488848, 17888747, 2742387, 8487108, 22003990, 49669459, 6384912, 10715875, 68172776, 60764740 People keep asking you to look up whether a particular ID number is in the list. Is a student with ID Aaaarrrgggh! 49457283 enrolled in the class? How about 39585207? 57439046? People keep asking you to look up whether a particular ID number is in the list. There’s gotta be a better way to search for these numbers! People keep asking you to look up whether a particular ID number is in the list. Can I make a computer do this for me? Can I write a program to search the huge list of ID numbers? Well, we could put the ID numbers into a program…. id_numbers_list = [57653291, 77974202, 48255064, 50207222, 64327022, 124359, 63817496, 58405436, 25849336, 2472481, 75132998, 75157472, 17504896, 44628635, 71803121, 60578923, 39500049, 80927192, 6013783, 1753947, 41600085, 63630375, 27411604, 2266772, 1876442, 70037639, 16791517, 3405289, 38008671, 26822328, 826108, 93585196, 57231458, 80432166, 15898393, 325166, 27182396, 9980623, 52043583, 46417853, 75067816, 93080379,80006753, 63763649, 70163825, 75992680, 83819701, 41048764, 69114073, 42204250, 81387373, 56124523, 95869383, 41128399, 81794220, 31352781, 72159769, 3180908, 35393222, 21608155, 90427286, 14141847, 9465016, 55643749, 42230760, 71764328, 12688576, 7962189, 42378930, 76296176, 80671990, 46498407, 32040088, 84436740, 79974249, 83114317, 93258187, 90886474, 15092431, 13525665, 28427034, 81774244, 74116912, 67661230, 68114047, 86052223, 41107776, 68254428, 32185835, 77720864, 39574223, 50496301, 71770551, 29904350, 32018874, 17487375, 96645404, 8932932, 68504204, 31471516, 82736372, 50993878, 79981976, 69678695, 73837172, 89450303, 65252607, 63400970, 38338141, 37064007, 692899, 56662000, 33776992, 41824071,15276083, 83279627, 91988800, 56678667, 60166494, 5920219, 36514409, 91794150, 23430314, 92924419, 10987159, 18834841, 19683736, 85098330, 33649023, 68054688, 99470738, 28355571, 43342771, 59546955, 44973645, 80164480, 17362473, 61913631, 93718882, 10426440, 24730250, 7626153, 55752830, 36316758, 82135131, 8991920, 1189936, 3999980, 5085935, 80025899, 37921450, 61990737, 88409230, 10762169, 4863131, 48520540, 71301552, 99393961, 57937674, 37254359, 85368896, 73346077, 32675274, 2453304, 88257335, 95397732, 60620609, 95214574, 17415138, 60348442, 97989270, 54893057, 73070608, 84727623, 95534022, 97461108,81359424, 79361707, 54451332, 71460551, 5904284, 71341587, 23894936, 80948727, 13731268, 14398208, 24830512, 719995, 28999931, 78135920, 95488848, 17888747, 2742387, 8487108, 22003990, 49669459, 6384912,10715875, 68172776, 60764740] Well, how would you find a number, say 18834841, in real life? id_numbers_list = [57653291, 77974202, 48255064, 50207222, 64327022, 124359, 63817496, 58405436, 25849336, 2472481, 75132998, 75157472, 17504896, 44628635, 71803121, 60578923, 39500049, 80927192, 6013783, 1753947, 41600085, 63630375, 27411604, 2266772, 1876442, 70037639, 16791517, 3405289, 38008671, 26822328, 826108, 93585196, 57231458, 80432166, 15898393, 325166, 27182396, 9980623, 52043583, 46417853, 75067816, 93080379,80006753, 63763649, 70163825, 75992680, 83819701, 41048764, 69114073, 42204250, 81387373, 56124523, 95869383, 41128399, 81794220, 31352781, 72159769, 3180908, 35393222, 21608155, 90427286, 14141847, 9465016, 55643749, 42230760, 71764328, 12688576, 7962189, 42378930, 76296176, 80671990, 46498407, 32040088, 84436740, 79974249, 83114317, 93258187, 90886474, 15092431, 13525665, 28427034, 81774244, 74116912, 67661230, 68114047, 86052223, 41107776, 68254428, 32185835, 77720864, 39574223, 50496301, 71770551, 29904350, 32018874, 17487375, 96645404, 8932932, 68504204, 31471516, 82736372, 50993878, 79981976, 69678695, 73837172, 89450303, 65252607, 63400970, 38338141, 37064007, 692899, 56662000, 33776992, 41824071,15276083, 83279627, 91988800, 56678667, 60166494, 5920219, 36514409, 91794150, 23430314, 92924419, 10987159, 18834841, 19683736, 85098330, 33649023, 68054688, 99470738, 28355571, 43342771, 59546955, 44973645, 80164480, 17362473, 61913631, 93718882, 10426440, 24730250, 7626153, 55752830, 36316758, 82135131, 8991920, 1189936, 3999980, 5085935, 80025899, 37921450, 61990737, 88409230, 10762169, 4863131, 48520540, 71301552, 99393961, 57937674, 37254359, 85368896, 73346077, 32675274, 2453304, 88257335, 95397732, 60620609, 95214574, 17415138, 60348442, 97989270, 54893057, 73070608, 84727623, 95534022, 97461108,81359424, 79361707, 54451332, 71460551, 5904284, 71341587, 23894936, 80948727, 13731268, 14398208, 24830512, 719995, 28999931, 78135920, 95488848, 17888747, 2742387, 8487108, 22003990, 49669459, 6384912,10715875, 68172776, 60764740] Is a[0] == 18834841? No. id_numbers_list = [57653291, 77974202, 48255064, 50207222, 64327022, 124359, 63817496, 58405436, 25849336, 2472481, 75132998, 75157472, 17504896, 44628635, 71803121, 60578923, 39500049, 80927192, 6013783, 1753947, 41600085, 63630375, 27411604, 2266772, 1876442, 70037639, 16791517, 3405289, 38008671, 26822328, 826108, 93585196, 57231458, 80432166, 15898393, 325166, 27182396, 9980623, 52043583, 46417853, 75067816, 93080379,80006753, 63763649, 70163825, 75992680, 83819701, 41048764, 69114073, 42204250, 81387373, 56124523, 95869383, 41128399, 81794220, 31352781, 72159769, 3180908, 35393222, 21608155, 90427286, 14141847, 9465016, 55643749, 42230760, 71764328, 12688576, 7962189, 42378930, 76296176, 80671990, 46498407, 32040088, 84436740, 79974249, 83114317, 93258187, 90886474, 15092431, 13525665, 28427034, 81774244, 74116912, 67661230, 68114047, 86052223, 41107776, 68254428, 32185835, 77720864, 39574223, 50496301, 71770551, 29904350, 32018874, 17487375, 96645404, 8932932, 68504204, 31471516, 82736372, 50993878, 79981976, 69678695, 73837172, 89450303, 65252607, 63400970, 38338141, 37064007, 692899, 56662000, 33776992, 41824071,15276083, 83279627, 91988800, 56678667, 60166494, 5920219, 36514409, 91794150, 23430314, 92924419, 10987159, 18834841, 19683736, 85098330, 33649023, 68054688, 99470738, 28355571, 43342771, 59546955, 44973645, 80164480, 17362473, 61913631, 93718882, 10426440, 24730250, 7626153, 55752830, 36316758, 82135131, 8991920, 1189936, 3999980, 5085935, 80025899, 37921450, 61990737, 88409230, 10762169, 4863131, 48520540, 71301552, 99393961, 57937674, 37254359, 85368896, 73346077, 32675274, 2453304, 88257335, 95397732, 60620609, 95214574, 17415138, 60348442, 97989270, 54893057, 73070608, 84727623, 95534022, 97461108,81359424, 79361707, 54451332, 71460551, 5904284, 71341587, 23894936, 80948727, 13731268, 14398208, 24830512, 719995, 28999931, 78135920, 95488848, 17888747, 2742387, 8487108, 22003990, 49669459, 6384912,10715875, 68172776, 60764740] Is a[1] == 18834841? No. id_numbers_list = [57653291, 77974202, 48255064, 50207222, 64327022, 124359, 63817496, 58405436, 25849336, 2472481, 75132998, 75157472, 17504896, 44628635, 71803121, 60578923, 39500049, 80927192, 6013783, 1753947, 41600085, 63630375, 27411604, 2266772, 1876442, 70037639, 16791517, 3405289, 38008671, 26822328, 826108, 93585196, 57231458, 80432166, 15898393, 325166, 27182396, 9980623, 52043583, 46417853, 75067816, 93080379,80006753, 63763649, 70163825, 75992680, 83819701, 41048764, 69114073, 42204250, 81387373, 56124523, 95869383, 41128399, 81794220, 31352781, 72159769, 3180908,

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    82 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us