0% found this document useful (0 votes)
3 views1 page

Homework Arrays

The document outlines homework assignments focused on arrays in C++. It includes tasks such as finding the largest and smallest elements, implementing binary search, rotating array elements, rearranging even and odd numbers, and using Kadane's Algorithm to find the maximum sum of a subarray. Each task is accompanied by example inputs and outputs for clarity.

Uploaded by

0262351
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Homework Arrays

The document outlines homework assignments focused on arrays in C++. It includes tasks such as finding the largest and smallest elements, implementing binary search, rotating array elements, rearranging even and odd numbers, and using Kadane's Algorithm to find the maximum sum of a subarray. Each task is accompanied by example inputs and outputs for clarity.

Uploaded by

0262351
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

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:

• Input: array = {1, 2, 3, 4, 5}, k = 2

• Output: array = {4, 5, 1, 2, 3}

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:

• Input: array = {-2, 1, -3, 4, -1, 2, 1, -5, 4}

• Output: 6 (because the maximum sum comes from the subarray {4, -1, 2, 1})

You might also like