NetApp Interview Question for Software Engineer / Developers
- 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