当前位置:天才代写 > C++/C代写 > C语言编程代写 function代写 code代写

C语言编程代写 function代写 code代写

2022-01-26 09:15 星期三 所属: C++/C代写 浏览:119

C语言编程代写

SampleProblem

C语言编程代写 Task 3: Add a recursive function, printReverseList, that will print the elements of the linked list in the reverse order, without changing thelist.

LinkedList: In this question, you have been provided with an incomplete code for a Dynamic Linked List. Your task is to complete the code by adding some functionalities to the program. Before describing the tasks, read the following initial notes, that show some differences between the linked list program we saw in the course and the one you are going to develop in this question:

Initial Notes:    C语言编程代写

  • The data of the structure has only one integer. This means every node of the self-referential structure has one integer as data and a pinter to the same structure.
  • You must not only keep a pointer to the beginning of the linked list, startPtr, but also keep a pointer to the last node of the linked list, endPtr. Note that it is not a doubly-linked list. It is a single linked list, with one extra pointer that points to the end of the list.
  • We do not have the two functions, insert and delete, in this program.
  • The linked list that is generated is not ordered. The elements will be appended to the beginning or end of the list depending on the add function used.
  • The functions isEmpty, printList, and menu, have already been developed, so you should not alter them. You just use them inside the other parts that you mustcomplete.
C语言编程代写
C语言编程代写

Tasks:   C语言编程代写

  • Task 1: Complete the function addFirst, that will add a new element to the beginning of the linked list.
  • Task 2: Complete the function addLast, that will add a new element to the end of the linked list.

Note that in both functions above, you must update the starting and ending pointers, when needed.

  • Task 3: Add a recursive function, printReverseList, that will print the elements of the linked list in the reverse order, without changing thelist.      C语言编程代写
  • Task 4: Add a function, reverseList, that will reverse the list, in-place. This means at the end you have the same elements in the linked list but in the reverse order. Note that “in-palce” means that you should not use any other dynamic data structure, like another linked list, stack or queue. You must reverse the list itself.
  • Task 5: Add a function, emptyList, that will safely empty a list. “Safely” means that you should make sure that you won’t make any memory leakage when you empty a list.

  • Task 6: Add a function, merge, that merges two ordered lists into a new linked list. The new list must have all the elements from the two original lists, ordered. No need to worry about any possible duplicates. This means if there are similar nodes inside the two lists, they will be copied into the new list one after another.
  • Task 7: Inside the main function, based on the comments provided, complete the code by calling the proper functions, along with adding some other required statements.   C语言编程代写

To fulfill the above tasks, you must complete the C program, LinkedList.c, that is provided for you.

*Note: You should first CAREFULLY READ THE COMMENTSprovided for each part of the program, and then start completing it.

*Note: DO NOT ALTER/DELETE any part of the existing code. ONLY complete the incompleteparts.

Sample execution of the program:   C语言编程代写

Enter your choice:

1to add a new element to the beginning of the

2to add a new element to the end of the

3to print the list in the reverse

4to reverse the list,in-place.

5to merge two ordered lists into a new ordered

6to end

? 1

Enter an integer number: 14 The list is:

14 –> NULL

Enter your choice:

1to add a new element to the beginning of the

2to add a new element to the end of the

3to print the list in the reverse

4to reverse the list,in-place.

5to merge two ordered lists into a new ordered

6to end

? 1     C语言编程代写

Enter an integer number: 23 The list is:

23 –> 14 –> NULL

Enter your choice:

1to add a new element to the beginning of the

2to add a new element to the end of the

3to print the list in the reverse

4to reverse the list,in-place.

5to merge two ordered lists into a new ordered

6to end

? 2

Enter an integer number: 41 The list is:

23 –> 14 –> 41 –> NULL

Enter your choice:

1to add a new element to the beginning of the

2to add a new element to the end of the

3to print the list in the reverse

4to reverse the list,in-place.

5to merge two ordered lists into a new ordered

6to end

? 3

The list in reverse order is: NULL –> 41 –> 14 –> 23 –>

Enter your choice:

1to add a new element to the beginning of the

2to add a new element to the end of the

3to print the list in the reverse

4to reverse the list,in-place.

5to merge two ordered lists into a new ordered

6to end

? 4        C语言编程代写

The list is:

41 –> 14 –> 23 –> NULL

Enter your choice:

1to add a new element to the beginning of the

2to add a new element to the end of the

3to print the list in the reverse

4to reverse the list,in-place.

5to merge two ordered lists into a new ordered

6to end

? 5

List 1:

The list is:

1 –> 4 –> 7 –> 10 –> 13 –> 16 –> 19 –> NULL

List 2:

The list is:

2 –> 9 –> 16 –> 23 –> 30 –> NULL

Merged list:

The list is:

1 –> 2 –> 4 –> 7 –> 9 –> 10 –> 13 –> 16 –> 16 –> 19 –> 23 –> 30 –> NULL

Enter your choice:

1to add a new element to the beginning of the

2to add a new element to the end of the

3to print the list in the reverse

4to reverse the list,in-place.

5to merge two ordered lists into a new ordered

6to end

? 6

C语言编程代写
C语言编程代写

 

更多代写:宏观经济online quiz代考  雅思代考  宏观经济代上网课价格  会计?Accounting Essay代写  计算机Computer science论文代写  代写留学生金融作业价格

合作平台:essay代写 论文代写 写手招聘 英国留学生代写

 

天才代写-代写联系方式