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...
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[],...
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'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...
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...
***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...
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(); } }...
Modify the sorts (selection sort, insertion sort, bubble sort, quick sort, and merge sort) by adding code to each to tally the total number of comparisons and total execution time of each algorithm. Execute the sort algorithms against the same list, recording information for the total number of comparisons and total execution time for each algorithm. Try several different lists, including at least one that is already in sorted order. ---------------------------------------------------------------------------------------------------------------- /** * Sorting demonstrates sorting and searching on an...
How can i make a counter for the number of exchanges made in the linear algorithm?? The binary counter works but the linear doesn't. Here's my code. #include <iostream> using namespace std; void selectionSort(int[], int, int& ); void showSelection(int[], int); void sortArray(int[], int, int&); void showArray(const int[], int); int main() { int values[25] = { 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24...
I need help fixing my code: In C++ *************** 1) I want to sum the digits of an n*n matrix 2) find the average I have completed the rest ****Do not use C++ standard library. You must use pointers and pointer arithmetic to represent the matrix and to navigate through it. MY CODE: (I have indicated at which point I need help) #include <iostream> using namespace std; void swap(int *xp, int *yp) { int temp = *xp; *xp = *yp;...