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

[2022] COMP2017/9017 System Programming - Final Exam - Q3 Unique

This question has been solved
Engage in a Conversation

Unique - 30%

CourseNana.COM

Keep the unique elements of the doubly linked list (free others). CourseNana.COM

There is the following linked list structure: CourseNana.COM

  CourseNana.COM

struct node { CourseNana.COM

const char *id; CourseNana.COM

struct node *next; CourseNana.COM

struct node *prev; CourseNana.COM

}; CourseNana.COM

  CourseNana.COM

Each node is created as part of a doubly linked list. The identifier is allocated on the heap. There are no sentinel nodes. NULL represents an empty list. CourseNana.COM

  CourseNana.COM

Remove all duplicate entries of a doubly linked list (uniq) CourseNana.COM

  CourseNana.COM

struct node * list_unique(struct node *list, struct node **removed, int *removed_count); CourseNana.COM

  CourseNana.COM

Given a doubly linked list, you are to delete any nodes which duplicate the identifier string (id). CourseNana.COM

  CourseNana.COM

For example, if the list contains the sequence A, B, D, A, B, B, C then the resulting list should be A, B, D, C. Nodes of the returned list are presented in the same order they are seen in the original linked list. CourseNana.COM

  CourseNana.COM

The parameter removed is modified by your function to record which node addresses were removed from the original list (even though they are freed). The parameter removed_count is modified by your function to specify how many nodes were removed. You are guaranteed that the size of removed is equal to the length of the linked list. If one node is removed, it is expected that the memory address of removed_count stores a value 1 and that the address of that removed is stored in the array starting at the address removed. CourseNana.COM

  CourseNana.COM

Notes CourseNana.COM

  CourseNana.COM

The case of all identifier strings is guaranteed to be all uppercase, C functions strcmp() , malloc() , free() CourseNana.COM

  CourseNana.COM

You are guaranteed that list, removed , removed_count are never NULL . CourseNana.COM

  CourseNana.COM

You are guaranteed that id in any node is a heap allocated C string and is not NULL. 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,