Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

No need to write the code. No computer code written in any computer programming language. Just need to write a recursive algorithm for each method

No need to write the code. No computer code written in any computer programming language. Just need to write a recursive algorithm for each method in English explaining how are you going to approach the code.

Long Integer Addition

For this assignment you are to write a class that supports the addition of extra long integers, by using linked-lists. Longer than what is supported by Java's built-in data type, called long.

Your program will take in two strings, consisting of only digits, covert each of them to a linked-list that represents an integer version on that string. Then it will create a third linked-list that represents the sum of both of the linked lists. Lastly, it will print out the result of the sum.

Conceptual Example For the string: "12", create a list: head->1->2->null For the string: "34", create a list: head->3->4->null Add the two lists to create a third list: head->4->6->null print the resulting linked list as "46" Where "->" represents a link.

Keep in mind that the conceptual example above is conceptual. It does suggest a certain implementation. However as you read on you will see that you have several options for implementing your solution. You need not use the suggested implementation above.

For this class you are to implement a minimum of three methods. They are:

  1. A method called makeSDList() that takes in a string, consisting only of digits, as an argument, and creates and returns a linked-link representation of the argument string.

    The method has the following header:

    SDList makeSDList(String s) { }

    where s is a string, and SDList is the class name of the linked list.

  2. A method called addLists() that takes takes two lists, adds them together, and creates and returns a list that represents the sum of both argument lists.

    The method has the following header:

    SDList addLists(SDList c) { }

    wherec linked-list of type SDList .

  3. A method called displayList() that takes takes a list, prints the value of each digit of the list.

    The method has the following header:

    void displayList() { }

Programming Notes

  1. You need not add any methods you don't need.
  2. You can add any methods use wish.
  3. You can use any type of linked list like: singly-linked, doubly-linked, circular, etc.
  4. You can choose you own list implementation such-as with or without sentinels, with head and/or tail points, etc.
  5. Do not assume any maximum length for either addend.
  6. You can assume that an each addend is a least one digit long.
  7. You need not test for the null or empty string ("") cases.
  8. The addends need not be the same length.

Programming Rules:

  1. You are not allowed to change the signature of the three methods above.
  2. You are not allowed to use arrays or ArrayLists anywhere in your solution.
  3. You are not allowed to use any Java built-in (ADTs), such as Lists, Sets, Maps, Stacks, Queues, Deques, Trees, Graphs, Heaps, etc. Or make any class that inherits any of those ADTs.
  4. You are to create your own node and list class. For your node and list class you can use the code that was used in the book, video and lecture notes related to the node and lists class examples.
  5. You are only allowed to have one class for your nodes and one class for your lists.
  6. You are not allowed to use Java Generics.
  7. You can use any data type to represent the digits (in the node). However, each node must represent one and only one digit.
  8. If hard-coding detected in any part of your solution your score will be zero for the whole assignment.

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

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions

Question

a. How are members selected to join the team?

Answered: 1 week ago

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago