Having trouble figuring this out. If I have 2 sets of integers how would I use a hash table to test if set A is a subset of set B (in pseudocode). I think I understand that basically I would need to create a hash table for all the elements of B. Then, the traverse A and search for each element in the hash table. If the element is not found return 0. If all elements are found return 1 (meaning A is a subset of B).

Also, I believe the average run time and worst case run time would be the same in this scenario,,, O(n+m)

Further than that though, I am having trouble creating an algorithm (pseudocode) for this problem. Any help would be appreciated. Thanks

  • 2
    $\begingroup$ We discourage "please check whether my answer is correct" questions, as only "yes/no" answers are possible, which won't help you or future visitors. See here and here. Can you edit your post to ask about a specific conceptual issue you're uncertain about? As a rule of thumb, a good conceptual question should be useful even to someone who isn't looking at the problem you happen to be working on. If you just need someone to check your work, you might seek out a friend, classmate, or teacher. $\endgroup$ – D.W. Dec 11 '17 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.