Find Jobs
Hire Freelancers

Linked Lists

$30-5000 USD

Concluído
Publicado há mais de 20 anos

$30-5000 USD

Pago na entrega
Overview For this assignment, you will be implementing a singly linked list to store polynomials. For instance, the polynomial 5*X^4 + 3*X^3 + 7*X + 10 will be stored as a linked list made up of 4 nodes. The first node will contain the coefficient of 5 and exponent of 4. It will be followed by a node with coefficient and exponent of 3, a node with coefficient of 7 and exponent 1, and finally a node with coefficient 10 and exponent 0. Notice that the nodes are stored in descending order based on the exponent. class Term This class will store information about one term in the polynomial, therefore this is the class that is used as the nodes in the linked list. The definition for this class should be contained in a file called ***Term.h***, while the implementation should be contained in a file called ***[login to view URL]***. The Poly class (described below) is eventually going to need access to the private members of the Term class. Data members This class should have three data members that are not available to the outside world. The first is an integer that is used to hold the coefficient for a term in the polynomial. The second is an integer that is used to hold the exponent for a term in the polynomial. The third is pointer to a Term object, which will hold the address of the next Term in the linked list. Constructor This class should have one constructor. It takes three arguments: the first is an integer value that will be used to set the coefficient, the second is an integer that will be used to set the exponent, and the third is a pointer to a Term object that will be used to set the link field for the Term. All three of the arguments should have default values of 0. ### Methods Input (or extraction) operator: istream >> Term Overload the input operator to read in two integers, a coefficient and an exponent, from one line. The two integers should be stored in the appropriate fields of the Term. #### Output (or insertion) operator: ostream << Term Overload the output operator to print a Term in the following format: coefficient*X^exponent There are a couple of special cases that need to be handled: 1. If the exponent is 1, print only coefficient*X 2. If the exponent is 0, print only the coefficient. ## Deliverables continued..... Multiplication Operator: Term * Term Overload the multiplication operator to multiply two Term objects. This is a constant method that takes one argument, a reference to a constant Term, and returns a Term object. The new Term that is created should have an exponent equal to the sum of the exponents for the two Terms, a coefficient equal to the product of the coefficients for the two Terms, and a pointer field that is 0. For instance: class Poly This class will store the polynomial, therefore this is the class that is used as the linked list. The definition for this class should be contained in a file called Poly.h, while the implementation should be contained in a file called Poly.cc. The Poly class is going to use the Term class so Term.h should be one of the #included files. For this class, you should have at least the following data member and methods: Data member This class should have one data member that is not available to the outside world. It is a pointer to a Term object, which will hold the address of the first Term in the linked list. Constructors Default Constructor The default constructor should initialize the pointer to 0 to indicate that the linked list is empty. Copy Constructor The copy constructor for this class should create a new Poly object that has Term's that are identical to those in an existing Poly object. It takes as its argument a reference to a constant Poly object. Think about calling the Copy() method described below. Destructor The destructor for this class should release all of the Terms in a Poly object. Think about calling the Dismantle() method described below. Methods Copy This is a private helper method that creates a copy of an existing Poly object. It takes two arguments and returns nothing. The first argument is a pointer to a Term object, while the second is a reference to a pointer to a Term object (ie. Term *&). This method is going to create a copy of the existing Poly object one Term at a time. It can be implemented recursively. The initial call to Copy will have sourcePtr pointing at the first Term of an existing Poly object, and destinationPtr referencing the first Term of the copy of the Poly object that is being created. Dismantle This is a private helper method that deletes all of the Terms in an existing Poly object. It takes one argument and returns nothing. The argument to this method is a reference to a pointer to a Term object. This method will delete the Terms one at a time. It can be implemented recursively. Equality Operator: Poly == Poly Overload the equality operator to determine if two Poly objects are equal. Two polynomials are equal if the corresponding coefficients and exponents of every Term are equal. Output (or insertion) Operator: ostream << Poly Overload the output operator for the purpose of printing out an instance of the Poly class. The function should print out the polynomial one Term at a time. This can be implemented by starting a pointer at the first Term in the Poly object and stepping through the Terms as long as the pointer is not 0. At each step, the Term is printed using the output operator for Term. If the Poly object is empty (i.e. there are no Terms to print), the function should print a message saying so. This function is going to need access to private data from BOTH the Poly and Term classes. Therefore, this function should be made a friend of BOTH the Poly and Term class. Input (or extraction) Operator: istream >> Poly Overload the input operator to read in the data to form a Poly object. The function is first going to read in an integer that is equal to the number of Terms that will make up the polynomial (lets call this numTerm). Now implement a loop that will execute numTerm times. Inside of the loop: ## Platform Tera Term Pro 2.3 continued... Add. Operator: Poly += Term Overload += operator to add Term to an existing Poly object. This takes 1 argument, a reference to a constant Term, and returns reference to a Poly object. Assignment Operator: Poly = Poly Overload assign. operator so that it assigns contents of the Poly on the right of the operator to the Poly on left. Takes 1 argument, reference to a constant Poly, and returns reference to a Poly. Add. Operator: Poly + Poly Overload add. operator so that two instances of Poly can be added together. Takes 1 argument, reference to a constant Poly object, and returns a Poly object. Sub. Operator: Poly - Poly Overload subtraction operator so one instance of Poly can be subtracted from another. Takes 1 argument, reference to a constant Poly object, and returns Poly object.
ID do Projeto: 2998777

Sobre o projeto

26 propostas
Projeto remoto
Ativo há 20 anos

Quer ganhar algum dinheiro?

Benefícios de ofertar no Freelancer

Defina seu orçamento e seu prazo
Seja pago pelo seu trabalho
Descreva sua proposta
É grátis para se inscrever e fazer ofertas em trabalhos
Concedido a:
Avatar do Usuário
See private message.
$42,50 USD em 4 dias
5,0 (1 avaliação)
2,3
2,3
26 freelancers estão ofertando em média $27 USD for esse trabalho
Avatar do Usuário
See private message.
$46,75 USD em 4 dias
5,0 (84 avaliações)
6,3
6,3
Avatar do Usuário
See private message.
$42,08 USD em 4 dias
5,0 (159 avaliações)
6,0
6,0
Avatar do Usuário
See private message.
$36,55 USD em 4 dias
4,9 (203 avaliações)
6,3
6,3
Avatar do Usuário
See private message.
$42,50 USD em 4 dias
5,0 (33 avaliações)
5,0
5,0
Avatar do Usuário
See private message.
$15,30 USD em 4 dias
4,9 (104 avaliações)
4,9
4,9
Avatar do Usuário
See private message.
$42,50 USD em 4 dias
5,0 (17 avaliações)
4,3
4,3
Avatar do Usuário
See private message.
$33,15 USD em 4 dias
5,0 (17 avaliações)
4,2
4,2
Avatar do Usuário
See private message.
$11,90 USD em 4 dias
4,0 (11 avaliações)
4,6
4,6
Avatar do Usuário
See private message.
$17 USD em 4 dias
5,0 (12 avaliações)
3,6
3,6
Avatar do Usuário
See private message.
$17 USD em 4 dias
5,0 (20 avaliações)
3,5
3,5
Avatar do Usuário
See private message.
$93,50 USD em 4 dias
4,7 (15 avaliações)
3,8
3,8
Avatar do Usuário
See private message.
$25,50 USD em 4 dias
5,0 (1 avaliação)
3,3
3,3
Avatar do Usuário
See private message.
$15,30 USD em 4 dias
4,9 (13 avaliações)
3,1
3,1
Avatar do Usuário
See private message.
$17 USD em 4 dias
4,6 (11 avaliações)
2,8
2,8
Avatar do Usuário
See private message.
$16,15 USD em 4 dias
4,6 (12 avaliações)
2,4
2,4
Avatar do Usuário
See private message.
$3,40 USD em 4 dias
4,6 (3 avaliações)
1,7
1,7
Avatar do Usuário
See private message.
$85 USD em 4 dias
5,0 (1 avaliação)
0,6
0,6
Avatar do Usuário
See private message.
$11,05 USD em 4 dias
4,9 (4 avaliações)
0,3
0,3
Avatar do Usuário
See private message.
$12,75 USD em 4 dias
0,0 (0 avaliações)
0,0
0,0
Avatar do Usuário
See private message.
$6,80 USD em 4 dias
0,0 (0 avaliações)
0,0
0,0

Sobre o cliente

Bandeira do(a) UNITED STATES
DeKalb, United States
5,0
2
Membro desde out. 30, 2003

Verificação do Cliente

Obrigado! Te enviamos um link por e-mail para que você possa reivindicar seu crédito gratuito.
Algo deu errado ao enviar seu e-mail. Por favor, tente novamente.
Usuários Registrados Total de Trabalhos Publicados
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Carregando pré-visualização
Permissão concedida para Geolocalização.
Sua sessão expirou e você foi desconectado. Por favor, faça login novamente.