Python Tutorial - || Dictionaries || Hash Table || Hashmap || Code Walk-through ||

preview_player
Показать описание
Welcome everyone! This is a Python tutorial on creating your own python dictionaries using hash table and hashmap. This is a code walk-through were i explain everything that I'm doing, so that you can learn python! Python tutorials, GitHub code, and subreddit link below!

*** If you would like to leave a tip you can do so below, thanks **
Bitcoin: 1EHmioBmujNAyVs5A6Uo1nfto9JZhGBDLd

[*] Hit that SUBSCRIBE button.
[*] Hit that NOTIFICATION button.
[*] Leave a COMMENT and a LIKE, SHARE the video, and LEARN something new.

I appreciate all the feedback on my content, you guys are great! :) If you have any questions or need help with anything, don't hesitate to ask.

Hashtag...
#python#hashmap#hash#table#dictionary
Lets learn everyone! :)

NOTE_;
This is for educational purposes and is not malicious in anyway. As always this channel is mainly a coding channel to teach people how to code and what a fantastic skill it is to learn and also how to better protect themselves. My videos are purely ethical and breaking apart how these programs work and how to better protect. This channel does not condone illegal activity and nor does it show anyone how to commit malicious acts or even present enough information for persons to be able to. This channel has taught many children, and adults in schools/colleges/universitys. I have been asked to present talks at conferences and to be published as my teachings are very good and professional.
Рекомендации по теме
Комментарии
Автор

Learn how dictionaries are created and implemented using Python, We use them all the time... may as well know how they work. 👍
*** If you would like to leave a tip you can do so below, thanks ***

www
Автор

Great tutorials one thing the key error should be raised outside the for loop not inside as there may be more key value paid you need to iterate



""" Get """
hashKeyIndex = self.HashFunction(key)
slots = self.bucket[hashKeyIndex]

for i in range(0, len(slots)):
if slots[i][0] == key:
return slots[i][1]
else:
pass

raise KeyError("Key you have entered Dont exists ")

SoumilShah
Автор

Using i outside of the loop is a terrible idea, you should store the value of i in an external variable before you break and use that instead, other than that I would say great tutorial I found it very useful so thank you very much!

achrafelouazouzi
Автор

If you add
if not slot:
raise KeyError('Key not found')
before the for-Loop in the get-Method, you avoid getting a NoneType back, since
if key == k:
only raises an error if a slot is alread taken and the keys don't match.
Thanks for the video.

philperry
Автор

Nice implementation.
But at 7:57 line 27, I don't think you should use a local variable in for-loop outside of the for-loop.
Even though it works, it is dangerous.

chris.w
Автор

class MyHashMap(object):
def __init__(self):
self.arr = [-1] *

def put(self, key, value):
self.arr[key] = value

def get(self, key):
if self.arr[key] in self.arr:
return self.arr[key]
else:
return -1

def remove(self, key):
self.arr[key] = -1

drisaudagthare