Question: Define a class to find the third root of your B[15].
Please write this in programming C or C++ language and please explain what we are doing in each step.
Please find the code below:
#include <iostream>
#include <string>
using namespace std;
class ThirdRoot{
public:
// Returns the absolute value of
n-mid*mid*mid
double diff(double n,double mid)
{
if (n > (mid*mid*mid))
return
(n-(mid*mid*mid));
else
return
((mid*mid*mid) - n);
}
// Returns cube root of a no n
double findThirdRoot(double n)
{
// Set start and end for binary
search
double start = 0, end = n;
// Set precision
double e = 0.0000001;
while (true)
{
double mid =
(start + end)/2;
double error =
diff(n, mid);
// If error
is less than e then mid is
// our answer so
return mid
if (error <=
e)
return mid;
// If
mid*mid*mid is greater than n set
// end =
mid
if
((mid*mid*mid) > n)
end = mid;
// If
mid*mid*mid is less than n set
// start =
mid
else
start = mid;
}
}
};
int main(){
cout<<"Enter the number : ";
double num;
cin>>num;
ThirdRoot rootFinder;
cout<<"Third root of number
"<<num<<" is :
"<<rootFinder.findThirdRoot(num);
return 0;
}
output:
Question: Define a class to find the third root of your B[15]. Please write this in...
Question (1) Write for statements that print the following sequences of values a) 30, 20, 10, 0, –10, –20, –30 b) 15, 23, 31, 39, 47, 55 Question (2) Write a function call it cube to find the cube of each number. Please write this in programming C language and please explain what we are doing in each step.
Please program in the Java language. a) Write driver class that instantiates 5 objects of class Circle with radius is an even number from 2 to 10 b) Write/define the class Circle
Programming Language in Healthcare - Please write at least 250 words. 1a. In your own words, discuss what is meant by programming language? 1b. Use the Internet to find an example of a voice recognition program (natural language) used in the healthcare industry. Please cite your source(s).
Write a function int levelSearch(Node* root, int key) that takes as input the root node of a Binary Search tree and a key. The function searches the key in the BST and returns the level of the found node. If the key is not found in the tree, return -1. The level starts at 0 for the root node and increases from top to bottom. We have defined the following node C++ Node class for you: class Node { public: ...
Write a C++ program that does the following : Define a class myInt that has as its single attribute an integer variable and that contains member functions for determining the following information for an object of type myInt: A. Is it multiple of 7 , 11 , or 13. B. Is the sum of its digits odd or even. C. What is the square root value. D.Is it a prime number. E. Is it a perfect number ( The sum...
1.Define a class to hold information about a single point (Point class). 2.Write a method of the Point class to determine the distance to another Point. 3.Use composition to define a Circle. 4.Write a method of the Circle classes to determine if a Point is inside the Circle. 5.Write a method of the Circle classes to determine if a Circle is wholly inside another Circle. 6.Write a method of the Circle classes to determine if a circle surrounds another circle....
Question 8, please. 2. Prove: (a) the set of even numbers is countable. (b i=1 3. The binary relation on pair integers - given by (a,b) - (c,d) iff a.d=cbis an equivalence relation. 4. Given a graph G = (V, E) and two vertices s,t EV, give the algorithm from class to determine a path from s to t in G if it exists. 5. (a) Draw a DFA for the language: ( w w has 010 as a substring)....
3. Define a class License. A License has a license number and an suggest using java.time.LocalDate, but there are other possibilities). Then do the following: expiration date ( (a) Think what it might mean for two License instances to represent the same real- world license. Write the Boolean equals method that takes another License as argument and returns true if the two Licenses are "equal" in this sense. The block comment for your method should explain how you are doing...
write c++ to solve this linear system. Given 2x+4y-z 2 -2x -3y +7z 10 Write a program to solve the linear system above using Gauss- Elimination. Question2 Let f(x) = x3-6x2 + 11x-6, Write a program to i) Check whether the root exist in the interval: a) .5, 5.0] b) 2.5, 4.0] ii Based on interval found in 4(i), find the root using Bisection method. Do your calculation in 4 decimal points and 0.0001. Programming language: C or C++ Given...
part C please 8 BST 15 Points Given a BST T with root r write algorithms (pseudocode) to determine: (a) The height of T. (b) The maximum element in T. (c) If T is height balanced. Please select file(s) Select file(s) Q9 Double