日韩精品一区二区三区高清_久久国产热这里只有精品8_天天做爽夜夜做爽_一本岛在免费一二三区

合肥生活安徽新聞合肥交通合肥房產生活服務合肥教育合肥招聘合肥旅游文化藝術合肥美食合肥地圖合肥社保合肥醫院企業服務合肥法律

CSE2425代寫、C++編程語言代做
CSE2425代寫、C++編程語言代做

時間:2024-12-09  來源:合肥網hfw.cc  作者:hfw.cc 我要糾錯



CSE2425, C programming lab, course 2020-2021
Final assignment: Hash map
1 Introduction
In this final assignment you will implement a hash map
1
. A hash map is a data
structure that associates a key with a value (a chunk of data). Most hash maps
are implemented as an array of so-called buckets. A hash function translates
a given key (e.g., a name) to an index in the array, where the corresponding
bucket is stored.
Below we will specify the data structures that you have to provide, and the
functions that you have to implement. This assignment includes two bonus
functions that can raise your score from pass (C) to good (B) to excellent (A).
2 Testing
The first part of the assignment consist of implementing a test set for the hash
map. We have created a number of incorrect hash map implementations. The
goal is to create a test set on which these incorrect implementations fail. When
you have finished creating this test set, you can use this test set to test your own
implementation by copy&pasting it into the my tests of the Hashmap assignment
in Weblab.
3 Hash map structure
Define a type HashMap, which represents the hash map data structure.
Note: Use typedef such that a HashMap structure can be used without using
the struct keyword, i.e. the following construction should be possible:
HashMap *hm;
4 Creating a hash map
1. Implement a function create_hashmap that returns a pointer to the newly
constructed HashMap structure and has parameter
ˆ key_space, a size_t
2
that represents the number of buckets in the hash
map.
1http://en.wikipedia.org/wiki/Hashmap
2http://en.wikipedia.org/wiki/Size_t
1CSE2425, C programming lab, course 2020-2021
This function should allocate enough memory to fit key_space buckets, and the
allocated memory should be zeroed (i.e., NULLed).
2. A hash function maps a string (i.e. an array of chars ending with a null
character) to an index, so it returns a unsigned int. The parameter of a hash
function is simply a
ˆ key, a null-terminated string of characters.
As the hash map can only hold up to key_space buckets, using the hash function
–for example to lookup a mapping– requires some care; apply modulo key_space
to the result such that the value will be in the available bucket range.
3. A default hash function named hash should be implemented. This function
should sum all ASCII values of the characters of the key.
For example:
char *key = "AC";
unsigned int h = hash(key);
=> h = 1**
5 Inserting data
Implement a function insert_data that has parameters
ˆ hm, a pointer to a hash map;
ˆ key, a null-terminated string of characters;
ˆ data, a void pointer to the source data;
ˆ resolve_collision, a ResolveCollisionCallback (see below).
The function should store the data pointer and a copy of the key in the bucket
that can be found by applying the hash function on the key. In case of a
collision, i.e. when there already is data with the same key in the hash map, the
resolve_collision function should be called with the the previously stored
data and data as arguments and the returned void pointer should be stored in
the bucket instead.
ResolveCollisionCallback, a pointer to a function that returns a void pointer
and has two parameters:
ˆ old_data, a void pointer to the previously stored data;
ˆ new_data, a void pointer to the data that is being newly inserted.
The function should determine what data is stored in the has map in case of a
key collision by returning the void pointer to the data that is to be stored.
2CSE2425, C programming lab, course 2020-2021
6 Retrieving data
Implement a function get_data that has parameters
ˆ hm, a pointer to a hash map;
ˆ key, a null-terminated string of characters.
The function should return the data pointer (a void pointer) in the hash map
that is associated with the key. If the key is not present in the hash map, NULL
should be returned.
7 Iterator
Implement a function iterate that has parameters
ˆ hm, a pointer to a hash map;
ˆ callback, a pointer to a function that returns nothing (i.e. void) and has
two parameters:
– key, a null-terminated string of characters;
– data, a void pointer to the data.
This function should iterate over the entire hash map. For each data element
it finds, the callback function should be called with the two members of the
element.
8 Removing data
Implement a function remove_data that has parameters
ˆ hm, a pointer to a hash map;
ˆ key, a null-terminated string of characters.
ˆ destroy_data, a DestroyDataCallback (see below).
This function should remove the element in the hash map that is associated with
the given key. If the destroy_data parameter is non-NULL it should be called
with the data pointer of the element as argument. If the key is not present, the
hash map should remain untouched. As the remove_data function cannot fail,
its return type is void.
DestroyDataCallback, a pointer to to a function that returns nothing (i.e.
void) and has one parameter:
ˆ data, a void pointer.
The function should clean up the data (e.g. free allocated memory).
3CSE2425, C programming lab, course 2020-2021
9 Deleting a hash map
Implement a function delete_hashmap that has parameters
ˆ hm, a pointer to the hash map that is to be deleted;
ˆ destroy_data, a DestroyDataCallback (see 8).
The function should deallocate all memory that was allocated by the hash map.
If the destroy_data parameter is non-NULL it should be called for every data
element that is stored in the hash map with the data pointer of the element as
argument.
10 Bonus: New hash function
Implement a function set_hash_function that has parameters
ˆ hm, a pointer to a hash map;
ˆ hash_function, a pointer to a hash function that returns a unsigned int
and a single parameter:
– key, a null-terminated string of characters.
This function should set hash_function as the new hash function of the hash
map hm. Changing the hash function means that a particular key may now be
hashed to different bucket than it was with the previous hash function. The
hash map must be updated (rehashed) to reflect this so that all data in the
hash map can still be retrieved with their corresponding keys.
11 Bonus: Counting Words
Implement a function count_words that has parameters
ˆ stream, a pointer to a FILE.
This function should count the number of times each word in the stream occurs
using the hash map you implemented. A word is defined as a sequence of one or
more alphanumeric characters (case sensitive). You may use fscanf
3
to read a
particular set of characters from a stream but other solutions are also accepted.
The data stored in the hash map should be properly allocated and deallocated,
do not simply store an integer that is cast to a pointer type. The return type
of the function is void.
3http://en.cppreference.com/w/c/io/fscanf
4CSE2425, C programming lab, course 2020-2021
Given the input:
foo bar_, foo!
bar "baz".
foo?
The program should write the following to the standard output:
bar: 2
baz: 1
foo: 3
The order in which the output is printed is not important.
12 Submission
The assignment should be implemented on Weblab.
ˆ All test code should be located in the Testing assignment.
ˆ All hash map code should be located in the Hashmap assignment.
ˆ Put all the word count source code inside the Wordcount assignment;
ˆ If you have implemented the first bonus exercise, add the following macro
to your Hashamp submission:
#define NEW_HASH
ˆ Do not include a main function. (We will use our own test driver, just like
the example test provided.)
Submissions violating the above requirements will be automatically rejected by
the Weblab system.


請加QQ:99515681  郵箱:99515681@qq.com   WX:codinghelp

掃一掃在手機打開當前頁
  • 上一篇:COMP42215代做、代寫Python設計程序
  • 下一篇:CS-350代寫、C++編程語言代做
  • 無相關信息
    合肥生活資訊

    合肥圖文信息
    急尋熱仿真分析?代做熱仿真服務+熱設計優化
    急尋熱仿真分析?代做熱仿真服務+熱設計優化
    出評 開團工具
    出評 開團工具
    挖掘機濾芯提升發動機性能
    挖掘機濾芯提升發動機性能
    海信羅馬假日洗衣機亮相AWE  復古美學與現代科技完美結合
    海信羅馬假日洗衣機亮相AWE 復古美學與現代
    合肥機場巴士4號線
    合肥機場巴士4號線
    合肥機場巴士3號線
    合肥機場巴士3號線
    合肥機場巴士2號線
    合肥機場巴士2號線
    合肥機場巴士1號線
    合肥機場巴士1號線
  • 短信驗證碼 酒店vi設計 deepseek 幣安下載 AI生圖 AI寫作 aippt AI生成PPT 阿里商辦

    關于我們 | 打賞支持 | 廣告服務 | 聯系我們 | 網站地圖 | 免責聲明 | 幫助中心 | 友情鏈接 |

    Copyright © 2025 hfw.cc Inc. All Rights Reserved. 合肥網 版權所有
    ICP備06013414號-3 公安備 42010502001045

    日韩精品一区二区三区高清_久久国产热这里只有精品8_天天做爽夜夜做爽_一本岛在免费一二三区

      <em id="rw4ev"></em>

        <tr id="rw4ev"></tr>

        <nav id="rw4ev"></nav>
        <strike id="rw4ev"><pre id="rw4ev"></pre></strike>
        国产精品一区二区在线| 亚洲一区激情| 国产亚洲一级高清| 欧美日韩综合视频| 亚洲欧美日本国产有色| 蜜桃av一区二区三区| 狼人社综合社区| 一本色道久久综合亚洲二区三区| 99热这里只有精品8| 亚洲日本中文字幕| 午夜精品美女久久久久av福利| 亚洲一区三区在线观看| 国产精品视频福利| 欧美久久成人| 国产欧美欧美| 欧美黄色影院| 一区免费观看视频| 红桃视频国产精品| 国产精品99久久久久久久女警| 亚洲一区二区三区四区视频| 久久久91精品国产一区二区精品| 在线视频欧美日韩| 欧美14一18处毛片| 久久国产精品色婷婷| 欧美日韩国产在线播放| 欧美不卡视频一区发布| 理论片一区二区在线| 欧美午夜视频网站| 久久躁日日躁aaaaxxxx| 在线视频成人| 国产日韩欧美日韩| 国产精品麻豆成人av电影艾秋| 亚洲乱码国产乱码精品精| 亚洲精品看片| 亚洲欧美国产三级| 国产日韩欧美日韩| 久久久激情视频| 国产欧美一区二区白浆黑人| 中文亚洲欧美| 亚洲另类在线视频| 国产日韩视频一区二区三区| 国产一区99| 国语自产在线不卡| 午夜日韩激情| 国产精品爱啪在线线免费观看| 老鸭窝毛片一区二区三区| 亚洲免费激情| 欧美一区二区日韩一区二区| 欧美日韩国产美女| 欧美激情综合五月色丁香小说| 亚洲欧美日韩精品久久奇米色影视| 一区二区在线免费观看| 国产一区二区三区奇米久涩| 国产美女一区二区| 欧美在线不卡视频| 亚洲第一黄色网| 欧美一区二区三区电影在线观看| 亚洲精品国产精品国自产观看| 亚洲一区影音先锋| 欧美日韩一区二区视频在线观看| 亚洲精品久久7777| 日韩一区二区精品葵司在线| 你懂的视频一区二区| 国产一区二区三区在线观看视频| 国产日本欧美一区二区三区在线| 久久国产精品久久久久久久久久| 99在线精品视频在线观看| 亚洲久久视频| 亚洲欧洲日产国产综合网| 亚洲国产一区二区精品专区| 久久久之久亚州精品露出| 麻豆成人91精品二区三区| 国产亚洲永久域名| 激情久久一区| 一本色道久久88综合日韩精品| 免费成人激情视频| 欧美日韩成人在线观看| 欧美日韩系列| 久久免费视频一区| 美女精品网站| 99热在这里有精品免费| 夜夜嗨av一区二区三区| 亚洲性xxxx| 欧美午夜视频在线| 亚洲黄色免费电影| 亚洲成色最大综合在线| 欧美一区二区在线免费播放| 欧美成年人网站| 欧美精选午夜久久久乱码6080| 欧美乱妇高清无乱码| 欧美日韩调教| 亚洲国产精品久久精品怡红院| 麻豆精品视频在线观看| 欧美日本在线一区| 免费一级欧美在线大片| 一本色道88久久加勒比精品| 在线观看日韩一区| 欧美黄色小视频| 国产精品v亚洲精品v日韩精品| 国产一级揄自揄精品视频| 蘑菇福利视频一区播放| 欧美日韩国产系列| 91久久精品国产91久久| 欧美国产精品专区| 国产精品扒开腿做爽爽爽软件| 欧美大片免费| 伊人色综合久久天天| 亚洲视频在线看| 久久精品国产综合| 亚洲一区二区三区三| 欧美专区中文字幕| 亚洲第一天堂av| 国产美女精品在线| 欧美精品电影在线| 久久超碰97中文字幕| 亚洲人午夜精品免费| 亚洲国产精品热久久| 免费在线观看日韩欧美| 韩国免费一区| 性娇小13――14欧美| 伊人成人开心激情综合网| 欧美日韩国产成人在线免费| 亚洲欧美日韩一区| 欧美一区二区播放| 国产在线高清精品| 国产美女精品视频免费观看| 国产欧美日韩| 久久亚洲捆绑美女| 亚洲精品久久久久久久久| 亚洲一区二区三区久久| 欧美在线一区二区| 免费国产自线拍一欧美视频| 久久在精品线影院精品国产| 亚洲国产精品久久91精品| 国产精品丝袜白浆摸在线| 日韩视频永久免费观看| 久久激情视频免费观看| 一二三区精品福利视频| 黄色资源网久久资源365| 久久黄色影院| 午夜国产欧美理论在线播放| 国语自产精品视频在线看抢先版结局| 1024精品一区二区三区| 欧美人成在线视频| 欧美四级在线观看| 久久一区二区精品| 国产精品二区在线观看| 欧美影片第一页| 欧美精品亚洲二区| 国产三级欧美三级| 一区二区三区高清在线| 国产人成一区二区三区影院| 欧美成人影音| 午夜国产一区| 久久国产精品一区二区三区四区| 久久大香伊蕉在人线观看热2| 亚洲自拍偷拍视频| 久久综合成人精品亚洲另类欧美| 欧美女主播在线| 国产欧美69| 一区二区高清在线| 欧美视频国产精品| 韩国成人理伦片免费播放| 欧美视频在线免费|