CEIS295 Lab 1: Exercise 1,2 and 3 – Header and cpp files included for all exercises – Perfect Solution – Instant Delivery
WEEK 1: LAB OVERVIEW
Table of Contents
Lab Overview
Scenario/Summary
The purpose of the Lab exercises is to help the student acquire skills in developing programs that require implementation with arrays of abstract data types, such as lists and bags.
Deliverables
There are four exercises in this Lab, 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 3 contains parts a, b, c and continues through part 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 1 Lab. 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 for the Week 1 Lab, and submit the resulting zipped folder.
• Note that Exercises 2, 3, and 4 require software development. For each of them, place in the corresponding folder the source code files (i.e., .h and .cpp files) you created, and a screenshot of the execution window. Do not submit other files or folders, including those automatically generated by the IDE.
Required Software
Visual Studio
Use a personal copy or access the software at https://lab.devry.edu (Links to an external site.)Links to an external site..
All steps.
Lab Steps
Exercise 1: Lecture Review—Array-Based List and STL Vector
Create two projects, A Simple ArrayList Class and Using the STL Vector, using the programs in:
• A Simple ArrayList Class (Links to an external site.)Links to an external site.
• STL Vector (Links to an external site.)Links to an external site.
Compile the two projects, run them, and review the code that is given carefully. These programs test the code discussed in the lesson.
Exercise 2: Implementing an Array List
Modify the class ArrayList given in Exercise 1 by using expandable arrays. That is, if the list is full when an item is being added to this list, the elements will be moved to a larger array. The new array should have twice the size of the original array.
Using the new class ArrayList, write a program to store 1,000 random numbers, each in the interval [0, 500]. The initial size of the array in the class should be set to 100. Print the numbers.
Exercise 3: Implementing a Bag Class
Create a class Bag (multiset) that uses an expandable array to store the bag items. The item type must be int. The class should have the methods listed below. Create a main class to test your bag class. This main class should fill a bag of integers with 10 random numbers, each in the interval [0, 20], and print how many times each integer in the interval [0, 20] appears in the bag.
a. Bag(): default constructor
b. bool isEmpty(): determines whether the bag is empty
c. void print(): prints the bag elements
d. int getLength(): returns the number of items in the bag
e. void clear(): removes all of the items from the bag
f. void add(int item): adds an item to the bag
g. void remove(int item): removes item from the bag; only one occurrence of item should be removed.
h. int count(int item): counts the number of occurrences of item in the bag.
Exercise 4: Using the C++ STL Vector
Write a program that fills a vector object with the keywords of the C++ language. Once filled, the vector elements should be displayed.