C++/ Java Interview Questions - Alcatel Lucent: Data Structure
C++/ Java Interview Questions - Alcatel Lucent: Data Structure
Questions were:
The next question was related to matrix . Suppose u have a nXn matrix and having different
elements then , find out the realtion between minimum of maximum of each row and
maximum of minimum of each column .
1) Design a data structure which contains the behaviour of a bag.
2) Write a method to sort the matrix such that each row should be in increasing
order and each column should be in decreasing order and find the time complexity .
3) Write a dynamic programming solution for travelling sales man problem.
4) Many other questions from bitwise operations .
Explain recursion.
A function is called recursive if a statement within the function can call the same function.
In circular definition it is the process of defining something in terms of itself.
It is represented as rec( ).
An if statement is used within recursive statement to avoid infinite loop.
Can user defined functions be added to the library ?If yes, explain.
Yes, the user defined functions can be added to the library.
Also different compilers provide different utilities to modify functions and for c compilers utility called tlib.exe (Turbo
library) is used.
Initially create the function and then compile the file using Alt f9.
This file contains the code in machine language and then add file to the library using the command c:\.>tlib
math.lib + c:\filename.obj
Declare the prototype of function in the header file.
To include it in a program use syntax : #include c:\\filename.h.
float x = 3.3;
int i;
i = (int) x;
print i;
3
3.3
3.0
3.00
5. What is the purpose of getc() for?
read a character from STDIN
read a character from a file
both and b above
read a character from an input of user
8. ___________ will immediately jump to the end of the current block of code
continue
exit
goto
break
9. Importance of "auto" specifier
Automatically initializes a variable to NULL.
Automatically initializes a variable to 0;.
Automatically increments the variable when used.
Indicates that a variable's memory space is allocated upon entry into the block.
Indicates that a variable's memory will automatically be preserved.
10. How to read a character from the keyboard and will store it in the variable a.
a = getchar( stdin );
a = getchar();
a = getc();
getchar( &a )
getc( &a );
11. Which one is used for moving blocks of binary data that are of arbitrary size and position in memory?
strncpy()
memcpy()
memmove()
strcpy()
memset()
12. _________________ function to read a specified number of elements from a file.
gets()
fileread()
readfile()
fread()
getline()
13. What function should be used to release allocated memory which is no longer needed?
free()
dealloc()
release()
dropmem()
unalloc()