• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

some difficult questions!

 
liu hao
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Answers deleted: please don't provide straight answers.]
 
Rob Spoor
Sheriff
Pie
Posts: 20671
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20671
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic