[removed] Developing Technical Software Assignment TP3 2016 © S w i n b u r n e U n i v e r s i t y o f T e c h n o l o g y Page 1 COS10007 - Developing Technical Software Assignment (4 x 6.25= 25 Marks) Submission Requirements 1. No zip files, no multiple files 2. Submit only one file 3. Copy and paste your codes into one word document 4. Copy and paste the screen shot of the output window in the same word document 5. Use only .doc, .docx extensions – no other format will be accepted for marking You may be asked to demonstrate/explain your work to the tutor, if you are absent/unavailable or fail to demonstrate properly, zero marks will be awarded. Please note, this is an individual task and it will be checked for plagiarism. Both parties will be penalised if any plagiarism found. Developing Technical Software Assignment TP3 2016 © S w i n b u r n e U n i v e r s i t y o f T e c h n o l o g y Page 2 Qn 1. Creating Linked List in C Create a linked list using the following structure struct studentid { int id; struct studentid *next; }; typedef struct studentid STUDENTid; typedef STUDENTid *STUDENTidPtr; You have to create a linked list manually similar to week 4 Qn1 lab exercise. The re should be five nodes in the linked list and the elements should be the last 5 digits of your student id . One d igit will go to one node and the node insertion should happen in order similar to week 4 Qn 1 . Eg: Assume your student id is 100989674, take the last five digits which is 89674 so the insertion order is newptr= ... ... ..malloc( STUDENTid ); newptr - >id=8; . . . 9 . . 6 . 7 . . 4 and the final linked list should b e 4 6 7 9 8 NULL Developing Technical Software Assignment TP3 2016 © S w i n b u r n e U n i v e r s i t y o f T e c h n o l o g y Page 3 Qn2. Write the following functions in C program, assuming the node type used is as follows: struct node { int data; struct node* next; }; and head is the head pointer of a list: struct node* head; a) Write a sortedMerge() function in C program that taking two lists, each of which is sorted in increasing order, and merges the two together into one list which is increasing order. This function should return a new list, which should be intertwining the nodes of the first two lists. You should consider various cases, e.g. i. either 'a' or 'b' may be empty, ii. during processing either 'a' or 'b' may run out first You should use the following function header: struct node* sortedMerge(struct node* a, struct node* b) { /* Your code... */ b) Write another function named removeRedundant() which takes a list sorted in increasing order and deletes any duplicate nodes from the list. Ideally, the list should only be traversed once. /* Remove duplicates from a sorted list. */ void removeRedundant(struct node* head) { // Your code... Developing Technical Software Assignment TP3 2016 © S w i n b u r n e U n i v e r s i t y o f T e c h n o l o g y Page 4 Qn3. Write a complete C++ program to compute the value of a g.
[removed] Developing Technical Software Assignment TP3 2016 © S w i n b u r n e U n i v e r s i t y o f T e c h n o l o g y Page 1 COS10007 - Developing Technical Software Assignment (4 x 6.25= 25 Marks) Submission Requirements 1. No zip files, no multiple files 2. Submit only one file 3. Copy and paste your codes into one word document 4. Copy and paste the screen shot of the output window in the same word document 5. Use only .doc, .docx extensions – no other format will be accepted for marking You may be asked to demonstrate/explain your work to the tutor, if you are absent/unavailable or fail to demonstrate properly, zero marks will be awarded. Please note, this is an individual task and it will be checked for plagiarism. Both parties will be penalised if any plagiarism found. Developing Technical Software Assignment TP3 2016 © S w i n b u r n e U n i v e r s i t y o f T e c h n o l o g y Page 2 Qn 1. Creating Linked List in C Create a linked list using the following structure struct studentid { int id; struct studentid *next; }; typedef struct studentid STUDENTid; typedef STUDENTid *STUDENTidPtr; You have to create a linked list manually similar to week 4 Qn1 lab exercise. The re should be five nodes in the linked list and the elements should be the last 5 digits of your student id . One d igit will go to one node and the node insertion should happen in order similar to week 4 Qn 1 . Eg: Assume your student id is 100989674, take the last five digits which is 89674 so the insertion order is newptr= ... ... ..malloc( STUDENTid ); newptr - >id=8; . . . 9 . . 6 . 7 . . 4 and the final linked list should b e 4 6 7 9 8 NULL Developing Technical Software Assignment TP3 2016 © S w i n b u r n e U n i v e r s i t y o f T e c h n o l o g y Page 3 Qn2. Write the following functions in C program, assuming the node type used is as follows: struct node { int data; struct node* next; }; and head is the head pointer of a list: struct node* head; a) Write a sortedMerge() function in C program that taking two lists, each of which is sorted in increasing order, and merges the two together into one list which is increasing order. This function should return a new list, which should be intertwining the nodes of the first two lists. You should consider various cases, e.g. i. either 'a' or 'b' may be empty, ii. during processing either 'a' or 'b' may run out first You should use the following function header: struct node* sortedMerge(struct node* a, struct node* b) { /* Your code... */ b) Write another function named removeRedundant() which takes a list sorted in increasing order and deletes any duplicate nodes from the list. Ideally, the list should only be traversed once. /* Remove duplicates from a sorted list. */ void removeRedundant(struct node* head) { // Your code... Developing Technical Software Assignment TP3 2016 © S w i n b u r n e U n i v e r s i t y o f T e c h n o l o g y Page 4 Qn3. Write a complete C++ program to compute the value of a g.