NetApp Interview Report
- 0of 0 votes
AnswersThis is incremental.
Q1. Write the the algo for linked list traversal.
Q2. Now, modify this to give the index of a element "x" in list (index== its location in list, rather number of comparison needed to finally get to X, else 0)
Q3. modify and give the prototype of function will work generally (that means a function prototype which takes any data strcutre(list, q, tree, heap), X, and return the count)
Q4. Now declare the function defined above.
Answers I gave:
1.bool traverse ( list * head) { while (head) {head=head->next;} return TRUE; }
2. bool findx (list *head, void *x, int num_bytes)
- Varun October 04, 2011 in India
{
bool ret = FALSE;
while (head) {
if (memcmp(head->data, x, num_bytes)){ ret=TRUE; return ret;}
else ret;
}
3. int findX(void *head, int (*traverse(void *node, void *x))
where *traverse is a function pointer that can be changed depending upon data structure for which we need to find the index of X.| Report Duplicate | Flag | PURGE
NetApp Software Engineer / Developer Algorithm - 0of 0 votes
Answersmain() { char *c; printf("\n%d", *c); printf("\n%d", c); printf("\n%d", &c); }
output of above program.
- Varun October 04, 2011 in India
*c some junk value, c some memory address, &c address where the pointer is stored.
Q. if we re-run the program, then what's the output.
A. all output may change.
He stressed that &c won't change, everything else might..but &c will remain same.??
I just tried on my unix box, and saw it to change?| Report Duplicate | Flag | PURGE
NetApp Software Engineer / Developer