Please analyze the run time of the following two programs in terms of the tightest Big O.
Q: What will be displayed in the screen after the following program executes, provided the formal…
A: After the execution of the code we get some errors.
Q: Write a program of multiply two matrices without using functions?
A: Sample Response: //C++ program to multiply two matrices without using functions#include…
Q: iterate func s 0 = s iterate func s n = func (iterate func s (n-1)) What is the output of the…
A: see first x is changed to 2x then rest of the things are done
Q: What is the effect of single sqrtss and double sqrtsd if the description is Floating-point square…
A: What is the effect of single sqrtss and double sqrtsd if the description is Floating-point square…
Q: Suppose a value is bound to a variable at run time, as opposed to compile time. This is called…
A: Your answer is given below.
Q: Write a Java program that simulates a calculator. It first displays a menu like the one given below:…
A: To give calculator program
Q: Consider the following program: int a- 1; int main(void)H a- al2:0; return n(a); int n(int x) if (x)…
A: The main will return 2.
Q: Identify the errors in the following program segment and describe how to correct them. You can…
A: Given: FloatProperty f=new FloatProperty(1.0); FloatProperty f2=new FloatProperty(2.0);…
Q: By looking at this formula, F=9/5C+32, it can be used to convert Celsius temp to Farenheight. Write…
A: Below is the answer:
Q: 3. Write a program that takes one argument, a positive integer n, and prints the product 1*2*..*n.…
A: Step 1: Check whether the number of command-line arguments not equals to 2. Step 2: If the condition…
Q: What is the Following code doing? for y in range(img.getHeight(): for x in range(img.getWidth()): p…
A: I have Provided this answer with full description in step-2.
Q: Which of the following is/are valid ways to allocate memory for an integer by dynamic memory…
A: Option A which is the int *p = new int(100); allocates memory at run time and the new operator is…
Q: Write the output of the following program let name = 'Juliya'; { let name = 'Oliviya'; }…
A: Required:- Write the output of the following programlet name = 'Juliya';{ let name = 'Oliviya';}…
Q: Decryption Key A|B|C|D|E|F|G|H|I|J|K|L|M N|O|P|Q|R|S|T|U| V| W|X|Y|Z (letter above equals below, and…
A: Here is the c++ program of above problem. See below step for code.
Q: Write a Java program that simulates a calculator. It first displays a menu like the one given below:…
A: while(true){ menu(); char c = sc.next().charAt(0); if(c == '+') { double[] values…
Q: If you forget to declare the variable i in the following, what kind error will be raised? c++ while…
A: Variable are the name Which stores values.
Q: reate a program implementing try, except and finally
A: NOTE: SINCE THE LANGUAGE IS NOT MENTIONED I HAVE USED PYTHON FOR THE SOLUTION. Define variable x…
Q: main() { int arr[] = {'A', 'B','C','D'}; int i; 6 7 8 9 for (i = 0; i <= 3; i++) 10 printf("\n%d",…
A: Answer- There is no error occur in the given code.I write it to the C compiler and execute it and…
Q: Note: Please answer the question in Python only: Citizens of Byteland play the game regularly. They…
A: Coded using Python 3 language.
Q: If you are not able to specify the output of the above program exactly, explain why.
A: The sample output of the given program is:
Q: Given this function below: int tribonacci(int n) { if (n<=3) return 3; else return tribonacci (n-1)…
A: 1) The tribonacci numbers are like the Fibonacci numbers, but instead of starting with two…
Q: Compile: g++ -Wall -pedantic-errors -o exclusive exclusive.cpp g++ -Wall -pedantic-errors -o…
A: How do I make the following commands into a makefile in C++ on the terminal? I have attached my…
Q: 23. The following python program can work with parameters. def f(x): def f1(*args, **kwargs):…
A: The above python program can work with combining keyword and non keyword variable length parameters.…
Q: What is the runtime analysis (expressed using Big-O notation) of the following code snippet?…
A: The above question is solved in step 2 :-
Q: void foo(int n) { } int i; for (i = 0; i 0) i = 1 / 2;
A:
Q: void MyFunc (int n). if(n return; MyFunc(n-1); System.out.printin(n); what is the objective of this…
A: Java is a programming language. It contains extensive libraries (package). It can be used to create…
Q: Which of the following is NOT a reserved word in Java? Group of answer choices for loop do while
A: Reserved words: Words that have a pre-defined meaning. Reserved words cannot be used as names of…
Q: The command int(s,var,a,b) is used to solve definite and indefinite integrals. True or False
A: In MATLAB we know that F = int(expr,var,a,b) is used for computing the definite integral of expr…
Q: CAN YOU CONVERT FROM C TO C++? #include #include #include int r_pc[3] = {0, 0, 0}; int…
A: code is given below;
Q: Consider the following declarations. In each case, write the English name of the type of x. Example:…
A: (a) int *x[];(b) int (*x)[];(c) double **x;(d) unsigned long int (*x[])[n]; Given the declarations.
Q: Which represents a tight upper bound on the runtime of the following code using Big-O notation: sum…
A: We are given a code and we are going to find out upper bound for it:
Q: What problem arises in running the following program? How do you fix it?class A:def _ _init_ _(self,…
A: Python is an interpreter and it is a high level language. It also is an object oriented language.…
Q: By using class interface write a program to read three numbers and using a friend function to find…
A: Algorithm: Start Define a class with one virtual method and one friend method. Implement the 2…
Q: Q2) Write and test the following power() function that returns x raised to the power n, where n can…
A: C++ Code for Above : #include <bits/stdc++.h> using namespace std; //power function double…
Q: As usual, we recommend you approach the program in stages, rather than trying to complete everything…
A: Java code : EncriptionMachine.java import java.util.*; public class EncriptionMachine{ //Method…
Q: What is the result after execution of the following code: int i 1, x 4: while (++i <= 10) { x++:…
A: The given C++ code is executed and the result which is the correct answer is provided with…
Q: What problem arises in running the following program? How do you fix it?class A:def _ _init_ _(self,…
A: Step 1:- Program:- class A:def _ _init_ _(self, i):self.i = idef main():a = A()print(a.i)main() #…
Q: Find out (add code to print out) the address of the variable x in foo1, and the variable y in foo2.…
A: #include <stdio.h>void foo1(int xval){int x;x = xval;/* print the address and value of x here…
Q: write the run program of command windows function c = fact (n)v = 1;for i = 1:n v = v *i ;end *
A: In this question, we are asked to choose correct option out of 4 options. Given: A command line…
Q: What problem arises in running the following program? How do you fix it?class A:def _ _init_ _(self,…
A: Step 1:- Program:- class A:def _ _init_ _(self, i = 0):self.i = iclass B(A):def _ _init_ _(self, j =…
Q: Write a program for a calculator. Write the following sub getOption, getNumbers, printResult,…
A:
Q: Consider the following source code : c = a + b d = c c = c – e a = d – e b = b * e b = d/b…
A: Given source code is c = a + b d = c c = c – e a = d – e b = b * e b = d/b
Q: Which represents a tight upper bound on the runtime of the following code using Big-O notation:
A: O(nlogn) represents tight upper bound on the runtime of the following code using Big-O notation
Q: Write out the memory snap shot of all declared variables after the following is executed. double…
A: Note: Answering in C++ as no language is mentioned. Input : Value of a. Value of n. Output :…
Q: Show that the following statement is true: n?ε Ω(nlog n)
A:
Please analyze the run time of the following two
Step by step
Solved in 2 steps
- /** * Write a Java function to determine if the elements of an array can be split into two groups such that the sum of one group is a non-zero multiple of 10 and the sum of the other group is odd. Your solution must use recursive backtracking. <code> * Example: * Given: {1, 2, 6, 3, 1} * Result: true because {1,2,6,1}, {3} is one possibility. * * Example: * Given: {4, 3, 5, 2} * Result: false * </code> */ public static boolean splitOdd10(int[] num) { }In java Develop a function that accepts an array and returns true if the array contains any duplicate values or false if none of the values are repeated. Develop a function that returns true if the elements are in decreasing order and false otherwise. A “peak” is a value in an array that is preceded and followed by a strictly lower value. For example, in the array {2, 12, 9, 8, 5, 7, 3, 9} the values 12 and 7 are peaks. Develop a function that returns the number of peaks in an array of integers. Note that the first element does not have a preceding element and the last element is not followed by anything, so neither the first nor last elements can be peaks. Develop a function that finds the starting index of the longest subsequence of values that is strictly increasing. For example, given the array {12, 3, 7, 5, 9, 8, 1, 4, 6}, the function would return 6, since the subsequence {1, 4, 6} is the longest that is strictly increasing. Develop a function that takes a string…In java: Develop a function that accepts an array of integers and returns their average. Develop a function that accepts an array of integers and a threshold value from the user. The function returns how many values in the array are strictly greater than the cutoff. Using the functions written for #1, #3, and #4, find the number of values above average in two randomly generated arrays. Develop two functions:a. a function that returns the index of the maximum value in an array of integers passed by a caller, the caller prints the returned index and the value at that indexb. a function that returns the index of the alphabetically first value in an array of strings, the caller prints the returned index and the value at that inde Develop two functions:a. a function that swaps the alphabetically first value in an array of Strings with the first value in the array. Call this function twice on two different arrays of Strings; in the caller, use the function written for #2b to display…
- In python, Problem Description:Sheldon and Leonard are physicists who are fixated on the BIG BANG theory. In order to exchange secret insights they have devised a code that encodes UPPERCASE words by shifting their letters forward. Shifting a letter by S positions means to go forward S letters in the alphabet. For example, shifting B by S = 3 positions gives E. However, sometimes this makes us go past Z, the last letter of the alphabet. Whenever this happens we wrap around, treating A as the letter that follows Z. For example, shifting Z by S = 2 positions gives B. Sheldon and Leonard’s code depends on a parameter K and also varies depending on the position of each letter in the word. For the letter at position P, they use the shift value of S = 3P + K. For example, here is how ZOOM is encoded when K = 3. The first letter Z has a shift valueof S = 3 × 1 + 3 = 6; it wraps around and becomes the letter F. The second letter, O, hasS = 3 × 2 + 3 = 9 and becomes X. The last two letters…Implement a program that contains the following two functions: 1. A function that accepts a list of numbers as an argument, the function should recursively calculate the sum of all the numbers in the list and returns that value2. A function that uses recursion to raise a number to a power. The function should accept two arguments: the number to be raised, and the exponent. Assume the exponent is a positive integerJAVA Question 2: For two integers m and n, their GCD (Greatest Common Divisor) can be computed by a recursive method. Write a recursive method gcd(m,n) to find their Greatest Common Divisor. Method body: If m is 0, the method returns n. If n is 0, the method returns m. If neither is 0, the method can recursively calculate the Greatest Common Divisor with two smaller parameters: One is n, the second one is m mod n (or m % n). The recursive method cannot have loops. Note: although there are other approaches to calculate Greatest Common Divisor, please follow the instructions in this question, otherwise you will not get the credit. main method: Prompt and read in two numbers to find the greatest common divisor. Call the gcd method with the two numbers as its argument. Print the result to the monitor. Example program run: Enter m: 12 Enter n: 28 GCD(12,28) = 4 And here is what I have so far, package CSCI1302;import java.util.*;public class RecursionDemo { public static void…
- please help me with the following 1) make a sierpenski triangle using java and recursion. Make it similar to the code below. And please comment the code 2) Please make the follow code out put on the console. It a t square fractal import java.awt.image.*;import java.awt.Color;import java.io.*;import javax.imageio.*; public class Main{ static final int DIMENSION = 1000; static BufferedImage image = new BufferedImage(DIMENSION, DIMENSION, BufferedImage.TYPE_INT_RGB); static final int WHITE = Color.WHITE.getRGB(); static final int BLACK = Color.BLACK.getRGB(); private static void drawSquare(int x, int y, int side) { if (side <= 0) return; else { int left = x - side/2; int top = y - side/2; int right = x + side/2; int bottom = y + side/2; for (int i = left; i < right; i++) for (int j = top; j < bottom; j++) { image.setRGB(i, j, BLACK); }…Implement the vacuum cleaning agent function in Python/Java for the scenario described below: Consider two-dimensional Boolean array of size m x n (m and n can each be equal to 4) where m is the number of rows, and n is the number of columns. Obtain numerical positive integer values for m and n as inputs from the user. Generate random numbers and scale them down to either a “0” or a “1” according to whether they represent “Clean” or “Dirty”, respectively. After filling the array with 0s or 1s, start at some random array position indicating the initial position of the vacuum cleaner. First check if at that current position, there is the presence of a “Dirt” or not determined by whether 0 or 1 is filled in at that initial position of the vacuum cleaner. If there is a “Dirt”, clean it, and if there is no “Dirt” do a No-operation. After this is done, generate random numbers modulo 4 to obtain random numbers 0, 1, 2, 3 indicating whether to take a left, right, up or down correspondingly. If…Do not use static variables to implement recursive methods. USING JAVA USING: // P4 public static int min(int [] a, int begin, int end) { } Implement a recursive method min that accepts an array and returns the minimum element in the array. The recursive step should divide the array into two halves and find the minimum in each half. Demonstrate the output of min on the array int [] a = { 2, 3, 5, 7, 11, 13, 17, 19, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 23, 29, 31, 37, 41, 43 }
- Artificial Intelligence (Part - 2) ==================== The Towers of Hanoi is a famous problem for studying recursion incomputer science and searching in artificial intelligence. We start with N discs of varying sizes on a peg (stacked in order according to size), and two empty pegs. We are allowed to move a disc from one peg to another, but we are never allowed to move a larger disc on top of a smaller disc. The goal is to move all the discs to the rightmost peg (see figure). To solve the problem by using search methods, we need first formulate the problem. Supposing there are K pegs and N disk. (2) What is the size of the state space?Implement a recursive C++ function which takes an integer array (A) and the starting (start) and ending(end) indices of that array, and returns the sum of all elements present in that array. The prototype ofyour function should be:int findSum (int* A, int start, int end)Write a Java program: A palindromic number or palindrome number is a number that remains the same when its digits are reversed. Like 16461. Write a Java program that implements the helper method isPalindrome() that decides whether a given int number is a palindrome or not. Do not use ready String class functions like reverse() or arrays and array functions!!! Input FormatA line contains an Integer N. Constraints 1 <= N <= 999999 Output FormatA text containing either "This number is a palindrome" or "This number is not a palindrome" (the code should have the structure as in the picture)