- Placement Papers
- Interview Zone
- Resume Corner
- Contact Us
(Paper) LUCENT (ASCENT) - US Test Paper
Submitted by admin on Mon, 2007-12-24 18:08
LUCENT (ASCENT) - US Test Paper
(TEST Duration ---- 1hr 45min )
Two Sections :
1. Writing program/functions ( almost all directly from K&R )
2. Logical questions
function names and parameters are given in 7 questions.
1) to find x^y. double Power(int x, int y) ------------- this is given.
Note: double type is returned so check for -ve powers also. do take special check for x=0.
2) to find GCD of two numbers. eg. GCD of 9 and 12 is 3.
int gcd(intx, int y)
a) binary search. int bin_search(char *a, int start, int end)
b) Note that for this routine start is supposed to be always equal to 0.why?
Ans. array subscript starts from 0 and if it doesnot starts from 0 then it will lead to wastage of memory.
c) why this type of prototype is chosen?
Ans. so that we donot have to always start with 0.?
4) pattern matching i.e. to search a particular string in a given string.
int search(char *string,char *pattern)
a) INPLACE string reversal without using standard functions.
char *str_rev(char *string)
b) what value should it return?
Ans. Original string pointer.
6) Hexadecimal conversion to decimal where input is essentially of the form: "0xhhhh" where all are small case letters and if input is not of this form -1 should be returned indicating error in input.
7) Node insertion i.e to insert a node c between two nodes a and b in a doubly link list where Node ptr of the node a after which it is to insert is given.
where structure is of the form:
typedef struct node *NODE;
BOOL insert(NODE a,NODE c)
NOTE: i think returned value (BOOL) is boolean type. so check initially that a, c is not NULL and if it is so return 0 and return 1, if insertion is done successfully. Also, note that pointer "a->next" can be equal to NULL.
Mask is given and we have to form three functions with minimum number of instructions to do the following 3 operations on bitfields:
i) Setbit : to set the given bits(or all, i don t remember actually) to 1.
ii) Clearbit : to clear given bits (or all, i don t remember actually) to 0.
iii) Testbit : to test that the given one or more bits are all set or not.