SIT102 – Introduction to Programming Answers for 6.2P Working With Vectors Student Name: Eiman Student ID: XXXXXXXXXX Question 1: Summarise in your own words what the difference is between a standard...

1 answer below »
I just need the code structure at the end of the document. Nothing else.


SIT102 – Introduction to Programming Answers for 6.2P Working With Vectors Student Name: Eiman Student ID: 5000834 Question 1: Summarise in your own words what the difference is between a standard array and a dynamic array (such as a vector). The main difference between a dynamic array and a regular array is the size. In a regular array the sized is fixed from compilation. In closing the size of an array you can't change it again just think of it set in stone. A dynamic array is basically an array that grow and shrink on demand during run time. Question 2: How can we add elements to a vector in C++? - what is the procedure we call to increase the size of the vector? The C++ function std::vector::resize() changes the size of vector. If n is smaller than current size then extra elements are destroyed. If n is greater than current container size then new elements are inserted at the end of vector. If val is specified then new elements are initialled with val. Question 3: How can you remove the last element from a vector, thereby reducing the size of the vector? clear() removes all elements from vector and reducing it to size 0. erase() is used to remove specific elements from vector. Question 4: Briefly explain why we would want to use pass-by-reference when working with a vector instead of pass-by-value. In pass by reference, no new copy of the variable is made, so overhead of copying is saved. This makes programs efficient especially when passing objects of large structs or classes. Include a screenshot of your program running here: Include a copy of your program code here:
Answered Same DaySep 25, 2021SIT102Deakin University

Answer To: SIT102 – Introduction to Programming Answers for 6.2P Working With Vectors Student Name: Eiman...

Harsimran answered on Sep 26 2021
149 Votes
SIT102 – Introduction to Programming
Answers for 6.2P Working With Vectors
Student Name: Eiman    
S
tudent ID: 5000834        
Question 1: Summarise in your own words what the difference is between a standard array and a dynamic array (such as a vector).
    The main difference between a dynamic array and a regular array is the size. In a regular array the sized is fixed from compilation. In closing the size of an array you can't change it again just think of it set in stone. A dynamic array is basically an array that grow and shrink on demand during run time.
Question 2: How can we add elements to a vector in C++? - what is the procedure we call to increase the size of the vector?
    The C++ function std::vector::resize() changes the size of vector. If n is smaller than...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here