QuestionQuestion

Goal
You will implement a suite of functions for manipulating a doubly linked list of movies, and you will provide a simple user interface for testing.

Learning Objectives
• get familiar with more complex dynamic memory operations by managing a linked list

Instructions
1. Data structures
Your program will define the following data types:
• a MovieGenre enumerated data type to represent a kind of movie, for example comedy, drama, action, etc.
• a Movie structure type: each movie will have a title, a year, a movie genre, and an array of cast members
• a DblList structure type to represent a doubly linked list that holds the head and the tail of the list
o your linked list must be implemented as we saw in class
o do not use dummy nodes! every node in the list must correspond to a movie instance
o the head of the list points to what is currently the first node in the list
o the tail of the list points to what is currently the last node in the list
• a Node structure

2. Linked list functions
You will implement the following functions:
• an initialization function with prototype: void dl_init(DblList *dlist)
o this function initializes the fields of the doubly linked list
• an add function with prototype: void dl_add(DblList *dlist, Movie *newMovie)
o this function adds the given movie to the list in its correct position, in alphabetical order by title
• a remove function with prototype: void dl_del(DblList *dlist, Movie *newMovie)
o this function removes the given movie from the list
• a print forward function with prototype: void dl_printFwd(DblList *dlist)
o this function traverses the list from head to tail, and prints each movie’s information to the screen
• a print backward function with prototype: void dl_printBack(DblList *dlist)
o this function traverses the list from tail to head, and prints each movie’s information to the screen
• a print by genre function with prototype:
void dl_printByGenre(DblList *dlist, enum MovieGenre genre)
o this function traverses the list from tail to head, and prints the information about movies of that genre
• a cleanup function with prototype: void dl_cleanup(DblList *dlist)
o this function deallocates the memory for the doubly linked list

3. User interface
You will create a small program to interact with the user and allow the testing of all the linked list functions. Your user interface must provide the following features:
• the user can add any number of movies of different genres to the doubly linked list
• the user can remove any movie
• the user can print the movie list forward, backward, or by genre

Note:
• your program must store one instance of the doubly linked list
• the list must be declared as a local variable in main

Constraints
• you must use the function prototypes exactly as stated
• do not use any global variables
• compound data types must be passed by reference, not by value
• you must reuse functions everywhere possible
• your program must be thoroughly commented
• do not leave memory leaks

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

#ifndef HEADER_H
#define HEADER_H

#ifdef __cplusplus
extern "C" {
#endif

#define TITLE_LENGTH 100
#define CAST_MEMBER_NUM 100
#define GENRE_LENGTH 20
   
enum MovieGenre{
    comedy = 0,
    drama,
    action
};

struct Member{
    char name[TITLE_LENGTH];
};

typedef struct Member Member;

struct Movie{
    char tile[TITLE_LENGTH];
    int year;
    enum MovieGenre genre;
    Member castMember[CAST_MEMBER_NUM];
    int castMemberNum;
};

typedef struct Movie Movie;...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

$50.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats