Sapient  Placement Paper   Technical - Other   -11 Apr 2008

#### Sapient  Placement Paper   Technical - Other   -11 Apr 2008

• Posted by  FreshersWorld
7 Jan, 2012

SAPIENT PAPER ON 11TH APRIL,2008

Hi friends, Here I m making for u available all the technical questions that are asked in the written of Sapient . The problems that are given below were asked in either of the two technical written of sapient. Thoroughly go through all these programs ?.. make them by your own that will be much better because the technical interview is maximum based on the 2nd written paper i.e. u must be clear with the concepts and especially the logic behind the solution for the program made by u.

Instructions:
Focus on the approach & demonstrate problem comprehension & logic.
Assume anything required & clearly indicate your assumptions. Note: Don?t write any input functions such as main().

Program1.  Reservation
there are 67 seats in train . there are only 5 seats in a row and in last row there are only 2 seats. One person can reseve only 5 seat at a time. If person reserving seat , the care is taken that he may get all in row. If seats are not available in row then the arrangement is so that person group get nearby seats.
The following class is given
public class seat
{
char name; int seat; boolean is Seatempty
}

1.Draw require class diagram and object diagram.
2. Write function seatallot (int noofperson)
to allocate seat with seat number printed for the each name.

Program 2.  Stringreplace
The forum is going on and administrator find that some people use abusing or bad language in discussion.so he decided that when he uses such language it was replaced with beap.
question:
1. draw class diagram,and use appropriate data structure.
2. write function replacestring()

1) Write a program for the problem: the array of integers indicating the marks of the students is given, U have to calculate the percentile of the students according to this rule: the percentile of a student is the %of no of student having marks less then him. For eg:
suppose Student Marks
A 12
B 60
C 80
D 71
E 30
F 45
percentile of C = 5/5 *100 = 100 (out of 5 students 5 are having marks less then him)
percentile of B = 3/5*100 = 60% (out of 5, 3 have marks less then him)
percentile of A = 0/5*100 = 0%.

2) The code was given for a problem and u has to identify the logical error in it. That was simple. The code was to merge the Danagrams of 2 words. The denagram of a word is the letters of word arranged in sequential order. eg danagram of abhinav is aabhinv. merging of Danamagram is to merge the danagrams of 2 or more words such that the highest no of occurance are coming for each alphabet.
eg merging of aabhinv and abbhhixz is aabbhhinvxz.

3)you have to write a program to calculate the sales price of the product for a given conditions. it is very simple. (20 minutes)

4) You need to create a class diagram or data model for the given requirements. The requirement is as follows:-
In a village there are only few families and there were only one newspaper/magazine agent.
there are lot of news paper and magazine available and every month a new magazine or newspaper it introduced. Every family is getting at least one newspaper or magazine.
Every month at the end the cost is calculated and collected. Suppose if a family wants to cancel the subscription, they should be able to do it at any day of the month. The family should be billed only for the days which they got the newspaper or Magazine. The agent plans to buy a computer and proceed. Please create a class diagram or data model which helps him in developing a new software for it. Do not write the code or Flowchart.(25 minutes)

5) . Design a class diagram or data model for this problem:-
A company has some clients and some officers. Also it has some rooms to be used for meetings between client and officers. One officer is responsible for each room. And room has unique room id. A meeting will be arranged only when the officer and client are free and room is also free. The officer and clients must be registered to the system which will give them unique email ids. Arrange the meetings. Don?t write code.

6) Write a program to find the occurrence of characters '!', '\$' '?' '.' ',' etc. Also write a function to replace all odd occurrence of '?' to ' . '  .

7) There was a given program to insert a value at the proper position in a doubly linked list. There was some logical error in that due to which it was not working properly. Find out that error. It was easy.

Java Program to convert the numeric to Words, and there was a bug in it. we have to solve it and give the comments. There is no Syntax error but only the logical error. The program compiles without errors and runs, but the desired output is not got. for example
Input: 456
Output : four hundred and fifty six (correct)
Input :14000
Output : hundred and fourteen thousand. (wrong)
Desired output : fourteen hundred thousand.
Input :235126
output : hundred and two hundred and thirty five thousand hundred and one hundred and twenty six (wrong)
I am not much clear about the question but frame it out.(15 minutes)

Additional 2 programs to search an element immediately gr8r then all present in an array without sorting and a modified version of it to handle all error conditions

Instructions:
2. Focus on the approach & demonstrate problem comprehension & logic.
3. Assume anything required & clearly indicate your assumptions.

Qs.1: A company has many employees & each employee is led by only 1 person except for the CEO (who has no boss). The cost to the company of an employee is the sum of his salary plus the cost to the company of all the people led by him. Given is the following structure :
Employee
Data members:
Name
Salary
isBoss
nameOfBoss

Methods:
getSalary
getName

a) Define the class/structure
b) Write a function get Cost To Company() to calculate the cost to the company of an employee whose name is passed as a parameter to the function get Cost To Company()
public float get Cost To Company (String name)

Note: Donâ??t write any input functions such as main() & assume that the data structures have already been defined.

Qs. 2: Generate an ordered sequence of 4 unique alphabets, where an ordered sequence is one which is arranged in ascending alphabetic order.
Eg. Ordered : ABCD, BCHU, KRXZ
Unordered : DCBA, BNMA

Technical interview: 50 minutes technical interview .
10 min: Debugging
q1 .They had given me one program for debugging. The program is in java .and don?t have any syntax error. Just logical error.
10 min : Then told me to correct the mistake I had done in 2nd round answer paper.