# Nagarro Previous Years Questions

Posted on :05-04-2016

TECHNICAL QUESTIONS:

Q1. Write a function to give demonstrate the functionality of 3D matrix in 1D matirx. Function prototye:

void set (int value, int index X, int index Y, int index Z, int [] 1dArray);

void get (int value, int index X, int index Y, int index Z, int [] 1dArray);

Q2.

Struct person{
char * name;
person[] friends;
};

Given the network list of friends. Each has set of friends which was unidirectional i.e, if you are my friend, then I may or may not be in your friends list. Network was like this:

Amit - -> Rahul -> Aman -> kumar
Rahul- -> Vipin-> Ankit-> Reena-> kumar
Kumar- -> Rahul-> Reena-> Tanmay

We need to identify whether 1st person being passed is a friend of another person or not. Friends can be friends friend also and so on. And we need to identify the distance.

For example:

Input: Amit, Kumar
Output: Distance 1

Input: Amit, Tanmay
Output: Distance 2

Input: Rahul, Aman
Output: Not friends.

Q3. Seat Reservation program for the theatre. Write a function for seat allocation for the movie tickets. Total number of seats available are 200. 20 in each row. Each row is referred by the Character, A for the first row and J for the last. And each seat in a row is represented by the number 1-20. So seat in different rows would be represented as A1, A2â€¦.; B1, B2â€¦..;â€¦â€¦.. J1, J2â€¦ Each cell in the table represent either 0 or 1. 0 represent would seat is available, 1 would represent seat is reserved.

Booking should start from the last row (J) to the first row (A). At the max 20 seats can be booked at a time. If seats are available, then print all the seat numbers like B2 i.e (2 row, 3 col) otherwise Print Seats are not available and must book consecutive seats only.

Q4. Int Matrix of certain size was given, few values are in it like this.

â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”
1  |  4  |     |  5  |     |  45
â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”
|  3  |  3  |  5  |     |  4
â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”
34 |  3  |  3  |     |  12 |
â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”
3  |     |  3  |  4  |     |  3
â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”
3  |     |     |     |  3  |
â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”â€”
|     |  4  |     |  4  |  3

To move back all the spaces in it at the end.

Note: If implemented this program using recursion, would get higher preference.

Q5. A chessboard was given to us. Where in there was a Knight and King was placed on certain positions. Our aim is to reach the king from the knight in minimum number of counts. As we know, knight can either move 2 steps vertical/horizontal and 1 step horizontal/vertical. Same goes here as well. Proper image of the chess board was given in the question paper, and all the positions (max   were given that knight can take in the first step).

Q6. Write the function to check the password entered is correct or not based on the following conditions.

a) It must have atleast one lower case character and one digit.

b) It must not have any Upper case characters and any special characters.

c) length should be b/w 5-12.

d) It should not have any same immediate patterns like

abcanan1: not acceptable because of an an pattern
abc11se: not acceptable, because of pattern 11
123sd123: acceptable, as not immediate pattern
adfasdsdf : not acceptable, as no digits
Aasdfasd12: not acceptable, as have uppercase character

Q7. There is a magic square matrix in such a way that sum of a column or a row are same like

3 5 2
4 3 3
3 2 5

sum of each column and row  is 10. Check that matrix is magic matrix or not?

Q8. There are 100 students in a class. The management keep information in two tables. Those two tables are given like

And

They want the information like this

And

All information is kept in structure in main memory. Find the last two tables.

Q9. Given an array containing k numbers in the range 1..n and another scratch array of size n. Write a program to remove the duplicates from the array.

Q10. Definition of priority queue was given. We have to implement the priority queue using array of pointers with the priorities given in the range 1..n.

The array could be accessed using the variable top. The list corresponding to the array elements contains the items having the priority as the array index.

Adding an item would require changing the value of top if it has higher priority than top.

Extracting an item would require deleting the first element from the corresponding queue.

The following class was given:

class PriorityQueue
{
int *Data[100];
int top;
public:
void put(int item, int priority); // inserts the item with the given priority.
int get(int priority); // extract the element with the given priority.
int count(); // returns the total elements in the priority queue.
int isEmpty(); // check whether the priority queue is empty or not.
};

We had to implement all these class functions.

Q11. Given a table of the form:

Product    Sold on
A           1/1/1980
B           1/1/1980
C           1/1/1980
A           1/1/1980
B           1/1/1980
C           2/1/1980
A           2/1/1980

There are 30 products and 10,000 records of such type. Also the month period during which sales happened is given to u.

Write the program to display the result as:

Product  Month     No. of copies
A           January       12
A           February     15
A           March         27
B           January       54
B           February     15
B           March         10
C           January       37

Q12. If employee B is the boss of A and C is the boss of B and D is the boss of C and E is the boss of D. Then write a program using the Database such that if an employee name is Asked to Display it also display his bosses with his name.

For eg. If C is displayed it should also display D and E with C?

Q13. Arrange Doubly linked list in the ascending order of its integral value and replace integer 5 with 7?

Q14. There was a 2D matrix given, we were supposed to sort the all diagonals elements. diagonals of Top left corner and Top right corner were to be sorted in the same matrix in an efficient way.

APTITUDE QUESTIONS:

Q15. If a person got 20% profit on sale of an item after giving 10% discount, what is the advertise price of the product?

Q16. If f(x) is divided by (1+x)/ (1-x). What is the value of x?

Q17. How much cost should a seller increase the cost of a product so that he can earn 15% profit after giving 20% discount?

Q18. (sin x - cos x)2 =0. What is the value of tan x?

FreshersLive - No.1 Job site in India. Here you can find latest 2018 government as well as private job recruitment notifications for different posts vacancies in India. Get top company jobs for both fresher and experienced. Job Seekers can get useful interview tips, resume services & interview Question and answer. Practice online test free which is helpful for interview preparation. Register with us to get latest employment news/rojgar samachar notifications. Also get latest free govt and other sarkari naukri job alerts daily through E-mail.

 ✖