Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[C PROGRAMMING] Please help fill out these two functions, I don't know how to do them. Some comments would be nice so I can understand

[C PROGRAMMING] Please help fill out these two functions, I don't know how to do them. Some comments would be nice so I can understand how you did it too. Thanks.

image text in transcribed

image text in transcribed

For void differences, I have the ham and spam from the file here (just unzip it): https://www.dropbox.com/s/u8yj0basrnt59nv/smsspamcollection.zip?dl=0

int bagsearch( struct bag-struct *bow, char *word ); This function will perform a binary search of the "bag" array contained in the struct bag_struct pointed to by the pointer bow. The binary search should look in the middle of the array for the "word". If the "word" is alphabetically before the middle word in the "bow", then the search should be repeated on the first "half" of the bow. This can be done by creating a new struct bag_struct with the same "bag" and "bag_size" equal to 1/2 of the original bag_size and calling "bagsearch" recursively. If the "word" is alphabetically after the middle word in the "bow", then the search should be repeated on the second half of the bow. This can be done by creating a new struct bag_struct with "bag" pointing one position past the middle element, and bag size equal to 12 of the orginal bag size. HA :do a few exam es to tizure out act how to ca te oud u or oun down so that you search exactly the right part of the array, and no ur er fa any po nt the muddle element mat he worthen th tune i la det n ndex word in the bag_struct. If"word" is not located in the bag_struct, then the return index should refer to the first word that is alphabetically after "word" int bagsearch( struct bag-struct *bow, char *word ); This function will perform a binary search of the "bag" array contained in the struct bag_struct pointed to by the pointer bow. The binary search should look in the middle of the array for the "word". If the "word" is alphabetically before the middle word in the "bow", then the search should be repeated on the first "half" of the bow. This can be done by creating a new struct bag_struct with the same "bag" and "bag_size" equal to 1/2 of the original bag_size and calling "bagsearch" recursively. If the "word" is alphabetically after the middle word in the "bow", then the search should be repeated on the second half of the bow. This can be done by creating a new struct bag_struct with "bag" pointing one position past the middle element, and bag size equal to 12 of the orginal bag size. HA :do a few exam es to tizure out act how to ca te oud u or oun down so that you search exactly the right part of the array, and no ur er fa any po nt the muddle element mat he worthen th tune i la det n ndex word in the bag_struct. If"word" is not located in the bag_struct, then the return index should refer to the first word that is alphabetically after "word

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

Students also viewed these Databases questions