Advertisement
Guest User

Untitled

a guest
Feb 14th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. Note that for this project, you must use linked list. As we discussed in class, linked list has a drawback. Imagine if you develop your class using linked list to store items from the example in previous page, you will end up with a linked list consisting of 21 nodes. Each node for each item. Now, if you need to return the frequency of 3 (getFrequencyOf(3)), you need to traverse the linked chain from the first node to the last node and count how many 3 are there. Same situation with the method getProbabilityOf(). Imagine if you have to use this frequency bag to store 100,000 or more items. Any applications that use a lot of getFrequencyOf() and getProbabilityOf() methods will suffer a huge performance lost. Suppose you store data as a pair of data and frequency (e.g., (1,1), (2,2), (3,4), (4,3), ...). In doing so, the number of nodes in your linked chain to store the same set of data (shown in the example on the previous page) is now only 8. Obviously the methods getFrequencyOf() and getProbabilityOf() should run a little bit faster. For this project, you must implement your frequencyBag this way because our test class will call methods getFrequencyOf() and getProbabilityOf() very often.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement