Homework Arrays
Homework Arrays
1.- Write a C++ program to find the largest and smallest element of an array
2.- Write a program to search an element in array using binary search metho
3.- Write a C++ program that takes an array of integers and a number k. The function should rotate
the elements of the array k positions to the right. If k is negative, rotate to the left.
Example:
4.- Write a C++ program that rearranges the elements of an array so that all even numbers appear
at the beginning of the array and all odd numbers appear at the end. The relative order of the
numbers does not need to be preserved.
Example:
• Input: array = {12, 17, 70, 15, 22, 65, 21, 90}
• Output: array = {12, 70, 22, 90, 17, 15, 65, 21}
5.- Write a C++ function to find the maximum sum of a subarray in a given array of integers. Use
Kadane's Algorithm to solve the problem.
Example:
• Output: 6 (because the maximum sum comes from the subarray {4, -1, 2, 1})