Homework
Homework
1. Delete an element from a given array. (i.e arr[5]={1,3,7,5,2}. Delete 5 from the array. New array
will be arr[]={1,3,7,2}). [Not at first or last position]
2. Add an element to the given array. (i.e arr[6]={1,3,7,5,2}. Add 45 to the given array. New array
will be arr[6]={1,3,45,7,5,2}). [Not at first or last position]
3. Suppose you have an array {1,2,3,3,3,4,7,8,8,8,8,8,8,9,13}. Find the index of last occurrence of 8.
4. Suppose you have an array {1,2,3,3,3,4,7,8,8,8,8,8,8,9,13}. Find the index of first occurrence of
8.
5. Suppose you have an array {1,2,3,3,3,4,7,8,8,8,8,8,8,9,13.22,77}. Reverse the array without
using a new array.
6. Suppose you have an string str=“we are the champoions”. Reverse the string .
7. Suppose you have an array {7,1,4,9,4,2,1,78,45,14,5,7,0,13}. Only sort the array from index 4 to
index 8.
8. Suppose you have an array {1,2,3,3,3,4,7,8,8,8,8,8,8,9,13.22,77}. How many unique numbers in
this array?
9. Suppose you have an string str=“we are the champoions”. How many unique characters in this
string?
10. Suppose you have an array {1,2,3,3,3,4,7,8,8,8,8,8,8,9,13}. How many ‘8’ are there. [don’t use
any kind of loop]