Question
Part 2 - Programs C++ 1) Write a OOP program that can store an array of 10 Positive integers. Remember, you are creating a class
Part 2 - Programs C++
1) Write a OOP program that can store an array of 10 Positive integers.
Remember, you are creating a class with variables, an array and functions.
Create a UML class diagram:
Sketch out what: variables, an array and functions do you need ?
Functions: isfull, isEmpty, find, delete, print all
Initialize all elements in the array to all 99999's , 99999 mean an empty array element.
Add/code one of the good sorting algorithms: BUBBLE SORT
Add/code one of the top searching algorithms: BINARY SEARCH
Have a function to ask the user for input. Hint, got to check if array is not Full, before you can add a value.
Have a function to print out the array, non 99999 values.
Have a function to delete an integer. Hint, got to find if it exists in array first, before it can over write with 99999.
Have the ability to know/printout the count the number of integers
Test:
* Enter 23, 42, 75, 104, 32, 21, 11, 49 in this order...
* Sort element in array
* Find value 42
* Try to find value 91
* Delete 32 and resort array
* Print all element in array
Note: The int main() function contents, you write for program 1, should be exactly the same as program 2.
filename: week5YourNameProg1SortFindArrayList
2) Write an OOP program to store integers into a two way linked list.
( Note: Internet research - search for an example of a two way linked list, and Insertion sort )
* Create a UML class diagram...
Add code so that the linked list is sorted ( May not be necessary - depends on how you insert a value )
Add a function so you can search for an integer
Have a function to ask the user for input.
Add a function to delete an integer
Have the ability to know/printout the count of the number of integers in the list ( Hint: Keep a count variable )
Have a function to print out the list
Test:
* Enter 23,42,75, 104, 32, 21, 11, 49 in this order...
* Sort elements in array ?? Did you use insertion sort - so a separate sort function is NOT necessary.
( Hint: This may not be necessary, it you write an Enter value Insertion function that places the value in the right position, so it is ordered )
* Find value 42
* Try to find value 91
* Delete 32 and ( No re-sort should not be necessary since it is a linked list - depends on how you code the delete function ! )
* Print all element in list
Note: The int main() function contents should be exactly the same as program 1.
filename: week5YourNameProg1sortFindlinkedList
---------------------------
Hint: Here is most of the code for the int main() function for BOTH prog 1 and prog 2.
Example of int main() {
className List; // use class definition and declare instance.
List.Insert(23);
List.Insert(42);
List.Insert(75);
List.Insert(104);
List.Insert(32);
List.Insert(21);
List.Insert(11);
List.Insert(49);
List.Sort(); // required in prog 1. Should not be needed in prog 2 if you do insertion sort properly.
List.PrintAll();
cout << List.Find(42) << endl;
cout << List.Find(91) << endl;
List.Delete(32);
List.Sort(); // required in prog 1. Should not be needed in prog 2 if you do insertion sort properly.
List.PrintAll();
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started