ECET 370 Week 2 ilab Linked Lists

Published on January 2018 | Categories: Public Notices | Downloads: 169 | Comments: 0 | Views: 778
of 1
Download PDF   Embed   Report

iLAB OVERVIEW Scenario and Summary The purpose of the iLab exercises is to help the student acquire skills in developing programs that require the implementation with linked lists of abstract data types, such as lists and bags. Deliverables There are four exercises in this iLab, although not all of them will be required for submission. Be sure to read the following instructions carefully. Exercise 1: No submission is required. Exercise 4 contains Parts a, b, c, d, e, f, g, and h. Keep in mind that the methods developed for each of these parts should be within the same bag class. Create a folder and name it Week 2 iLab. Inside this folder, create the subfolders Ex2, Ex3, and Ex4. Place the solution to each of the three exercises required for submission in the corresponding subfolder. Compress the folder Week 2 iLab, and drop the resulting zipped folder into the Dropbox. Note that Exercises 2, 3, and 4 require software development. Place in the corresponding folders only .java files. Do not submit the .class files or other files or folders that are generated by the IDE. Required Software ECLIPSE Access the software at https://lab.devry.edu . iLAB STEPS Exercise 1: Review of Linked Lists Back to Top Create a project using the classes in "A Simple LinkedList Class." Compile it, run it, and review the code that is given carefully. This code tests the LinkedList class provided in the lecture. Exercise 2: Implementing a Doubly Linked List Back to Top Modify the class LinkedList in Exercise 1 to make it a doubly linked list. Name your class DoublyLinkedList. Add a method addEnd to add an integer at the end of the list and a method displayInReverse to print the list backwards: void addEnd(int x): create this method to add x to the end of the list. void displayInReverse(): create this method to display the list elements from the last item to the first one. Create a main class to test your DoublyLinkedList class. Exercise 3: Using a Doubly Linked List Back to Top Using the class DoublyLinkedList completed in the previous exercise, write a program to store all the prime numbers up to 100 in a DoublyLinkedList object. The numbers should be stored in such a way that when “display” is invoked, the listing will be shown in increasing order: 2, 3, 5, 7, 11, 13, 17, … . Exercise 4: Implementing a Bag Class Back to Top Create a class bag that uses a linked list to store the bag items. The item type must be a Java String type, that is, the bag will store strings of characters. The class should have the methods listed below. Create a main class to test your bag class. This main class should fill a bag with the keywords of the Java language. . Bag(): default constructor boolean isEmpty(): determines whether the bag is empty void print(): prints the bag elements int getLength(): returns the number of items in the bag void clear(): removes all of the items from the bag void add(String item): adds an item to the bag void removeOne(String item): removes an item from the bag; only one occurrence of the item should be removed. int count(String item): counts the number of occurrences of an item in the bag. (Note that you can reuse the code in Exercise 1 for the LinkedList class to create your bag class. It will help you to save development time.)

Comments

Content

iLAB OVERVIEW Scenario and Summary The purpose of the iLab exercises is to help the student acquire skills in developing programs that require the implementation with linked lists of abstract data types, such as lists and bags. Deliverables There are four exercises in this iLab, although not all of them will be required for submission. Be sure to read the following instructions carefully. Exercise 1: No submission is required. Exercise 4 contains Parts a, b, c, d, e, f, g, and h. Keep in mind that the methods developed for each of these parts should be within the same bag class. Create a folder and name it Week 2 iLab. Inside this folder, create the subfolders Ex2, Ex3, and Ex4. Place the solution to each of the three exercises required for submission in the corresponding subfolder. Compress the folder Week 2 iLab, and drop the resulting zipped folder into the Dropbox. Note that Exercises 2, 3, and 4 require software development. Place in the corresponding folders only .java files. Do not submit the .class files or other files or folders that are generated by the IDE. Required Software ECLIPSE Access the software at https://lab.devry.edu . iLAB STEPS Exercise 1: Review of Linked Lists Back to Top Create a project using the classes in "A Simple LinkedList Class." Compile it, run it, and review the code that is given carefully. This code tests the LinkedList class provided in the lecture. Exercise 2: Implementing a Doubly Linked List Back to Top Modify the class LinkedList in Exercise 1 to make it a doubly linked list. Name your class DoublyLinkedList. Add a method addEnd to add an integer at the end of the list and a method displayInReverse to print the list backwards: void addEnd(int x): create this method to add x to the end of the list. void displayInReverse(): create this method to display the list elements from the last item to the first one. Create a main class to test your DoublyLinkedList class. Exercise 3: Using a Doubly Linked List Back to Top Using the class DoublyLinkedList completed in the previous exercise, write a program to store all the prime numbers up to 100 in a DoublyLinkedList object. The numbers should be stored in such a way that when “display” is invoked, the listing will be shown in increasing order: 2, 3, 5, 7, 11, 13, 17, … . Exercise 4: Implementing a Bag Class Back to Top Create a class bag that uses a linked list to store the bag items. The item type must be a Java String type, that is, the bag will store strings of characters. The class should have the methods listed below. Create a main class to test your bag class. This main class should fill a bag with the keywords of the Java language. . Bag(): default constructor boolean isEmpty(): determines whether the bag is empty void print(): prints the bag elements int getLength(): returns the number of items in the bag void clear(): removes all of the items from the bag void add(String item): adds an item to the bag void removeOne(String item): removes an item from the bag; only one occurrence of the item should be removed. int count(String item): counts the number of occurrences of an item in the bag. (Note that you can reuse the code in Exercise 1 for the LinkedList class to create your bag class. It will help you to save development time.)

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close