CEG5201 Hardware Technologies Principles & Platforms (Semester I AY2024/2025)Python

Java Python CEG5201 Hardware Technologies, Principles, & Platforms

(Semester I, AY2024/2025)

CA-2 Statement

I. Objective

In this group assignment, each member will focus on benchmarking one of the following sorting algorithms—Merge SortBucket SortQuicksort, or Odd-Even Transposition Sort— using both sequential and multiprocessing methods. The objective is to compare the performance of these algorithms across different implementations.

To complete the assignment, all group members should familiarize themselves with the Python multiprocessingpackage using the following resources:

•    Python multiprocessing tutorial:https://www.datacamp.com/tutorial/python- multiprocessing-tutorial

•    The pool class -https://superfastpython.com/multiprocessing-pool-python/

•    Multiprocessing pool example -https://superfastpython.com/multiprocessing-pool- example/

•    Threadpool vs. pool class differences -https://superfastpython.com/threadpool-vs-pool- in-python

Feel free to explore additional learning materials and share useful links by posting on the Canvas Discussion to benefit your classmate

II. Project Overview

In this project, your team will implement four sorting algorithms shown in Table II. Each team will select one of the sorting algorithms and implement it in both sequential and multiprocessing modes. Furthermore, in addition to individual tasks, the project includes joint tasks as detailed in Table I.

•    Individual tasks are highlighted as blue.

•    Joint tasks are highlighted as yellow.

Table I. Overview of the tasks

Task ID

Task description

O

Getting started

A

#include <iostream> #include <cstring> #include <utility> #include <vector> using namespace std; // 书 class Book { public: Book(const char *name, const char *isbn = "", float price=0.0, const char *text=""); // 构造函数 Book(const Book &copy); // 复制构造函数 Book(Book &&copy) noexcept; // 移动构造函数 Book & operator=(const Book &copy); // 重载赋值运算符 Book & operator=(Book && copy) noexcept; // 移动赋值 void setText (const char *text); // 修改书的描述 ~Book() { delete [] strText; } // 析构函数 void Show() const; // 显示书本:名称(isbn, 价格): 书的描述 friend ostream& operator<<(ostream& out,const class Book& bk); private: char name[128]; // 书名 char ISBN[32]; // ISBN号 float price; // 价格 char *strText; // 书的描述 }; // 图书馆 class Library { public: Library(const char *name, int size=100); // 默认构造函数 Library(const Library & copy); // 拷贝构造 Library(Library && copy) noexcept; // 移动构造 Library & operator= (const Library &copy); // 赋值 Library & operator= (Library &&copy) noexcept; // 移动赋值 void Show(); // 显示名称和藏书数量 void addBook(const Book &book); // 增加一本书的收藏 vector<Book> & getBooks(); // 获取图书 friend ostream& operator<<(ostream& out,const class Library& lib); private: char name[128]; // 图书馆的名字 vector<Book> books; // 收藏的书 }; /* 请在这里填写答案 */ // 主函数main() int main() { char txt1[] = "C++ Programming"; Book b1("BK0011", "ISBN-0011", 35.0, txt1); char txt2[] = "Operating System"; Book b2("BK0022", "ISBN-0022", 40.0, txt2); Library lib1("HangZhou Library"); // 创建图书馆并增加2本书 lib1.addBook(b1); lib1.addBook(b2); // lib1.Show(); cout << lib1 << endl; Library lib2(lib1); // 拷贝构造并增加1本书 lib2.addBook(Book("BK1031", "ISBN-1031", 100, "Economy Theory")); // lib2.Show(); cout << lib2 << endl; Library lib3 = std::move(lib1); // 移动构造 // lib3.Show(); // lib1.Show(); cout << lib3 << endl; cout << lib1 << endl; Library lib4("NanJing"); lib4.addBook(Book("BK2109", "ISBN-2109", 200, "The Law Principles")); lib4 = std::move(lib2); // 移动赋值 // lib4.Show(); // lib2.Show(); cout << lib4 << endl; cout << lib2 << endl; }会得到: HangZhou Library:2 BK0011(ISBN-0011,35):C++ Programming BK0022(ISBN-0022,40):Operating System HangZhou Library:3 BK0011(ISBN-0011,35):C++ Programming BK0022(ISBN-0022,40):Operating System BK1031(ISBN-1031,100):Economy Theory HangZhou Library:2 BK0011(ISBN-0011,35):C++ Programming BK0022(ISBN-0022,40):Operating System :0 HangZhou Library:3 BK0011(ISBN-0011,35):C++ Programming BK0022(ISBN-0022,40):Operating System BK1031(ISBN-1031,100):Economy Theory NanJing:1 BK2109(ISBN-2109,200):The Law Principles
03-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值