Algorithms And Programming #3

21. Delete an element from a doubly linked list.

22. Write a function to find the depth of a binary tree.

23. Given two strings S1 and S2. Delete from S2 all those characters, which occur in S1 also and finally create a clean S2 with the relevant characters deleted.

24. Assuming that locks are the only reason due to which deadlocks can occur in a system. What would be a foolproof method of avoiding deadlocks in the system?

25. Reverse a linked list.
Ans:
Possible answers -
iterative loop
curr->next = prev;
prev = curr;
curr = next;
next = curr->next
endloop

Recursive reverse (ptr)
if (ptr->next == NULL)
return ptr;
temp = reverse (ptr->next);
temp->next = ptr;
return ptr;
end

26. Write a small lexical analyzer - interviewer gave tokens. expressions like "a*b" etc.

27. Besides communication cost, what is the other source of inefficiency in RPC?
(Answer: context switches, excessive buffer copying).
How can you optimize the communication?
(Ans: communicate through shared memory on same machine, bypassing the kernel _ A Univ. of Wash. thesis)

28. Write a routine that prints out a 2-D array in spiral order!

29. How is the readers-writers problem solved? - using semaphores/ada .. etc.

30. Ways of optimizing symbol table storage in compilers.


NEXT
BACk

No comments:

Post a Comment