CSC 3002 分析

鼍龙
• 阅读 777

CSC 3002 (Spring 2021) Assignment 4
Problem 1
If you search the web for fractal designs, you will find many intricate wonders beyond the Koch
snowflake illustrated in this chapter. H-fractal, in which the repeated pattern is shaped like an
elongated letter H in which the horizontal bar and vertical lines on the sides have the same length.
Thus, the order-0 H-fractal looks like this:
To create the order-1 fractal, all you do is add four new H-fractalseach one half of the original
sizeat each open end of the order-0 fractal, like this:
To create the order-2 fractal, all you have to do is add even smaller H-fractals (again half the
size of the fractal to which they connect) to each of the open endpoints. This process gives rise to
the following order-2 fractal:
Write a recursive function
where x and y are the coordinates of the center of the H-fractal, size specifies the width and
the height, and order indicates the order of the fractal. As an example, the main program
would draw an order-3 H-fractal at the center of the graphics window, like this:
Requirments & Hints:
Please fill in the TODO part of the function drawHFractal() in P1HFractal.cpp.
Problem 2
The game of tic-tac-toe is played by two players who take turns placing Xs and Os in a 3 × 3
grid that looks like this:
The object of the game is to line up three of your own symbols in a row, horizontally, vertically,
or diagonally. In the following game, for example, X has won the game by completing three in a
row across the top:
If the board fills up without anyone completing a row, the game is a draw, which is called a cats
game in tic-tac-toe. Write a program that uses the minimax algorithm to play a perfect game of
tic-tac-toe. Figure shows a sample run against a particularly inept player.
Requirments & Hints:
Please fill in the TODO part of the functions in P2TicTacToe.cpp.
Problem 3
Rewrite the implementation of the merge sort algorithm from Figure 10-3 so that it sorts an
array rather than a vector. As in the reimplementation of the selection sort algorithm on page 499,
your function should use the prototype
Requirments & Hints: Do not use other sort algorithms! Do not modify the header file and
the implementation should be in the .cpp file. We will check your implementation and make sure
it uses exactly the merge and sort strategy.
Please fill in the TODO part of function sort() in P3MergeSort.cpp.
Problem 4
Implement the EditorBuffer class using the strategy described in the section entitled Doubly
linked lists (Page 606). Be sure to test your implementation as thoroughly as you can. In particular,
make sure that you can move the cursor in both directions across parts of the buffer where you
have recently made insertions and deletions.
In this implementation, the ends of the linked list are joined to form a ring, with the dummy
cell at both the beginning and the end. This representation makes it possible to implement the
moveCursorToEnd method in constant time, and reduces the number of special cases in the
code. The constructor is already given. Methods need to be implemented:
• The destructor that delete all cells
• Methods move the cursor
• A insertCharacter method that inserts one character into the buffer on the cursor
• A deleteCharacter method that deletes one character after the cursor
• A getText method that returns the content in buffer
• A getCursor method that returns the index of the cursor
Implement the EditorBuffer class using this representation (which is, in fact, the design strategy
used in many editors today). Make sure that your program continues to have the same
computational efficiency as the two-stack implementation in the text and that the buffer space
expands dynamically as needed.
Requirments & Hints:
Please fill in the TODO part of the methods in buffer.cpp.
Requirements for Assignment 4
I’ve provided a project named as Assignment4.pro. You should write TODO part in each .cpp
file according to the problem requirements. Finally, please pack your whole project files into a
single .zip file, name it using your student ID (e.g. if your student ID is 123456, hereby the file
should be named as 123456. zip ), and then submit the .zip file via BB system. The zip file should
be less than 8 MB.
Please note that, the teaching assistant may ask you to explain the meaning of your program, to
ensure that the codes are indeed written by yourself. Please also note that we may check whether
your program is too similar to your fellow students’ code using BB.
Please refer to the BB system for the assignment deadline April 18, 2021. For each day of late
submission, you will obtain late penalty in the assignment marks. If you submit more than 3 days
later than the deadline, you will receive 0 in this assignment.
Marking scheme:
• 1.5 + 3.5 + 1.5 + 3.5 = 10 grades for each problem and the whole Assignment 4
• 25% Marks will be given to students who have submitted the program on time.
• 25% Marks will be given to students who wrote the program that meet all the requirements
of the questions
• 25% Marks will be given to students who programs that can be compiled without errors.
• 25% Marks will be given to students whose programs produce the correct output if their
programs can be compiled.
Reminder: For windows users, please switch your input language to English before interacting
in Stanford console. Or, you will get no response.
WX:codehelp

点赞
收藏
评论区
推荐文章
blmius blmius
4年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
Wesley13 Wesley13
3年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
美凌格栋栋酱 美凌格栋栋酱
7个月前
Oracle 分组与拼接字符串同时使用
SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(
Wesley13 Wesley13
3年前
VBox 启动虚拟机失败
在Vbox(5.0.8版本)启动Ubuntu的虚拟机时,遇到错误信息:NtCreateFile(\\Device\\VBoxDrvStub)failed:0xc000000034STATUS\_OBJECT\_NAME\_NOT\_FOUND(0retries) (rc101)Makesurethekern
Wesley13 Wesley13
3年前
FLV文件格式
1.        FLV文件对齐方式FLV文件以大端对齐方式存放多字节整型。如存放数字无符号16位的数字300(0x012C),那么在FLV文件中存放的顺序是:|0x01|0x2C|。如果是无符号32位数字300(0x0000012C),那么在FLV文件中的存放顺序是:|0x00|0x00|0x00|0x01|0x2C。2.  
Stella981 Stella981
3年前
SpringBoot整合Redis乱码原因及解决方案
问题描述:springboot使用springdataredis存储数据时乱码rediskey/value出现\\xAC\\xED\\x00\\x05t\\x00\\x05问题分析:查看RedisTemplate类!(https://oscimg.oschina.net/oscnet/0a85565fa
Wesley13 Wesley13
3年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Wesley13 Wesley13
3年前
PHP创建多级树型结构
<!lang:php<?php$areaarray(array('id'1,'pid'0,'name''中国'),array('id'5,'pid'0,'name''美国'),array('id'2,'pid'1,'name''吉林'),array('id'4,'pid'2,'n
Easter79 Easter79
3年前
SpringBoot整合Redis乱码原因及解决方案
问题描述:springboot使用springdataredis存储数据时乱码rediskey/value出现\\xAC\\xED\\x00\\x05t\\x00\\x05问题分析:查看RedisTemplate类!(https://oscimg.oschina.net/oscnet/0a85565fa
Wesley13 Wesley13
3年前
Java日期时间API系列36
  十二时辰,古代劳动人民把一昼夜划分成十二个时段,每一个时段叫一个时辰。二十四小时和十二时辰对照表:时辰时间24时制子时深夜11:00凌晨01:0023:0001:00丑时上午01:00上午03:0001:0003:00寅时上午03:00上午0
Wesley13 Wesley13
3年前
MBR笔记
<bochs:100000000000e\WGUI\Simclientsize(0,0)!stretchedsize(640,480)!<bochs:2b0x7c00<bochs:3c00000003740i\BIOS\$Revision:1.166$$Date:2006/08/1117
鼍龙
鼍龙
Lv1
阳光照在我们脸上,我们还沉浸在这如诗如画的美景中。
文章
3
粉丝
0
获赞
0