What's the conversion from C++ to assembly code x86
int findMinIndex (int integer_array[], int i, int j)
{
// C code to be converted to x86 assembly
/*
int iMin = i;
// test against elements after i and before j to find the
smallest
for ( i ; i < j; i++) {
// if this element is less, then it is the new minimum
if (integer_array[i] < integer_array[iMin]) {
// found new minimum; remember its index
iMin = i;
}
}
return iMin;
*/
void selectionSort (int integer_array[], int array_size)
{
// C code to be converted to x86 assembly
/*
int j;
int iMin;
int temp;
// advance the position through the entire array
//
// (could do j < n-1 because single element is also
min element) //
for (j = 0; j < array_size-1; j++) {
// find the index of min element
in the unsorted a[j .. n-1] //
iMin = findMinIndex
(integer_array, j, array_size);
if(iMin != j) { // swap
values
temp =
integer_array[iMin];
integer_array[iMin] = integer_array [j];
integer_array[j]
= temp;
}
}
*/
We need at least 10 more requests to produce the answer.
0 / 10 have requested this problem solution
The more requests, the faster the answer.
What's the conversion from C++ to assembly code x86 int findMinIndex (int integer_array[], int i, int...
Selection sort is often the first sorting algorithm covered in introductory computer science courses. Java code that uses selection sort to place the elements of an integer array into non-decreasing order is shown here: public void swapNumbers(int i, int j) { int temp = numbers[i]; /* put numbers[i] somewhere to keep it safe */ numbers[i] = numbers[j]; /* put numbers[j] at index i */ numbers[j] = temp; /* put numbers[i] at index j */ } public void selectionSort(int[] numbers) {...
I need help of how to include the merge sort code into this counter code found below: #include<iostream> using namespace std; int bubble_counter=0,selection_counter=0; // variables global void bubble_sort(int [], int); void show_array(int [],int); void selectionsort(int [], int ); int main() { int a[7]={4,1,7,2,9,0,3}; show_array(a,7); //bubble_sort(a,7); selectionsort(a,7); show_array(a,7); cout<<"Bubble counter = "<<bubble_counter<<endl; cout<<"Selection Counter = "<<selection_counter<<endl; return 0; } void show_array(int array[],int size) { for( int i=0 ; i<size; i++) { cout<<array[i]<< " "; } cout<<endl; } void bubble_sort( int array[],...
I'm trying to code a C program so it sorts an array of integer numbers of size n in ascending order. My code is written below but its not working properly, its giving me errors, I think my sort and swap functions aren't done right maybe, please help and fix. It says "undefined reference to "SelectionSort" as an error. But the question asks to not change the PrintArray and Main function. #include <stdio.h> void PrintArray(int size, int array[]) { for...
***Please give comments and show it running*** Create a MIPS program that gets a set of numbers from the user, sorts them using selection sort, and displays the sorted numbers on the screen. You should create a subprogram to do the selection sort, sending it the length and address of the array. This is the pseudo code for the structure the selection: for (int i = 0; i < aLength-1; i++) { /* find the min element in the...
How can I convert the following C code to MIPS Assembly? +++++++++++++++++++++++++++++++++ MIPS main program ++++++++++++++++++++++++++++++++ .data # Defines variable section of an assembly routine. array: .word x, x, x, x, x, x, x, x, x, x # Define a variable named array as a word (integer) array # with 10 unsorted integer numbers of your own. # After your program has run, the integers in this array # should be sorted. .text # Defines the start of the code...
The following code snippet is for C++ int selection_Sort(int A[ ], int n) { int I, j, small, temp; for( i = 0; i < n-1; i++) { small = i; for(j = i + 1; j < n; j++) { if ( A[ j ] < A[ small ] small = j; } temp = A [ i ]; A[ i ] = A[small]; A[small] = temp; } } Please explain in rich detail the logic behind every execution...
Hello this is my java sorting algorithm program i need all of my errors corrected so I can run it. thank you!! import java.util.Scanner; public class SortingAlogs { public static void main(String[]args){ int array [] = {9,11,15,34,1}; Scanner KB = new Scanner(System.in); int ch; while (true) { System.out.println("1 Bubble sort\n2 Insertion sort\n3 Selection sort\n"); ch = KB.nextInt(); if (ch==1) bubbleSort(array); if (ch==2) insertion(array); if (ch==3) Selection(array); if (ch==4) break; print(array); System.out.println(); } }...
Please help me debug the following code
#include
int main(void){
int a = 11, b = 5;
int *ptr1 = &a, *ptr2 = &b;
printf("%d %d\n", *ptr1, *ptr2);
swap(&ptr1, &ptr2);
printf("%d %d\n", *ptr1, *ptr2);
minimum(ptr1, ptr2);
printf("%d %d\n", a, b);
return 0;
}
// Part A
void swap(int **ptr1, int **ptr2){
int *temp = *ptr1;
*ptr1 = *ptr2;
*ptr2 = temp;
return;
}
// Part B
void minimum(int *ptr1, int *ptr2){
if(*ptr1 > *ptr2){
*ptr1 = *ptr2;
}else{
*ptr2 =...
Translate the following piece of code into MIPS assembly. int x, y; int A=100, B=15, C=19, D=21; main(){ x = A + B; y = C + D; if (x > y) swap(&x,&y); } int swap (int *arg1,int *arg2) { int temp; temp = *arg1; *arg1 = *arg2; *arg2 = temp; }