91精品国产91久久久久久_国产精品二区一区二区aⅴ污介绍_一本久久a久久精品vr综合_亚洲视频一区二区三区

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

代寫COMP26020、代做Java,c++語言編程

時間:2024-02-15  來源:合肥網hfw.cc  作者:hfw.cc 我要糾錯



Lab Exercises for COMP26020 Part 2:
Functional Programming in Haskell
December 8, 2023
The deadline for this lab is 6pm on 16/2/2024.
This lab has three exercises, for a total of ten marks. The first two exercises
together are worth eight marks, and I advise all students to focus exclusively
on these exercises. Seven marks are given based on automated testing, and one
is reserved for human judgement by the marker. These exercises are described
in Section 1 below. Section 2 contains submission information and a checklist
of tasks for the first two exercises.
If you are certain that your solutions are completely correct you might like
to look at Section 3 below, which describes a thought-provoking, open-ended
exercise requiring significant creativity, worth two marks. It is designed to be
extremely difficult, and is not a practical way of gaining marks!
1 Simple Quadtrees
This lab exercise concerns as data structure called a ‘quadtree’ which can be
used to represent an image. There are sophisticated versions of the quadtree
data structure, but for the purposes of the lab we will use a very simple version
of the idea.
Suppose we want to represent a square, black and white bitmap image which
is 2n by 2n pixels. The usual way to do this is as a 2n by 2n grid of bits, but
this can be wasteful if there are large monochrome areas.
1
In that case, a simple optimization is to think of the image as split into four
sub-images of size 2n−1 by 2n−1 which we will call ‘quadrants’. If the sub-image
is all one colour, we can represent this by one bit of information.
But if it contains different colours, we can subdivide again, and keep going
recursively until we do get sub-images which are only one colour. (This definitely
happens once we get down to the scale of the original pixels!). We call these
single colour sub-images in the final data structure ‘cells’.
This lab exercise is about the resulting data structure, the tree of cells. You
don’t have to care about the details of an original image which such a structure
might have come from – for instance you don’t need to record the dimensions in
pixels of the original image. That means that your data structure is correct if it
represents the way the image looks geometrically, ignoring the size. Nor do you
need to worry about whether a particular structure is the most efficient way of
representing a given image. In fact it is useful to allow non-optimal quadtrees.
The way you think about the data structure could differ from someone else by
rotation, scaling, and even reflection, as well as the details of how you order and
organize the various components, and you can both be correct as long as you
are each internally self-consistent.
For that reason, if you are working out what the exercises mean with a friend,
or asking something on the forum, you should describe everything in terms of
pictures, or describe quadtrees using the four functions in Exercise 1 below, so
that you don’t accidentally discuss the details of your data structure.
2
1.1 Exercise 1: (3 marks) representing quadtrees
For this exercise, you should define an Algebraic Data Type (that means a
custom type defined by the data keyword) to model quadtrees in the sense
described above. Do this in whatever way you like (as long as you use an
Algebraic Data Type), but provide four functions with the following properties:
• A function allBlack which takes an Int number n and returns your
representation of a single cell which is all black. The argument n represents
the image ‘size’, but since all-black images of any size look the same, you
can ignore this argument! (See notes below...)
• A function allWhite which takes an Int number n, as above, and returns
your representation of a single cell which is all white.
• A function clockwise which takes four quadtrees and returns the quadtree
whose four subtrees are the given inputs, arranged in a clockwise order.
• A function anticlockwise which takes four quadtrees and returns the
quadtree whose four subtrees are the inputs, arranged in an anticlockwise
order.
Note the following:
• For allBlack and allWhite the ‘size’ argument can be ignored, but for
some ways of modelling it might be useful. Neither using the argument
nor ignoring it is the ‘best’ approach: there are a huge number of different
correct solutions! You can assume that any testing data come from real
bitmaps (square bitmaps whose width is a power of 2), and the ‘size’
arguments tell us how many pixels wide each cell is in the originating
bitmap.
• A clockwise ordering means that in the tree clockwise a b c d, the subtree b is located in the quadrant next to a which is reached by moving
clockwise, c is in the quadrant reached by moving clockwise from b, d
is in the quadrant reached by moving clockwise from c, and a is in the
quadrant reached by moving clockwise from d.
• For clockwise and anticlockwise it doesn’t matter how subtrees are
stored or ordered internally, or which quadrant comes ‘first’ – a correct
solution is still correct if we rotate, reflect, or scale every quadtree and
all tests involved in marking will respect this. However, the choices you
make should be consistent: the clockwise and anticockwise orderings must
be opposite to each other, and all uses of clockwise and anticlockwise
in your solution should make the same choice about which quadrant the
first argument goes in!
You must use at least one Algebraic Data Type in your model, but you may
use several. For each Algebraic Data Type, you must add the expression
deriving (Eq, Show) to the end of the line which defines the datatype.
3
For example, below is an Algebraic Data Type representing a list of Int
values
data MyList = Elist |
Cons Int MyList
If I used such a data structure in my solution, I would append the expression
above to the end of the definition, to obtain
data MyList = Elist |
Cons Int MyList deriving (Eq, Show)
Make sure you have done this for all the Algebraic Data Types you have defined.
For now we treat this as a ‘magic incantation’ which lets Haskell know we want
to be able to print values of our datatype and compare them for equality. What
is really going on in this expression will be covered in the videos in the last week
of the Haskell part.
Note that the four functions completely specify how the quadtree is split up
into cells.: it is best not to optimize when given an input which is not efficiently
encoded. You won’t actually lose marks for this, but it makes exercise 2 harder
if you optimize the tree structure!
4
Marking Exercise 1
This exercise is has a total of three marks available. The marks will be
assigned based on testing on quadtrees of different sizes and complexities.
The tests will consist of checking consistency properties which we expect to
hold. For example, we expect
clockwise (allBlack 1) (allBlack 1) (allWhite 1) (allWhite 1) ==
anticlockwise (allBlack 1) (allWhite 1) (allWhite 1) (allBlack 1)
The tests will also involve checking inequalities such as
clockwise (allBlack 1) (allBlack 1) (allWhite 1) (allWhite 1) /=
anticlockwise (allBlack 1) (allBlack 1) (allWhite 1) (allBlack 1)
Otherwise you could represent all trees with a single value! Note however that
they do not check anything which depends on the size of the image, so for
instance they never check whether allBlack 128 == allBlack 2, because geometrically these look the same, so you are free to represent them as the same or
different, whichever works for your data structure. The tests only check equalities and inequalities which must hold for all correct representations.
You solution will receive:
• One mark for passing the tests on quadtrees described at most one use
of clockwise or anticlockwise (so they either have 1 cell or 4 cells),
• One mark for passing the tests on quadtrees which represent 4 by 4
images (they can have up to 16 cells, but may have fewer if they have an
interesting structure),
• One mark for passing the tests on all quadtrees,
for a total of three marks. The quadtrees used for testing are no larger than
required to represent a 210 by 210 image. You need only consider square images
whose dimensions are powers of 2. Your solution must use at least one Algebraic
Data Type to qualify for any of the marks above.
5
1.2 Exercise 2: (4 marks) A crude ‘blurring’ operation
For this exercise, you should define a function blur which takes a quadtree as
input and returns a quadtree as output. It should not change the structure of
the quadtree1
, but it should change the data representing the black and white
colours.
To find the colour of a cell in the output blur q we look at all of its ‘neighbours’:
other cells which touch it along an edge (or part of an edge), not just a corner.
The colour of a cell in blur q should be the opposite of the colour of that cell
in the input q if and only if more than half of its neighbours have the opposite
colour in q. E.g. if a cell is black in the input q then it should be white in the
output blur q if and only if in q more of its neighbours are white cells than
black. You can think of such a function as an extremely crude approximation
to a blurring operation, although it is not practical to use it for that purpose!
For example
If your implementations of clockwise and anticlockwise perform any optimisations, your
implementation of blur should perform matching optimisations to the result of the operation
described; most students will not need to worry about this as there are no marks for optimizing
clockwise or anticlockwise.
6
Note that cells at the border usually have fewer neighbours, so the definition
behaves quite strangely there. For example
blur
which shows that in many cases the approximation to ‘blurring’ is very bad indeed! The image below shows how many neighbours each cell of the quadtrees
above has. Note that a cell is not one of its own neighbours.
Coming up with a solution all at once is hard! For that reason, the mark scheme
below gives most of the marks for solving special cases. It may be best to try
the special cases first if you can’t see how to solve the whole problem straight
away. To define the special cases, let us call a quadtree striped if it satisfies
the following recursive specification:
• Base case: For all Int values z (satisfying the conditions from Exercise1),
the quadtrees allBlack z and allWhite z are striped quadtrees;
• Step case: If q1 and q2 are striped quadtrees, then clockwise q1 q1 q2 q2
is a striped quadtree.
Try drawing some pictures of striped quadtrees by building up from the
base case. Notice how q1 and q2 are repeated in the step case – this repetition
means that we already know the values of a cell’s neighbours in one dimension.
(Though we do still have to worry about whether is has any neighbours in the
other dimension, or if it is on the border.)
7
Marking
This exercise is has a total of four marks available. The marks will be assigned
based on testing on quadtrees of different sizes and complexities.
The tests will consist of checking properties which we expect to hold. For
example,
blur (clockwise (allWhite 2)
(clockwise (allBlack 1) (allBlack 1)
(allBlack 1) (allWhite 1))
(allBlack 2) (allWhite 2)) ==
clockwise (allWhite 2)
(clockwise (allWhite 1) (allBlack 1)
(allBlack 1) (allBlack 1))
(allWhite 2) (allWhite 2)
You solution will receive:
• One mark for implementing a function blur of the correct type which
does not ‘go wrong’ as long as its argument is a suitable quadtree (one
which could come from a real image),
• One mark for passing the tests on striped quadtrees which represent 1
by 1, 2 by 2, or 4 by 4 images (so have at most 16 cells),
• One mark for passing the tests on all striped quadtrees, and
• One mark for passing the tests on all quadtrees,
for a total of four marks. The maximum size for test inputs is the same as for
Exercise 1.
One additional mark is available for the first two exercises according to the
marker’s judgement. This mark will be given for clearly commented code which
explains your solution or where you got stuck. But it may also be given for
other good work towards solving any of the above if the marker feels, according
to their judgement, that it is not reflected fairly in the automated mark.
8
2 Submission
To submit the exercises above, clone the git repository
26020-lab3-s-haskell_<your username> present in the department’s GitLab.
In that directory, save your submission as submission.hs
Remove any definition of main from submission.hs. Make sure you have done
git add submission.hs.
A testing script is provided called check_submission.sh (note ‘sh’ not
‘hs’!). Running this file checks that your submission will work with the automated marking script. Please check at least once that you can run this successfully on a lab machine, as this is the set-up used to mark your code.
Note that it creates/overwrites a file called check_submission_temp_file.hs
by concatenating submission.hs and two testing files. It does not remove this
file after running, so you can inspect it if anything went wrong.
This script checks that your solution is in the right format for the automated tests (e.g. that you have used the right function names, added the
deriving (Eq, Show) incantation where necessary, and have remembered to
remove any definition of main) but it does not test your submission well!
Come up with your own test examples, and reason about whether your code is
correct for all inputs!
You might have to make check_submission.sh executable by running
chmod u+x check_submission.sh.
Once check_submission.sh tells you that all its checks have passed, double
check that you have added submission.hs and push the files on the master
branch.
If you decide to try the creative exercise below and think you have succeeded
or very nearly succeeded, add your work to the repo as creative.hs. Students
are strongly encouraged to focus on the exercises above.
Once you are confident that your solution is correct (i.e. after doing more
testing than just running the format checking script!), push your final version
on the master branch and create a tag named lab3-submission to indicate
that the submission is ready to be marked.
In most cases marking will be done without any further input needed from you
once you have submitted, but in some cases we may need you to explain your
solution face-to-face in order to complete marking.
9
Talking to each other and using the internet
When talking to other students about the coursework, keep in mind some “do”s
and “don’t”s:
• Do discuss what the exercise means, e.g. what the function blur does to
examples in terms of inputs and outputs.
• Do discuss example quadtrees in terms of pictures or geometry which
doesn’t change when rotated, translated, or scaled.
• Do discuss example quadtrees in terms of the four functions allBlack ,
allWhite , clockwise and anticlockwise.
• Do discuss general Haskell questions, e.g. how to write an Algebraic Data
Type using data, how Maybe or lists work, how to bracket when defining
recusive functions, etc.
But:
• Don’t discuss quadtrees using terminology not in this lab script – that
probably contains ideas about how your solution works!
• Don’t discuss how to define a data structure for quadtrees (inlcuding for
instance where your solution puts which quadrant of the pictures)
• Don’t discuss how to define blur or similar operations in terms of recursive functions
• Don’t show anyone your solution to get help with Haskell syntax – instead
try to describe the problem in general or reproduce it in an unrelated
example
Talking to others is an important way to learn a subject, and I encourage you
to discuss Haskell in general. When discussing the lab exercises with other students, stick to the rules above.
Similarly, when using the internet to help with this coursework
• Do use non-interactive resources like tutorials and documentation. I recommend
– https://en.wikibooks.org/wiki/Haskell/Other_data_structures
– https://www.haskell.org/tutorial/goodies.html
• Do ask general Haskell questions (not based on the lab exercises!) in
forums, chatrooms etc.
But:
• Don’t discuss anything derived from the lab exercises on interactive services like forums, chatrooms, Stack Exchange, etc.
• Don’t upload the lab script or anything derived from lab work to filesharing websites, document-sharing websites, or notes-sharing websites.
10
Checklist for Exercises 1 and 2
Exercise Task Marks Done?
1 Create a data type using data to model quadtrees
1
Ensure any data type declarations you use end
with deriving (Eq,Show)
1 Write the allBlack function
1 Write the allWhite function
1 Write the clockwise function
1 Write the anticlockwise function
1
Ensure the functions work for quadtrees with
between 1 and 4 cells
1 mark
1
Ensure the functions work for quadtrees with
at most 16 cells
1 mark
1 Ensure the functions work for all quadtrees 1 mark
2 Write a function blur from quadtrees
to quadtrees (which does anything!)
2
Ensure your function does not ‘go wrong’ for
any well-defined input
1 mark
2
Make the blur function work correctly for
striped quadtrees with at most 16 cells
1 mark
2
Make the blur function work correctly for all
striped quadtrees
1 mark
2 Make the blur function work for all quadtrees 1 mark
all Document your code clearly with comments 1 mark
all Thoroughly test and reason about your solutions
all Test your submission using your own test data
all Remove any definition of main from your
submission
all Run check submission.sh and make sure
there are no errors
all Make sure you have added submission.hs,
pushed, and tagged your submission correctly
11
3 An open-ended exercise
The exercise described in this section is designed to be extremely difficult: no
amount of time spent on it is guaranteed to result in gaining marks, and it is
best attempted only if the thinking in itself is sufficient motivation. In particular, it will only be marked if your submission for exercises 1 and 2 receive full
marks. I have told the TAs that they do not need to prepare to support these
exercises, so you may need to ask me directly about any questions you have!
For this exercise, we assume that quadtrees do not record any size information about their cells. If your data structure for Exercises 1 and 2 records size
information, make a different Algebraic Data Type for this exercise which does
not do so, and provide implementations for the four functions from Exericse
1, except that allBlack and allWhite should now take no arguments. Note
that you should do this exercise in a separate file, so that you don’t modify
anything to do with your existing solutions!
This means we can now write infinite quadtrees, such as
let q = clockwise allWhite allBlack allWhite q in q
which form the basis of the exercise.
First, we define a notion of approximation for quadtrees for each natural number
n which we call the n
th coarse work approximation. This is specified by
the following equalities:
• coarsework 0 q == allWhite
• coarsework n allWhite == allWhite
• coarsework n allBlack == allBlack
• coarsework (n+1) (clockwise a b c d)
== clockwise (coarsework n a)
(coarsework n b)
(coarsework n c)
(coarsework n d)
A value q of the quadtree type is called ergodomestic if for all natural numbers
n the expression coarsework n q does not ‘go wrong’ in the sense we have been
using that phrase heretofore.
A function which takes a quadtree as input and outputs a Bool is called a fair
exercise if and only if when given an ergodomestic quadtree, it evaluates to
either True or False in finite time.
Your task is to define a function my_solution which takes as input a function
from quadtrees to Bool and outputs a quadtree, with the property that for all
fair exercises f, my_solution evaluates in finite time to a quadtree (which may
be finite or infinite), and we have
12
• f (my_solution f) == True if there exists a value of the quadtree type
q such that f (q) == True , and
• f (my_solution f) == False if there is no such value.
A correct, well-documented solution is worth two marks.
如有需要,請加QQ:99515681 或WX:codehelp

掃一掃在手機打開當前頁
  • 上一篇:代寫CS9053、代做Java語言編程
  • 下一篇:代發EI論文 EI論文轉證 EI源刊助發
  • 無相關信息
    合肥生活資訊

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

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

    Copyright © 2025 hfw.cc Inc. All Rights Reserved. 合肥網 版權所有
    ICP備06013414號-3 公安備 42010502001045

    91精品国产91久久久久久_国产精品二区一区二区aⅴ污介绍_一本久久a久久精品vr综合_亚洲视频一区二区三区
    欧美日韩一视频区二区| 日韩欧美一区二区三区在线| 极品少妇一区二区三区| 欧美一区激情视频在线观看| 99久久国产综合精品色伊| 国产福利不卡视频| 风流少妇一区二区| 国产.欧美.日韩| 9i在线看片成人免费| eeuss鲁片一区二区三区在线看| 懂色一区二区三区免费观看| 成人黄色小视频| 欧美日韩高清在线一区| 欧美成人蜜桃| 99视频一区| 色婷婷国产精品久久包臀| 久久精品一区二区国产| 欧美无乱码久久久免费午夜一区 | 国产精品豆花视频| 在线精品观看| 色94色欧美sute亚洲线路一久| 日本道色综合久久| 欧美一区欧美二区| 久久精品视频免费观看| 国产精品毛片高清在线完整版| 亚洲另类春色国产| 免费在线观看一区| 国产电影精品久久禁18| 午夜精品久久久久99热蜜桃导演 | 国产一区二区三区蝌蚪| 99亚偷拍自图区亚洲| 国产专区一区| 看欧美日韩国产| 欧美电视剧在线观看完整版| 国产精品女上位| 日本人妖一区二区| 成人aaaa免费全部观看| 亚洲欧洲日本一区二区三区| 欧洲一区二区三区在线| 精品久久久影院| 亚洲宅男天堂在线观看无病毒| 日本亚洲天堂网| 91在线视频官网| 国产精品乱子乱xxxx| 欧美精品成人一区二区三区四区| 久久综合999| 首页亚洲欧美制服丝腿| 不卡视频在线看| 久久精精品视频| 久久久久久久久久久久久女国产乱| 亚洲三级理论片| 国产精品一区二区久激情瑜伽 | 色婷婷精品久久二区二区蜜臂av| 精品处破学生在线二十三| 亚洲综合网站在线观看| 成人黄色片在线观看| 久久久蜜桃一区二区人| 久久久综合视频| 蜜芽一区二区三区| 欧美日韩在线精品一区二区三区| 欧美亚洲国产一区二区三区va| 中文字幕va一区二区三区| 国精产品一区一区三区mba桃花| 精品91视频| 久久午夜电影网| 久久国产福利国产秒拍| 夜夜爽www精品| 国产视频一区二区在线| 国产专区综合网| 一本色道**综合亚洲精品蜜桃冫 | 91婷婷韩国欧美一区二区| 在线免费不卡视频| 亚洲精品第1页| 欧美精品91| 日韩视频在线你懂得| 日本欧美一区二区| 99视频+国产日韩欧美| 欧美精品一区二区三区蜜臀| 久久国产视频网| 久久久久综合| 亚洲国产日韩精品| 亚洲一级特黄| 中文字幕精品一区二区三区精品 | 欧洲激情一区二区| 亚洲图片有声小说| 精品动漫3d一区二区三区免费版| 久久久久久久久久久久久久久99| 国产精品白丝av| 欧美少妇bbb| 日本aⅴ亚洲精品中文乱码| 国产日韩欧美一区二区三区在线观看 | 成人av网址在线| 日韩三级中文字幕| 国产精品99久久久| 欧美高清视频www夜色资源网| 日韩电影在线免费观看| 久久综合伊人| 丝袜美腿亚洲色图| 久久久久久久久久久久久久一区| 伊人一区二区三区| 国产精品毛片| 亚洲123区在线观看| 久久九九国产| 青草av.久久免费一区| 欧美曰成人黄网| 美女一区二区在线观看| 欧美午夜在线一二页| 久久精品国产精品亚洲综合| 精品视频色一区| 国产精品99久| 久久久久久久久岛国免费| 95精品视频在线| 国产精品成人一区二区艾草| 亚洲网站啪啪| 亚洲高清视频的网址| 久久久xxx| 国内一区二区在线| 精品久久一区二区| 欧美日韩一区二| 亚洲成人www| 欧美日韩一区二区三区四区 | 欧日韩精品视频| 国产成人精品网址| 久久综合久色欧美综合狠狠| 欧美日韩综合| 午夜久久久久久久久| 欧美日本精品一区二区三区| 不卡在线视频中文字幕| 中文字幕第一区二区| 中文亚洲字幕| 久久国产精品色婷婷| 久久综合色鬼综合色| 日韩视频在线观看国产| 男人的天堂亚洲一区| 久久一区二区三区国产精品| 99视频+国产日韩欧美| 久久激情五月婷婷| 久久综合九色综合欧美亚洲| 日韩视频不卡| 国产成人亚洲精品青草天美| 国产精品高潮久久久久无| 久久久夜夜夜| 成人av电影在线观看| 亚洲一级二级三级在线免费观看| 欧美精品日韩精品| 亚洲视频免费| 韩国在线一区二区| 中文字幕日韩一区| 欧美丝袜自拍制服另类| 欧美特黄一级| 久久99国产精品久久99| 日韩一区在线看| 91精品久久久久久蜜臀| 99精品视频免费| 国产高清不卡一区二区| 日韩久久一区二区| 91精品免费在线观看| 日韩一级不卡| 豆国产96在线|亚洲| 婷婷中文字幕一区三区| 国产日韩欧美麻豆| 欧美美女一区二区在线观看| 99热精品在线| 91天堂素人约啪| 国内精品伊人久久久久av影院| 亚洲欧美偷拍三级| 精品国产91乱码一区二区三区| 久久久久欧美| 影音先锋在线一区| 99久久婷婷国产| 精品一区二区影视| 亚洲国产精品久久久久婷婷884| 久久久久九九视频| 欧美高清激情brazzers| 亚洲欧美精品| 韩日欧美一区| 91蜜桃免费观看视频| 国产美女视频91| 日韩av网站免费在线| 伊人一区二区三区| 中文字幕av不卡| 久久青草国产手机看片福利盒子| 欧美视频在线一区| 久久婷婷一区| 亚洲一区二区三区涩| 在线欧美福利| 欧美午夜免费| 欧美一区二区三区四区在线观看地址 | 石原莉奈在线亚洲三区| 一区二区三区日韩精品视频| 亚洲国产岛国毛片在线| 精品美女在线观看| 欧美一区二区三区在线观看 | 亚洲丝袜精品丝袜在线| 国产三级一区二区| 国产无遮挡一区二区三区毛片日本| 日韩欧美资源站| 日韩欧美在线一区二区三区| 91精品久久久久久蜜臀| 欧美日韩黄色一区二区|