Sale!

CST Training Assignment 3 solved

Original price was: $35.00.Current price is: $30.00.

Download Details:

  • Name: assignment3-dmazdi.zip
  • Type: zip
  • Size: 911.52 KB

Category:

Description

5/5 - (5 votes)

Question-1
Write a program to find largest number in an array that is not a perfect cube such that complexity must be
of the order O(n).
Input: arr[] = {16, 8, 25, 2, 3, 10}
Output: 25
25 is the largest number that is not a perfect cube.
Input: arr[] = {36, 64, 10, 16, 29, 25}
Output: 36
Question-2
Write a program to find Number of pairs in an array with the sum greater than 0. Try to keep complexity
below O(n2
)
Input: arr[] = { 3, -2, 1 }
Output: 2
Explanation:
There are two pairs of elements in the array whose sum is positive. They are:
{3, -2} = 1
{3, 1} = 4
Input: arr[] = { -1, -1, -1, 0 }
Output: 0
Explanation:
There are no pairs of elements in the array whose sum is positive.