method to return the position of the smallest item in an array
1. Complete the algorithm below for a method to return the position of the smallest item in array data with bounds 0..limit. What is the time complexity of this algorithm?
positionOfSmallest(data[0..limit])
1. set largest = data[0].
2. set indexOfLargest = 0.
3. set index = 1.
happy if anyone can answer this questions as soon as possible
thank you!!!!!!!
Re: method to return the position of the smallest item in an array
izzahmed,
Please read, Announcements - What's Wrong With My Code? , we are not a homework service for you. You must show an attempt at completing the question and outline where you are stuck and what you do not understand.
This question is very simple, and you should be able to work it out just by thinking about it. Rather than just copy pasting and hoping someone will complete it for you.
Regards,
Chris
Re: method to return the position of the smallest item in an array
Quote:
Originally Posted by
izzahmed
happy if anyone can answer this questions as soon as possible
Done! I hope you're happy.
Re: method to return the position of the smallest item in an array
Quote:
Originally Posted by
izzahmed
1. Complete the algorithm below for a method to return the position of the smallest item in array data with bounds 0..limit. What is the time complexity of this algorithm?
positionOfSmallest(data[0..limit])
1. set largest = data[0].
2. set indexOfLargest = 0.
3. set index = 1.
happy if anyone can answer this questions as soon as possible
thank you!!!!!!!
1. Turn on your PC.
2. Think for a while about what you want to do.
3. Try to write algorithm on a page
4. Implement it.
5. Try to run it.
6. IF successful, good luck
7. ELSE try to think or post here what are the errors.
8. We will try to help you learning through those errors.
9. You will learn and will get your problem solved.
Was this the algorithm you wanted us to complete?
Re: method to return the position of the smallest item in an array
No need to be mean man lol
He might be asking people to fix his code for him, It simply means his new to java.
Just post a few booklets full of data for him to read :D
Re: method to return the position of the smallest item in an array
Quote:
Originally Posted by
macko
No need to be mean man lol
He might be asking people to fix his code for him, It simply means his new to java.
Just post a few booklets full of data for him to read :D
I was never mean....
He wanted us to write an algorithm for him and i did that. I hope this algorithm will teach him some of the forum rules and learning rules too.