Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a C program project5.c that operates as described below Your program should accept three command line arguments. Argument 1 is the name of an
Write a C program project5.c that operates as described below Your program should accept three command line arguments. Argument 1 is the name of an input file that contains a list of key words. Argument 2 is the name of an input file that contains a list of query words. Argument 3 is the name of an output file First your program reads all the key words in the first input file, and it adds each such key word into a linked list that maintains these key words in alphabetical order. This process ends when the end-of-file condition is reached for the key words. Next your program allocates an array of strings, with size of the array equal to the number of key words in the linked list. Then it copies all the key words from the linked list into this array so that the words remain in alphabetical order Finally your program reads each query word from the second input file, and it uses the binary search algorithm to search for each query word within the array. For each query word that is found to appear in the array of key words, your program prints the word and its index to the output file. This process ends when the end-of-file condition is reached for the query words. Here is an example: Kevwords file red green blue yellow cyan magenta white black gray orange pink Queries file indigo white violet black purple yellow brown cyan gold magenta silver gray crimson pink maroon orange scarlet red beige green tan blue na Output file white 9 black 0 yellow 10 cyan 2 magenta 5 gray 3 pink 7 orange 6 red 8 green 4 blue 1 rds arra 0: black : blue 2: cyan 3: gray 4:green 5: magenta 6: orange 7: pink 8: red 9: white 10: yellow
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started