comp10002 Foundations of Algorithms

算法基础第五版 Foundation Of Algorithms 各章节代码,以及课后习题代码 python版 算法基础第五版 Foundation Of Algorithms 各章节代码,以及课后习题代码 各章节(1-11章)的代码基本上都有。习题只有写代码的有参考答案。证明没有,个人做的。如有错误欢迎纠正。本书图灵出版社翻译的错误不少,建议对照原英文版观看。 立即下载

School of Computing and Information Systems

comp10002 Foundations of Algorithms

Semester 2, 2024

Assignment 1

Learning Outcomes

In this assignment you will demonstrate your understanding of arrays,  strings, functions, and the typedef facility.  You may also (but are not required to) use structs (see Chapter 8) if you wish. You must not make any use of malloc() (Chapter 10) or file operations (Chapter 11) in this project.

TSV Files

The tab separated format is a common and convenient way of storing structured data in a text file. The first line of the file stores a set of c “column header” entries all represented as text strings that may contain alphanumeric, blank characters and punctuation characters, but no tab (’\t’) or newline (’\n’) characters, stored with c − 1 tab characters between the c entries to denote the breaks between the strings, and with a final newline character at the end of the line. A set of r following rows each also store c data items, represented in the same format.  For example, consider the data file test0 .tsv, with tabs and newline characters shown explicitly:

Year\tEvent\tGender\tCountry\tMedal\n

2024\tSwimming\tWomens\tNew  Zealand\tfirst:  gold\n 2024\tSwimming\tWomens\tChina\tsecond:  silver\n

2024\tSwimming\tWomens\tIndonesia\tthird:  bronze\n 2024\tCycling\tWomens\tChina\tfirst:  gold\n

2024\tCycling\tWomens\tNew  Zealand\tsecond:  silver\n 2024\tCycling\tWomens\tNew  Zealand\tthird:  bronze\n

This test file has c  =  5 columns, headed “Year”, “Event”, “Gender”, “Country”, and “Medal” respectively;  and contains r  =  6 data  rows  that  show (for example) that in “2024” the country  “New  Zealand” is associated with the medals “second:  silver” and “third:  bronze” in the  sport “Cycling” in connection with the gender “Womens” .  Note that r and c are not stored, and are  implicit via the appearance of the newline and tab characters.

Before doing anything else, you should copy the skeleton program ass1-skel .c from the LMS Assignment 1 page, and read through the code.  Check that you can compile it via either Grok or a terminal shell and gcc. Once you have it compiled, you should see this when you run it:

mac:  ./ass1-skel ta  daa!

You are now ready to start adding functionality.

Stage 1 – Reading and Printing (12/20 marks)

Extend the skeleton program so that it that reads a TSV input stream from stdin and builds a corre- sponding internal data structure using a 2d array of strings. You may assume that at most 1,000 input lines will be presented, that each input line contains at most 30 columns of information, and that each entry contains at most 50 characters.

The required output for this first stage is a summary of what was read, here is an example:

mac:  ./ass1-soln  < test0 .tsv Stage 1

input  tsv  data  has  6  rows  and  5  columns

row  6  is:

1:  Year 2024

2:  Event Cycling

3:  Gender Womens

4:  Country New  Zealand

5:  Medal third:  bronze

To be eligible for full marks your output must exactly match.  Other input files and example output files are linked from the LMS page. Note that the columns are labeled from 1, and that the data rows are also labeled starting with 1 – this information is for non-computer scientists!

You may assume throughout that all input files you will be provided with will be “correct”,with all rows having the same number of entries; the number of rows and columns being within the specified bounds; the length of each entry being within the specified bound; and with no additional (or missing) newline or tab characters. The last character of all valid input files will be a ’\n’ character, and if you create your own test files, make sure you do the same.

Note that the getfield() function handles the PC-versus-Unix newline differences.  These dif- ference have the potential to be very frustrating if you don’t allow for them (see the section about this in the “Programming Tips” page linked from the LMS).

Temptations to avoid: use the getfield() function provided in the skeleton (rather than try and do it yourself with scanf() or etc); do not try and use malloc() or the other similar functions from Chapter 10; do not use any of the file operations described in Chapter 11 (except for fflush(stdout) when debugging, see the FAQ page); and do not print any prompts of any sort.

Stage 2 – Sorting (16/20 marks)

Now modify your program so that it accesses a sequence of integers from the command-line, each of them a value between 1 and c, indicating which column(s) should be used as sort keys. For example, for test0.tsv, if columns 4 and then 2 are specified, the r data rows in your internal format are to be reordered so that they are sorted first by Country (as a string, using strcmp()), and then where the Country fields are equal, using Event as a secondary key. Where two rows have the same values in the selected columns, they should be retained in the same order as they were originally; that is, your sort should be stable. The header row should not be sorted. For test0.tsv, sorting by the program arguments “4 2” gives:

Year

Event

Gender

Country

Medal

2024

Cycling

Womens

China

first: gold

2024

Swimming

Womens

China

second: silver

2024

Swimming

Womens

Indonesia

third: bronze

2024

Cycling

Womens

New Zealand

second: silver

2024

Cycling

Womens

New Zealand

third: bronze

2024

Swimming

Womens

New Zealand

first: gold

Think of that (hint, hint) as being “debugging” output. Then the actual Stage 2 output requires that the first data row, the middle data row (that is, row「r/2⌉), and the last data row:

mac:  ./ass1-soln  4  2  < test0 .tsv

<<>> Stage  2

sorting  by  "Country",

then  by  "Event"

row  1  is:

<<<5 1="" utput="" lines="" for="" row="">>>

row  3  is:

<<<5 3="" utput="" lines="" for="" row="">>>

row  6  is:

<<<5 6="" utput="" lines="" for="" row="">>>

Full examples are provided at the LMS page. If there are no column numbers supplied on the command line, your program should exit after completing Stage 1, without any Stage 2 output. You may assume that each specified integer will be in the range 1 to c inclusive, and that no values will be repeated.

Use insertionsort rather than quicksort (this project is about programming inC, not about algorithm implementation, and there won’t be a penalty for using insertionsort). And keep it simple and elegant – use functions sensibly, including a suitable comparison function and a suitable swapping function.

Stage 3 – Tabulation (20/20 marks)

Now use the sorted TSV values to generate a report that shows counts of rows matching the same selected column combination:

mac:  ./ass1-soln  4  2  < test0 .tsv

<<>>

Stage  3

Country

Event Count

------------------

China

Cycling 1

Swimming 1

Indonesia

Swimming 1

New Zealand

Cycling 2

Swimming 1

The last column starts one space to the right of the longest entry (including the column header) in the last column getting printed, with the counts then printed as five-digit numbers under the word “Count” . There are no tabsinthe Stage 3 output, and the formatting is based solely on spaces. Marks will be deducted for layout discrepancies. The format descriptor * will be your friend to help achieve this goal, use printf("%-*s",  num,  str) to print the string str left-justified in num columns, where num is a variable/value calculated while your program is executing.

General Tips...

You will probably find it helpful to include a DEBUG mode in your program that prints out interme- diate data and variable values. Use #if   (DEBUG) and #endif around such blocks of code, and then #define  DEBUG  1 or #define  DEBUG  0 at the top.  Turn off the debug mode when making your final submission, but leave the debug code in place. The FAQ page has more information about this.

The sequence of stages described in this handout is deliberate – it represents a sensible path through to the final program.  You can, of course, ignore the advice and try and write final program in a single effort, without developing it incrementally and testing it in phases.  You might even get away with it, this time and at this somewhat limited scale, and develop a program that works. But in general, one of the key things that makes some people better at programming than others is the ability to see a design path through simple programs, to more comprehensive programs, to final programs, that keeps the complexity under control at all times. That is one of the skills this subject is intended to teach you. And if you submit each of the stages as you complete it, you’ll know that you are accumu- lating evidence should you need to demonstrate your progress in the event of a special consideration application becoming necessary.

Boring But Important...

This project is worth 20% of your final mark, and is due at 6:00pm on Friday 13 September.

Submissions that are made after the deadline will incur penalty marks at the rate of two marks per (part or all) working day. For example, submissions made after 6:00pm Friday and before 6:00pm Monday will lose two marks.  Multiple submissions may be made; only the last submission that you make before the deadline will be marked. If you make any late submission at all, your on-time submissions will be ignored, and if you have not been granted an extension, the late penalty will be applied.

A rubric explaining the marking expectations is linked from the LMS, and you should study it carefully. Marks and feedback will be provided approximately two weeks after submissions close.

You need to submit your program for assessment via the link to GradeScope at the bottom of the LMS Assignment page. Submission is not possible through Grok.

Foundations Of Algorithms(5th) mobi Foundations Of Algorithms(5th) 英文mobi 第5版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书 立即下载

相关推荐

Foundations Of Algorithms(5th) epub

Foundations Of Algorithms(5th) 英文epub 第5版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书

COMP10002 Foundations of Algorithms

the main function so that you 代写COMP10002 Foundations of Algorithmsdo not have to worry about carrying over。

thkgyout的博客 937

Foundation of Algorithms

经典英文原版算法书,epub格式,ISBN:1284049191

COMP10002 Foundations of Algorithms-大数加减乘乘方运算

COMP10002 Foundations of Algorithms Semester 1, 2018 Assignment 1 1 Learning Outcomes In this assignment, you will demonstrate your understanding of arrays, pointers, input processing, and functi...

Gexrior的博客 651

QMT实盘交易入门:5分钟搞定ETF全球配置策略(附完整代码)

本文详细介绍了如何使用QMT平台实现ETF全球配置策略,从环境准备到策略编写、实盘部署全流程仅需5分钟。通过xtquant库对接交易所接口,提供完整的动量轮动策略代码,帮助投资者快速掌握自动交易技术,优化全球资产配置。

weixin_30675247的博客 336

C#实现跨域访问共享文件夹的账号密码验证方案

本文详细介绍了在C#中实现跨域访问共享文件夹的账号密码验证方案。通过调用Windows API LogonUser函数,结合LOGON32_LOGON_NEW_CREDENTIALS登录类型,可安全模拟指定用户身份,有效解决工作组与域环境间的文件共享访问难题。文章提供了完整的工具类封装、多种实战场景示例及详细的错误排查指南。

pea55的博客 542

comp10002 Foundations of Algorithms Semester 2 2024 2Python

10002ofAlgorithmsSemester2, 2024AssignmentcellsstatesruleIn anelementaryonandoffruncode131230341050,5630,107189101112131415161718192021222324RULE: 184;252627282930313233343536。

bilimint的博客 748

华为硬件工程师笔试题

1、基尔霍夫定理的内容是什么?(仕兰微电子)   基尔霍夫定理包括电流定律和电压定律。   电流定律(KCL):在集总电路中,任何时刻,对任一结点,所有流出结点的支路电流的代数和恒等于零。   电压定律(KVL):在集总电路中,任何时刻,沿任一回路,所有支路电压的代数和恒等于零。   2、平板电容公式(C=εS/4πkd)。(未知)   3、最基本的如三极管曲线特性。(未知)   4、描述反馈电路...

weixin_33717117的博客 2万+

辅导 comp10002 Foundations of Algorithms Semester 2, 2024 Assignment 2辅导 留学生Python语言

BackgroundInput Data1 312 304 105 0,56 30,107Output。

Ccio0612的博客 1067

【推荐算法】召回模型总结

【推荐算法】召回模型总结

m0_48086806的博客 6252

STM32F407串口DMA收发实战:标准库配置与环形缓冲区实现

DMA(直接存储器访问)是嵌入式系统中提升数据传输效率的核心技术,它允许外设与内存直接交换数据而无需CPU干预。其工作原理是通过专用硬件控制器接管数据搬运任务,CPU仅需初始化传输参数即可处理其他事务,从而显著降低系统负载。这项技术的核心价值在于释放CPU算力,实现高吞吐、低延迟的实时通信,尤其适用于数据采集、工业控制和通信网关等场景。在STM32F407等ARM Cortex-M4芯片中,串口结合DMA可实现稳定的高速数据流处理。本文以STM32F407标准库为基础,深入解析USART1的DMA发送与接收

weixin_29169899的博客 323

The University of MelbourneSchool of Computing and Information Systems COMP10002 Foundations of Alg

QQ1703105484 The University of Melbourne School of Computing and Information Systems COMP10002 Foundations of Algorithms Semester 1, 2022 Assignment 1 Due: 4pm Friday 29 April 2022 Learning Outcomes In this assignment, you will demonstrate your und.

qq_37064135的博客 401

Rust练手:从零手撸RISC-V架构虚拟机(一)(附完整代码)

使用Rust实现一个简单的RISC-V架构的CPU雏形,支持add,sub,addi三个指令。

qq_45983373的博客 2575

c语言二叉树

Department of Computing and Information SystemsCOMP10002 Foundations of AlgorithmsSemester 2, 2014Assignment 2Learning OutcomesIn this project you will demonstrate your understanding of dynamic memory...

weixin_33842328的博客 160

C#串口通信从入门到精通(1)——硬件接线

RS-232接口一般都是9针的,有公母头(针头和孔头),为了便有理解以下都称为针头和孔头,针头就是露出来的针,孔头就是9个孔,总共使用3条线进行通信,一条用于发送,一条用于接收,另外一根是GND地线,由于线路的功能是永久性的,设置连接时,必须确保一个节点的发送线与另一个节点的接收线相连,反之亦然,RxD(PC的接收线)连接到TxD(传感器电子设备的发送线),TxD(PC的发送线)连接到RxD(传感器电子设备的发送线)。两条线路的电平都是相对于GND的。因此,GND也必须连接,但不能将GND与屏蔽连接。

qq_34059233的博客 1万+

Ardupilot飞控姿态角与姿态角速度控制过程分析(超长篇)

目录 目录 摘要 1.代码控制过程分析 摘要 本节主要记录自己学习ardupilot飞控代码的姿态角速度的控制过程 1.代码控制过程分析 可以看出:AC_AttitudeControl *attitude_control; //指针对象 virtual void rate_controller_run() = 0;是AC_AttitudeContro...

陌城烟雨 1万+

小白一键部署:VoiceStudio 本地语音工作室(Linux/Win/Mac)

VoiceStudio 是破十万星的开源本地语音工作室。本文在 Debian 13 实机用官方一行命令装上 0.5.7,记录 GPU 崩溃启动参数、Install local runtime、模型许可,以及 CPU 上 Voice Design 合成 7 秒 demo。与只做听写的 Hex 互补。

m0_56699208的博客 205

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

Mac 和 Windows 虚拟机怎么共享文件?用 UVM 设个共享文件夹

在 UVM 选择 Mac 共享文件夹,从 Windows 的「此电脑」打开共享盘,验证双向读写。文末附 UVM 简介与官方下载入口。

hsduren的专栏 149

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

WebStorm macOS 安装调优与实战效果全景

本文以实测视角展示 WebStorm 2025.3 在 macOS 上的极致体验:原生 arm64 启动仅需 3–5 秒,Islands 主题显著提升标签页辨识度,AI 全行补全精准响应,正确排除 node_modules 后索引时间压缩至 30 秒内,重命名重构时静态引用清晰呈现。通过真实项目流程验证其在 React + TypeScript、Vue 3 + Vite 中的高效开发闭环。文末明确适用边界——适合中大型项目与深度开发者,对轻量级或简单脚本场景优势有限。

独坐一隅,凝神遐想,是种幸福! —— 独隅 60

OpenClaw Mac mini部署教程:接入飞书、AI Agent与公网访问

OpenClaw Mac mini部署教程:接入飞书、AI Agent与公网访问

wei_shuo的博客 1万+

组网第64课:802.1X 与准入——三角色、Guest VLAN、MAC 认证、哑终端准入

2021 年一个制造客户,接入层四十多台交换机,端口全是默认开放。会议室墙上留了四个网口给投影和视频会议,平时没人管。某天流量监控报警:办公网里有台设备在扫 ,一小时扫了三百多个地址。顺着 ARP 表往上找,端口在会议室,MAC 不在资产台账里。到现场一看,一台不属于公司的笔记本插在墙插上,外包人员来开会顺手插的,插上就拿到了办公网 IP,直接能访问文件服务器。IT 负责人跟我说了句大实话:“我们没做过准入,端口插上就能用。”这就是准入要解决的问题。不是"防黑客"这种空话,是很具体的三件事:谁能接进来、接进

qq_36765170的博客 290

WebStorm macOS 安装部署与高效调优完全指南

本文为 WebStorm 2025.3/2026.1 在 macOS 上的安装与调优指南,针对零基础开发者,涵盖系统检查、dmg 安装、首次配置、快捷键迁移、Node.js 环境关联、调试实操及性能优化。重点澄清“右键排除 node_modules 无效”“nvm 用户需手动指定路径”等常见误区,提供内存调优、索引排除、插件精简等实战技巧,助用户构建高效稳定的前端开发环境。附常见报错排查表与资源链接,可快速上手并持续优化。

独坐一隅,凝神遐想,是种幸福! —— 独隅 445

电脑自带录屏功能怎么带声音?Windows 与 Mac 完整设置指南

Windows 用户优先用 Xbox Game Bar 或 Windows 11 截图工具,在音频面板里同时打开系统声音和麦克风即可;Mac 用户用 QuickTime 或 Shift + Command + 5 可以轻松录到人声,但要录系统内部声音需要额外配置虚拟音频设备,或者安装专业录屏软件。记住「系统声音」和「麦克风声音」是两套独立开关,分别确认,基本就能解决绝大多数录屏无声的问题。

xiaolu12388的博客 167

GitHub 今日推荐|Stela:在 PC 上直接启动 macOS 的翻译层

Stela 让 x86-64 PC 通过 UEFI 启动 macOS,用 Rust 实现 ARM64 到 x86-64 指令翻译和 NVIDIA Metal 驱动,模拟 M2 Mac mini 硬件环

wfly blog 288

截图快捷键不生效、被占用怎么办?Mac 和 Windows 的排查顺序

截图快捷键按了没反应,常见原因是同一个组合键已被聊天软件、输入法、系统功能或另一款截图工具占用,或者软件没有在后台运行、缺少系统权限。本文按「先确认谁在响应、再查冲突、最后改键」的顺序,给出 macOS 和 Windows 上的排查办法,并说明如何选一个不容易撞车的组合。macOS、Windows 和鸿蒙 OS 上的 InSnap 都可以在设置里自定义截图快捷键。

BingMao_Tp的博客 232
上一篇: ACCT1101 Accounting for Decision Making
下一篇: MAST90083: Computational Statistics and Data Science
wx__codinghelp
博客等级 码龄2年 514粉丝 61原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值