Algorithms And Programming #5

41. Fundas of RPC.

42. Given a linked list, which is sorted. How will u insert in sorted way.

43. Given a linked list how will you reverse it?

44. Give a good data structure for having n queues (n not fixed) in a finite memory segment. You can have some data-structure separate for each queue. Try to use at least 90% of the memory space.

45. Do a breadth first traversal of a tree.

46. Write code for reversing a linked list.

47. Write, efficient code for extracting unique elements from a sorted list of array. e.g. (1, 1, 3, 3, 3, 5, 5, 5, 9, 9, 9, 9) -> (1, 3, 5, 9).

48. Given an array of integers, find the contiguous sub array with the largest sum.

ANS. Can be done in O (n) time and O (1) extra space. Scan array from 1 to n. Remember the best sub array seen so far and the best sub array ending in i.

49. Given an array of length N containing integers between 1 and N, determine if it contains any duplicates.

ANS. [Is there an O (n) time solution that uses only O (1) extra space and does not destroy the original array?]

50. Sort an array of size n containing integers between 1 and s. The sum of the array is known not to overflow an integer. Compute the sum. What if we know that integers are in 2's complement form?


NEXT
BACk

No comments:

Post a Comment