首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
C++程序设计调试、讲解algorithm编程、c++程序辅导 解析Haskell程序|讲解留学生Prolog
项目预算:
开发周期:
发布时间:
要求地区:
Assignment Two
Objectives
• Understand how AVL tree works
• Understand how to design an efficient algorithm
• Give you further practice with time complexity analysis of algorithms
• Give you further practice with C and data structures
Admin
Marks 12 marks. Marking is based on the correctness and efficiency of your code. Your
code must be well commented.
Group? This assignment is completed individually.
Due Time 09:59:59pm on Sunday 4 April 2021.
Late Submissions Late submissions will not be accepted!
In this assignment, you will implement AVL tree and a set of functions associated with AVL
tree. For simplicity, we make the following assumptions:
1. Each item of an AVL tree contains an integer key and an integer value.
2. No AVL tree contains duplicate items. Two items (k1, v1) and (k2, v2) are duplicates
iff k1=k2 and v1=v2 hold.
3. An AVL tree may contain multiple items with the same key.
A template file named MyAVLTree.c is provided. MyAVLTree.c contains the type definitions of
AVL tree and AVL tree node as well as some basic functions. You can add your own helper
functions and auxiliary data structures for better performance in terms of time complexity.
You need to implement the following functions:
1. AVLTree *CreateAVLTree(const char *filename). This function creates an AVL tree by
reading all the items from a text file or from the standard input (keyboard)
depending on the argument filename. If filename is “stdin”, this function will read all
the items from the standard input. Otherwise, it will read all the items from a text
file with filename as its full path name. (2 marks)
An input text file contains zero or more items where each item is of the form (key,
value). Any characters such as white space between two adjacent items are ignored.
For example, the following sample file contains 10 items:
(2, 50) (4, 30) (9, 30) (10, 400) (-5, -40)
(7, 20) (19, 200) (20, 50) (-18, -200) (-2, 29)
Similarly, when reading from the standard input, each input line may have zero or
more items, separated by one or more white space characters. An empty line
indicates the end of input.
In case of an error in the input, this function will print the error and your program
terminates.
You may assume that the input does not contain duplicate items and thus this
function does not need to check for duplicate items.
The time complexity of this function cannot be higher than O(n logn), where n is the
size of the resulting AVL tree. If your time complexity is higher, you will get 0 mark
for this function. You may assume that each call to a C built-in function takes O(1)
time.
2. AVLTree *CloneAVLTree(AVLTree *T). This function creates an identical copy (clone)
of the input AVL tree T, and returns a pointer to the clone tree. (1 mark)
The time complexity of this function cannot be higher than O(n), where n is the size
of T. If your time complexity is higher, you will get at most 0.5 mark depending on
your time complexity.
3. AVLTree *AVLTreesUnion(AVLTree *T1, AVLTree *T2). This function computes the
union tree of two AVL trees T1 and T2 and returns a pointer to the union tree. The
union tree of two AVL trees T1 and T2 is an AVL tree that contains all the items of
both T1 and T2 without duplicate items. Assume that neither T1 nor T2 contains
duplicate items. (3 marks)
The time complexity of this function cannot be higher than O(m+n), where m and n
are the sizes of T1 and T2, respectively. If your time complexity is higher, you will get
at most 1.5 marks depending on your time complexity.
An example: consider the following two AVL trees T1 and T2:
The union tree of T1 and T2 is shown as follows:
Note that in general the union tree may not be unique with respect to shape
(structure) depending on how it is constructed.
4. AVLTree *AVLTreesIntersection(AVLTree *T1, AVLTree *T2). This function computes
the intersection tree of two AVL trees T1 and T2 and returns a pointer to the
intersection tree. The intersection tree of two AVL trees T1 and T2 is an AVL tree
that contains all the items that appear in both T1 and T2. Assume that neither T1 nor
T2 contains duplicate items. (3 marks)
The time complexity of this function cannot be higher than O(m+n), where m and n
are the sizes of T1 and T2, respectively, and k the size of the intersection tree. If your
time complexity is higher, you will get t most 1.5 marks depending on your time
complexity.
An example: consider the previous two AVL trees T1 and T2. The intersection tree is
shown as follows:
Note that in general the intersection tree may not be unique with respect to shape
(structure) depending on how it is constructed.
5. int InsertNode(AVLTree *T, int k, int v). If the item (k, v) exists in the tree, this
function simply returns 0 without adding the new item (k, v) to the tree. Otherwise,
it inserts the new item (k, v) into the AVL tree T, increases the tree size by one and
returns 1. (0.5 mark)
The time complexity of this function cannot be higher than O(log n), where n is the
size of T. If your time complexity is higher, you will get 0 mark for this function.
6. int DeleteNode(AVLTree *T, int k, int v). If the item (k, v) exists in the AVL tree T, this
function deletes the node containing this item, decreases the tree size by one and
returns 1. Otherwise, it returns 0 only. (1 mark)
The time complexity of this function cannot be higher than O(n), where n is the size
of T. If your time complexity is higher, you will get 0 mark for this function.
7. AVLTreeNode *Search(AVLTree *T, int k, int v). This function search for the item (k,
v) in the AVL tree T. If the item is found, it returns a pointer to the node containing
the item. Otherwise, it returns NULL. (0.5 mark)
The time complexity of this function cannot be higher than O(n), where n is the size
of T. If your time complexity is higher, you will get 0 mark for this function.
8. void FreeAVLTree(AVLTree *T). This function frees up the heap space occupied by
the AVL tree T. (0.5 mark)
The time complexity of this function cannot be higher than O(n), where n is the size
of T. If your time complexity is higher, you will get 0 mark for this function. You may
assume that each call to free() takes O(1) time.
9. void PrintAVLTree(AVLTree *T). This function prints all the items stored in the AVL
tree T sorted in non-decreasing order of keys on the standard output (screen). Each
item is denoted by (key, value) with one item per line. (0.5 mark)
The time complexity of this function cannot be higher than O(n), where n is the size
of T. If your time complexity is higher, you will get 0 mark for this function. You may
assume that each call to a built-in C function takes O(1) time.
For each function, analyze its time complexity, and put the time complexity analysis as
comments before the function. For the time complexity of each function, you just need to give
the time complexity of major components (loops) and the total time complexity. You may
assume that each call to a built-in C function takes constant (O(1)) time.
How to submit your code?
a. Go to the assignment page
b. Click on Assignment Specifications for Assignment 2
c. Click on Make Submission
d. Submit your MyAVLTree.c file that contains all the code.
Plagiarism
This is an individual assignment. Each student will have to develop their own solution without
help from other people. In particular, it is not permitted to exchange code or pseudocode.
You are not allowed to use code developed by persons other than yourself. All work
submitted for assessment must be entirely your own work. We regard unacknowledged
copying of material, in whole or part, as an extremely serious offence. For further information,
see the Course Information.
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做ceng0013 design of a pro...
2024-11-13
代做mech4880 refrigeration a...
2024-11-13
代做mcd1350: media studies a...
2024-11-13
代写fint b338f (autumn 2024)...
2024-11-13
代做engd3000 design of tunab...
2024-11-13
代做n1611 financial economet...
2024-11-13
代做econ 2331: economic and ...
2024-11-13
代做cs770/870 assignment 8代...
2024-11-13
代写amath 481/581 autumn qua...
2024-11-13
代做ccc8013 the process of s...
2024-11-13
代写csit040 – modern comput...
2024-11-13
代写econ 2070: introduc2on t...
2024-11-13
代写cct260, project 2 person...
2024-11-13
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!