Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

In a chained hash table, each table entry is a pointer to a collection of elements. It can be any collection that supports insert, remove, and find, but is commonly a linked list. The elements in the list can be stored by key value order, by frequency of access or by insertion time. Each list forms a bucket in which we place elements hashing to a specific position in the array. Because each bucket is a linked list, an unlimited number of elements can be inserted. However, performance degrades if the table becomes full.

"Chained hash tables have a simple solution for resolving collisions: elements are simply placed in the bucket where the collision occurs. One problem with this, however, is that if an excessive number of collisions occur at a specific position, a bucket becomes longer and longer. Thus, accessing its elements takes more and more time. Ideally, we would like all buckets to grow at the same rate so that they remain nearly the same size and as small as possible. In other words, the goal is to distribute elements about the table in as uniform and random a manner as possible. This theoretically perfect situation is known as uniform hashing; however, in practice it usually can only be approximated.

Even assuming uniform hashing, performance degrades significantly if we make the number of buckets in the table small relative to the number of elements we plan to insert. In this situation, all of the buckets become longer and longer. Thus, it is important to pay close attention to a hash table's load factor. The load factor of a hash table is defined as: where n is the number of elements in the table and m is the number of positions into which elements may be hashed. The load factor of a chained hash table indicates the maximum number of elements we can expect to encounter in a bucket, assuming uniform hashing.

For example, in a chained hash table with m = 1699 buckets and a total of n = 3198 elements, the load factor of the table is a = 3198/1699 = 2. Therefore, in this case, we can expect to encounter no more than two elements while searching any one bucket. When the load factor of a table drops below 1, each position will probably contain no more than one element. Of course, since uniform hashing is only approximated, in actuality we end up encountering somewhat more or less than what the load factor suggests. How close we come to uniform hashing ultimately depends on how well we select our hash function."

Problem

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

You will use the table to compare two Shakespeare plays: Hamlet and As You Like It. You will report the number of words that Shakespeare used in both plays. Have your program read the file hamlet.txt and insert each word into the table. For this assignment, a word will be delimited by a white space, so simple input with >> can be used. Some of the words will, of course, be nonsense, but we will ignore this. After inserting all the words from Hamlet, do a lookup for words from the file asyoulikeit.txt. Store and count the words that are duplicated in the two plays (i.e. words for which the search is successful). Your count may be slightly less than accurate in reality, since we will not strictly parse the words. However, each student should come up with the same list of words and the same count. For each word you insert, compute the number of elements in the bucket that are searched. Likewise, compute the number of unsuccessful searches. Report the average number of elements inspected during a search (average number per bucket). Determine if this is close to the expected size based on the load factor after all words have been inserted.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9543443

Have any Question?


Related Questions in Computer Engineering

Need help with a java program that takes two arrays a and b

Need help with a Java program that takes two arrays a and b of length 5 storing int values, and returns the dot product of a and b. That is, it returns an array c of length n such that c[i]=a[i]*b[i].

What are the implications of the shift from medical care to

What are the implications of the shift from medical care to the focus on overall health conditions?

student who is taking quizzes public class student

/** A student who is taking quizzes. */ public class Student { private String name; private double totalScore; private int quizCount; public Student (String n) { name = n; totalScore = 0; quizCount = 0; } public String g ...

Based on land minerals and natural resources labor and

Based on land, minerals and natural resources, labor and entrepreneurial innovation, which country do you feel has the greatest long-term potential China or Russia.

Question suppose that a car is moving through a suburban

Question : Suppose that a car is moving through a suburban environment that has a wireless channel with a coherence time of 10 ms and a coherence bandwidth of 600 kHz. The bit rate of the signal being used is 50 kbps. Ch ...

Write a matlab code to solve thisit seems that the math

Write a matlab code to solve this It seems that the Math department at a rival university has once again dropped the ball, and forgotten the value of n. You are to write a script which consumes a number that specifies th ...

Question high-performing teambullimagine that you are an

Question: "High-Performing Team" • Imagine that you are an agile coach. Outline a plan that sets the expectations for your team when beginning a project. Provide a rationale for your response. • Read the mini-case titled ...

Question suppose you are planning a party for 10 friends

Question : Suppose you are planning a party for 10 friends. You decide to make sandwiches to serve at the party, no more than one sandwich per person. Seven of your friends say they want turkey. Five say they want roast ...

Discuss how a successful organization should have the

Discuss how a successful organization should have the following multiple layers of security in place for the protection of its operations: Information security management. Data security Network security

Assume newspaper for garbage or recycling has a standard

Assume newspaper for garbage or recycling has a standard deviation of 2 pounds. If we want to estimate the average amount of newspaper for garbage or recycling within .25 pounds with 90% confidence, how many households m ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As