Algo

+1 Rehman . · April 4, 2015
i want to ask an algo of a problem which is : "Take an array and program it like it should print the smallest number " it should be like linear sort but dont sort it

Post a Reply

Replies

- page 2
Oldest  Newest  Rating
+1 Dol Lod · April 6, 2015
The logic itself is fine. 

However, what should you do if the array passed in is NULL? I would either return min or throw an exception.

In C++, arrays do not have lengths built into them. You have to have the size stored separately because of this. 
+1 Rehman . · April 6, 2015
Thanks for endorsing logic, yes maybe i should cover more depth of knowing how do we calculate the length of array as well 
0 Dol Lod · April 6, 2015
There are multiple fixes 

Approach 1 simplest: Make the size of the array a parameter to pass in. 

Approach 2: Make a templated class to simulate a java array. You could have an int member in the class to represent the length and a pointer to initialize using a method. You could make the length a public member or have a method to return the length. 
  • 1
  • 2

General Chat

107,075 followers
About

Chat about anything non-computer related including, music, movies, tuna sandwiches, and more!

Links
Moderators
Bucky Roberts Administrator