Note: No plagarism please! Correct and detailed answer will be Upvoted else downvoted. Thank you! Q. Write Pseudocode: (Provide alternative words for switch - also write full sentence for srand and rand) srand(time(NULL)); int n = rand(); switch (n%2) { case 0: a1 = first; cout << "first text\n"; break; case 1: a1 = second; cout << "second text\n"; }
Q: What is the overall running time of the following code snippet? for(i=0; i<n; i++) for(j=i; j<n;j++)…
A: Time complexity can be defined as the amount of time taken to run the algorithm.
Q: How about we call a positive integer n customary if in the decimal documentation every one of its…
A: Here have to determine about call a positive integer problem statement.
Q: What does the code below do if I answer "s"? Comment on the code to show what the different parts…
A: Given that What does the code below do if I answer "s"? Comment on the code to show what the…
Q: What’s wrong with the following while iteration statement?…
A: What’s wrong with the following while iteration statement?…
Q: Complete the program shown in the 'Answer' box below by filling in the blank so that the program…
A: As per our guidelines we are supposed to answer only one question . Kindly repost other question as…
Q: There are N stairs, and a person standing at the bottom wants to reach the top. The person can climb…
A: Write a C++ program to read the value of integer N from the user and print the number of ways to…
Q: In column H, find women who are white or have over 12 years of school In column I, find women…
A: Here I have provided an image in step 2 were you can get your answer in Excel table.
Q: Watson likes to challenge Sherlock's math ability. He will provide a starting and ending value…
A: function squares(a, b) { let arr = [], limit1 = 0, limit2 = 0; limit1 =…
Q: The following questions will be based on the recurrence relation: T(n) = 1 if n = 1 T(n) = 2T(n/2) +…
A: Iteration Methods It is a brute force method that means to expand the recurrence relation until n…
Q: a) FindMinIterative public int FindMin(int[] arr) { int x = arr[0];…
A: Please refer below for your reference: Time complexitites are below: a) FindMinIterative public int…
Q: What is the final value of x based on the following expressions? Show steps of the answer. Question…
A: Here we find the value of x of the given expressions and prove that both expressions are not related…
Q: Question 5: Consider the following program segment. Rewrite it using no gotos or breaks. j= -3; for…
A: There are multiple ways to rewrite the code. Here two ways are specifying: Instead of a switch…
Q: Trace the evaluation of the following expressions, and give their resulting values. Make sure give a…
A: 6/3+7/2 It will solve according to operator precedence 6/3=2 7/2=3.5 6/3+7/2=5.5
Q: PART 1. EXAMINE THE FF. CODE int numValue =2; int answer =0; switch(numValue){ case 1: answer…
A: 1. The output if the numValue is 22 is Answer: 0 Because the value 22 is not present in the case…
Q: Complete the following direct proof of the statement: If x and y are positive real numbers and x <…
A: We need to find the missing statements to complete the proof.
Q: Partial Question 5 Fill out the trace table below by following the execution. If the value is not…
A: Given code is: salary =1000 if salary >100: taxes= .5 else: taxes = .1 salary = taxes *…
Q: Use following series to do the given task; 1 35 7 9 11 13 15 17 19 21 23 25 27 29 31 ... Given the…
A: - We need to code for the sum problem of last three odds. - We are using python here.
Q: Complete the following direct proof of the statement: If x and y are positive real numbers and x <…
A: x^2<xy y/x xy<y^2 xy
Q: String[] name={"John", "Mary", "Jim", "Sam"}; Which choice is correct? Group of answer choices…
A: String Datatype: The datatype is a set of values and each datatype have its own purpose. Based on…
Q: Trace the following code and write the output and mention what the code does int algorithm(int…
A: - The question wants to know trace what the code does and the output of the code.
Q: def fcn(n, s) : if n < 1 : print ('done', s) return -4 else : print ('here', s * n) return 5 + fcn(n…
A: Introduction: The Python program is an example of a recursive function and here the function calls…
Q: O Make the program that finds the standard deviation (o) for (1- n) x values by using iteration and…
A: Note- since programming language is not specified we are providing answer in python programming
Q: Step 3: Complete the public boolean checkWin(int[][] board) method. In order to check if a puzzle is…
A: The complete code is given below with the output.
Q: Write a "Wizard Duel Matching" program in Python. In this program, two wizard names wll be taken as…
A: import mathdef getNames(): name1 = input("Enter first name: ") name2 = input("Enter second…
Q: A group of people, numbered 1 to N, are sitting in a circle. Starting at person 1, a hot potato is…
A: According to the information given:- We have to take input for number of people and number of passes…
Q: Debug the following program: 1- def factorial (n): if(n<0): 2 - 3 return 1 result!=n 0: result =…
A: To do : Debug the given program and to fix it
Q: n Python input 1 and input 2’s degree is 4 If input 1 and input 2 have same parents, result return 0…
A: SUMMARY: -Hence, we discussed all the points.
Q: a) Prove the assignment segment given below to its pre-condition and post-condition using Hoare…
A: Summary: - Hence, we have discussed all the points.
Q: 2 i) //L1 int x = 1; int y = 2; = 3; //L2 //L3 int z = //L4 //L5 z = y; у %3D х + 5; x = z; //L6…
A: Line numbers 1, 2 and 3 are used for initializing the variables x, y and z with values 1, 2 and 3.…
Q: Both players are given the same string. S. Both players have to make substrings using the letters of…
A: def minion_game(string): vowel =['A','E','I','O','U'] S=0 K=0 for i in…
Q: The chef gives you an A sequence of N's length. Let X mean MEX for A sequence. The cook is…
A: Algorithm: Firstly we will take the value of number of test cases t Then we will call mainsolve…
Q: end for for i1 to n do if B[i) == t then return TRUE end if end for return FALSE What is the…
A: In the worst case, the integer t (i.e search element) is the not present in both the cases. In that…
Q: Java code Ever wondered how change is disbursed to customers in certain stores? In country X the…
A:
Q: EXAMINE THE FF. CODE int numValue =2; int answer =0; switch(numValue){ case 1: answer +=1;…
A: 1. The answer(output) if the value of numValue is 22 is 0 2. The answer(output) if the value of…
Q: The chef gives you an A sequence of N's length. Let X mean MEX for A sequence. The cook is…
A: Algorithm: Firstly we will take the value of number of test cases t Then we will call mainsolve…
Q: Let p: 2 + 1 = 3; q: 16 − 9 = 7. (a) ~p ∨ q TrueFalse (b) ~p ∧ ~q TrueFalse (c)…
A: Here in this question we have given some statement with variable p and q..and we have asked to find…
Q: Note: Numbers greater then 3,999 require symbols with lines over letters. We can't use these, so use…
A: Note: The given python program has been compiled and executed in "repl.it" online…
Q: Q4/ Write C++ program to read a score of student and print the estimation to refer it using switch…
A: C++ program that read score and print estimation of score using switch case statements. Program…
Q: A What is one way of adding 1 and 2, binding the result to X? Selected Answer: X = 1 + 2 Correct…
A: This method of adding 1 and 2 is legitimate because it yields the correct result. However, there may…
Q: What does the statement 'guess == 5' do? a. assigns the value 5 to guess b. if guess is not equal to…
A: 1. Given statement is 'guess==5' In this statement, guess is a variable and == is a equality…
Q: I need to display each grade in a seperate line** smith= { "name": "John", "homework": [90.0\n,…
A: The code for the following problem is given below:
Q: How would the following be tokenized by the lexical analyzer? (Remember to skip over any…
A: Below i have answered:
Q: Loop Problems Write the program that would generate the multiplication table for numbers 1 to 10.…
A: AS it was not specified I have done the program in C language Code: #include <stdio.h> int…
Q: Both players are given the same string. S. Both players have to make substrings using the letters of…
A: def minion_game(string): vowel =['A','E','I','O','U'] S=0 K=0 for i in…
Q: There are N stairs, and a person standing at the bottom wants to reach the top. The person can climb…
A: Here we are given the number of stairs and we need to find the number of ways to reach the top, and…
Q: A group of people, numbered 1 to N, are sitting in a circle. Starting at person 1, a hot potato is…
A: //header files #include <iostream>#include<bits/stdc++.h> using namespace std;…
Q: Implement the following if-elif-else-nested-if conditions. Create a program that asks the user the…
A: # taking input from user and convert it to lower case fullyVac = input("Are you fully vaccinated ?…
Q: Exercise 2: Complete the following onDraw method to display the following Pie Chart:
A: public class PieChartView extends View{ private final static String[] RColors =…
Q: Show that the following statement is true: n?ε Ω(nlog n)
A:
Note: No plagarism please!
Correct and detailed answer will be Upvoted else downvoted. Thank you!
Q. Write Pseudocode: (Provide alternative words for switch - also write full sentence for srand and rand)
srand(time(NULL));
int n = rand();
switch (n%2) {
case 0: a1 = first; cout << "first text\n"; break;
case 1: a1 = second; cout << "second text\n";
}
Step by step
Solved in 2 steps
- This assignment does not exactly match the one in the textbook on which it is based. I don't want any counter-controlled loops in your solution. Your solution should be able to detect when the accuracy isn't improving and then display the results of the work (as outlined below): Look at Programming Exercise **5.25 in the textbook on approximating the value of π. It is described as: π = 4 ( 1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11 + ... + (-1)^(i+1)/(2i-1) ) Notice that Java has the best possible value of π that can be stored as a type double available as Math.PI (part of the java.lang package). See how close you can get to the best value of π using a loop with the above technique. Notice that the above implies you are testing the value of your own estimate as it approaches the best value available in Java (as a type double). This would not be a pre-determined, counter-controlled loop. You are testing the results (sentinel-controlled) until you reach a value with the minimum discrepancy…Exercise H for the Nested Loop Nested Loop Problems Write the program that would generate the multiplication table for numbers 1 to 10. For example: Result 1 2 3 4 5 6 7 8 9 10 2 4 6 8 10 12 14 16 18 20 3 6 9 12 15 18 21 24 27 30 4 8 12 16 20 24 28 32 36 40 5 10 15 20 25 30 35 40 45 50 6 12 18 24 30 36 42 48 54 60 7 14 21 28 35 42 49 56 63 70 8 16 24 32 40 48 56 64 72 80 9 18 27 36 45 54 63 72 81 90 10 20 30 40 50 60 70 80 90100In Python input 1 and input 2’s degree is 4 If input 1 and input 2 have same parents, result return 0 Else if input 1 and input 2 have same grandparents , result return 1 Else if input 1 and input 2 have same great_grandparents , result return 2 Else if input 1 and input 2 have same great_great_grandparents , result return 3 Continue until found they have the same great_great_great…._grandparents, For adding one great, result +1 Else: if no relationship between two input, return -1 tree = [[‘Max’, None , None], [‘Luc’, ‘Max’, None], [‘Lue’, ’Max’, None], [‘Joy’, ‘Luc’, ‘Yoyo’], [‘Eva’, ‘Joy’, ‘Zoe’,], [‘Julie’, ‘Geo’, ‘Eva’], [‘input1’, ‘Brand’, ‘Julie’], [‘Jim’, ‘Lue’, ‘Rae’], [‘Gil’, ‘Jim’, ‘Ree’], [‘Rose’, ‘Gil’, ‘Mandy’] [‘input2’, ‘James’, ‘Rose’] this follow by [people, father, mother] Make the function def degree(input1, input 2, tree)
- Write this using java Write a complete version of the Bresenham Midpoint algorithm to handle ALL slope values. m = 0 m > 0 m < 0 m = 1 m > 1 swap the rolls of x and y m < 1 m = infinity ( needs special test case) Include appropriate tests for ‘special case’ conditions. Insteadof “WritePixel” write to the screen the coordinates of the pixel that would be drawn. Please provide photos that it works and so I can understand the code betterWhich one is correct for the following snippet of code? def factorial1(x): if x== 0: return 1 return x *factorial1(x-1) def factorial2 (x,y=1): if x== 0: return y return factorial2 (x-1,x*y) Group of answer choices a) Both factorial1() and factorial2() aren’t tail recursive. b) Both factorial1() and factorial2() are tail recursive. c) factorial1() is tail recursive but factorial2() isn’t. d) factorial2() is tail recursive but factorial1() isn’t.What is the probability that in a classroom of x people, at least 2 will be born on the same day of the year (ignore leap year)? Use a Monte Carlo Simulation and a frequency table to write a program that calculates this probability, where the number of people (x) in the simulated class is given by the user. The probability for a class of size 23, should be right around 50%. NO language of "break" or "true" please! Please use the outline given below for the code:
- Calculate ?= ??−??+?? for ?=[?,?,?,−?,−?,???,−?] , print rules given below and y values for every step. You can use necessary library or your own algorithm for this calculation.‘’ if y < 0, print: y is negativeif y > 0, print: y is positiveif y = -690, print: y equals to -690otherwise, print: undefined result for y ‘’Step 3: Complete the public boolean checkWin(int[][] board) method. In order to check if a puzzle is solved or not, we need to check if the current puzzle satisfy the row rule, column rule, and grid rule. So that is to check if every row of the puzzle contains the number 1 to 9 exactly once, every column contains the number 1 to 9 exactly once, and every 3X3 subgrid contains the number 1 to 9 exactly once. The nested loops for checking rows are given to you for your reference. Read the comments to understand it. Then complete the code to check the columns and the subgrids This is step three. On this practice problem we were given an incomplete java file that is being used to solve a suduko board. Ill try to copy and paste the code I have so far down below but I dont know how well that will work. import java.util.Arrays;import java.util.Random; public class Sudoku { public static final int[][] BOARD = {{4, 3, 5, 8, 7, 6, 1, 2, 9},{8, 7, 6, 2, 1, 9, 3, 4, 5},{2, 1, 9, 4, 3, 5, 7, 8,…What is the probability that in a classroom of x people, at least 2 will be born on the same day of the year (ignore leap year)? Use a Monte Carlo Simulation and a frequency table to write a program that calculates this probability, where the number of people (x) in the simulated class is given by the user. The probability for a class of size 23, should be right around 50%. NO language of "break" or "true" please! PLEASE USE THE OUTLINE GIVEN BELOW TO WRITE THE CODE: # What is the probability that in a classroom of x people, at least 2 will be born on the same day of the year (ignore leap year)?# I have given you the skeleton and some of the code... you complete it using a frequency table!# Note: In a classroom of only 23 people, the probability is about 50.7% !# Try first with 10000 trials and then try with 100000 trials. This code runs somewhat slowly in repl.it import mathimport random # create and initialize frequency table:ft = []k = 0while(k < 365) : ft.append(0) k = k+1…
- Write this using java Write a complete version of the Bresenham Midpoint algorithm to handle ALL slope values. m = 0 m > 0 m < 0 m = 1 m > 1 swap the rolls of x and y m < 1 m = infinity ( needs special test case) Include appropriate tests for ‘special case’ conditions. Insteadof “WritePixel” write to the screen the coordinates of the pixel that would be drawn.(Intro to Python) 1. total = 0 for i in range(5): total = total + i print(total) Group of answer choices 10 5 4 20 2. b = 1 a = b print(a) Group of answer choices b none of these a 1What’s wrong with the following while iteration statement? while (z >= 0) {sum += z;}