Discussion Board
Go to the previous messageGo to the following message
Current Forum: Homework 3 Forum
Date: Thu Sep 27 2001 11:24 am
Author: Cipriani, Jason A. <jac4@andrew.cmu.edu>
Subject: Re: search function

yeah. as richard implies, that is silly.

search is supposed to return a line number. nothing more, nothing less. there is no distinction between the first, second, third, etc. times that word appears on a line.

read the homework description:

"The search function returns the line number on which word occurs, starting the search from line number mark. For example, if word is “hello” and mark is 30, you should start from line number 30 (inclusive) and look for the word “hello”, and if it occurs, returning the line number of the next occurrence, -1 if the word does not appear any more times in the file."

it specifically asks for line numbers.

besides, how would you implement such a search function? how would you chose to return information about the number of occurences of a word on a given line? would you return the count of a word on one line? you can't do that, because search() must return a LINE NUMBER. would you have search() return the same line N times before moving on, where N is the number of times that a word appears on a line? sure you could do that, but that implies that search() would need to be "reset" each time you wanted to start over. sure, search could automatically reset itself if it is called with a different word or mark than the last time it gets called... but why?

it just seems like a lot of extra work to do something that isn't even supposed to be done.

granted it would be more "robust"... but its not what the assignment asks for. implementing a search like that would not be going "above and beyond the call of duty"... it would just be doing the homework incorrectly... if you want extra points, write approximation().

but, that's just my opinion

jason
Post response

Go to the previous messageGo to the following message
Current Thread Detail:
search function      Durham, Patrick K.      Wed Sep 26 2001 2:22 pm       
Re: search function      White, David      Wed Sep 26 2001 3:31 pm       
Re: search function      Chen, Richard      Thu Sep 27 2001 12:15 am       
Re: search function      Cipriani, Jason A.      Thu Sep 27 2001 11:24 am       
Re: search function      White, David      Thu Sep 27 2001 11:49 am       
Re: search function      White, David      Thu Sep 27 2001 11:52 am       
Re: search function      Danish, Matt R.      Fri Sep 28 2001 11:44 am       
Re: search function      Cipriani, Jason A.      Fri Sep 28 2001 5:32 pm       
Re: search function      Yuen, John      Thu Sep 27 2001 12:06 pm       

Back to previous screen