Starting from:
$29.99

$23.99

Assignment 2 Solution

1.   (100 pts) Write a program to implement the following functions on linked lists. Assume that node structure of a singly linked list is as follows.

 

struct node

 

{

 

int info;

 

struct node *next;

 

};

 

typedef struct node node;

 

and node structure of a doubly linked list is as follows

 

struct cnode

 

{

 

int info;

 

struct cnode *next;

 

struct cnode *previous;

 

};

 

typedef struct cnode cnode;

 

Implement the below functions whose prototypes are given below

 

node *CopytoSinglyLinked(cnode *head)

 

node *Previous(node *head, node *current)

 

void PrintReverse(node *head)

 

node *RemoveDuplicates(node *head)

 

CopytoSinglyLinked function makes a singly linked copy of a doubly linked list that is provided as a parameter and returns a pointer to the singly linked list.

 

Previous function returns the previous node of current in a singly linked list pointed by head. If current is the rst node Previous returns null.

 

PrintReverse function prints a elements of a singly linked list in reverse order. This should be implemented as an iterative function. Use Previous function in your imple-mentation.

 

RemoveDuplicates function removes duplicate elements in a singly linked list that is provided as a parameter.  The contents of the list need not be sorted.  You should remove duplicates in an unsorted list without changing the order of elements in the list.

 

Submit your program electronically using the blackboard system

 

The program you submit should be your own work. Cheating will be reported to office of academic integrity. Both the copier and copiee will be held responsible.

More products