Answered step by step
Verified Expert Solution
Question
1 Approved Answer
i need sequence.cpp sequence.h and main.cpp please answer only if you can do it right Create a sequence data structure using dynamic arrays. Sequence is
i need sequence.cpp sequence.h and main.cpp please answer only if you can do it right
Create a sequence data structure using dynamic arrays. Sequence is similar to the beg but the order is important in it (1, 2, 3 is different then 2, 1, 3). Implement the erase_first and erase_last which respectively remove the first and last occurrence of a value. Implement the earse_occurence which removes the occurrence of a value (e.x. erase the second occurrence of the value 4). Implement the erase_from function which accepts index of an element and erases the element from that index (index starts from zero). Implement insert, count and size functions that respectively insert to the end of the sequence, count number of occurrence of a value and returns number of elements in the sequence. Implement the insert_first function that insert an element as the first index. Implement the insert_at function which insert some element at a specific index, if you have 3 values then you may have 1, 2, 3 and you want to insert 4 in the sequence, then you may insert at index 0, 1, 2, 3 and the result will be 4, 1, 2, 3 or 1, 2, 4, 2 or 1, 2, 3, 4 respectively. Implement the + operator that connects two sequences and create the third one, overload the + operator such that it connects a sequence to a number and return the result. Implement the + = as a member function that it will add a sequence to this sequence and the overload version which adds a number to this sequence. Implement the = operator this time try to return a sequence & instead of a sequence (This is the most accurate version of the = operator). Implement the == operator which checks the equality of two sequences. Overload stream (e.x. cout > s) operator so you may print a sequence or insert a sequence by console. In the main try to create a loop with 1,000,000,0000 iterations. Try to create an instance of a sequence class in the loop and add one element to that, run your program and check the memory usage. Add a destructor for to your sequence class and try the test again. What happens to the memory? Don't forget namespace and macro-guard. You will be familiar with these operators in the next class, however, it is better to start your homework nowStep 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