some difficult questions!

liu hao
Greenhorn
Posts: 9
1, To decide whether there are any duplicate values in an array (of over 100 entries), we do not need to first sort the array. TRUE or FALSE?

2,To find the 5th largest element in an array (of over 100 entries), we do not need to first sort the array. TRUE or FALSE?

3,To output both the largest and the smallest elements in an array (of over 100 entries), we must first sort the array. TRUE or FALSE?

Steve Luke
Bartender
Posts: 4181
22
Well, those are some pretty good questions. What do you think the answers are? Why?

You shouldn't expect us to give you the answers to these types of questions, we generally expect you to ShowSomeEffort, which in this case would be provide what you think the answers are and some justification. If you can not decide on an answer let us know exactly where you are hung up so we can help clear your mind.

Ireneusz Kordal
Ranch Hand
Posts: 423

Rob Spoor
Sheriff
Posts: 20707
68
Ireneusz Kordal wrote:1. TRUE
2. TRUE
3. FALSE

What did Steve say about not giving out the answers like that? It's a good thing you didn't provide any motivations for your answers...

liu hao
Greenhorn
Posts: 9
Steve Luke wrote:Well, those are some pretty good questions. What do you think the answers are? Why?

You shouldn't expect us to give you the answers to these types of questions, we generally expect you to ShowSomeEffort, which in this case would be provide what you think the answers are and some justification. If you can not decide on an answer let us know exactly where you are hung up so we can help clear your mind.

I just have no idea about the question. I know if sorting the array, we'll find a duplicate value;we'll do all the task. but if it is necessary i know not. and anyone can explain why nswers. lot of thanks

Rob Spoor
Sheriff
Posts: 20707
68
Ask yourself this: can you find a way, any way, to do it without sorting the array first? It will be easier and more efficient if the array is sorted, but that's not the question.