You are on page 1of 6

Name: ____M.

Baburao_______________________________ Phone Number:


___________7995494636________________

College Name: ___Sreenidhi Institute of Science and Technology__________________________


Email: ____malothbaburao2089@gmail.com_______________________________

CGPA : _7.90____________________________ Stream : __Information


Technology_________________________________

Batch: ____2021______

Please send the completed test to chaitanya.arikati@abjayon.com by 10 AM.

General Guidelines
1. All the questions compulsory
2. Read all the questions very carefully before answering. Write to the point answers
3. For every question write the logical reasoning, code in any language or Pseudo-code and
comments in the code.

Interview Questions
1. Given an array in such a way that the elements stored in array are in increasing order initially and
then after reaching to a peak element, element are in decreasing order. Find the highest element.

Example: Input 11

Output: 1 2 3 4 5 6 5 4 3 2 1

int findPeakElement(vector<int>& a)

int l=0,h=a.size()-1,mid;

while(l!=h){

mid = (l+h)/2;

if(a[mid]>a[mid+1]){

h = mid;continue;

else{

l=mid+1;continue;

return a[h];
}

Algorithm used:

Steps:

If in the array, the first element is greater than the second or the last element

is greater than the second last, print the respective element and terminate the program

Else traverse the array from the second index to the second last indexIf for an element array[i] it is
greater than both its neighbours array[i]>array[i-1] and array[i]>array[i+1] , then print that element
and terminate.

2. Write a program to multiply 3*3 matrix


M1=[ 1 1 1 2 2 2 3 3 3 ]
M2=[ 1 1 1 2 2 2 3 3 3 ]

Program:

#include<stdio.h>

int main() {

int a[10][10], b[10][10], c[10][10], i, j, k;

int sum = 0;

printf("\nEnter First Matrix : n");

for (i = 0; i < 3; i++) {

for (j = 0; j < 3; j++) {

scanf("%d", &a[i][j]);

printf("\nEnter Second Matrix:n");

for (i = 0; i < 3; i++) {

for (j = 0; j < 3; j++) {

scanf("%d", &b[i][j]);

printf("The First Matrix is: \n");

for (i = 0; i < 3; i++) {

for (j = 0; j < 3; j++) {

printf(" %d ", a[i][j]);

printf("\n");

}
printf("The Second Matrix is : \n");

for (i = 0; i < 3; i++) {

for (j = 0; j < 3; j++) {

printf(" %d ", b[i][j]);

printf("\n");

for (i = 0; i <= 2; i++) {

for (j = 0; j <= 2; j++) {

sum = 0;

for (k = 0; k <= 2; k++) {

sum = sum + a[i][k] * b[k][j];

c[i][j] = sum;

printf("\nMultiplication Of Two Matrices : \n");

for (i = 0; i < 3; i++) {

for (j = 0; j < 3; j++) {

printf(" %d ", c[i][j]);

printf("\n");

return (0);

}
Start

Declare variables and initialize necessary variables

Enter the element of matrices by row wise using loops

Check the number of rows and column of first and second matrices

If number of rows of first matrix is equal to the number of columns of second matrix, go to step 6.

Otherwise, print matrix multiplication is not possible and go to step 3.

Multiply the matrices using nested loops.

Print the product in matrix form as console output.

Stop

3. Find duplicate number in an array. [1,2,5,4,2,3]

M=[1,2,3,5,4,2,3]
d={}
for i in M:
if i in d:
print(i)
else:
d[i]=1

ALGORITHM:

Declare and initialize an array


Duplicate elements can be found using two loops. The outer loop will iterate through the array from 0 to
length of the array
If a match is found which means the duplicate element is found then, display the element.

You might also like