Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/main/java/com/oracle/arrays/impl/MultidimensionalImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,28 @@
import com.oracle.arrays.model.Posicion;

public class MultidimensionalImpl implements Multidimensional {
Posicion position;

@Override
public Posicion getPosition(String[][] datos, String dato) {
position = new Posicion(0, 0);
for (int i = 0; i < datos.length; i++) {
for (int j = 0; j < datos[i].length; j++) {
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!!!

}
}
}
return null;
}

@Override
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!!!

return data;
}

}
24 changes: 23 additions & 1 deletion src/main/java/com/oracle/arrays/impl/UnidimensionalImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,32 @@
public class UnidimensionalImpl implements Unidimensional {
@Override
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!!!

int temp = arr[i];
arr[i]= arr[j];
arr[j]= temp;
}
}
}
}

@Override
public int[] ordenamientoReversa(int[] arr) {
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!!!

int temp = arr[i];
arr[i]= arr[j];
arr[j]= temp;
}
}
}
int cpyArr [] = new int[arr.length];
for(int i = 0; i<arr.length; i++){
cpyArr[i]= arr[i];
}
return cpyArr;
}
}