Title: Hashtable - Linear probing __setitem__ not considering updates. · Issue #78 · codebasics/data-structures-algorithms-python · GitHub
Open Graph Title: Hashtable - Linear probing __setitem__ not considering updates. · Issue #78 · codebasics/data-structures-algorithms-python
X Title: Hashtable - Linear probing __setitem__ not considering updates. · Issue #78 · codebasics/data-structures-algorithms-python
Description: Case: Key exists after the first empty slot. Issue: Code inserts the new (key,value) instead of updating existing (key,value). Code in question: def find_slot(self, key, index): prob_range = self.get_prob_range(index) for prob_index in p...
Open Graph Description: Case: Key exists after the first empty slot. Issue: Code inserts the new (key,value) instead of updating existing (key,value). Code in question: def find_slot(self, key, index): prob_range = self.g...
X Description: Case: Key exists after the first empty slot. Issue: Code inserts the new (key,value) instead of updating existing (key,value). Code in question: def find_slot(self, key, index): prob_range = self.g...
Opengraph URL: https://github.com/codebasics/data-structures-algorithms-python/issues/78
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Hashtable - Linear probing __setitem__ not considering updates.","articleBody":"Case: Key exists after the first empty slot.\r\nIssue: Code inserts the new (key,value) instead of updating existing (key,value).\r\n``` \r\nCode in question:\r\ndef find_slot(self, key, index):\r\n prob_range = self.get_prob_range(index)\r\n for prob_index in prob_range:\r\n if self.arr[prob_index] is None:\r\n return prob_index\r\n if self.arr[prob_index][0] == key:\r\n return prob_index\r\n raise Exception(\"Hashmap full\") ```\r\nMaybe this can fix it:\r\ndef find_slot(self, key, index):\r\n first_slot = None\r\n prob_range = self.get_prob_range(index)\r\n for prob_index in prob_range:\r\n if first_slot == None and self.arr[prob_index] is None:\r\n first_slot = prob_index\r\n if self.arr[prob_index][0] == key:\r\n return prob_index\r\n if first_slot is not None:\r\n return first_slot\r\n raise Exception(\"Hashmap full\")","author":{"url":"https://github.com/ManuMathewVarghese","@type":"Person","name":"ManuMathewVarghese"},"datePublished":"2023-06-28T02:27:25.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/78/data-structures-algorithms-python/issues/78"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:243bb197-f7c0-e9b0-1d13-d57ad0651c2f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C41E:3DE253:181BA15:21C4BBD:696FD80A |
| html-safe-nonce | f66b95707c9237ca8aacc5d5ffa088feb57e75cf9419815c0c791f093f407fe0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNDFFOjNERTI1MzoxODFCQTE1OjIxQzRCQkQ6Njk2RkQ4MEEiLCJ2aXNpdG9yX2lkIjoiMTczMTY3NDAwNTk4MzcxMzI5MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4b7c9590408e6d290c96431391c0138f2b239a53a1e92f88e99e89a758766819 |
| hovercard-subject-tag | issue:1778062863 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/codebasics/data-structures-algorithms-python/78/issue_layout |
| twitter:image | https://opengraph.githubassets.com/007b817f2426ddb8abc7188ad01a1b08cea1a4d5f0830c35654a5848fd1b1a5a/codebasics/data-structures-algorithms-python/issues/78 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/007b817f2426ddb8abc7188ad01a1b08cea1a4d5f0830c35654a5848fd1b1a5a/codebasics/data-structures-algorithms-python/issues/78 |
| og:image:alt | Case: Key exists after the first empty slot. Issue: Code inserts the new (key,value) instead of updating existing (key,value). Code in question: def find_slot(self, key, index): prob_range = self.g... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ManuMathewVarghese |
| hostname | github.com |
| expected-hostname | github.com |
| None | a5d30ba41f7d9acded2fd135aa830ac2f5c7e52dca0e776e658d37eaf9dfb033 |
| turbo-cache-control | no-preview |
| go-import | github.com/codebasics/data-structures-algorithms-python git https://github.com/codebasics/data-structures-algorithms-python.git |
| octolytics-dimension-user_id | 16063416 |
| octolytics-dimension-user_login | codebasics |
| octolytics-dimension-repository_id | 299539326 |
| octolytics-dimension-repository_nwo | codebasics/data-structures-algorithms-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 299539326 |
| octolytics-dimension-repository_network_root_nwo | codebasics/data-structures-algorithms-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2f945b7bb88421600e89dfefbb1548ad0a44781a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width