COMP9024程序 写作、C++编程 写作

” COMP9024程序 写作、C++编程 写作COMP9024 Assignment OneObjectives Give you experience with doubly linked lists Understand how to solve set union, set intersection and longest sublist problems Give you practice with time complexity analysis Give you further practice with C and data structuresAdminMarks 12 marks. Marking is based on the correctness and efficiency of your code. Yourcode must be well commented.Group? This assignment is completed individuallyDue Time 10:00 pm Sunday, March 14, 2021.Late Submissions Late Submissions will not be accepted!AimsIn this assignment, you will implement a set of functions based on the doubly linked listdefined in MyDLList.c.The functions you need to implement are shown as follows:1. DLList *CreateDLListFromFileDlist(const char *filename). This function creates adoubly linked list of integers by reading all integers from a text file named filename,and returns a pointer to the doubly linked list where each node stores one integer.Assume that adjacent integers in the file filename and the standard input areseparated by one or more white space characters or a new line character.If filename is stdin, CreateDLListFromFileDlist (stdin) creates a doubly linked listby reading all integers from the standard input and the word end denotes the end ofinput.This function must check for invalid input. In case of invalid input, it prints an errormessage Invalid input! and returns NULL. (2 marks)2. void printDLList(DLList *u ). This function prints all the elements (integers) of a doublylinked list pointed by u in the Order from the first node to the last node in the list onthe standard output, one element per line. (1 mark)3. DLList *cloneList(DLList *u). This function creates an identical copy of a doubly linkedlist u and returns a pointer to the list cloned. (1 mark)4. DLList *longestSublist(DLList *u). This function returns a doubly linked list that is thelongest sublist of u. The longest sublist v of a list u is defined as follows:a. The greatest common divisor of all the elements (integers) of v is not 1 (weconsider positive divisors only).b. No other sublist of u contains more elements than v.Assume that all the integers in the list pointed by u are distinct.Consider a list u = {2, -6, 8, 15, 11,23, 20}. The longest sublist v of u is {2, -6, 8, 20},and the greatest common divisor of all the elements of v is 2.Note that the longest sublist of a list may not be unique. Consider a list u = {2, 6, 4, 3,9}. There are two longest sublists: v1={2, 6, 4} and v2={6, 3, 9}. If there are multiplelongest sublists, this function returns any one of them.When analysing the time complexity of your algorithm, you may assume that themaximum integer of the input list is a constant. Under this assumption, it takesconstant time O(1) to check if two integers are mutually prime (i.e., their only divisoris 1). (3 marks)5. DLList *setUnion(DLList *u, DLList *v). This function computes the union of the twosets of integers that are stored in the doubly linked lists pointed by u and v,respectively, and returns a pointer to the doubly linked list that stores the union. Eachelement (int) of a set is stored in a node of the corresponding doubly linked list.Given two sets A and B, the union of A and B is a set that contains all the distinctelement of A and B. For example, assuming that A = {2, 8, 5, 7} and B = {5, 9, 6, 7}, A B = {2, 8, 5, 7, 9, 6}. Note that in a set, all the integers are not necessarily sorted.(2 marks)6. DLList *setIntersection(DLList *u, DLList *v). This function computes the intersectionof the two sets of integers that are stored in the doubly linked lists pointed by u andv, respectively, and returns a pointer to the doubly linked list that stores theintersection. Each element (int) of a Set is stored in a node of the correspondingdoubly linked list. (2 marks)For simplicity, you may assume that all the elements of each input set are distinctfor both set union and set intersection. Therefore, you do not need to check if a setcontains duplicates.Given two sets A and B, the intersection of A and B is a set that contains all theelements of A that are also in B. For example, assuming that A = {2, 8, 5, 7} and B = {5,9, 6, 7}, A B = {5, 7}.7. void freeDLList(DLList *u). This function frees the space occupied by all the nodes ofthe doubly linked list pointed by u. (1 marks)Time complexity analysis: For each function, you need to analyze its time complexity in termsof big-O notation and put your analysis as comments immediately before the code of thefunction. You may assume that each built-in I/O function such as printf(), malloc() and free(),takes O(1) time.How to Submit your code?1. Go to the assignment one page2. Click on Assignment Specfication3. Click on Make Submission4. Submit your MyDLList.c file that contains all the code.PlagiarismThis is an individual assignment. Each student must work out his/her own solution withouthelp 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 worksubmitted for assessment Must be entirely your own work. We regard unacknowledgedcopying of material, in whole or part, as an extremely serious offence. For furtherinformation, see the Course Information.如有需要,请加QQ:99515681 或WX:codehelp

添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导