Kennesaw State University
CSE1322 – Lab 9 – ListsData StructuresLab 9ObjectivesLearn the basics of list based data structures.BackgroundMoving into more advanced data structures we begin with lists. There are many different types of lists, but two of the most popular and time honored are ArrayLists and LinkedLists. All lists share properties that differentiate them significantly from arrays. The largest one being that lists’ sizes, the amount of elements they can hold, can change as needed. This opens many new opportunities for problem solving as we no longer are limited to solutions that require knowing how many items were needed before attempting to solve, as well as being able to create a solution that can update and handle new problems without needing to change the code.TasksThis lab has three parts:Create an ArrayList class.Create a LinkedList class.Print out the results after testing each of the methods in both of the classes and solving a simple problem with them.Task 1 – ArrayList ClassCreate an ArrayList class. This is a class that uses an internal array, but manipulates the array so that the array can be dynamically changed. This class should contain a default and overloaded constructor, where the default constructor creates an empty array and the overloaded constructor creates one with a size specified by the parameter.There should also be a method that adds new elements to the array, which handles resizing and creation of the array if needed. As well as a method to remove elements from the array, which also handles resizing if needed. Finally, there should be a method that is able to retrieve an element at a given position in the internal array.Task 2 – LinkedList ClassCreate a LinkedList class. This is a class that uses references to create a list like structure. This class should have a default constructor that creates an empty list.We will also need a method that adds elements to the list and handles resizing and creation if needed. There should be a removal method and a method that gets elements at any given point in the list.Task 3 – The Tester ClassCreate a Tester Class, with a Main method. In the Main method, create one ArrayList and LinkedList object each. Use their addition, removal and get methods and show the results by printing the lists before and after each method call. Use user input to populate the lists, with at most ten inputs. After testing the methods, create two new methods, one that takes an ArrayList and one that takes in a LinkedList, and returns the sum of all the elements inside of each.? Some Sample Output:ArrayList Portion:Enter a number: 5Are you done entering numbers (y/n)? nEnter a number: 9Are you done entering numbers (y/n)? nEnter a number: 11Are you done entering numbers (y/n)? nEnter a number: 7Are you done entering numbers (y/n)? yInitial contents of the list: 5, 9, 11, 7Contents before adding another item: 5, 9, 11, 7Please enter another number to add: 21Contents after adding another item: 5, 9, 11, 7, 21Contents before removing an item: 5, 9, 11, 7, 21Please enter the index of the element to remove: 2Contents after removing an item: 5, 9, 7, 21Contents before retrieving a value from the list: 5, 9, 7, 21Please enter the index of the element to retrieve: 0Element at position 0 is: 5Contents after retrieving a value from the list: 5, 9, 7, 21Assume similar input for the LinkedList Portion.Sum of all items in the ArrayList: 42Sum of all items in the LinkedList: 42What to Turn In:Follow submission guidelines on this page: ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- illinois state university online courses
- illinois state university programs
- illinois state university bachelor degrees
- illinois state university degree programs
- illinois state university online degree
- illinois state university online masters
- illinois state university summer schedule
- illinois state university summer classes
- illinois state university phd programs
- illinois state university online program
- illinois state university online degrees
- illinois state university masters programs