Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question
100%

Implement a range function for a dynamic array which returns a new dynamic array that is a subset of the original.

input parameters: array - (the array and any related parameters) start - index of the first element
end - index of the last element
Interval - An integer number specifying the incrementation of index

This function returns a new dynamic array containing the elements from the start thru the end indices of the original array.
All array indexing must be done using pointer arithmetic.

For example, given the array: 49 96 99 47 76 29 22 16 30 22

If the start and end positions were 5 and 9 with step 2, return a new dynamic array: 29 16 22

Please use following main to test your function.

int main(){
int *p = new int[10]{49,96,99,47,76,29,22,16,30,22}; int *q = range(p,10,5,9,2);
for(int i=0;i<3;i++)

cout<<q[i]<<" "; // print 29 16 22 cout<<endl;
delete [] q;
q = range(p,10,1,8,3);

for(int i=0;i<3;i++)
cout<<q[i]<<" "; // print 96 76 16

cout<<endl;

delete [] q; }

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Similar questions
    SEE MORE QUESTIONS
    Recommended textbooks for you
    Text book image
    Computer Networking: A Top-Down Approach (7th Edi...
    Computer Engineering
    ISBN:9780133594140
    Author:James Kurose, Keith Ross
    Publisher:PEARSON
    Text book image
    Computer Organization and Design MIPS Edition, Fi...
    Computer Engineering
    ISBN:9780124077263
    Author:David A. Patterson, John L. Hennessy
    Publisher:Elsevier Science
    Text book image
    Network+ Guide to Networks (MindTap Course List)
    Computer Engineering
    ISBN:9781337569330
    Author:Jill West, Tamara Dean, Jean Andrews
    Publisher:Cengage Learning
    Text book image
    Concepts of Database Management
    Computer Engineering
    ISBN:9781337093422
    Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
    Publisher:Cengage Learning
    Text book image
    Prelude to Programming
    Computer Engineering
    ISBN:9780133750423
    Author:VENIT, Stewart
    Publisher:Pearson Education
    Text book image
    Sc Business Data Communications and Networking, T...
    Computer Engineering
    ISBN:9781119368830
    Author:FITZGERALD
    Publisher:WILEY