1. You're given an array containing positive and negative integers and required to find the sub-array with the largest sum (O(N) ). Write a routine in C for the above.
2. Given an array of size N in which every number is between 1 and N, determine if there are any duplicates in it. You are allowed to destroy the array if you like.
3. Write a routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without making use of any floating point computations at all
4. Give a one-line C expression to test whether a number is a power of 2
5. Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.
6. Give a very good method to count the number of ones in a "n" (e.g. 32) bit number
7. Reverse a linked list.
8. Insert in a sorted list
9. Write a function to find the depth of a binary tree.
10. 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.
No comments:
Post a Comment