Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Instructions: All tasks must be implemented using TEMPLATES AND C++ LANGUAGE. Task 4: Similar Elements 10 points Write a program to compare two arrays of

Instructions: All tasks must be implemented using TEMPLATES AND C++ LANGUAGE.

Task 4: Similar Elements 10 points Write a program to compare two arrays of different lengths to find similar values in the arrays. e.g array1 = [2,4,5,6,1] array2 = [3,6,9,0,23,55,2] The return should be [2,6]

Task 5: Perfect strip of Land 10 points In 1987 B.C. in Egypt snakes want to build the temple for their lord but they required such piece of land that meet their requirements. Formally, every strip of land, has a length. Suppose the length of the i-th strip is is Ni, then there will be Ni integers, Hi1, Hi2, .. HiNi, which represent the heights of the ground at various parts of the strip, in sequential order. That is, the strip has been divided into Ni parts and the height of each part is given. This strip is valid, if and only if all these conditions are satisfied: There should be an unique 'centre' part. This is where the actual temple will be built. By centre, we mean that there should be an equal number of parts to the left of this part, and to the right of this part. Hi1 = 1 The heights keep increasing by exactly 1, as you move from the left most part, to the centre part. The heights should keep decreasing by exactly 1, as you move from the centre part to the rightmost part. Note that this means that HiNi should also be 1. Your job is to look at every strip and find if it's valid or not.

For example [1,2,3,4,3,2,1] => true (perfect land) [2,3,4,3,2] => false (because we need to have start with 1)

TEST CASE FOR TASK 05

#include "pch.h" #include"What_to_test.h"

{

TEST(PerfectLand, T10){ int arr[]=[1,2,3,4]; EXPECT_false(false, perfectLand(arr,4)); } TEST(PerfectLand, T11){ int arr[]=[1,7,8,9,8,7,1]; EXPECT_false(false, perfectLand(arr,7));

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions