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
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
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
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
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,
@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
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
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
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
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,
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
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
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
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);
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
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
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
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
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
;)
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
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
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?
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
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
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
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
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
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
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
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
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
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
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)
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
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
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
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
37 matches
Mail list logo