You are on page 1of 9

Vector Homework

Tech Time
Problem 1

1.Implement swap(index1 , index2 ) function in class Vector – It is used to


swap the contents of one vector with another vector of same type. Sizes
may differ.
( Swap value in index1 to index2 && index2 to index 1)

Tech Time
Problem 2

Implement largest_element function in class Vector – It is used to return the


largest element of a Vector

Implement Second_largest_element function in class Vector – It is used to


return the largest element of a Vector

Tech Time
Problem 3
Deleting First element
● Implement method int pop_front () in the vector class
● It returns the deleted value
● Remove First element from the the Vector
● Assume array is: 4 0 1 2 3
● pop_front()
○ Return value 4
○ New array: 0 1 2 3
Tech Time
Problem 4
Deleting Last element
● Implement method int pop_back () in the vector class
● It returns the deleted value
● Remove last element from the the Vector
● Assume array is: 4 0 1 2 3
● pop_back()
○ Return value 3
○ New array: 4 0 1 2
Tech Time
Problem 5
Deleting Last element
● Implement method int pop_back () in the vector class
● It returns the deleted value
● Remove last element from the the Vector
● Assume array is: 4 0 1 2 3
● pop_back()
○ Return value 3
○ New array: 4 0 1 2
Tech Time
Problem 6
Deleting a position
● Implement method int pop(int idx) in the vector class
● It returns the deleted value
● Remove this element from the array
● Assume array is: 4 0 1 2 3
● pop_back(2)
○ Return value 1
○ New array: 4 0 2 3
Tech Time
Problem 6 : Right rotation

Tech Time
Problem 7: Left rotation

Tech Time

You might also like