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: patch-diff.githubusercontent.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:c464c0da-6d15-9590-6c46-b25ea5836ea6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E90A:3EABC2:1F757B9:29FFB7E:696EEC76 |
| html-safe-nonce | 1b71f0e2c878bd379726364a4cecb323be07440bbe2976db6cde885597bbe471 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOTBBOjNFQUJDMjoxRjc1N0I5OjI5RkZCN0U6Njk2RUVDNzYiLCJ2aXNpdG9yX2lkIjoiNjY1MDUzMjU5NzkwNzUxNjUzNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e9f5b76d9c947ef57b4a346be14ad531e9e6c8aa162427bd68303dc983eabab1 |
| 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 | b278ad162d35332b6de714dfb005de04386c4d92df6475522bef910f491a35ee |
| 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 | 39aed5006635ab6f45e6b77d23e73b08a00272a3 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width