Question

Write an algorithm, without using compound conditional expressions, that takes in three integers and determines if they are all distinct. On average, how many comparisons does your algorithm do? Remember to examine all input classes.

Answer #1

please please thumbs up!!

hope it will help uh out!!

Code::

(IN JAVA PROGRAMMING LANGUAGE)

---------------------------------------------------------

**NOTE :: HERE BELOW IS THE ALGORITHM WITHOUT USING
COMPOUND COMDITIONAL EXPRESSION AS YOU WANT FOR ABOVE
PROBLEM::-**

import java.util.Scanner;

class Distinct {

public static void main (String args[])

{

int x, y, z;

Scanner scanner = new Scanner(System.in);

System.out.println("Enter first number");

x = scanner.nextInt();

System.out.println("Enter second number");

y = scanner.nextInt();

System.out.println("Enter third number");

z = scanner.nextInt();

int check = 0;

if (x != y)

if (y !=
z)

if (x != z)

check = 1;

if (check == 1)

System.out.println("Numbers
are distinct");

else

System.out.println("Numbers
are not distinct");

}

}

-------------------------------------------------

output::

**IN GENERAL WE HAVE TO MAKE THREE
COMPARISIONS**

(a) Write an algorithm (use pseudo-code) to determine whether a
function
f ∶ Z100 → Z100 is surjective. That is, supply a “Method” to go
with
Input: A function (array) f with f(i) ∈ Z100 for i = 0, 1, . . . ,
99.
Output: Boolean B. B=‘true’ if f is surjective, ‘false’
otherwise.
Try to make your algorithm as efficient as possible.
Do NOT include an implementation of your algorithm in a programming
language.
(b) How many comparisons...

Write an application in Java which includes an algorithm that
takes an array of any size, selects the high and low integer from
the array of integers with each pass and builds a new array of
integers by inserting the high and low selection with each pass.
Your output should show the original array of integers and the
output of each pass on a new line.
Note: You can assume all integers are positive, but your
code must work for...

Using nested loops, write a function called primes(a,b) that
takes in two positive integers a and b (where a<b). Then simply
RETURNS a string containing all the prime numbers between a and b
(or if there are none, the string "No Primes"). You should check
that a and b are valid inputs, that is, that a and b are integers
such that a<b (otherwise, the function should print “No
Primes”). Three sample calls of your function (in IDLE) should
produce...

Arrays, loops, functions: Lotto
Element Repeated Function
Write a function that that takes as parameters an array of ints,
an int value named element, and an int value named end. Return a
bool based on whether the element appears in the array starting
from index 0 and up to but not including the end index.
Generate Random Array
Write a function that takes as parameters an array of integers
and another integer for the size of the array. Create a...

Write a function in c using #include <stdio.h> that takes
a one-dimensional integer array and returns the index of the first
occurance of the smallest value in the array. Your function must be
able to process all the elements in the array. Create a function
prototype and function definition (after the main function). Your
main function should declare a 100 element integer array. Prompt
the user for the number of integers to enter and then prompt the
user for each...

USING PYTHON do all the he problems using while loop , continue
and break 1-This problem provides practice using a while True
loop.write a function named twoWords that gets and returns two
words from a user. The first word is of a specified length, and the
second word begins with a specified letter.The function twoWords
takes two parameters: an integer, length, that is the length of the
first word and a character, firstLetter, that is the first letter
of the...

(For Python)
Evaluating Postfix Arithmetic Expressions. In this project you
are to implement a Postfix Expression Evaluator as described in
section 7-3b of the book. The program should ask the user for a
string that contains a Postfix Expression. It should then use the
string's split function to create a list with each token in the
expression stored as items in the list. Now, using either the stack
classes from 7.2 or using the simulated stack functionality
available in a...

Please create an array of Leg objects, one constructor that
takes three parameters as constant C string, and one number
representing the distance in miles between the two cities
Write a code block to create a static array (that is, not
dynamic and not a vector) of 3 Leg objects using
city names of your choosing. That's THREE objects, each
created using THREE parameters. For example, the Leg class
declaration looked like,
class Leg
{
const char* const startCity;
const...

The following algorithm finds the initial substring of y
that can be reversed and found in y. For example,
longestInitialReverseSubstringLength(“aabaa”) = 5, because “aabaa”
is the same string forwards and backwards, so the longest initial
substring that can be reversed and found in the string is “aabaa”.
Also, longestInitialReverseSubstringLength(“bbbbababbabbbbb”) is 6,
because “babbbb” can be found in the string (see color-highlighted
portions of the string), but no longer initial string exists
reversed in any part of the string.
longestInitialReverseSubstringLength(String
y)...

For this assignment, you need to write a parallel program in C++
using OpenMP for vector addition. Assume A, B, C are three vectors
of equal length. The program will add the corresponding elements of
vectors A and B and will store the sum in the corresponding
elements in vector C (in other words C[i] = A[i] + B[i]). Every
thread should execute an approximately equal number of loop
iterations. The only OpenMP directive you are allowed to use
is:...

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 5 minutes ago

asked 10 minutes ago

asked 10 minutes ago

asked 12 minutes ago

asked 16 minutes ago

asked 22 minutes ago

asked 53 minutes ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago