Re: [algogeeks] MS interview question

2013-04-26 Thread achala sharma
1. Make a trie of all dictionary words. 2.then run a loop for all characters of string 3.suppose start from I ,as I is a word in dictionary,word found then increment counter 4.Now counter comes to X,no word found 5.Now it comes to A,two word could start from A(A and AM) now run this loop till end

[algogeeks] MS interview

2012-08-24 Thread GAURAV CHAWLA
Ques Given a large text... in the text.. there are gt; , lt; etc representing and .(there can be others like eq; etc) the task is to replace such (gt;) with the '' symbol... and (lt;) with '' given the table which have corresponding matches... and table is

Re: [algogeeks] MS interview

2012-08-24 Thread Navin Kumar
Anagram problem solution using TRIE.. For each word in dictionary we will put it in TRIE as.. 1. First sort the word 2. Search in trie using sorted word. If search found then we will add the original word in that TRIE node. 3. If node node not found then using simple TRIE insertion insert

[algogeeks] MS interview

2012-08-22 Thread GAURAV CHAWLA
Ques.. Given a m-word dictionary ... and a n-sized word... .. now suggest DS for dictionary such that you can find out all the anagrams of the given word present in dictionary... -- Regards, G C -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

Re: [algogeeks] MS interview

2012-08-22 Thread Ashish Goel
O(n) convert each string into format a1b2and then insert into multimap wityh this a1b2...as key and original word as value. All words with same key are anagrams Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Wed, Aug 22, 2012 at 11:39 PM,

Re: [algogeeks] MS interview

2012-08-22 Thread Navin Kumar
@Ashish: According to your algo making multimap itself takes O(mn) time complexity (preprocessing). After then getting anagram of a string takes O(n) time. Am i right? On Thu, Aug 23, 2012 at 6:51 AM, Ashish Goel ashg...@gmail.com wrote: O(n) convert each string into format a1b2and then

Re: [algogeeks] MS interview

2011-09-17 Thread bharatkumar bagana
Memory management has following things.. 1.Relocation To maintain the free pages and when a page is to be swapped, we have to add that page into free page list .. For this ,if we maintain a bool array which is equal to # pages in RAM,it gives whether it is free or not .. 2.Protection If ours is

Re: [algogeeks] MS interview

2011-09-17 Thread Abhishek Yadav
What should be the answer to above questions...? On Sat, Sep 17, 2011 at 5:01 AM, bharatkumar bagana bagana.bharatku...@gmail.com wrote: Memory management has following things.. 1.Relocation To maintain the free pages and when a page is to be swapped, we have to add that page into free page

[algogeeks] MS interview

2011-09-15 Thread teja bala
13. Propose an algo/data struct for memory manager. 14. Propose and algo/data struct for timer manager. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this

[algogeeks] MS interview:

2011-07-27 Thread geek forgeek
Function to display the directory structure in a user friendly way taking root dir as arg for a general OS. You may assume and state some basic APIs available in that OS -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

Re: [algogeeks] MS interview:

2011-07-27 Thread Anand Saha
Implement Preorder Traversal in the File system tree. -- On Wed, Jul 27, 2011 at 12:06 PM, geek forgeek geekhori...@gmail.comwrote: Function to display the directory structure in a user friendly way taking root dir as arg for a general OS. You may assume and state some basic APIs

Re: [algogeeks] MS interview:

2011-07-27 Thread sunny agrawal
yes Preorder recursion will be good for displaying in User Friendly way... On Wed, Jul 27, 2011 at 12:49 PM, Anand Saha anands...@gmail.com wrote: Implement Preorder Traversal in the File system tree. -- On Wed, Jul 27, 2011 at 12:06 PM, geek forgeek geekhori...@gmail.comwrote: Function

Re: [algogeeks] MS interview:

2011-07-27 Thread geek forgeek
can some one give me the code plz? On Wed, Jul 27, 2011 at 12:26 AM, sunny agrawal sunny816.i...@gmail.comwrote: yes Preorder recursion will be good for displaying in User Friendly way... On Wed, Jul 27, 2011 at 12:49 PM, Anand Saha anands...@gmail.com wrote: Implement Preorder Traversal

Re: [algogeeks] MS interview:

2011-07-27 Thread Anantha Krishnan
Here is a Java code : *private static void _printTree(String root,int depth) { if(root==null || root.trim().length()==0) return; File f=new File(root); if(f.isFile()==true) { printTab(depth);

Re: [algogeeks] MS interview

2011-07-21 Thread subramania jeeva
consider two matrices A B Its solution is based on transposing a matrix B, so that its solution can be computed easily. Here I gave the solution in which each node has three variables index i,j and value. #includeiostream using namespace std; struct node { int val,i,j; node

[algogeeks] MS interview

2011-07-20 Thread ((** VICKY **))
Given a linked list with a n*n matrix elements write an algo to compute product of two such linked list. say n = 3then 1 2 3 4 5 6 7 8 9 will be given as 1-2-3-4-5-6-7-8-9 now given two matrices , given a algo to perform matrix multiplication giving result in thrid linked list. -- You

[algogeeks] MS Interview

2011-07-12 Thread rShetty
Given a very big file of words, a word in each line, sort the words . Please provide the algorithm and explanation . -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To

Re: [algogeeks] MS Interview

2011-07-12 Thread nicks
Algorithm along with code is explained very well in KR refer page 108;) On Wed, Jul 13, 2011 at 10:26 AM, rShetty rajeevr...@gmail.com wrote: Given a very big file of words, a word in each line, sort the words . Please provide the algorithm and explanation . -- You received this message

Re: [algogeeks] MS Interview

2011-07-12 Thread saurabh singh
maintain a key.Associate with each word a key.When comparing the string,if string1string2 swap the keys instead of the words.Saves enormous time. On Wed, Jul 13, 2011 at 10:32 AM, nicks crazy.logic.k...@gmail.com wrote: Algorithm along with code is explained very well in KR refer page 108 ;)

Re: [algogeeks] MS Interview

2011-07-12 Thread Aniket Dutta
you can sort it using external merge sort. if ur file is greater than memory refer henry F. korth Database System Concept On Wed, Jul 13, 2011 at 10:26 AM, rShetty rajeevr...@gmail.com wrote: Given a very big file of words, a word in each line, sort the words . Please provide the algorithm and

Re: [algogeeks] MS Interview

2011-06-13 Thread 李峰
A1.bitmap. A2.xor. On Thu, Jun 09, 2011 at 02:45:48AM -0700, Dumanshu wrote: Q1. I have a file in which there are supposed to be 4 billion numbers, starting from 1 to 4,000,000,000 but unfortunately one number is missing, i.e there are only 3,999,999,999 numbers, I need to find the

Re: [algogeeks] MS Interview

2011-06-09 Thread Ershad K
On Thursday 09 June 2011 03:15 PM, Dumanshu wrote: Q1. I have a file in which there are supposed to be 4 billion numbers, starting from 1 to 4,000,000,000 but unfortunately one number is missing, i.e there are only 3,999,999,999 numbers, I need to find the missing number. Is the array sorted?

Re: [algogeeks] MS Interview

2011-06-09 Thread Freak Algo
For Q2 Bitwise X-OR operation of all input numbers does the trick. --- On Thu, 9/6/11, Dumanshu duman...@gmail.com wrote: From: Dumanshu duman...@gmail.com Subject: [algogeeks] MS Interview To: Algorithm Geeks algogeeks@googlegroups.com Date: Thursday, 9 June, 2011, 9:45 AM Q1. I  have a file

Re: [algogeeks] MS Interview

2011-06-09 Thread Ershad K
On Thursday 09 June 2011 09:59 AM, Ershad K wrote: On Thursday 09 June 2011 03:15 PM, Dumanshu wrote: Q1. I have a file in which there are supposed to be 4 billion numbers, starting from 1 to 4,000,000,000 but unfortunately one number is missing, i.e there are only 3,999,999,999 numbers, I need

Re: [algogeeks] MS Interview

2011-06-09 Thread Navneet Gupta
The answer to second question is simple. XORing all the elements should do it for you. On Thu, Jun 9, 2011 at 3:15 PM, Dumanshu duman...@gmail.com wrote: Q1. I  have a file in which there are supposed to be 4 billion numbers, starting from 1 to 4,000,000,000 but unfortunately one number is

Re: [algogeeks] MS Interview

2011-06-09 Thread varun pahwa
2nd part can be done just take the xor of all the numbers same number xor returns 0 so only seven will remain. 1st part can be done in O(n) because estimate sum - n*(n+1)/2. now sub from estimated sum each array element. the last value remained is the missing number. correct me if i am wrong. On

[algogeeks] MS Interview

2011-06-09 Thread Dumanshu
Q1. I have a file in which there are supposed to be 4 billion numbers, starting from 1 to 4,000,000,000 but unfortunately one number is missing, i.e there are only 3,999,999,999 numbers, I need to find the missing number. Q2. I have an array consisting of 2n+1 elements. n elements in it are

Re: [algogeeks] MS Interview

2011-06-09 Thread • » νιρυℓ « •
For 1. sum the numbers in the file, subtract it from sum of first 4 billion numbers. On Thu, Jun 9, 2011 at 3:44 PM, Navneet Gupta navneetn...@gmail.com wrote: The answer to second question is simple. XORing all the elements should do it for you. On Thu, Jun 9, 2011 at 3:15 PM, Dumanshu

Re: [algogeeks] MS Interview

2011-06-09 Thread Naveen Kumar
I think numbers in question1 are in sequence (ascending order). 2011/6/9 • » νιρυℓ « • vipulmehta.1...@gmail.com For 1. sum the numbers in the file, subtract it from sum of first 4 billion numbers. On Thu, Jun 9, 2011 at 3:44 PM, Navneet Gupta navneetn...@gmail.comwrote: The answer to

Re: [algogeeks] MS Interview

2011-06-09 Thread sunny agrawal
sum can overflow Xor method can also be applied to Q1. no need of numbers to be sorted. 2011/6/9 • » νιρυℓ « • vipulmehta.1...@gmail.com For 1. sum the numbers in the file, subtract it from sum of first 4 billion numbers. On Thu, Jun 9, 2011 at 3:44 PM, Navneet Gupta

Re: [algogeeks] MS Interview

2011-06-09 Thread • » νιρυℓ « •
Sum wont overflow, ULL range will include sum. On Thu, Jun 9, 2011 at 3:52 PM, sunny agrawal sunny816.i...@gmail.comwrote: sum can overflow Xor method can also be applied to Q1. no need of numbers to be sorted. 2011/6/9 • » νιρυℓ « • vipulmehta.1...@gmail.com For 1. sum the numbers in

Re: [algogeeks] MS Interview

2011-06-09 Thread sunny agrawal
yes, but using xor no need of ULL :) 2011/6/9 • » νιρυℓ « • vipulmehta.1...@gmail.com Sum wont overflow, ULL range will include sum. On Thu, Jun 9, 2011 at 3:52 PM, sunny agrawal sunny816.i...@gmail.comwrote: sum can overflow Xor method can also be applied to Q1. no need of numbers to

Re: [algogeeks] MS interview question

2011-06-09 Thread Rohit Sindhu
I this this code will solves it ... *#include stdio.h #include stdlib.h struct node{ int val; struct node *next; }; int main(){ struct node *head = NULL , *next_ptr = head; int n = 1; while ( n = 6 ){ struct node *temp = (struct node*) malloc (sizeof(struct node)

Re: [algogeeks] MS interview question

2011-06-02 Thread wujin chen
how about this one? Node* reverseBy2(Node* head){ Node* p1 = head; if(p1 == NULL) return NULL; Node* p2 = p1-next; if(p2 == NULL) return head; Node* nextHead = p2-next; p2-next = p1; p1-next = reverseBy2(nextHead); return p2; } [?] 2011/6/1 Shivaji

Re: [algogeeks] MS interview question

2011-06-02 Thread Azhar Hussain
struct node *reverse(struct node *head, int k ) { struct node *prev = NULL; struct node *current = head; struct node *next = NULL; int count = 0; while(current count k) { next = current-next; current-next = prev; prev = current; current = next; count++; } /*** reverse remaining nodes

[algogeeks] MS interview question

2011-05-31 Thread Anand
Given a linked list of the form, 1-2-3-4-5-6, convert it into the form 2-1-4-3-6-5. Note that the nodes need to be altered and not the data contained in them -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] MS interview question

2011-05-31 Thread Shivaji Varma
Hi, Please take a look at this link. http://mycsinterviewsexperiences.blogspot.com/ -- Shivaji On Wed, Jun 1, 2011 at 6:26 AM, Anand anandut2...@gmail.com wrote: Given a linked list of the form, 1-2-3-4-5-6, convert it into the form 2-1-4-3-6-5. Note that the nodes need to be altered and