I need some help understanding a java program. Do not write loops everywhere whe
ID: 3917646 • Letter: I
Question
I need some help understanding a java program. Do not write loops everywhere where a search is needed. Write the method and call it from all the places you need to search a set for the presence of an element. I may not modify the original arrays once they have been loaded from the files. You do not have to use binary search or any algorithms that take advantage of sorting. You can do simple linear searching using a for loop.
For the xor method, I am not allowed to write loops or declare any arrays. Instead, you must generate the xor of the two incoming arrays with nothing but calls to the other set operations already defined. And write the entire method in a single one line statement.
Explanation / Answer
=================
please try to use above code.. i am making use of the fact that arrays are sorted.. i am not sure why do you want to go for linear search without taking advantage of sorting.
If the reason is complexity, it is not complex, i tell you. Please check the code comments above and you will understand very simply how it should be written. Probably take pen and paper and sketch the flow.. it will help you very much..
Still if you have concerns, please do comment.. i will respond in 5-6 hours probably. Thanks!