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 given position in Pascal’s Triangle. To compute the value at any give n position, just add up the numbers to the position’s right and left in the previous row (see picture below). For example, to get the middle number in the 5th row, add 3 and 3 (from the 4th row). The sides of the triangle are always 1, as it only add t he number of the upper left or the upper right, where there is no second number on the other side. Your program should prompt the user to input a row and a position in the row. The program should ensure that the input is valid before computing a value for the position. Then your trianglePascal() function will take this two parameters for calculation. 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 5 Q4. Write a complete C program, that Uses a one – dimension array to read 20 numbers, each of them is between 0 and 100, inclusive. a. Uses a selectionSort() function to sort the array in ascending order. Discuss the Big O of your sorting algorithm for the best case and worst case scenarios. b. Write another function that improve the performance of your program by using another sorting algorithm (any algorithm learned in the lecture), discuss the Big O of the new algorithm used.

 
 
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
given position in Pascal’s Triangle. To compute the value at any
give
n position, just add up the numbers to the position’s right and left in
the previous row (see picture below).
For example, to get the middle number in the 5th row, add 3 and 3
(from the 4th row). The sides of the triangle are always 1, as it
only
add t
he number of the upper left or the upper right, where there is
no second number on the other side.
Your program should prompt the user to input a row and a
position
in
the row.
The program should ensure
that the input is valid before
computing a value for
the position. Then your
trianglePascal()
function will take this two parameters for calculation.
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
5
Q4.
Write a complete C program, that Uses a one
dimension array
to read 20 numbers, each of them is between 0 and 100, inclusive.
a.
Uses a selectionSort() function to sort the array in ascending
order. Discuss the Big O of your sorting algorithm for the
best case
and worst case scenarios.
b.
Write another function that improve the performance of your
program by using another sorting algorithm (any algorithm learned
in the lecture), discuss the Big O of the new algorithm used.
order btn