Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

password for the website is cs2123 as well as the username cs2123 CS 2123 Data Structures Recitation Exercise 09 (Library Improving bufferADT implementations with search/replace

image text in transcribedimage text in transcribedimage text in transcribedpassword for the website is cs2123 as well as the username cs2123

CS 2123 Data Structures Recitation Exercise 09 (Library Improving bufferADT implementations with search/replace functions) As in the previous recitations/hw, first you need to get some already implemented programs from the textbook. Specifically, get all the files under 09-Efficiency-and-ADTs from the class web page. You can get all by simply following the link '"programs from the textbook" and then go to 00-zip-files and get 09-Efficiency-and-ADTs.zip and unzip it under directory X. I assume that you already got the booklib and installed it under directory X, as we described in previous recitations (if not, please follows the instructions at the end of this recitation to get booklib and 09-Efficiency-and-ADTs and save them under directory X) Then go to 09-Efficiency-and-ADTs, and simply say make to compile editor.c program with different implementation of buffer ADT. Then run editor program. After compiling/testing existing client/diver program called array-editor, stack-editor, and list-editor that uses different implementations of buffer ADT, you need to implement the following functions under single linked list in listbuf.c (you can try to implement them under other representations (i.e., array and stack) later at your own time) void ReplaceCharlnBuffer(bufferADT buffer, char oldch, char newch); When this function is called,t should start searching from the current cursor position, looking for the next occurrence of the character oldch in the rest of the buffer If it finds it, simply replace oldch with newch. Search should leave the cursor after the last character replaced in the buffer If oldch does not occur between the cursor and the end of the buffer, then there is nothing to replace and thus search should leave the cursor unchanged (in the original place) int SearchStrBuffer(bufferADT buffer, char* str); When this function is called, it should start searching from the current cursor position, looking for the next occurrence of the string str in the rest of the buffer I If it finds it, search should leave the cursor after the found string and return the valuc TRUE or 1 If the string str does not occur between the cursor and the end of the buffer then scarch should lcavc the cursor unchanged and return FALSE or 0 First, you need to add the above prototypes into buffer.h. * Second, you need to implement them in listbuf.c * Third, you need to update editor.c so that you can call those functions. So include the following in editor.o: o If user enters: Rxy, your editor.c should call ReplaceCharInBuffer (buffer, 'x', 'y') to replace all the occurrences of character 'x' with character 'y' after the cursor If user enters: Sxyz, your editor.c should call SearchStrBuffer (buffer, "xyz") to search string "xyz" in the buffer after the cursor o CS 2123 Data Structures Recitation Exercise 09 (Library Improving bufferADT implementations with search/replace functions) As in the previous recitations/hw, first you need to get some already implemented programs from the textbook. Specifically, get all the files under 09-Efficiency-and-ADTs from the class web page. You can get all by simply following the link '"programs from the textbook" and then go to 00-zip-files and get 09-Efficiency-and-ADTs.zip and unzip it under directory X. I assume that you already got the booklib and installed it under directory X, as we described in previous recitations (if not, please follows the instructions at the end of this recitation to get booklib and 09-Efficiency-and-ADTs and save them under directory X) Then go to 09-Efficiency-and-ADTs, and simply say make to compile editor.c program with different implementation of buffer ADT. Then run editor program. After compiling/testing existing client/diver program called array-editor, stack-editor, and list-editor that uses different implementations of buffer ADT, you need to implement the following functions under single linked list in listbuf.c (you can try to implement them under other representations (i.e., array and stack) later at your own time) void ReplaceCharlnBuffer(bufferADT buffer, char oldch, char newch); When this function is called,t should start searching from the current cursor position, looking for the next occurrence of the character oldch in the rest of the buffer If it finds it, simply replace oldch with newch. Search should leave the cursor after the last character replaced in the buffer If oldch does not occur between the cursor and the end of the buffer, then there is nothing to replace and thus search should leave the cursor unchanged (in the original place) int SearchStrBuffer(bufferADT buffer, char* str); When this function is called, it should start searching from the current cursor position, looking for the next occurrence of the string str in the rest of the buffer I If it finds it, search should leave the cursor after the found string and return the valuc TRUE or 1 If the string str does not occur between the cursor and the end of the buffer then scarch should lcavc the cursor unchanged and return FALSE or 0 First, you need to add the above prototypes into buffer.h. * Second, you need to implement them in listbuf.c * Third, you need to update editor.c so that you can call those functions. So include the following in editor.o: o If user enters: Rxy, your editor.c should call ReplaceCharInBuffer (buffer, 'x', 'y') to replace all the occurrences of character 'x' with character 'y' after the cursor If user enters: Sxyz, your editor.c should call SearchStrBuffer (buffer, "xyz") to search string "xyz" in the buffer after the cursor o

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

More Books

Students also viewed these Databases questions

Question

Explain how IT outsourcing can lead to loss of strategic advantage.

Answered: 1 week ago