Division Algorithm & Hashing Algorithms PDF
Document Details
Uploaded by SeasonedDialogue
Tags
Summary
This document explains the division algorithm and its real-world applications, including examples such as distributing books, laptops, and apples. It also covers the concept of hashing and its use in data structures, like hash tables. The document goes on to provide practice problems to help the user apply and understand the concepts.
Full Transcript
LSM1013-MATHEMATICS FOR COMPUTING CLO 1.3 Use the division algorithm to figure out division problems with remainders. ‹#› Division with Remainders Example 1: Divide 23 by 5 using the division algorithm. Step 1: 23÷5=4 (quotient is 4)....
LSM1013-MATHEMATICS FOR COMPUTING CLO 1.3 Use the division algorithm to figure out division problems with remainders. ‹#› Division with Remainders Example 1: Divide 23 by 5 using the division algorithm. Step 1: 23÷5=4 (quotient is 4). Step 2: 5×4=20. Step 3: 23−20=3 (remainder is 3). Result: 23 = 5×4+3 Example 2: Divide 102 by 7 using the division algorithm. Step 1: 102÷7=14 (quotient is 14). Step 2: 7×14=98. Step 3: 102−98=4 (remainder is 4). Result: 102 = 7×14 + 4 ‹#› Division with Remainders-Practice Problems Practice 1: Divide 37 by 6 using the division algorithm. Practice 2: Divide 89 by 8 using the division algorithm. Practice 3: Divide 54 by 9 using the division algorithm. Practice 4: Divide 94 by 7 using the division algorithm. Practice 5: Divide 65 by 2 using the division algorithm. ‹#› Real-Life Applications Scenario: You need to pack 52 books into boxes, with each box holding 9 books. How many boxes do you need, and how many books will be in the partially filled box? Step 1: Divide 52 by 9 using the division algorithm. Step 2: 52÷9=5 (quotient is 5). Step 3: 9×5=45. Step 4: 52−45=7 (remainder is 7). Result: You need 6 boxes (5 full, 1 partially filled) and the partially filled box will have 7 books. ‹#› Real-Life Applications Scenario: You have 83 laptops to distribute evenly among 7 schools. How many laptops does each school get, and how many are left? Step 1: Divide 83 by 7 using the division algorithm. Step 2: 83÷7=11 (quotient is 11). Step 3: 7×11=77. Step 4: 83−77=6 (remainder is 6). Result: Each school gets 11 laptops, with 6 laptops left over. ‹#› Real-Life Applications-Hashing Algorithms Hash Value: The hash value is the result of the hashing algorithm—a fixed-size string of letters and numbers. Think of it as a "fingerprint" for data. Just like fingerprints are unique to each person, a hash value is meant to be unique for different pieces of data. Example: Let’s say you type the word "Hello" into a hashing algorithm. The algorithm might turn that into something like 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c.If you change even one letter, like typing "hello" with a lowercase "h," the hash value would be completely different. ‹#› Real-Life Applications-Hashing Algorithms Hash Table: A hash table is a data structure that uses keys and values to store data. It uses a hash function to quickly determine where to store or retrieve the data, making it highly efficient for tasks like looking up information. Why Use Hash Tables? Fast Lookups: Hash tables are great for quick data retrieval. Instead of searching through a long list, the hash function jumps directly to where the data is stored. Efficient Storage: Hash tables can handle large amounts of data without becoming slow. ‹#› Real-Life Applications-Hashing Algorithms Hashing Algorithms: Hashing algorithms where division and remainders are used to distribute keys. Use the division algorithm to calculate hash values by dividing the key by the hash table size and taking the remainder. Example: In a hash table with 10 slots, a key value of 123 would be placed in slot 3 (remainder on dividing 123 by 10). ‹#› Real-Life Applications-Hashing Algorithms Practice 1: You need to pack 128 apples into baskets, with each basket holding 12 apples. How many baskets do you need, and how many apples will be in the partially filled basket? Practice 2: Use the division algorithm to calculate the hash value for the key 37 when the hash table size is 10. Practice 3: You have 95 tablets to distribute evenly among 8 classrooms. How many tablets does each classroom get, and how many are left? Practice 4: You have 123 chairs to distribute evenly among 9 offices. How many chairs does each office get, and how many are left? Thank You