C语言程序代做 – AVL tree代写 – 算法作业代写 – 计算机assignment助攻
c语言程序代做

C语言程序代做 – AVL tree代写 – 算法作业代写 – 计算机assignment助攻

Assignment Two

 

 

c语言程序代做 Understandhow AVL tree worksUnderstandhow to design an efficient algorithmGiveyou further practice with time complexity analysis of algorithms···

 

Objectives  c语言程序代做

  • Understandhow AVL tree works
  • Understandhow to design an efficient algorithm
  • Giveyou further practice with time complexity analysis of algorithms
  • Giveyou 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. Eachitem of an AVL tree contains an integer key and an integer
  2. NoAVL tree contains duplicate  Two items (k1, v1) and (k2, v2) are duplicates iff k1=k2 and v1=v2 hold.
  3. AnAVL 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: c语言程序代做

1.AVLTree *CreateAVLTree(const char *filename). This function creates an AVL tree byreading 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. c语言程序代做

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  (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 theunion 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  (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: c语言程序代做

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 computesthe 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  (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:c语言程序代做

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, thisfunction 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  (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, thisfunction deletes the node containing this item, decreases the tree size by one and returns  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.

c语言程序代做

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  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 bythe AVL tree T. (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 AVLtree T sorted in non-decreasing order of keys on the standard output (screen). Each item is denoted by (key, value) with one item per  (0.5 mark)

c语言程序代做

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?

  1. Goto the assignment page
  2. Clickon Assignment Specifications for Assignment 2
  3. Clickon Make Submission
  4. Submityour c file that contains all the code.

Plagiarism  c语言程序代做

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.

 

更多代写:java code代写 math代考 music代写 nursing essay代写  outline代写 美国网课托管

合作平台:天才代写 幽灵代  写手招聘  paper代写

发表回复