The GCD values of 2 sets are
GCD(1298, 561) - 11
GCD(1534, 663) - 13
Find the gcd for the following two problems; use the pseudo code. int main GCD (a,...
Consider the following C codes to compute the gcd of two integers. /// code 1 #include <stdio.h> int gcd(int a, int b) { while (a != b) { if (a > b) a = a - b; else b = b - a; } return a; } /// code 2 #include <stdio.h> int getint() { int i; scanf("%d", &i); return i; } void putint(int i) { printf("%d\n", i); } int main()...
Look at the following pseudo code: Binary_search(int a[], int size) { ……….// binary search and return } Selection_Sort(int a[], int z) { …..// do the selection sort } main() { Selection_Sort(array, size); Binary_Search(array, item); } Calculate the time complexity of this code and use O() notation.
c++ 4) Look at the following pseudo code: Binary..search(int a[], int size) { } wel binary search and return Selection Sort(int a[], int z) { ww/ do the selection sort } main { Selection Sort(array, size): Binary. Search(array, item): IS Calculate the time complexity of this code and use 0 ) notation. +12 fa 11.
This code needs to be written in Assembly language using Keil uvision 5. Please use Keil Assembler. Or ARM assembly. Thanks. int main(void) { // initializing int R0 = 5; int R1 = 10; // for loop addition with CMP while(RO <=| 10) R$++; // for loop subtraction without CMP#10 while(R1 > 0) R1--; // if else statement if (RO > 0) R0 = 10; R1 = 10; else | R0 = 20; R1 = 30; // must using branching...
its brr[8] (40%) Convert the following C-pseudo code into MIPS assembly code as a standalone program (including main and all the required directives). You can use any register. You must comply, however, with the convention of register usage. Before writing your code perform an explicit register allocation phase. Note that the C snippet is int arr[8]; int brr[4]-{1, 2, 3, 4, 5, 6, 7, 8) int i-8; while (i>-0) arrli]-brr[i-); (40%) Convert the following C-pseudo code into MIPS assembly code...
Given the following pseudo code: int result; (result is 1 byte) int count; (count is 1 byte) for (result= 10, count= -10; count < result ; count++) { if(count > 2) result--; else result ++; } 1) write an assembly language program that will implement this pseudo code using a while construct. 2) write an assembly language program that will implement this pseudo code using a do-until construct Note: For both 1) and 2), do not forget to include the...
Consider the problem of finding the Greatest Common Divisor (GCD) of two positive integers a and b. It can be mathematically proved that if b<=a GCD(a, b) = b, if (a mod b) = 0; GCD(a, b) = GCD(b, a mod b), if (a mod b) != 0. Write a recursive function called GCD with signature “public static int GCD(int a, int b)” that returns the greatest common divisor of two positive integers a and b with b <= a....
Find out what the following assembly code calculates AREA my code, CODE EXPORT main ALIGN ENTRY main PROC MOVS MOVS MOVS r0,#0 r1,#15 r2,#0 loop CMP BGT MLA ADDS r2,r1 stop re,r2,r2,ro r2,r2,#1 loop % The final result is saved in register r0 stop B stop ENDP END
Write a recursive method in java to find GCD of two integers using Euclid's method. Integers can be positive or negative. public class Recursion { public static void main(String[] args) { Recursion r = new Recursion(); System.out.println(“The GCD of 24 and 54 is “+r.findGCD(24,54)); //6 } public int findGCD(int num1, int num2){ return -1; } }
Write the branch-friendly pseudo code int i = 10; int sum = 0; while (i >= 0) { sum = sum + i; i = i – 1; }