Some additional information: getIndex function (using linear search): 1) Accepts a value of type T as a parameter. 2) Iterate through the array checking if the value is in the array. If it is return the index. If it is not, return -1. Example Given 5 10 15 20 25 30 and value 15, return the index 2. erase function: 1) Accepts an index as a parameter. 2) Use a loop to shift all elements from the index to the end of the array to the left by 1. 3) Decrement size by 1. Example Given 5 10 15 20 25 30 and index 3 we would shift 25 and 30 to the left thereby overwriting the number 20 resulting in the array 5 10 15 25 30.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

need help with this c++ question....THIS IS ONLY ONE LONG QUESTION

Some additional information:
getIndex function (using linear search):
1) Accepts a value of type T as a parameter.
2) Iterate through the array checking if the value is in the array.
If it is return the index.
If it is not, return -1.
Example
Given 5 10 15 20 25 30 and value 15, return the index 2.
erase function:
1) Accepts an index as a parameter.
2) Use a loop to shift all elements from the index to the end of the
array to the left by 1.
3) Decrement size by 1.
Example
Given 5 10 15 20 25 30 and index 3 we would shift 25 and 30 to the left
thereby overwriting the number 20 resulting in the array 5 10 15 25 30.
Transcribed Image Text:Some additional information: getIndex function (using linear search): 1) Accepts a value of type T as a parameter. 2) Iterate through the array checking if the value is in the array. If it is return the index. If it is not, return -1. Example Given 5 10 15 20 25 30 and value 15, return the index 2. erase function: 1) Accepts an index as a parameter. 2) Use a loop to shift all elements from the index to the end of the array to the left by 1. 3) Decrement size by 1. Example Given 5 10 15 20 25 30 and index 3 we would shift 25 and 30 to the left thereby overwriting the number 20 resulting in the array 5 10 15 25 30.
Implementation
Implement a class SomeObj:
1) data member:
a) id
an integer named
2) constructors:
a) default
b) single parameter constructor to set the value of id
3) functions:
a) getId
return the value of id
a) output
output the value of id to console
Implement a Template Class MyArray (modify/augment example 12.6):
1) data members:
a) data
dynamic array of type T
b) capacity
c) size
capacity of the dynamic array
number of elements in the array
2) constructors:
- create an empty array of capacity 10
- create an array of a specified capacity
a) default
b) single parameter
3) functions:
a) getSize
b) getCapacity
return the size
return the capacity
b) grow
private grow function (capacity*2) +1
given a value, return its index or -1 if not found
c) getIndex
use a linear or binary search
d) push_back
append element to the end of the array
- remove the element at the specified index
- overloaded [] operator (regular and const versions)
e) erase
f) []
4) the big three
A Non-Member Print function:
1) Prints the contents of a template MyArray object given via as a parameter.
Main:
1) Instantiate a template MyArray object of SomeObj pointers.
2) Instantiate 10 SomeObj objects and append them to the MyArray object.
3) Print the SomeObj contents of the MyArray object.
Transcribed Image Text:Implementation Implement a class SomeObj: 1) data member: a) id an integer named 2) constructors: a) default b) single parameter constructor to set the value of id 3) functions: a) getId return the value of id a) output output the value of id to console Implement a Template Class MyArray (modify/augment example 12.6): 1) data members: a) data dynamic array of type T b) capacity c) size capacity of the dynamic array number of elements in the array 2) constructors: - create an empty array of capacity 10 - create an array of a specified capacity a) default b) single parameter 3) functions: a) getSize b) getCapacity return the size return the capacity b) grow private grow function (capacity*2) +1 given a value, return its index or -1 if not found c) getIndex use a linear or binary search d) push_back append element to the end of the array - remove the element at the specified index - overloaded [] operator (regular and const versions) e) erase f) [] 4) the big three A Non-Member Print function: 1) Prints the contents of a template MyArray object given via as a parameter. Main: 1) Instantiate a template MyArray object of SomeObj pointers. 2) Instantiate 10 SomeObj objects and append them to the MyArray object. 3) Print the SomeObj contents of the MyArray object.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 1 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education