A list of puns related to "Hash Tables"
Sorry if this is a stupid question, I have been searching but din't find anything which could clarify to me the answer, (sorry for bad english)
I built an implementation of the A* algorithm which internally uses two HASH-TABLEs:
cost-so-far
, mapping all the searched states the cost required to get there, from the initial state -- this is used to calculate the final cost to move from the initial state to the goal onecome-from
, mapping all the searched states to their previous state -- this is used to calculate the complete path to move from the initial state to the goal oneAs I was profiling this, I came to the conclusions that representing search states with 2D ARRAYs instead of HASH-TABLEs of the same size would have a huge positive impact on the overal runtime (i.e. it's better to use the former than the latter), but I cannot quite understand why, hence this post.
Now, it does not matter if you are not familiar with A*; in fact, we can completely ignore all its mechanics and simply pretend we have two HASH-TABLEs we need to update. In addition, let's pretend our search state was a 2
rows by 10
columns grid, with numbers in it.
I came up with (and benchmarked) the following 3 state representations:
(row col)
as keys(+ (* row 100) col)
as keys -- this to rule out any excessive consing from the aboveThe benchmark is simple:
cost-so-far
and come-from
hash tablescost-so-far
and come-from
Here is the run time for the first state representation, HASH-TABLE with LISTs as
... keep reading on reddit β‘i want to create a hash table fom a txt file that has 149 keys
each line in the txt is in this format 1.word:meaning
I'am stiil new to hashing so i don't know how to start
Basically, I don't know a clear difference between a map and a hash table ,but I know how a hash table works and all the stuff, Can u help me with this question pls!!
So. I'm writing a mid-level VM in C11, and it has come to the part where the application reads a bytecode file and assigns a module name to it. These modules are organized in trees, which essentially represent a file system. So you could think of it as a VFS.
For the application to execute bytecode after said bytecode has been loaded, it needs to query the already loaded files for symbols appearing in the executing code, which are all in fully qualified names. So my system resembles the JVM somewhat. For this querying task, I figured a hash table would be perfect, as a backbone to the VFS-like interface.
Here's the problem: I've written hash tables before, but I'm not so sure on how to optimize one for reliability, speed and concurrency (multiple threads can be loading bytecode simultaneously) and I'd need a little hint on this sorta stuff. I know some common optimization points of a hash table include the cost of expanding one, the speed of the hash function and queries, but as said I do not have experience on speeding things up. So, would someone who knows about this give some ways of making a hash table fast and thread-safe?
Apologies if this is the wrong subreddit.
I have a data stream I'm reading that has addresses 0-9999. I'm currently able to read and display them just fine on my PIC16. What I'd like to do is keep track of how many have been seen "recently". Typically this would be on the order of 5-25, perhaps with an absolute maximum of 100 addresses in use at any one time.
My thought was to do a hash table of some sort. Each entry would be a 8-bit count-down timer to indicate the freshness. This would give me the following functions I'd like to have:
add_or_update(address) -- add address to the hash table if necessary, set it's count-down timer to 255.
decrement() - For each entry in the hash table decrement the timer by 1 if > 0, if 0 remove entry.
count() - How many entries are currently in the hash table.
Where I'm a bit stuck is a hash table implementation. There are obviously hundreds out there, but most are tuned to modern 32-bit or higher CPUs. I need something that's going to be reasonably performant on a PIC16 with its instruction set.
Can anyone provide pointers to hash table algorithms specifically for 8-bit CPU's, or the PIC16, or thoughts on how to handle my use case above? I've googled around a bit and not found anything I considered very helpful yet.
Hi all,
I'm trying to scan through a column in my dataframe, df, and compare each cell to a hash table. I've been using the Hash package for this, and its been going well so far (much faster than using two dataframes and nested for loops to run individual comparisons!). However, I just realized I wanted to add a new key:value pair to my hash table, where the key includes a wildcard. For example, if the key:value pairing was "ab*c:def" then searching the hash table for "abc" "ab1c" "ab123c" etc would all return "def."
Is this possible, or would I need to look to another data structure to perform this sort of thing? Overall what I am trying to do is check each cell in this column of df, see if it corresponds to a key:value pair of interest, and if yes, update a different column in df with the associated value it found from the hash table.
Thanks for any help you can offer!
Basically we were given a txt file with the dictionary words, and some starter code from our textbook. Now, this is some custom written stuff so I can't really compare it to Java's implementation which is really confusing me.
There is this method called put()
which I would guess is similar to add()
in Java. Here is the thing though:
>public void put(Key key,
>
>Value val)
>
>Inserts the specified key-value pair into the symbol table, overwriting the old value with the new value if the symbol table already contains the specified key. Deletes the specified key (and its associated value) from this symbol table if the specified value is null.
What do I do with the Key key and Value val? I would assume all I had to do is pass the dictionary word (String) into the method and it would has it and appropriately place it. The fact that there are two arguments doesn't make sense to me.
TLDR: why are their two arguments in the method? I don't know where it should be inserted, the hash function should know...
Oh also, there is indeed a hashing function that is set to private in the textbook imported code. So there's that.
Reference: https://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/SeparateChainingHashST.java.html
Hey guys, I'm fairly new to Python and I need to know if anyone can point me in the direction of any resources that can help me with the issue in the title. It's for a school project. I've tried looking around but I've found no luck.
Thanks in advance.
My textbook provides two classes, one for linear probing and one for separate chaining. I've successfully made a spell checker using one. My next step for extra credit is to implement the other and compare/describe performance differences. How exactly do I go about doing this? I have no idea how to prove anything.
I realise that this isn't something that will be an issue while submitting to leetcode but in interviews does it ever happen that the interviewer wants guarantees on the worst case time complexity?
Hey guys, long time lurker. I'm at my wits end with trying to optimize this script. I'm pulling resource values from servers to generate an e-mail report. For the sake of not posting the whole script, I'm gonna focus on the parts of the script with storage info.
I'm trying to simplify the use of my Select-Object statements, and wanted to store my calculated properties in an array to pass as an argument. (Not even sure if what I'm saying makes sense, I digress.)
This is what my (sad) attempt at doing this currently looks like, I've tried many (bonehead) iterations and cannot for the life of me get this to work.
$DriveSpaceTableObjects = @(
@{'Name' = 'Drive Letter'; Expression= {$_.DeviceID}}
@{'Name' = '% Utilization'; Expression= {(($_.Size - $_.FreeSpace) / $_.Size).ToString('P')}}
@{'Name' = 'Size (GB)'; Expression= {[int]($_.Size / 1GB) }}
@{'Name' = 'Free (GB)'; Expression= {[int]($_.FreeSpace / 1GB) }}
@{'Name' = 'Server'; Expression = {$env:COMPUTERNAME}}
)
Get-CimInstance -ClassName Win32_LogicalDisk | Where-Object {$_.DriveType -notlike 4 -and $_.DriveType -notlike 5} | Select-Object $DriveSpaceTableObjects
Here's what's frustrating, this works for the above, but when I try to pass it with Invoke-Command
as below:
$dcserverspaceremote = Invoke-Command -Authentication Kerberos -ComputerName $DCServers -ScriptBlock{
Get-CimInstance -ClassName Win32_LogicalDisk | Where-Object {$_.DriveType -notlike 4 -and $_.DriveType -notlike 5} | Select-Object $Using:DriveSpaceTableObjects
}}
It doesn't work. I cannot figure out why. Please help. Lol
EDIT:
Here are the responses for the respective commands.
Local Get-CimInstance
Drive Letter : C:
% Utilization : 37.05 %
Size (GB) : 200
Free (GB) : 126
Server : EXAMPLESERVER
Invoke-Command
Drive Letter :
% Utilization :
Size (GB) :
Free (GB) :
Server :
PSComputerName : EXAMPLESERVER.EXAMPLE.LOCAL
RunspaceId : 93767eab-5cf7-4018-9791-c94d5961b5bb
EDIT FROM COMMENT:
Okay, I'm onto something. See the following:
Using this array (Modification on the last line)
$DriveSpaceTableObjects = @(
@{'Name' = 'Drive Letter'; 'Expression' = {$_.DeviceID}}
@{'Name' = '% Utilization'; 'Expression' = {(($_.Size - $_.FreeSpace) / $_.Size).ToString('P')}}
@{'Name' = 'Size (GB)'; 'Expression' = {[int]($_.Size / 1GB)}}
... keep reading on reddit β‘Hello, have quite a complex home brewed abstract data type HW assignment I need help on. Involves using an interface already programmed for you that will interface with a hash table. You just have to do the user input part. Quite a few files and criteria, not for the faint of heart.
My weakness in PowerShell is that I don't use or fully understand hash tables. Yes, I realize the importance, and Yes, I plan to fix that, but at the moment, I need assistance with an urgent (according to my boss) problem.
The goal: Look through a fileserver of a couple million files and find:
I have an easy one liner that recursively checks the server for all files. It finds the owner and size (i.e. length). I've left out the option "-Force" because I'm not interested in hidden files.
Get-ChildItem -file -Recurse | Select @{Name="Owner";Expression={(Get-ACL $_.Fullname).Owner}},length | ft -HideTableHeaders
This leaves me with something like:
user1 1000
user2 2000
user3 3000
user2 4000
Etc. The information is there, but what I want to do is count the recurrence of each user (easy), but also get the sum total of the file sizes (here as "length") for each user. In my example above, this would look like:
user1, 1, 1000
user2, 2, 6000
user3, 1, 3000
And so on.
For a small number of files, I'd solve the immediate problem by putting this in a spreadsheet or something, but that seems impractical with 2 million files.
Any hash masters out there willing to share some code?
Thanks.
[edit]
A couple of really good suggestions here. I will check these out tomorrow when I'm back in the office. Thanks, everyone.
Hey guys, I had a small doubt in hashing. When we are talking about the load factor, we say that it should be less than 1. If it is 1 or more, we rehash.
Load factor = n/N where n = number of entries in the structure; N= number of slots in the array.
If I have 10 elements and 10 slots in the array, then the load factor is 1. How is this load factor bad? If each slot has 1 entry, isn't that good?
Here's what I think it is:
Does that sound right? Anything I missed? Thanks!
Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.