1. Homepage
  2. Exam
  3. [2022] COMP2017/9017 System Programming - Final Exam - Q2 Merger

[2022] COMP2017/9017 System Programming - Final Exam - Q2 Merger

This question has been solved
Engage in a Conversation

Merger - 20% CourseNana.COM

  CourseNana.COM

This question relies on the following linked list structure CourseNana.COM

  CourseNana.COM

struct node { CourseNana.COM

const char *id; CourseNana.COM

struct node *next; CourseNana.COM

}; CourseNana.COM

  CourseNana.COM

Each node is created as part of a singly linked list. The identifier is a C string. There are no sentinel nodes. NULL represents an empty list. CourseNana.COM

  CourseNana.COM

Merge two linked lists. CourseNana.COM

struct node * merge_lists(struct node *a, struct node *b); CourseNana.COM

  CourseNana.COM

Given two linked lists, you are to merge these two lists into a single one and return the head of the linked list. CourseNana.COM

The merge operation alternates between nodes of lists a and b in the order a_1, b_1, a_2, b_2, CourseNana.COM

a_3, b_3 etc. CourseNana.COM

  CourseNana.COM

If the lists are of unequal length, the remaining nodes are used in the longer list e.g. a is longer than b, then it would return a_1, b_1, a_2, b_2, a_3, b_3, a_4, a_5, a_6 CourseNana.COM

  CourseNana.COM

Notes CourseNana.COM

No allocation, nor deallocation, of nodes, or C strings are necessary in this problem. malloc/free are not permitted. CourseNana.COM

  CourseNana.COM

Assume that a and/or b, as heads of the linked list. CourseNana.COM

  CourseNana.COM

If both lists a and b are NULL, NULL is returned. If list a or b are NULL, then they are equivalent to a zero length list and merge should proceed as described. CourseNana.COM

  CourseNana.COM

There are no guarantees about the value of id for any node in this part. CourseNana.COM

  CourseNana.COM

Helper functions are permitted. CourseNana.COM

Get the Solution to This Question

WeChat WeChat
Whatsapp WhatsApp
COMP2017代写,COMP9017代写,System Programming代写,University of Sydney代写,COMP2017代编,COMP9017代编,System Programming代编,University of Sydney代编,COMP2017代考,COMP9017代考,System Programming代考,University of Sydney代考,COMP2017help,COMP9017help,System Programminghelp,University of Sydneyhelp,COMP2017作业代写,COMP9017作业代写,System Programming作业代写,University of Sydney作业代写,COMP2017编程代写,COMP9017编程代写,System Programming编程代写,University of Sydney编程代写,COMP2017programming help,COMP9017programming help,System Programmingprogramming help,University of Sydneyprogramming help,COMP2017assignment help,COMP9017assignment help,System Programmingassignment help,University of Sydneyassignment help,COMP2017solution,COMP9017solution,System Programmingsolution,University of Sydneysolution,