Python代写:FIT1008 Hash Table代写Python编程

代写哈希表,使用Linear Probing的方式实现。Objectives of this practical sessionTo be able to implement and use hash tables in Python.Note:You should provide documentation and testing for each piece of functionality in your code. Your documentation needs to include pre and post conditions, and information on any parameters used.Create a new file/module for each task or subtask.You are not allowed to use the Python built-in dict methods.Name your files task[num] to keep them organised.TestingFor this prac, you are required to write:(1) a function to test each function you implement, and(2) at least two test cases per function.The cases need to show that your functions can handle both valid and invalid inputs. There is no need to test menu functions.MarksFor this assessed prac, there are a total of 30 marks. There are 10 marks allocated to your understanding of the solutions and your implementations in the prac overall. In addition to these, the marks for each task are listed with the tasks. A marking rubric is available online for you to know and understand how you will be marked.Task 1Implement a complete version of a hash table using Linear Probing to resolve collisions. Include implementations for the following 4 functions:__getitem__(self, key): Returns the value corresponding to key in the hash table. Raises a KeyError if key does not exist in the hash table. Called by table[key]__setitem__(self, key, value): Sets the value corresponding to key in the hash table to be value. Raise an exception if the hash table is full and the key does not exist in the table yet. Called by table[key] = value__contains__(self, key): Returns True if key is in the table and False otherwise.hash(self, key): Calculates the hash value for the given key. Use the hash function given below.Task 2Download from Moodle the dictionary files english_small.txt, english_large.txt and french.txt.For each of these dictionaries, time how long it takes to read all words in it into the hash table (i.e. wall time). Do this for each of the following table_size values: 210000, 209987, 400000 and 399989 and 202361. Present the wall times recorded in a table.Write a short analysis reporting what values work best and which work poorly. Explain why these might be the case.Task 3Modify your hash table implementation to now track the number of collisions as well as the average probe length. For the latter, it is advisable to track the total probe length in an instance variable. The average probe length is the total probe length divided by the number of items on the table.Using collisions, probe length and wall time, choose appropriate values of a (in your hash function) and table_size. You want to find values that perform well across all three files. For this task use a maximum table size of 400000.You should try at least 10 values, and explain your choice by presenting all data behind your reasoning recorded in a table 2 .Task 4Modify your hash table from the previous tasks to:use Quadratic Probing to resolve collisions.implement dynamic hashing, by doubling the size of the underlying array (and rehashing) every time the load exceeds 32Compare the number of collisions, probe length and running time found when loading each dictionary against the best combination found using the Linear Probing hash table.Task 5Implement a hash table which uses Separate Chaining to resolve collisions. It is a good idea to first implement and test the Linked List separately. Compare the performance of Separate Chaining against the linear probe above.BackgroundIn most large collections of written language, the frequency of a given word in that collection is inversely proportional to its rank in the words. That is to say that the second most common word appears about half as often as the most common word, the third most common word appears about a third as often as the most common word and so on.If we count the number of occurrences of each word in such a org/wiki/Zipf%27s_law collection, we can use just the number of occurrences to determine the approximate rank of each word. Taking the number of occurrences of the most common word to be max and the relationship described earlier, we can assume that any word that appears at least max/100 times appears in the top 100 words and is therefore common.The same can be applied as max/1000 times for the next 900 words, rounding out the top 1000 words, considered to be uncommon. All words that appear less than max/1000 times are considered to be rare. In this prac we have been implementing hash tables and so we will use one here to facilitate a frequency analysis on a given text file.Task 6Download some ebooks as text files from https://www.gutenberg.org/ and use these files as a collection of English. Read these into your Quadratic Probing hash table to count the number of each word in the texts. Considering the data you collected in Task 2, select an appropriate table size for the text files. Use these occurrence counts to construct a table which can be used to look up whether a given word is common, uncommon or rare within written English.Task 7Download another ebook from https://www.gutenberg.org/ and using your table from Task 6, analyse the percentage of common, uncommon and rare words. If a word is not found in the table, consider it misspelled. Print the percentage of common, uncommon, rare and misspelled words for the given text.Task 8 - Just for funImplement the program in Task 3 using Python’s dict class. How does the performance of your own implementations compare to Python’s in terms of the wall time? What factors may drive the differences? How close can you get to the reference implementation?本团队核心人员组成主要包括BAT一线工程师,精通德英语!我们主要业务范围是代做编程大作业、课程设计等等。我们的方向领域:window编程 数值算法 AI人工智能 金融统计 计量分析 大数据 网络编程 WEB编程 通讯编程 游戏编程多媒体linux 外挂编程 程序API图像处理 嵌入式/单片机 数据库编程 控制台 进程与线程 网络安全 汇编语言 硬件编程 软件设计 工程标准规等。其中代写编程、代写程序、代写留学生程序作业语言或工具包括但不限于以下范围:C/C++/C#代写Java代写IT代写Python代写辅导编程作业Matlab代写Haskell代写Processing代写Linux环境搭建Rust代写Data Structure Assginment 数据结构代写MIPS代写Machine Learning 作业 代写Oracle/SQL/PostgreSQL/Pig 数据库代写/代做/辅导Web开发、网站开发、网站作业ASP.NET网站开发Finance Insurace Statistics统计、回归、迭代Prolog代写Computer Computational method代做因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:[email protected] 微信:codehelp QQ:99515681 或邮箱:[email protected] 微信:codehelp

你可能感兴趣的:(Python代写:FIT1008 Hash Table代写Python编程)