Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C Code - Structures, Searching, Sorting Skeleton Code: #include #include #define MAX_MEMBER 20 #define MAX_RECORD 100 #define MAX_RESULT 1000 #define MAX_LENGTH 50 typedef struct {

C Code - Structures, Searching, Sorting

image text in transcribed

image text in transcribed

image text in transcribed

Skeleton Code:

#include  #include  #define MAX_MEMBER 20 #define MAX_RECORD 100 #define MAX_RESULT 1000 #define MAX_LENGTH 50 typedef struct { char name[MAX_LENGTH+1]; char title[MAX_LENGTH+1]; } result_t; void sortResults(result_t results[], int); void printResults(result_t results[], int); int main(void) { int numRes; result_t results[MAX_RESULT]; sortResults(results, numRes); printf("The results of the join are as follows: "); printResults(results, numRes); return 0; } /* Sample printf statements for readInputs() printf("Enter operation of members: "); printf("Enter members: "); printf("Enter operation of records: "); printf("Enter records: "); printf("Enter operation: "); */ // Sort the results first by name and then by book title // in alphabetical order void sortResults(result_t results[], int size){ int i, start, index; result_t temp; for (start = 0; start  

Test Data: http://www.comp.nus.edu.sg/~cs1010/practice/2017s1/Practice-S12P09/testdata/

Objective: Structures, searching and sorting Task statement In today's world, many applications use database technology to manage a large amount of data in an organized wa For example, a book club may store data about its members, books, and information about which member has read which book. A summary of such data can be generated and used for many practical purposes, such as to recommend books to a member based on other members who have read similar books In this exercise, you are to write a program to read in some data, store them into arrays of structure variables, and perform some operations on the data to generate a summary More specifically, you are given the following structure type definitions: typedef struct t typedef struct i int id; char name [MAX LENGTH+1] int memID; char title [MAX LENGTH+1]; ) member_t; record t; The variables of the structure type member t are used to store the ids and the names of the members. For example, [111, "Mary"] refers to a member whose id is 111 and name is Mary In addition, the variables of the structure type record t are used to store who has read which book. For example, (111, "GameOfThrones" refers to a member whose id is 111 and this member has read a book called "GameOfThrones" The input to your program consists of multiple parts as shown on the right 111 Mary 222 Peter 333 Lucy 6 333 MaryPoppins 222 WarAndPeace 111 GameOfThrones 222 HarryPorter 222 AloneInTheDark 333 TheWizardofOz 1 The number of members The id and the name of each member The number of records The member ID and the title of the book read by this member. An integer (1 or 2) which represents the operation to be performed to generate a summary Objective: Structures, searching and sorting Task statement In today's world, many applications use database technology to manage a large amount of data in an organized wa For example, a book club may store data about its members, books, and information about which member has read which book. A summary of such data can be generated and used for many practical purposes, such as to recommend books to a member based on other members who have read similar books In this exercise, you are to write a program to read in some data, store them into arrays of structure variables, and perform some operations on the data to generate a summary More specifically, you are given the following structure type definitions: typedef struct t typedef struct i int id; char name [MAX LENGTH+1] int memID; char title [MAX LENGTH+1]; ) member_t; record t; The variables of the structure type member t are used to store the ids and the names of the members. For example, [111, "Mary"] refers to a member whose id is 111 and name is Mary In addition, the variables of the structure type record t are used to store who has read which book. For example, (111, "GameOfThrones" refers to a member whose id is 111 and this member has read a book called "GameOfThrones" The input to your program consists of multiple parts as shown on the right 111 Mary 222 Peter 333 Lucy 6 333 MaryPoppins 222 WarAndPeace 111 GameOfThrones 222 HarryPorter 222 AloneInTheDark 333 TheWizardofOz 1 The number of members The id and the name of each member The number of records The member ID and the title of the book read by this member. An integer (1 or 2) which represents the operation to be performed to generate a summary

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

Advances In Spatial And Temporal Databases 10th International Symposium Sstd 2007 Boston Ma Usa July 2007 Proceedings Lncs 4605

Authors: Dimitris Papadias ,Donghui Zhang ,George Kollios

2007th Edition

3540735399, 978-3540735397

More Books

Students also viewed these Databases questions