99爱在线视频这里只有精品_窝窝午夜看片成人精品_日韩精品久久久毛片一区二区_亚洲一区二区久久

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

代寫CS111 2025、C/C++程序設計代做
代寫CS111 2025、C/C++程序設計代做

時間:2025-06-04  來源:合肥網hfw.cc  作者:hfw.cc 我要糾錯



CS111 2025 Spring Homework 2: 
Task 0 
For this program, the source code files appear in different folders: Algorithms, Core, IO, Utils, and each of them has its own Test folder containing a testing file.
Compare this organization with putting all files in a single folder. 
•Which approach is better for a project with many files, and why? 
•Consider aspects such as maintainability, compilation speed, teamwork, and ease of navigation.
Answer:  
Task 1: Answer the question.
In the Utils folder, you see files with .h, .hpp, .cpp, and .c extensions. Explain the typical use of each extension in a C++ project. When should you use .h vs .hpp, and .cpp vs .c?

Task 2: Answer the question.
In the Utils folder, according to the Makefile, the file c_utils.o (created by the C compiler gcc) will be linked with test_c_util.o (created by the C++ compiler g++). 
•How can this be done successfully? 
•What must be considered in the header files to ensure correct linkage? 

Task 3: Answer the question. 
There are three header files in the Utils folder:
•c_and_cpp_utils.hpp
•c_only_utils.h
•cpp_only_utils.hpp
What are the different intended uses of each file, and why? 
Task 4 
•In bit_stream.hpp, there is a line:
BitStream() = default;
Is this line needed? Why or why not? 
•Consider another similar case, doubly_linked_list.hpp, there is a line:
DoublyLinkedList() = default; 
Is this line needed? Why or why not? 

Task 5
In bit_stream.hpp, there is a line:
size_t size() const noexcept;
•Is the noexcept part proper or helpful here? Why or why not? 
•Discuss the implications of using noexcept regarding performance, correctness, and code design. 

Task 6
In the file, there are two lines: 
class BitProxy; 
BitProxy operator[](size_t index);
Why is the first line (class BitProxy;) needed?
Why does operator[] return a BitProxy object instead of a bool& or bool?
Compare this design to how operator[] works in standard containers like std::vector or arrays.

Task 7
Regarding the design of the BitStream as shown in the file bit_stream.hpp, why not simply use an array of bool to replace it? Explain. 
Regarding the design of the BitStream as shown in the file bit_stream.hpp, why not simply use an array of bool to replace it? Explain.
•Discuss the advantages and disadvantages of using an array of bool versus a BitStream.
•Consider aspects such as memory usage, performance, and practical implementation details, and relevance to the project. 

Task 8
In the file bit_stream.hpp, you will find the following declaration:
std::vector<uint8_t> data;
Suppose we replace uint8_t with char, i.e.,
std::vector<char> data;
•Would this change be appropriate? Why or why not? 
•Discuss the implications of using char instead of uint8_t for storing raw bit data, considering type safety, portability, and clarity.

Task 9
In bit_stream.cpp, consider the function definition of append_internal. 
a.) Explain the meaning of the following code:
 if (byte_index >= data.size()) { 
        data.push_back(0); 
    }
b.) Provide the missing statements in the following code, and briefly explain what your code does:
    if (bit) {
          // code missing
    } else {
         // code missing
    }

Task 10
In the file bit_stream.cpp, in the definition of the function write_to_file, there are two lines:
const uint64_t bit_count = end_pos - start_pos; 
file.write(reinterpret_cast<const char*>(&bit_count), sizeof(bit_count));
Explain these two lines of statements. 

Task 11
In the file bit_stream.cpp, in the function read_from_file, there is a loop to read the bits one by one from the file.
 for (uint8_t byte : buffer) { 
            for (int bit_pos = 7; bit_pos >= 0 && bits_added < bit_count; --bit_pos) { 
                append_internal((byte >> bit_pos) & 1); 
                bits_added++; 
            } 
        }
Is this necessary? Why not simply read a sequence of uint8_t bytes from the file and save them into the BitStream object? Why?

Task 12 
In doubly_linked_list.hpp, there are lines to assign values to members that are not part of a constructor, like:
Node* head = nullptr; 
Node* tail = nullptr; 
size_t len = 0;
What is the meaning of these, and why are these allowed? How does this differ from initializing these members in the constructor’s initializer list?

Task 13 
In doubly_linked_list.hpp, the structure Node is declared in the public section of the class. Compared to another choice, putting this declaration in a private section of the class, what are the advantages and disadvantages of these two choices? Which is better for this project, and why? 

Task 14
In doubly_linked_list.hpp, consider the constructor of Node:
explicit Node(const T&& val) : ... 
What is the meaning of this? When does the method of the DoublyLinkedList class call this constructor of Node? 

Task 15
In doubly_linked_list.hpp, in the function link_node, the code part for inserting a new node before an existing node is missing. Provide the missing code.
•You can put it in both places, here in this report file, and in the missing-code place in doubly_linked_list.hpp. 

Task 16 
In doubly_linked_list, there is a template function:
template<typename U>  
  void insert_back(U&& value) {
      link_node(new Node(std::forward<U>(value)), tail, false);
  }
What is the meaning of calling the forward function here?

Task 17 
Since the insert_back function appears in the template class DoublyLinkedList, it is automatically a template function. So, maybe the template type name can be ignored and shared with the template type name T of the class. Then, can we use the following function? Why? 
  void insert_back(T&& value) {
      link_node(new Node(std::forward<T>(value)), tail, false);
  }

Task 18
How about writing the insert_back function as follows:
  template <typename T>
  void insert_back(T&& value) {
      link_node(new Node(std::forward<T>(value)), tail, false);
  }
Is it ok? Why? 

Task 19
In the file linked_list_and_priority_queue_tests.cpp, we see a range-based for loop: 
for (auto& item : list) {
        forward.push_back(item);
        std::cout << item << " " << "pushed back" << " forwardly " <<std::endl;
}
Here list is an object of the DoublyLinkedList class. Why is the range-based for loop supported here?
Alternatively, for a class X to support range-based for loop, what are the requirements of X?

Task 20
In doubly_linked_list.hpp, inside the iterator class, 
there is a statement: 
using iterator_category = std::bidirectional_iterator_tag;
Which header file is needed for this statement? 
How about a typedef in this line, like:
typedef std::bidirectional_iterator_tag iterator_category ; 
Which is better, and why? 

Task 21
The type alias iterator_category, which is defined in doubly_linked_list.hpp, is not used in the program. Why is it needed or useful? 

Task 22 
In the file priority_queue.hpp, the template class PriorityQueue is declared as follows:
template < 
    typename T, 
    typename Compare = std::greater<T>, 
    //template <typename, typename> class Container = VectorHeapContainer 
    // Use the VectorHeapContainer for faster performance.  
    template <typename, typename> class Container = OrderedLinkedListContainer 

class PriorityQueue { 
    //... 
};
By observing this code snippet, we should have learned something. Answer the following questions: 
•When a template class has a template parameter that is also another template class, how do you express the code?
•How do you specify the default choice of a template parameter?

Task 23
In priority_queue.hpp, by observing, the PriorityQueue class can use any template class that satisfies some specific requirements, working as the container. Briefly describe what these requirements are. 

Task 24
The requirements for a possible container class are similar to the concepts of interface and the is-a relationship, which the public inheritance mechanism can describe. 
Sketch some design: a Container class that describes these requirements, so that any derived class of the Container class can be used by the PriorityQueue, which is adjusted accordingly. 
Bonus Points if the adjusted program can compile and run correctly. 

Task 25
In priority_queue.hpp, in the class OrderedLinkedListContainer, in the insert function, there is a statement.
static_assert(
            std::is_convertible<typename std::decay<U>::type, T>::value, // C++11 syntax
            "calling OrderedLinkedListContainer::insert() with data of type U. Type U must be implicitly convertible to T");
What is the meaning of this statement? Explain in terms of the usage of:
•is_convertible
•std::decay
•and std::static_assert; 
Is it similar to some validation function defined in this program? What are the differences? 
Task 26
In the file priority_queue.hpp, inside the class OrderedLinkedListcontainer, in the insert function, there is a statement missing, which is to locate the iterator it to the first place where the value is larger than the data of it or it reaches the end. 
Provide the missing code (write the code here and in the . hpp file)

Task 27 
In doubly_linked_list.hpp, in the class DoublyLinkedList, there are two iterator classes, iterator and const_iterator, defining the same overloaded operators. Why do we need these iterator classes ? Alternatively, asking, what would happen if only one iterator type were provided?

Task 28
In doubly_linked_list.hpp, the arrow operator -> will return a pointer. Explain how it works. Alternatively, explain, given the following sketch of statements:
iterator it = ...;
it->some_member; 
What is an expression equivalent to it->some_member? 

Task 29
The -- operator has a prefix version and a postfix version. How are the two operator functions declared differently, as shown in doubly_linked_list.hpp? A similar mechanism can overload the ++ operators. 

Task 30
In the file link_list_and_priority_queue_tests.cpp. Two macros, TEST_FUNCTION and END_TEST, are defined. Some tests are carried out and the number of passing and failure are recorded. This mechanism is similarly used in the huffman_tests.cpp in the Algorithms folder. Describe this pattern of writing and testing code. What is the advantage of doing so? 

Task 31:
In the file IO/Bit_stream/bit_stream.hpp
For the class BitStream, we observe that the BitProxy class has no copy constructor or copy assignment. 
•Is defining these special methods (with copy semantics) problematic for this class? Why? 
•If we want to turn off using these methods for this class explicitly, how do we do it? 
–Discuss the legacy way and/or a modern C++ way.

Task 32:
In the file huffman_tree.hpp. The two concrete classes LeafNode and InternalNode share the same base class Node. What are the advantages and usefulness of this design? Consider the print_huffman_tree function defined in the huffman_tree.cpp as an example for the explanation. 

Task 33:
In huffman_tree.hpp, in the classInternalNode, its two members left and right are unique pointers: 
const std::unique_ptr<HuffmanNode> left;
const std::unique_ptr<HuffmanNode> right;
Why are these unique pointers proper? Comparing using raw pointers for left and right, what are the advantages/disadvantages? 

Task 34:
In huffman_tree.cpp, in the print_huffman_tree definition, the code in the else block is missing, which should handle the recursive case of the function. It will print the left subtree, the internal node (the root of the subtree), and the right subtree. Provide the missing code. 
•Write missing statements in the .cpp file, and also paste them here. 

Task 35:
In huffman_algorithm.cpp, in the function string_to_frequence_map, a part is missing, which is to compute the count of each character in a string text. 
Provide the missing code in the .cpp file and paste the lines here in this report file. 

Task 36:
In huffman_tree.cpp, in the constructor of HuffmanTree, which builds a tree based on a frequency map (the parameter), there are missing parts of code. 
•Provide code for both (a) inserting leaf nodes into the priority queue and (b) combining nodes to build the tree.
–The comments in the file are helpful.
–Put the missing code in the .cpp file and here in the report document.
•Explain in Part (b) why is needed when combining nodes?

Task 37:
In huffman_algorithm.cpp, in the function buildwere_table, why need to handle the special case that, if the prefix is empty, push afalseinto theprefix`? What would happen if this special case was not handled?

Task 38:
In huffman_algorithm.cpp, for the class HuffmanEncoder, the body is missing for the method encod. Write the missing code of the body. 
•Hint: The comments in the function are helpful. 
•Paste the code in the .cpp file and also here in this report file. 

Task 39:
In huffman_algorithm.cpp, for the class HuffmanDecoder, the method decode, a loop is missing. Provide the missing code. 
•Hint: the comments in the function are helpful. 
•Paste the code in the .cpp file and also here in this report file. 

Task 40:
Based on your code, 
•During the encoding process, what will happen if there is a character in the string that is not in a leaf of the tree, therefore is not included in the encoding table? 
•Any idea to solve the problem? 
•Bonus , modify the code so that this problem be solved. 

Task 41:
In huffman_tree.cpp, in the constructor of HuffmanTree, we see a line:
PriorityQueue<std::unique_ptr<HuffmanNode>, CompareNodes> pq;
So, the HuffmanTree object will always choose the default container choice of PriorityQueue. That is, there is no way to have two HuffmanTree objects simultaneously using different containers for their PriorityQueue.
How can the HuffmanTree declaration be modified so that different kinds of containers can possibly be used? Describe your idea.
Bonus: Compile and test the modified code. 

Task 42
Based on a Makefile that you possibly want to use, explain the meaning of the following two rules: 
1.
bit_stream.o: ../../IO/Bit_stream/bit_stream.cpp
    $(CXX) $(CXXFLAGS) -c $< -o $@
1.
bit_stream_tests: bit_stream_tests.o bit_stream.o
    $(CXX) $(CXXFLAGS) -o $@ $^
1.
all_exe: huffman_tests linked_list_and_priority_queue_tests \
         bit_stream_tests c_utils_tests
4.
clean_o:
    rm -f *.o

Task 43: Compilation and Execution 
•Compile the program using the provided Makefile for your OS (Linux/MAC/Windows). 
•Run and test all your generated executable files. 
–If there are some errors and you can not fix them, describe the errors here. 
Deliverable: 
a) Paste a screenshot of your terminal showing: 
•Simply type your name, and the terminal will ignore it as a wrong command 
•The compilation command that uses a Makefile. 
–You may use make or mingw32-make. 
Paste the image in this report. 
A sample screenshot could show something like: 
  \Huffman_code_program\Build\Windows_g++> my name is LI, BAI
'my' is not recognized as an internal or external command,
operable program or batch file.

\Huffman_code_program\Build\Windows_g++> mingw32-make
g++ -c ../../IO/Bit_stream/bit_stream.cpp -o bit_stream.o
g++ -o bit_stream_tests bit_stream_tests.o bit_stream.o
...
b) a screen shot of running an exectuable file. Paste the image in this report. 
c) [optional]: redirect output to a file, like: 
\Huffman_code_program\Build\Windows_g++>huffman_tests.exe > huffman_tests_output.txt
 Upload test ouptut .txt files together with the report file. 

Task 44
[optional]
Describe any other extra work that worth bonus points. 

Task 45
Summarize your experience, what you have learned in this project. You may think in the aspects like: 
•The specific C++ features you found valuable: design patterns, skills of debugging, testing and compiling skills ... 
•How will this experience help you in future programming projects? 
•How this project can assist a future Data Structure and algorithm course? 

Submission Instructions: 
Submit the folloing files: 
1.The completed report file (Word/PDF) with answers 
2.A .zip file made by compressing the whole program folder, which contain all subfolders as distributed by this homework. The folder should contain all your modified program files. 
3.Other supporting files, like
•the executing output recording files. 
•... 

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

掃一掃在手機打開當前頁
  • 上一篇:代寫MIT203、代做SQL編程設計
  • 下一篇:FIT2004代寫、代做FIT2004語言編程
  • 無相關信息
    合肥生活資訊

    合肥圖文信息
    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

    99爱在线视频这里只有精品_窝窝午夜看片成人精品_日韩精品久久久毛片一区二区_亚洲一区二区久久

          9000px;">

                精品久久99ma| 亚洲欧美国产高清| 亚洲精品免费在线观看| 国产成人av电影在线播放| 国产午夜精品福利| 成人ar影院免费观看视频| 亚洲欧美在线高清| 欧美精品久久99久久在免费线 | 一区二区三区四区激情| 欧美午夜精品一区二区三区| 亚洲韩国精品一区| 国产拍揄自揄精品视频麻豆| 欧美性猛交xxxx黑人交| 国产一区二区在线视频| 有坂深雪av一区二区精品| 2021久久国产精品不只是精品| fc2成人免费人成在线观看播放| 亚洲地区一二三色| 国产日韩欧美制服另类| 欧美精品tushy高清| 99久久精品免费看国产免费软件| 日韩精品久久久久久| 中文av一区二区| 日韩欧美一级在线播放| 色嗨嗨av一区二区三区| 国产在线精品免费| 亚洲成人免费视| 成人免费在线播放视频| 久久久久久久综合| 欧美精品丝袜久久久中文字幕| 国产宾馆实践打屁股91| 久久成人av少妇免费| 一区二区三区四区乱视频| 国产精品美女久久久久久久久| 欧美不卡在线视频| 91国产免费看| 在线视频综合导航| 丁香亚洲综合激情啪啪综合| 蜜桃精品视频在线观看| 亚洲一区中文在线| 中文字幕制服丝袜成人av| 久久久久久久综合日本| 337p粉嫩大胆色噜噜噜噜亚洲| 欧美性猛片xxxx免费看久爱 | 国产综合色产在线精品| 午夜精品久久久久久久蜜桃app| 国产精品二区一区二区aⅴ污介绍| 久久综合色天天久久综合图片| 51精品秘密在线观看| 欧美在线视频全部完| 色8久久人人97超碰香蕉987| 91麻豆精品在线观看| 99久久99久久综合| 色菇凉天天综合网| 欧美亚洲图片小说| 欧美巨大另类极品videosbest | 国产亚洲综合性久久久影院| 精品国产一区二区三区不卡| 欧美刺激脚交jootjob| 日韩欧美综合在线| 久久亚洲一区二区三区明星换脸| 精品国产乱子伦一区| 精品精品欲导航| 国产精品女主播av| 国产精品理论片| 一区二区三区欧美日韩| 午夜精品久久久久久久久| 麻豆一区二区三区| 国产福利精品一区| 日本韩国一区二区| 欧美一级高清片| 久久久99久久| 亚洲色图制服诱惑| 日韩成人一区二区| 国产老肥熟一区二区三区| 99国产精品国产精品毛片| 欧美无砖专区一中文字| 日韩免费一区二区| 中文字幕中文字幕一区二区| 偷窥少妇高潮呻吟av久久免费| 麻豆免费看一区二区三区| 国产盗摄精品一区二区三区在线| 成人黄色大片在线观看| 欧美日韩亚洲另类| 国产喂奶挤奶一区二区三区| 亚洲丝袜另类动漫二区| 免费不卡在线视频| 不卡av电影在线播放| 91精品国产综合久久久久| 国产亚洲一本大道中文在线| 一区在线播放视频| 看片网站欧美日韩| 在线免费av一区| 国产日韩高清在线| 精品在线免费视频| 在线一区二区三区| 精品久久国产97色综合| 亚洲精品国产无天堂网2021| 国产一区二区免费看| 欧美日韩大陆一区二区| 中文字幕电影一区| 亚洲成人av福利| 99re66热这里只有精品3直播 | 91精品国产色综合久久ai换脸| 久久嫩草精品久久久精品一| 亚洲永久免费av| 国产激情91久久精品导航 | 欧美成人高清电影在线| 亚洲综合久久av| 成人免费观看视频| 国产午夜亚洲精品理论片色戒| 日本欧美大码aⅴ在线播放| 色综合天天在线| 中文字幕欧美三区| 国产一区二区福利视频| 精品久久久三级丝袜| 性做久久久久久久免费看| 91成人在线精品| 亚洲免费在线观看| 97精品久久久午夜一区二区三区| 久久久亚洲精品一区二区三区| 日韩高清在线观看| 91精品国产综合久久久久久漫画| 五月婷婷综合网| 欧美日韩成人一区| 婷婷六月综合网| 7777精品久久久大香线蕉 | 国产成人精品一区二区三区网站观看| 6080国产精品一区二区| 日韩av一区二区三区四区| 日韩一级欧美一级| 久久99国产精品成人| 亚洲精品一区二区三区香蕉| 国产中文字幕精品| 26uuu亚洲| 波多野结衣在线aⅴ中文字幕不卡| 国产精品不卡一区| 欧美三级一区二区| 日本不卡的三区四区五区| 26uuu欧美| 91蜜桃网址入口| 日韩av在线免费观看不卡| 日韩一区二区不卡| www.欧美亚洲| 亚洲无人区一区| 欧美精品一区二区在线观看| 国产乱人伦偷精品视频免下载| 国产调教视频一区| 一本高清dvd不卡在线观看 | 免费一区二区视频| 久久综合九色综合欧美就去吻| 国产成人av电影在线播放| 一区二区三区四区激情| 欧美一区二区在线看| 国产主播一区二区三区| 一区2区3区在线看| 日韩天堂在线观看| 99久久伊人精品| 人人爽香蕉精品| 国产精品久久午夜| 91精品国产高清一区二区三区蜜臀 | 久久精品网站免费观看| 大尺度一区二区| 午夜精品一区在线观看| 国产精品美女久久久久久2018| 欧美久久久久免费| 成人小视频在线观看| 日韩av中文字幕一区二区| 中文字幕欧美一| 久久久久久久久久久久久夜| 欧美影视一区在线| 懂色av一区二区三区免费看| 青青草97国产精品免费观看无弹窗版| 日韩一区中文字幕| 国产欧美日韩亚州综合| 日韩一区二区三区电影在线观看| 91成人国产精品| 99精品黄色片免费大全| 国产在线精品免费| 日韩国产一二三区| 亚洲欧美日韩一区二区 | 亚洲一区二区欧美日韩 | 日韩一区欧美一区| 亚洲国产精品国自产拍av| 欧美一区二区三区四区五区| 欧美午夜电影网| 欧美色精品在线视频| 91亚洲精品久久久蜜桃网站| 成人av电影在线观看| 91天堂素人约啪| 精品一区二区三区久久久| 丝袜美腿亚洲综合| 午夜精品成人在线视频| 亚洲黄色片在线观看| 亚洲欧美一区二区三区孕妇| 中文字幕一区二区三中文字幕| 国产免费观看久久| 国产精品高清亚洲| 亚洲精品国产精华液| 一区二区三区在线免费播放|