EBK DATA STRUCTURES AND ALGORITHMS IN C
4th Edition
ISBN: 9781285415017
Author: DROZDEK
Publisher: YUZU
expand_more
expand_more
format_list_bulleted
Question
Chapter 1, Problem 2PA
Program Plan Intro
Quaternion
Program plan:
- Define a class named “Quaternion” that defines basic operations of quaternion
- Define a function named “operator+()” that adds two input terms and displays the result.
- Define a function named “operator-()” that subtracts two input terms and displays the result.
- Declare a function named “operator*()” that multiplies two input terms and displays the result.
- Define a function named “operator/()” that divides one input term with the other and displays the result.
- Define a function named “operator<<()” that overloads the output operator to output the fraction.
- Declare a function named “operator=()” that performs the function of assignment operation.
- Declare a function named “operator~()” that computes the conjugate of given input quaternion term.
- Declare a function named “normSquared()” that computes the squared norm of an input term and displays the result.
- Declare a function named “operator+=()” that denotes the operation of add AND assignment operators.
- Declare a function named “operator-=()” that denotes the operation of subtract AND assignment operators.
- Declare a function named “operator*=()” that denotes the operation of multiply AND assignment operators.
- Declare a function named “operator/=()” that denotes the operation of divide AND assignment operators.
- Declare a function named “operator==()” that denotes the operation of equality comparison operators.
- Declare a function named “operator!=()” that denotes the operation of add equality operators of comparison type.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Definition. A Pythagorean triple (x, y, z) is a triple of positive integers where x² + y² = z². This can be
thought of as describing an x × y rectangle with the property that the diagonal z is also of integer length.
A Pythagorean triple (x, y, z) is primitive if x, y, z are coprime (i.e. there is no integer k > 1 which divides all
of them).
(a) Write a Python function PrimPyth (n) which returns a list of primitive Pythagorean triples (x, y, z) where
0 < x < y < z
Please implement a complex class which can process complex numbers. It should have two
member variables double real and double imaginary, and some methods, so that we can
use it in the main function like the following:
int main()
{
Complex a(3, 5);
Complex b(1, 4);
Complex c
a + b; // (3+5i) + (1+4i)
( 4+9i)
b;
// (3+5i)
(1+4i)
(2+i)
= a
// (3+5i) * (1+4i) = (-17+17i)
* b;
a
= a / b;
// (3+5i) / (1+4i)
(1.35-0.41i)
%3D
}
In Lisp
Chapter 1 Solutions
EBK DATA STRUCTURES AND ALGORITHMS IN C
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Write a Java program to solve quadratic equations.Design a class QuadraticRoots which has following members: Data:1.a2.b3.c Methods: Setter functions (total 3) Getter functions (total 3) computeRoots> if the discriminant greater than zero --- find two distinct real roots> if the discriminant equal to zero find the real roots> if the discriminant is less than zero find the two distinct complex(imaginary) roots> should also handle the iota (i) displayRoots get values of a, b, c from the user and display the output for each case.arrow_forwardProblem 4 We can use lists of numbers like l to represent a mathematical vector. Recall from math classes that a vector is an object with a magnitude and direction. The magnitude is the sqrt of the sum of the squares (for a vector (x,y) it's the Pythagorean theorem for the magnitude (x^2 + y^2)**(1/2)). For a vector of any other length, the formula generalizes to (l[0]^2 + l[1]^2 + l[2]^2 + ... )**(1/2). For this problem use l from Problem 1 and a for loop to compute the magnitude of l with the result stored in l_mag. For l above, its magnitude is 12.96. Python gives you the ** exponentiation operator to raise a number to a power. You could also import math and use math.sqrt(). l = [1, 2, 3, 4, 5, 7, 8] Please give proper explanation and typed answer only.arrow_forwardHallo by Peter Linz, "Introduction to Formal Languages and Automaton", 6th edition, 2017. The cut is from chapter 2, section 1. thank u s much :)))))arrow_forward
- use c++ programming language to create a derived, or child class for Cylinder, that is, a Cone class. The same function, with the same parameters, is used. However, the formula is different for a cone. // The formula is: V = (1/3) * pi * (r^2) * harrow_forwardPlease Answer this in C++ only Devo is learning Combinatorics in his college. He finds it very interesting to calculate number of ways of going to point (c, d) from point (a, b) in co-ordinate plane. We can take horizontal and vertical steps only and cannot visit at a point twice. In a step, you can move one unit only. We have to reach to the point (c, d) from the point (a, b) using abs(a-c) + abs(b-d) steps only. Devo has two sets of points. Set A contains points having X co-ordinate 0 and Y co- ordinates varying from 1 to N (both inclusive). Set B contains points having X co- ordinate K and Y co-ordinates varying from 1 to N (both inclusive). Both sets contain N number of integral points. He wants to calculate the sum of number of ways to going to each point of set B from each point of set A. As the answer can be large, print it modulo 1000000007. Input 2 22 45 Output 8 236arrow_forwardEvaluate the following lambda expressions using eager beta-reduction (use the standard interpretations for numbers and booleans wherever meeded). (a) ((Lx.x*x)5) (b) ((Ly.((Lx.x+y+z)3))2) (c) ( (Lv.(Lw.w)((Lx.x)(y(Lz.z)))) 14.3 Evaluate the following expressions. (you could use a Scheme interpreter) (a) (null ? ()) (b) (null ? '(a bede)) (c) (car '(a (b c) de)) (d) (cdr '(a (b c) de)) (e) (cadr '(a (bc) de))arrow_forward
- 1. The homomorphism h is defined by h(a) = 01 and h(b) = 10. What is h(aaba)? a) aaba b) 01010101 = c) 01011001 d) 010101 2. Let h be the homomorphism defined by h(a) = 01, h(b) = 10, h(c) = 0, and h(d) : 1. If we take any string w in (0+1)*, h¨¹ (w) contains some number of strings, N(w). For example, h¹ (1100) = {ddcc, dbc}, i.e., N(1100) = 2. We can calculate the number of strings in h¨¹ (w) by a recursion on the length of w. For example, if w = 00x for some string x, then N(w) = N(0x), since the first 0 in w can only be produced from c, not from a. Complete the reasoning necessary to compute N(w) for any string w in (0+1)*. Then, choose the correct value of N(01101). a) 8 b) 6 16 d) 4 3. The operation DM(L) is defined as follows: 1. Throw away every even-length string from L. 2. For each odd-length string, remove the middle character. For example, if L = {001, 1100, 10101}, then DM(L) = {01, 1001}. That is, even-length string 1100 is deleted, the middle character of 001 is removed…arrow_forwardDraw Flowchart of this program // C# program for implementation // of Lagrange's Interpolation using System; class GFG { // To represent a data point // corresponding to x and y = f(x) class Data { public int x, y; public Data(int x, int y) { this.x = x; this.y = y; } }; // function to interpolate the given // data points using Lagrange's formula // xi corresponds to the new data point // whose value is to be obtained n // represents the number of known data points static double interpolate(Data []f, int xi, int n) { double result = 0; // Initialize result for (int i = 0; i < n; i++) { // Compute individual terms // of above formula double term = f[i].y; for (int j = 0; j < n; j++) { if (j != i) term = term * (xi - f[j].x) / (f[i].x - f[j].x); } // Add current term to result result += term; } return result; } // Driver code public static void Main(String[] args) { // creating an array of 4 known data points Data []f = {new Data(0, 2), new Data(1, 3), new Data(2, 12), new Data(5,…arrow_forwardWrite a java code to implement four new functions DFA Union: Given Two DFAs, M1 and M2, create a DFA which accepts the union of the languages of M1 and M2. Intersection: Given Two DFAs, M1 and M2, create a DFA which accepts the intersection of the languages of M1 and M2. Difference: Given Two DFAs, M1 and M2, create a DFA which accepts the set difference of the languages of M1 and M2, that is, L(M1) - L(M2), the set of strings accepted by M1 but not M2. Complement: Given DFA M, create a DFA which accepts the complement of the language of M.arrow_forward
- C++arrow_forwardI need some help generating a UML diagram from this assigment.arrow_forwardPlot the orbit in 3D using a suitably dimensioned sphere for the Earth. [6]: # YOUR CODE HERE raise NotImplementedError() Not Implemented Error Cell In [6], line 2 1 # YOUR CODE HERE ----> 2 raise NotImplementedError() Not ImplementedError: Problem 1.6 Plot the Specific Energies (i.e., all three Kinetic, Potential and Total Energy) in the same plot as a function of time. The x-axis must show time (in hours) and y axis must show the Energy (in km² /s²). [7] # YOUR CODE HERE Traceback (most recent call last) raise NotImplementedError()arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
6 Stages of UI Design; Author: DesignerUp;https://www.youtube.com/watch?v=_6Tl2_eM0DE;License: Standard Youtube License