日韩精品一区二区三区高清_久久国产热这里只有精品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++編程語言代做
  • 無相關信息
    合肥生活資訊

    合肥圖文信息
    2025年10月份更新拼多多改銷助手小象助手多多出評軟件
    2025年10月份更新拼多多改銷助手小象助手多
    有限元分析 CAE仿真分析服務-企業/產品研發/客戶要求/設計優化
    有限元分析 CAE仿真分析服務-企業/產品研發
    急尋熱仿真分析?代做熱仿真服務+熱設計優化
    急尋熱仿真分析?代做熱仿真服務+熱設計優化
    出評 開團工具
    出評 開團工具
    挖掘機濾芯提升發動機性能
    挖掘機濾芯提升發動機性能
    海信羅馬假日洗衣機亮相AWE  復古美學與現代科技完美結合
    海信羅馬假日洗衣機亮相AWE 復古美學與現代
    合肥機場巴士4號線
    合肥機場巴士4號線
    合肥機場巴士3號線
    合肥機場巴士3號線
  • 短信驗證碼 trae 豆包網頁版入口 目錄網 排行網

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

    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>
        亚洲另类在线视频| 在线亚洲免费视频| 欧美一区二区三区免费看| 欧美日韩国产麻豆| 91久久精品国产91久久| 亚洲破处大片| 欧美福利在线观看| 亚洲欧美日韩国产精品| 久久久久久久久久久一区| 日韩午夜在线播放| 久久在线免费观看| 欧美日韩日本视频| 国产精品久久久久久久电影| 每日更新成人在线视频| 99视频国产精品免费观看| 亚洲欧美制服另类日韩| 亚洲激情欧美| 一本色道婷婷久久欧美| 久久久久久自在自线| 欧美午夜www高清视频| 亚洲欧洲美洲综合色网| 亚洲免费在线观看| 一区在线观看| 亚洲精品免费在线| 国产亚洲精品bv在线观看| 国产丝袜一区二区三区| 一区二区免费看| 黄色资源网久久资源365| 欧美午夜片欧美片在线观看| 亚洲高清自拍| 中日韩美女免费视频网站在线观看| 国产午夜精品麻豆| 美脚丝袜一区二区三区在线观看| 久久资源在线| 影音先锋亚洲视频| 久久se精品一区二区| 亚洲成色www久久网站| 欧美性jizz18性欧美| 中文精品99久久国产香蕉| 亚洲精品乱码久久久久久| 亚洲午夜在线观看视频在线| 在线观看视频日韩| 国产精品综合av一区二区国产馆| 欧美激情中文字幕一区二区| 一区二区三区福利| 国产偷国产偷精品高清尤物| 欧美精品久久久久久久免费观看| 亚洲人成人一区二区在线观看| 国产精品美女久久福利网站| 欧美日韩福利视频| 欧美日本亚洲| 欧美日本国产一区| 亚洲区第一页| 国产精品久久久久久久久借妻| 欧美精品一区二区蜜臀亚洲| 国产真实久久| 国产精品99久久久久久宅男| 99re66热这里只有精品4| 亚洲一区二区三区四区五区午夜| 国产精品免费观看视频| 亚洲国产第一| 欧美日韩一区综合| 欧美日韩成人免费| 久久成人免费日本黄色| 欧美精品一区二区久久婷婷| 亚洲精品亚洲人成人网| 欧美久久久久久蜜桃| 亚洲一区三区电影在线观看| 1024成人网色www| 欧美日韩一卡| 午夜精品一区二区三区电影天堂| 亚洲自拍偷拍网址| 激情久久中文字幕| 国产欧美日韩一区| 激情视频一区二区三区| 99国产精品久久久久久久| 国产精品视频xxx| 欧美激情视频一区二区三区不卡| 国产精品人人做人人爽人人添| 欧美精品在线免费观看| 国产毛片精品国产一区二区三区| 欧美视频专区一二在线观看| 欧美一二三区在线观看| 久久―日本道色综合久久| 国产一区二区三区久久久| 亚洲午夜小视频| 久久久久久欧美| 国产亚洲午夜高清国产拍精品| 国产女主播一区| 欧美sm重口味系列视频在线观看| 亚洲综合导航| 99国产精品私拍| 久久精品国产第一区二区三区最新章节| 亚洲性感美女99在线| 久久av一区| 麻豆精品视频在线| 欧美天天综合网| 亚洲激情在线观看视频免费| 久热成人在线视频| 亚洲欧美国产va在线影院| 亚洲欧美激情视频在线观看一区二区三区| 国产精品久久婷婷六月丁香| 欧美日韩亚洲天堂| 亚洲专区在线| 久久福利毛片| 久久综合九色综合网站| 欧美亚洲视频一区二区| 亚洲成色777777在线观看影院| 国产一区二区三区黄视频| 蜜臀a∨国产成人精品| 亚洲国产欧美一区二区三区同亚洲| 日韩视频精品在线观看| 国内精品久久久久影院薰衣草| 欧美91精品| 亚洲欧美日韩在线观看a三区| 亚洲第一区在线| 国产亚洲免费的视频看| 亚洲三级电影全部在线观看高清| 欧美一激情一区二区三区| 国产主播喷水一区二区| 国产一区在线免费观看| 欧美第一黄色网| 国产亚洲人成a一在线v站| 亚洲清纯自拍| 国产精品手机视频| 一区二区欧美在线| 国产真实乱偷精品视频免| 欧美怡红院视频一区二区三区| 91久久国产综合久久蜜月精品| 国产欧美日韩精品丝袜高跟鞋| 欧美资源在线观看| 久久精品一区二区三区不卡| 欧美一级理论片| 亚洲肉体裸体xxxx137| 欧美日韩ab片| 日韩一区二区精品| 亚洲最快最全在线视频| 国产欧美二区| 亚洲精品欧美激情| 久久久精彩视频| 欧美中日韩免费视频| 亚洲在线成人| 欧美日韩成人网| 国产专区欧美精品| 国产精品久久久久9999吃药| 久久久国产视频91| 国产精品白丝av嫩草影院| 精久久久久久| 欧美日韩和欧美的一区二区| 亚洲福利在线观看| 狠色狠色综合久久| 欧美综合二区| 篠田优中文在线播放第一区| 韩国精品在线观看| 欧美日韩国产一区精品一区| 欧美一级在线播放| 亚洲视频axxx| 91久久精品网| 欧美一区二区三区视频免费| 久久久无码精品亚洲日韩按摩| 亚洲国产精品成人va在线观看| 亚洲高清影视| 黄色日韩精品| 国产日韩欧美精品综合|