[algogeeks] Write a C program to sort a stack in ascending order.

2010-07-17 Thread vijay
Write a C program to sort a stack in ascending order. You should not make any assumptions about how the stack is implemented. The following are the only functions that should be used to write this program: Push | Pop | Top | IsEmpty | IsFull The algorithm is O(N^2) and appears below. Do we have

[algogeeks] GIven 2 dates, print out the lines in the file between these 2 dates. Also optimize solution because the file may be huge and so dont go line by line.

2010-07-17 Thread vijay
a file contains lot of log information in the form of DD:MM:YY HOURS: MINUTES:SECOND: random length text GIven 2 dates, print out the lines in the file between these 2 dates. Also optimize solution because the file may be huge and so dont go line by line. -- You received this message

[algogeeks] Re: Write a C program to sort a stack in ascending order.

2010-07-17 Thread xyombie
What about a quick sort O(log n) void sort_stack(Stack *src, Stack *dst) { if(! src-IsEmpty() ) { Stack smaller, larger; int pivot = src-Pop(); while(! src-IsEmpty() ) { int tmp = src-Pop();

Re: [algogeeks] Dynamic Programming Problem on Strings

2010-07-17 Thread Ashish Goel
dp[i][0]=1 implies that there is 1 combination which will ensure that the number of A's and B's is same in the string. eg AAA is not a valid string dp[0][0]=1 doesnot satisfy property 1 either with this algo and tring length 4(possible strings AABB, ABAB) a[i][j] will look like 1 1 1 0 1 0 0

Re: [algogeeks] Dynamic Programming Problem on Strings

2010-07-17 Thread Rahul Singhal
It can be solved with trie On Sun, Jul 18, 2010 at 10:28 AM, Ashish Goel ashg...@gmail.com wrote: dp[i][0]=1 implies that there is 1 combination which will ensure that the number of A's and B's is same in the string. eg AAA is not a valid string dp[0][0]=1 doesnot satisfy property 1 either