Wednesday, June 27, 2007

some more interview questions

1. Consider a linked list where every node has one data field and one next field. The next field is used to point to the following node. You get a pointer to a node in such a list. You are required to delete the node. Please describe how you delete such a node. You are not allowed to change the structure of the nodes.

2. Consider a linked list where every node has one data field and one next field. You need to explain what operation do you need to do in order to be able to traverse such a list from head (a pointer to the first node of the list) to tail (a pointer to the last node of the list) and from tail to head. You are not allowed to change the structure of the nodes.

3. Explain the assembler language that you're familiar with and describe the architecture of the processor this assembler is for.

4. Write a Lex program that copies a file, replacing each non-empty sequence of white space by a single blank

5. Write a Lex program that copies a C program, replacing each instance of the keyword float by double

6. Consider the following C code:

int state;
int **transition_table;/* num_states x alphabeth_size*/
.
.
.
state = transition_table[state][input_char++];
Suggest how to optimize this code.

7. Please give an object oriented description of the data structures required for an implementation of a jigsaw-puzzle game.

8. implement int strcmp(const char *s1, const char *s2); and int strncmp(const char *s1, const char *s2, size_t n); in the assembler language that you are familiar with.

9. Write a grammar (e.g., for YACC) for a calculator that supports the four basic arithmetic operations:
-+*/ and using the round brackets ( and ) for priorities.

10. Write a function void fizz_bazz(char* in, char* out, int l, int skew) that receives two strings, an input string and an output string. The memory for both strings is allocated a-priori and the length of both strings is l. You need to implement the function so that the output string will be as follows:
* every character c in the string in should be shifted skew positions upper or further.
* whenever a character in an odd position in the in array is being processed print fizz
* whenever a character in an even position in the in array is being processed print bazz
* whenever a character in a position that is divisible by 3 in the in array is being processed print boo

so for the following contents in the in array
ABxyz
the expected contents in the out array is
NOklm
and the output on the standard output is expected to be
bazzboofizzbazzfizzboobazz