0% found this document useful (0 votes)
47 views

Diagnostic CPC 1 HR Algorithm Paper Total-80

The document provides instructions for a coding interview containing 5 questions. It specifies that for each question, candidates should provide the time and space complexity of their solutions, even if the solutions do not meet stated constraints. Questions include: 1) Computing a value in a recursive sequence, 2) Finding triplets in an array where each element is greater than the next, 3) Implementing bucket sort, 4) Spirally traversing a matrix, 5) Converting between decimal and Roman numerals. The total time allotted for the interview is 1 hour and the test is out of 80 marks.

Uploaded by

VikrantRajSingh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views

Diagnostic CPC 1 HR Algorithm Paper Total-80

The document provides instructions for a coding interview containing 5 questions. It specifies that for each question, candidates should provide the time and space complexity of their solutions, even if the solutions do not meet stated constraints. Questions include: 1) Computing a value in a recursive sequence, 2) Finding triplets in an array where each element is greater than the next, 3) Implementing bucket sort, 4) Spirally traversing a matrix, 5) Converting between decimal and Roman numerals. The total time allotted for the interview is 1 hour and the test is out of 80 marks.

Uploaded by

VikrantRajSingh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

DIAGNOSTIC CPC

ALGORITHM PAPER

1 HR
Total-80

Instructions:>All the questions are general interview questions.


>Give time and space complexity of your solution. Even if your solution doesnt
satisfy the given constraints, partial marks may be awarded.
>A Readable code is expected.

1.MATEXPO

15

Given the following recursive equation


F(n)=a*F(n-1)+b*F(n-3). For the given n, generate the value of F(n)%1000000007.
0<=n<=2^31-1. F(0)=F(1)=F(2)=1.
2.TRIPLETS
Given an array of n integers, find total number of triplets( i, j, k) such that
a[i] > a[j] > a[k] and i < j < k.
1<=n<=10^5.
3.BUCKET SORT
Implement Bucket sort.
4.SPIRAL TRAVERSAL
Traverse n*m matrix spirally. For example,
R=4,C=3. You have to print,
1
10
9
8

2
11
12
7

3
4
5
6

25

10
10

5. Write functions for following:


10 + 10
A. Decimal to Roman( pass integer as argument and return roman string)
B. Roman to Decimal( pass roman string as argument and return integer)
(Integer<5000).

You might also like