Skip to content

Conversation

@AdolfCarr
Copy link

I'd been on test week at school, that's why I'd a delay with this delivery, I apollogize for that.

Greeting!!!

public void ordenamiento(int[] arr) {
for(int i = 0; i < arr.length; i++){
for(int j = i+1; j< arr.length; j++){
if(arr[i]> arr[j]){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puedes ver si hay una mejora de ordenamiento con respecto a tu actual solucion, hay algoritmos mas rapidos que puedes implementar incluso Arrays.sort()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assertion attended, Thanks Christian!!!

return null;
for(int i = 0; i < arr.length; i++){
for(int j = i+1; j< arr.length; j++){
if(arr[i]< arr[j]){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puedes ver si hay una mejora de ordenamiento con respecto a tu actual solucion, hay algoritmos mas rapidos que puedes implementar incluso Arrays.sort()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assertion attended, Thanks Christian!!!

if (datos[i][j].equals(dato)) {
position.setX(i);
position.setY(j);
return position;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

puedes buen uso de metodos setter, aunque tambien puedes devolver la creacion de instancion del objeto Posicion con el new

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assertion attended, Thanks Christian!!!

public String getData(String[][] datos, Posicion posicion) {
return null;
String data;
data = datos[posicion.getX()][posicion.getY()];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aqui puede ahorrarte la asignacion de variable y devolver tal cual la posicion del array

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assertion attended, Thanks Christian!!!

I'd used the divide and conquer technique by implementing Quiksort on the Unidimentional array.
On the getPosition method the return statement was simplified just returning the constructor initialized with the indexes where the seeked data is, instead of initializing the setters explicitly.

On the getData method the declaration of variables was reduced at it's minimum just returning the data on the given position instead of declaring a string variable and assigning it the value at the bidimentional array "datos" that the given position holds.

Great assertions, Thanks for sharing your knowledge Christian!!!
When removing the element is made in time complexity O(1) (constant time), I just replace the erased element by the last element of the array. But when copying the temporal new array to the main array this is made in O(n).

The resize() method increments by two ints sizes only if the current sizes is equal to the capacity of the main array.
get() method prints on raw screen command the element of the main array in the given index
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants