Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Abstract data types are represented by two thingsThe data, andThe functions that act on the dataWe saw in class how a fraction was created as

Abstract data types are represented by two thingsThe data, andThe functions that act on the dataWe saw in class how a fraction was created as an abstract data type. In this lab, we are going to create an abstract data type for quadratic equations of the form ax2+ bx + c. Here are the functions that operate on quadratics.make_quadratic(a, b, c)-- This creates and returns a quadratic ax2+ bx + c. coefficient(q, i)-- Return the ith coefficient of the quadratic q. That is, if q is ax2+ bx + c, thencoefficient(q,2) is acoefficient(q,1) is bcoefficient(q,0) is c The two functions above are the only ones that need to know about how quadratics are represented internally. Everything else uses and builds on the two functions above.These functions perform arithmetic with quadratics.add_quadratic(q1, q2)-- Takes two quadratics and returns the result of adding themmultiply(n, q)-- Takes a number n and returns the result of multiplying the quadratic by it, i.e. n x q = n x (ax2+ bx + c)has_real_roots(q)-- Takes a quadratic q and return true if it has one or two real roots, or false otherwise. Recall from basic algebra that a quadratic has real roots only if the discriminant is zero or positive.differentiate_quadratic(q)-- Differentiate the quadratic q, i.e. perform dq/dx. Recall from basic calculus that if q = ax2+ bx + c, then dq/dx =2ax + bYour task is to write these functions. You can choose any internal representation you wish.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Performance Indexing In SQL Server

Authors: Jason Strate, Grant Fritchey

2nd Edition

1484211189, 9781484211182

More Books

Students also viewed these Databases questions

Question

How would you train others to perform the task? Explain.

Answered: 1 week ago