[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

# Practice Questions & Answers :: Cocubes

111.4K

## Total Practice Qs: 137+

NA
SHSTTON
79
Solv. Corr.
152
Solv. In. Corr.
231
Attempted
0 M:7 S
Avg. Time

51 / 137

Choose the correct option.

Which of the following is not an application of sorted array?

AHash Tables

BCommercial computing

CPriority Scheduling

DDiscrete Mathematics

| | Topic: | Asked In Cocubes |

Explanation:

Sorted arrays have widespread applications as all commercial computing involves large data which is very useful if it is sorted. It makes best use of locality of reference and data cache. Linked lists are used in Hash Tables not arrays.

Tags: No Tags on this question yet!

NA
SHSTTON
8
Solv. Corr.
13
Solv. In. Corr.
21
Attempted
0 M:0 S
Avg. Time

52 / 137

Choose the correct option.

What is the time required to locate the occurrences of a pattern P of length m in a string of length n using suffix array?

AO(mlogn)

BO(nm)

CO(n2)

DO(mnlogn)

| | Topic: | Asked In Cocubes |

Explanation:

Suffix arrays are used to find the occurrences of a pattern in a string. Pattern of length m will require m characters to compare, so using suffix array we can find occurrences of a pattern in the string of length n in O(mlogn) time.

Tags: No Tags on this question yet!

NA
SHSTTON
8
Solv. Corr.
9
Solv. In. Corr.
17
Attempted
0 M:0 S
Avg. Time

53 / 137

Choose the correct option.

What does the number of inversions in an array indicate?

Amedian value of the elements of array

Bmean value of the elements of array

Cmeasure of how close or far the array is from being sorted

Dthe distribution of values in the array

| | Topic: | Asked In Cocubes |

Explanation:

The number of inversions in an array indicates how close or far the array is from being completely sorted. The array is sorted if the number of inversions are 0.

Tags: No Tags on this question yet!

NA
SHSTTON
19
Solv. Corr.
199
Solv. In. Corr.
218
Attempted
0 M:17 S
Avg. Time

54 / 137

What will be the auxiliary space complexity of the following code?
#include <iostream>
using namespace std;
int main()
{
int arr[] = {1,2,3,4,5,6};
int n = sizeof(arr)/sizeof(arr[0]);
int d=4;
int temp[10];

for(int i=0;i<d;i++)
temp[i]=arr[i];

int j=0;
for(int i=d;i<n;i++,j++)
arr[j]=arr[i];

int k=0;
for(int i=n-d;i<n;i++,k++)
arr[i]=temp[k];

for(int i=0;i<n;i++)
cout<<arr[i]<<" ";
return 0;
}

AO(n*d)

BO(1)

CO(n)

DO(d)

| | Topic: | Asked In CapgeminiCocubes |

Explanation:

The given code rotates an input array by d. It does so by using an auxiliary array temp[] which stores first d elements of the original array. So the auxiliary space complexity will be O(d).

Tags: Capgemini

NA
SHSTTON
31
Solv. Corr.
37
Solv. In. Corr.
68
Attempted
0 M:0 S
Avg. Time

55 / 137

What will be the time complexity of the following code?
#include <bits/stdc++.h>
using namespace std;
void func(int arr[], int left, int right)
{
while (left < right)
{
int temp = arr[left];
arr[left] = arr[right];
arr[right] = temp;
left++;
right--;
}

}

void printArray(int arr[], int size)
{
for (int i = 0; i < size; i++)
cout << arr[i] << " ";
}

int main()
{
int arr[] = {1,4,3,5};
int n = sizeof(arr) / sizeof(arr[0]);
func(arr, 0, n-1);
printArray(arr, n);
return 0;
}

AO(n log n)

BO(n)

CO(log n)

DO(1)

| | Topic: | Asked In Cocubes |

Explanation:

The given code reverses the input array and then prints the resulting array. So the time complexity of the given code will linearly vary with the number of elements in the array and thus the time complexity will be O(n).

Tags: No Tags on this question yet!

NA
SHSTTON
5
Solv. Corr.
9
Solv. In. Corr.
14
Attempted
0 M:0 S
Avg. Time

56 / 137

What will be the time complexity of the following code?
#include <bits/stdc++.h>
using namespace std;

void func(int a[], int n, int k)
{
if (k <= n)
{
for (int i = 0; i < k/2; i++)
swap(a[i], a[k-i-1]);
}

}
int main()
{
int a[] = {1, 2, 3, 4, 5};
int n = sizeof(a) / sizeof(int), k = 3;
func(a, n, k);
for (int i = 0; i < n; ++i)
cout << a[i]<<" ";
return 0;
}

AO(n log n)

BO(k)

CO(n)

DO(k log k)

| | Topic: | Asked In Cocubes |

Explanation:

The given code reverses only a specified segment of the input array. This segment is decided by the value of k so the time complexity of the code will be O(k).

Tags: No Tags on this question yet!

NA
SHSTTON
13
Solv. Corr.
48
Solv. In. Corr.
61
Attempted
0 M:0 S
Avg. Time

57 / 137

What will be the time complexity of the following code?
#include <bits/stdc++.h>
using namespace std;

int min(int x, int y)
{ return (x < y)? x: y; }

int func(int arr[], int n)
{

int *jump = new int[n];
int i, j;

if (n == 0 || arr[0] == 0)
return INT_MAX;

jump[0] = 0;

for (i = 1; i < n; i++)
{
jump[i] = INT_MAX;
for (j = 0; j < i; j++)
{
if (i <= j + arr[j] && jumps[j] != INT_MAX)
{
jump[i] = min(jump[i], jump[j] + 1);
break;
}
}
}
return jump[n-1];
}

int main()
{
int arr[] = {1, 3, 6, 1, 9,7};
int size = sizeof(arr)/sizeof(int);
cout<< func(arr,size);
return 0;
}

AO(n2)

BO(n log n)

CO(n)

DO(n1/2)

| | Topic: | Asked In Cocubes |

Explanation:

The given code finds the minimum number of steps required to reach the end of an array by using dynamic programming. As there is a nested loop in the code so the time complexity will be O(n2).

Tags: No Tags on this question yet!

NA
SHSTTON
5
Solv. Corr.
14
Solv. In. Corr.
19
Attempted
0 M:0 S
Avg. Time

58 / 137

Choose the correct option.

5/9 of the part of the population in a villagae are males.if 30 % of the males are married.the percentage of unmarried females in the total population is?

A13.45%

B43.20%

C45%

D27.78%

ENone of above

| | Important Formulas | Topic: | Asked In HCL TechnologiesSSC CGL Tier I |

Explanation:

Let total population = p
no. of males =5p/9
no. of females =(p-5p/9)=4p/9
married males = 30% of 5p/9=30*5p/100*9 =p/6
married females = p/6
unmarried females =(4p/9-p/6)=5p/18
%age of unmarried females in the total population = {(5p/18)/p}*100= 250/9% = 27.78%

NA
SHSTTON
1
Solv. Corr.
15
Solv. In. Corr.
16
Attempted
0 M:0 S
Avg. Time

59 / 137

Choose the correct option.

Anil bought a T.V with 20% discount on the labeled price . Had he bought it with 25% discount, he would have saved Rs. 500. At what price did he buy the T.V?

A10000

B8000

C12000

D11340

ENone of above

| | Important Formulas | Topic: | Asked In HCL TechnologiesSSC CGL Tier I |

Explanation:

Let the labelled price of TV be Rs. x, then difference between 80% of x and 75% of x is Rs. 500.
=> 0.8x - 0.75x = 500
=> 0.05x =500 or x=10000
So the buying price=80% of x= 0.8*10000=Rs. 8000

NA
SHSTTON
3
Solv. Corr.
11
Solv. In. Corr.
14
Attempted
0 M:0 S
Avg. Time

60 / 137

Choose the correct option.

Water is continuously poured from a reservoir to a locality at the steady rate of 10,000 liters per hour. When delivery exceeds demand, the excess water is stored in a tank. If the demand for 8 consecutive three-hour periods is 10000,10000,45000,25000,40000,15000,60000 and 35000 liters respectively, what will be the minimum capacity required of the water tank (in 1000 litres) to meet the demand?

A10

B30

C40

D50

| | Important Formulas | Topic: | Asked In HCL TechnologiesSSC CGL Tier I |

Explanation:

In the period of First 3 hrs, the demand of water = 10000.
but the water poured by 10000 per hour.
Thus the end of 3 hours it will poured 30000 ltr then the excess of water = 20000.
Similarly at the end of Second 3 hrs period the excess of water 20000+20000 = 40000.

Third, 3 hrs water poured = 30000
already we have 40000 of excess water and demand 45000.
Then the excess water at the end of 3rd 3 hrs= 40000+30000–45000= 25000
Fourth 3 hrs. water = 25000+30000–25000= 30000
Fifth = 30000+30000–40000= 20000
Sixth = 20000+30000–15000=35000
Seventh = 35000+30000–60000= 5000
Eighth = 5000+30000–35000= 0
By analyzing the above results, we have 40000 ltrs is the highest measure of excess water.
So the minimum capacity of water tank = 40000 litres = 40
i.e. = 40