Write a pseudo code of an algorithm that returns "yes" if the input array (contains integers) is a palindrome, and no if it is not (means first item is the same as last one, second one is the same as second from the last & ...)
Pseudocode
CheckArrayPalindrome(A, n)
START
DECLARE Flag =
false
DECLARE i =
0
WHILE (i
<= n/2 and n != 2)
IF (A[i] != A[n - i - 1])
Flag = true;
break;
i += 1;
IF Flag ==
1
PRINT "NO"
Else
PRINT "YES"
END
Write a pseudo code of an algorithm that returns "yes" if the input array (contains integers)...
(a) Give the pseudo-code for a recursive algorithm called Find_Smallest(A, n) that returns the value of the smallest element in an array of n integers called A. Assume the elements in the array are at locations A[1]..A[n]. (b) Give a recurrence T(n) for the running time of your algorithm. (c) Solve the recurrence in part (b)
java code
Write a method called reverse that takes an array of integers as an input and returns the same values in reverse order as the output. Test your method in the main.
Design an algorithm for the following description. Solution can
be done in pseudo-code or steps of the algorithm.
Describe and analyze an algorithm that takes an unsorted array A of n integers (in an unbounded range) and an integer k, and divides A into k equal-sized groups, such that the integers in the first group are lower than the integers in the second group, and the integers in the second group are lower than the integers in the third group,...
Code in C++ please! Write a function that takes an array of integers as an input parameter (the address of the first value of the array). It returns nothing. It prints out the array as a single line, with commas between each number, and when the array is finished being printed, it prints an endl; so that we flush the buffer and move to a new line. (I’m having you write this function because you’ll be wanting to print out...
Question 4 6 points You have to design an algorithm that verify if an array contains duplicate values. This algorithm simply returns true as soon as two identical values are found. To perform this task you must not change the order of the elements in the array (so you cannot sort it) or use an auxiliary array. Write the pseudo-code of this algorithm and give the Big-2 complexity in the worst case.
Write a Java program that reads a 1D array of integers from standard input and returns it.
Title Algorithms Functional Requirements and Marks using c++ Write a pseudo-code algorithm for the following problems: Detect if three angles can make a triangle. (1) Hint: In a triangle, the sum of all angles is 180. Switch the value of two numbers (1) If a=2 and b=5, we want to have a=5 and b=2 at the end. Remember that a=b will result in the old value to of a to get lost. Receive a set of numbers and find...
Discrete Mathematics
22. Let r be a relation on the integers such that (a, b) E r if and only if a +b 1. What is the transitive closure of r? 23. Write an algorithm in pseudo code that converts numbers in decimal representation to octal (base 8) representation 24. Prove that the set of integers in countable
22. Let r be a relation on the integers such that (a, b) E r if and only if a +b 1....
The input is an array of N integers ( sorted ) and an integer X. The algorithm returns true if X is in the array and false if X is not in the array. Describe an algorithm that solves the problem with a worst case of O(log N) time.
Write a program that asks the user to input 10 integers of an array. The program then inserts a new value at position (or index) given by the user, shifting each element right and dropping off the last element. For example, in the sample input/output below, the program will insert the value 30 at index 3. All the previous numbers of the array starting from position 3 (i.e., 7 1 20 9 23 8 22 will be shifted one position...