Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How would I do this? 1 Singly-Linked List Use this #define: #define MAX STATE NAME LENGTH 64 and use this structure: typedef struct StateListNode Struct

How would I do this?image text in transcribedimage text in transcribed

1 Singly-Linked List Use this #define: #define MAX STATE NAME LENGTH 64 and use this structure: typedef struct StateListNode Struct { int population; char name [MAX STATE NAME LENGTH] ; struct State List NodeStruct *next; } StateListNode; and write functions to maintain a singly-linked list. Here are four functions to write: int insert State (StateListNode **list , char *name, int population) This will insert a new record in the list, sorted (ascending) by population. When you insert, first check to see whether the length of the name string is less than MAX_STATE_NAME LENGTH. If it isn't, then just return 1. Otherwise, check whether there is already a record in the list having that name. If there is, don't insert a new record and return 1. Otherwise, create a new list node, put the list node in the correct place in the list, and return 0. int find State (StateListNode *list , char *name, int * population) Find the record having the specified name. If there is one, then copy the population from that record to the population parameter and return 0. Otherwise, just return 1. int deleteState (StateListNode **list , char *name) Delete the record from the list having a name that matches the specified name. If there isn't one, then just return 1. Otherwise, delete the record from the list and return 0. Free the memory (using free()) associated with the node that you delete. int printList (State List Node *list) Print the records from this list. Print them one to a line, in in this form: |name| population name| population |name| population (Put the pipe character before and after the name string.) If the list is empty, then print this: (list is empty) 1 Singly-Linked List Use this #define: #define MAX STATE NAME LENGTH 64 and use this structure: typedef struct StateListNode Struct { int population; char name [MAX STATE NAME LENGTH] ; struct State List NodeStruct *next; } StateListNode; and write functions to maintain a singly-linked list. Here are four functions to write: int insert State (StateListNode **list , char *name, int population) This will insert a new record in the list, sorted (ascending) by population. When you insert, first check to see whether the length of the name string is less than MAX_STATE_NAME LENGTH. If it isn't, then just return 1. Otherwise, check whether there is already a record in the list having that name. If there is, don't insert a new record and return 1. Otherwise, create a new list node, put the list node in the correct place in the list, and return 0. int find State (StateListNode *list , char *name, int * population) Find the record having the specified name. If there is one, then copy the population from that record to the population parameter and return 0. Otherwise, just return 1. int deleteState (StateListNode **list , char *name) Delete the record from the list having a name that matches the specified name. If there isn't one, then just return 1. Otherwise, delete the record from the list and return 0. Free the memory (using free()) associated with the node that you delete. int printList (State List Node *list) Print the records from this list. Print them one to a line, in in this form: |name| population name| population |name| population (Put the pipe character before and after the name string.) If the list is empty, then print this: (list is empty)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions

Question

Find V0 in the circuit of Fig. 1.31. +t 28 V IA 3 +28V 28 V S A

Answered: 1 week ago