you can't implement in O(log n). It can be done in O(log n) in case of
Ranked BS Tree.
--
Amitesh
On Sun, Jan 20, 2013 at 6:23 PM, Praveen praveensonare...@gmail.com wrote:
If for all the nodes in BST we also store the size of subtree, then it is
possible to find nth smallest element in
not possible unless u use augmented bst..which itself takes o(n) to built
--
http://stackoverflow.com/questions/2329171/find-kth-smallest-element-in-a-binary-search-tree-in-optimum-way
On Sun, Jan 20, 2013 at 4:57 PM, Guneesh Paul Singh gunees...@gmail.comwrote:
not possible unless u use augmented bst..which itself takes o(n) to built
--
--
If for all the nodes in BST we also store the size of subtree, then it is
possible to find nth smallest element in O(logN).
On Sun, Jan 20, 2013 at 4:57 PM, Guneesh Paul Singh gunees...@gmail.comwrote:
not possible unless u use augmented bst..which itself takes o(n) to built
--
--
Given a BST, how would you return the nth smallest element. The code had to
cover all the edge cases and was expected to write a logn solution.
--
Umer
--
Hi all,
This was asked in microsoft, question is write a program to
reverse a linked list.and write it's test cases.
i got very few test cases
1) check if the node is null
2) check if there is only one node
3) check if there is any loop in the linked list.
can any one tell how to
Reversing a linked list if loop exists:
1. Find the node from which loop start by any loop finding algorithm in
linked list and keep the position of that node.
2. Unroll the loop i.e. set the last node's(last unrepeating node) next
pointer to NULL.
3. Reverse this singly linked list.
4. Change
Few more Test cases :
Check for 10 node.
Check for 1 million node
Check for even number of nodes
Check for odd number of nodes...
etc etc...
On Fri, Aug 24, 2012 at 6:25 PM, Navin Kumar algorithm.i...@gmail.comwrote:
Reversing a linked list if loop exists:
1. Find the node from which loop
peacelover1987...@yahoo.co.in wrote:
This is a variant of that one
--
*From:* saurabh singh saurab...@gmail.com
*To:* algogeeks@googlegroups.com
*Sent:* Friday, 29 June 2012 3:05 PM
*Subject:* Re: [algogeeks] MS Question: Segregrate positive and
negative nos
--
*From:* saurabh singh saurab...@gmail.com
*To:* algogeeks@googlegroups.com
*Sent:* Friday, 29 June 2012 3:05 PM
*Subject:* Re: [algogeeks] MS Question: Segregrate positive and
negative nos in array without changing order
duplicate of a previous post.Kindly refer
;
}
On Fri, Jun 29, 2012 at 3:37 PM, raghavan M
peacelover1987...@yahoo.co.in wrote:
This is a variant of that one
--
*From:* saurabh singh saurab...@gmail.com
*To:* algogeeks@googlegroups.com
*Sent:* Friday, 29 June 2012 3:05 PM
*Subject:* Re: [algogeeks] MS Question
@amol :
#includestdio.h
int main()
{
int arr[]={5,0,1,2,6,7,8,3,4,9};
int i,j,n,temp;
n=sizeof(arr)/sizeof(arr[0]);
for(j=0;j=1;j++)
{
for(i=0;in;i++)
{
if(arr[i]!=i){
temp=arr[i];
arr[i]=arr[arr[i]];
i don't see any change in the code you posted...other than expanding swap
function
i believe in discussing the idea/algonot the code..
--
Amol Sharma
Final Year Student
Computer Science and Engineering
MNNIT Allahabad
http://gplus.to/amolsharma99
yes it is same and it not working . Apart for this you had provided code
for sorting O(n) time and not the idea/algo.
please explain the algorithm , how you are sorting it within O(n) time and
O(1) space complexity.
On Mon, Jul 2, 2012 at 3:18 PM, Amol Sharma amolsharm...@gmail.com wrote:
i
opssyeah dat was the bug... now got it :)
On Mon, Jul 2, 2012 at 4:08 PM, Amol Sharma amolsharm...@gmail.com wrote:
@atul:
the logic for the O(n) counting is same as for the count sort.
you haven't write the swap function correctly,
here is correct code for swap function --
: [algogeeks] MS Question: Segregrate positive and
negative nos in array without changing order
duplicate of a previous post.Kindly refer to that post.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com
On Fri, Jun 29, 2012 at 10:41 AM, raghavan M
peacelover1987
PM, raghavan M
peacelover1987...@yahoo.co.in wrote:
This is a variant of that one
--
*From:* saurabh singh saurab...@gmail.com
*To:* algogeeks@googlegroups.com
*Sent:* Friday, 29 June 2012 3:05 PM
*Subject:* Re: [algogeeks] MS Question: Segregrate positive
saurab...@gmail.com
*To:* algogeeks@googlegroups.com
*Sent:* Friday, 29 June 2012 3:05 PM
*Subject:* Re: [algogeeks] MS Question: Segregrate positive and
negative nos in array without changing order
duplicate of a previous post.Kindly refer to that post.
Saurabh Singh
B.Tech (Computer Science
: [algogeeks] MS Question: Segregrate positive and
negative nos in array without changing order
duplicate of a previous post.Kindly refer to that post.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com
On Fri, Jun 29, 2012 at 10:41 AM, raghavan M
--
*From:* saurabh singh saurab...@gmail.com
*To:* algogeeks@googlegroups.com
*Sent:* Friday, 29 June 2012 3:05 PM
*Subject:* Re: [algogeeks] MS Question: Segregrate positive and
negative nos in array without changing order
duplicate of a previous post.Kindly
--
*From:* saurabh singh saurab...@gmail.com
*To:* algogeeks@googlegroups.com
*Sent:* Friday, 29 June 2012 3:05 PM
*Subject:* Re: [algogeeks] MS Question: Segregrate positive and
negative nos in array without changing order
duplicate of a previous post.Kindly refer to that post
Hi
Question as in subject
*No extra spaceĀ (can use one extra space)-O(1) max
*No order change allowed
example:
input : 1,-5,2,10,-100,-2
output: -5,-10,-100,1,2
input : -1,-5,10,11,15,-500,200,-10
output : -1,-5,-10,-500,-10,10,11,15
Thanks
Raghavn
--
You received this message because you
This link should help
http://stackoverflow.com/questions/5667793/how-does-a-read-write-mutex-lock-work?rq=1
-mithun
On Fri, Jun 29, 2012 at 7:30 AM, bharat b bagana.bharatku...@gmail.comwrote:
class lock
{
enum{read, write,free}status;
};
By default, make status value as free.
Based
duplicate of a previous post.Kindly refer to that post.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com
On Fri, Jun 29, 2012 at 10:41 AM, raghavan M
peacelover1987...@yahoo.co.inwrote:
Hi
Question as in subject
*No extra space (can use one extra
one can modify dutch national flag algo for two colors(2 types positive n
negative)
--
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 group, send email to
Quick sort partition routine variation.
On Fri, Jun 29, 2012 at 3:06 PM, Ravi Ranjan ravi.cool2...@gmail.comwrote:
one can modify dutch national flag algo for two colors(2 types positive n
negative)
--
You received this message because you are subscribed to the Google Groups
Algorithm
To: algogeeks@googlegroups.com
Sent: Friday, 29 June 2012 3:06 PM
Subject: Re: [algogeeks] MS Question: Segregrate positive and negative nos in
array without changing order
one can modify dutch national flag algo for two colors(2 types positive n
negative)
--
You received this message because you
This is a variant of that one
From: saurabh singh saurab...@gmail.com
To: algogeeks@googlegroups.com
Sent: Friday, 29 June 2012 3:05 PM
Subject: Re: [algogeeks] MS Question: Segregrate positive and negative nos in
array without changing order
duplicate
of that one
--
*From:* saurabh singh saurab...@gmail.com
*To:* algogeeks@googlegroups.com
*Sent:* Friday, 29 June 2012 3:05 PM
*Subject:* Re: [algogeeks] MS Question: Segregrate positive and negative
nos in array without changing order
duplicate of a previous
:* Friday, 29 June 2012 3:05 PM
*Subject:* Re: [algogeeks] MS Question: Segregrate positive and negative
nos in array without changing order
duplicate of a previous post.Kindly refer to that post.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com
On Fri, Jun
*Subject:* Re: [algogeeks] MS Question: Segregrate positive and
negative nos in array without changing order
duplicate of a previous post.Kindly refer to that post.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com
On Fri, Jun 29, 2012 at 10:41 AM
:05 PM
*Subject:* Re: [algogeeks] MS Question: Segregrate positive and
negative nos in array without changing order
duplicate of a previous post.Kindly refer to that post.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com
On Fri, Jun 29, 2012 at 10:41
*Subject:* Re: [algogeeks] MS Question: Segregrate positive and
negative nos in array without changing order
duplicate of a previous post.Kindly refer to that post.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com
On Fri, Jun 29, 2012 at 10:41 AM, raghavan M
we can create linked list for the number where each node will store some k
digits (say 5) in the reverse order.then we just perform a normal addition
of the data of the nodes with the help of carry.
note that if the numbers are not positive then we need to maintain a sign
bit node also.if any of
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
--
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 group, send
class lock
{
enum{read, write,free}status;
};
By default, make status value as free.
Based on the request, status value will be changed...
Based on the value of the status, we should decide whether another
read/write lock can be given.
Any suggestions ?
On Thu, Jun 28, 2012 at 4:46 PM, Ashish
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
--
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 group, send
whether it is in character array or integer array??
On Tue, Jun 26, 2012 at 3:40 PM, Ashish Goel ashg...@gmail.com wrote:
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
--
You received this message because you are subscribed to the Google
^ Does it make any difference?
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com
On Tue, Jun 26, 2012 at 5:32 PM, Navin Kumar algorithm.i...@gmail.comwrote:
whether it is in character array or integer array??
On Tue, Jun 26, 2012 at 3:40 PM, Ashish Goel
MSB is at end or at the last of the array .. ??
On Tue, Jun 26, 2012 at 5:43 PM, saurabh singh saurab...@gmail.com wrote:
^ Does it make any difference?
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com
On Tue, Jun 26, 2012 at 5:32 PM, Navin Kumar
I mean 123 is store as 1,2,3 or 3,2,1
On Tue, Jun 26, 2012 at 6:01 PM, Kumar Vishal kumar...@gmail.com wrote:
MSB is at end or at the last of the array .. ??
On Tue, Jun 26, 2012 at 5:43 PM, saurabh singh saurab...@gmail.comwrote:
^ Does it make any difference?
Saurabh Singh
the base is not given, so 10 can't be assumed
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
On Tue, Jun 26, 2012 at 4:38 PM, amrit harry dabbcomput...@gmail.comwrote:
make size of both array by adding '0' in front of smaller array
then
int
This solution works perfectly :)
On Friday, June 15, 2012 10:59:22 AM UTC+5:30, Navin Kumar wrote:
I corrected in function InsertAtBottom :In my code isntead of
(!IsEmptyStack) use IsEmptyStack
On Fri, Jun 15, 2012 at 10:49 AM, Navin Kumar algorithm.i...@gmail.comwrote:
@all:
In my
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
--
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 group, send
to store items in stack you will need some DS. Do they mean you cant use
any auxillary DS than stack ?
On Thu, Jun 14, 2012 at 2:24 PM, Ashish Goel ashg...@gmail.com wrote:
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
--
You received this
void Reverse(struct Stack *S) {
int data;
if(IsEmptyStack(S)) return;
data=pop(s);
ReverseStack(S);
InsertAtBottom(S, data);
}
void InsertAtBottom(struct stack *S, int data)
{
int temp;
if(!IsEmptyStack(S)){
push(S,data);
return;
}
temp=pop(S);
@ Navin Kumar
Nice . Solution.
But
your function also make a stack only. so you are using a stack[internal]
here.
but may be this one is allowed:-)
On Thu, Jun 14, 2012 at 5:23 AM, Navin Kumar algorithm.i...@gmail.comwrote:
void Reverse(struct Stack *S) {
int data;
Navin: copy pastes not encouraged till the logic is also clarified ;)
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
On Thu, Jun 14, 2012 at 7:25 PM, Sourabh Singh singhsourab...@gmail.comwrote:
@ Navin Kumar
Nice . Solution.
But
your
how can you pop from empty stack ?
temp=pop(S);
Regards,
Hassan
On Thu, Jun 14, 2012 at 8:25 PM, Ashish Goel ashg...@gmail.com wrote:
Navin: copy pastes not encouraged till the logic is also clarified ;)
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
void pushreverse(int data)
{
int temp;
if(top==0)
{
push(data);
return;
}
else
temp=pop();
pushreverse(data);
push(temp);
}
int reversestack()
{
//static int arr[50];
int top2=0;
int i;
if(top==0)
{ return top2;
}
top2=pop();
reversestack();
pushreverse(top2);
}
On Thu, Jun 14, 2012 at 2:44
Hi all,
Generate combinations (taken k out of n) of a given string
Eg: Input : abcd
Output:
abc
acd
abd
bcd
--
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
the steps would be like this :
if i say stack is like this 1,2,3,4 then
1) pop each and every item from the stack till stack is empty
the nodes will be ther in function call stack stil not pushed
2) now now take elements from function call stack like 4 and push it
3) when 3 comes next time first
stack means inbuild stack we cant use any DS from our program explicitly.
On Thu, Jun 14, 2012 at 2:44 PM, rahul patil
rahul.deshmukhpa...@gmail.comwrote:
to store items in stack you will need some DS. Do they mean you cant use
any auxillary DS than stack ?
On Thu, Jun 14, 2012 at 2:24 PM,
i think i already explained the logic initially :)
On Thu, Jun 14, 2012 at 9:30 PM, Hassan Monfared hmonfa...@gmail.comwrote:
how can you pop from empty stack ?
temp=pop(S);
Regards,
Hassan
On Thu, Jun 14, 2012 at 8:25 PM, Ashish Goel ashg...@gmail.com wrote:
Navin: copy pastes not
@all:
In my code isntead of (!IsEmptyStack) use IsEmptyStack
Logic :
First pop the all element and then start putting element at bottom in
reverse order i.e. the element which is fetched last is put at the bottom
and so on.
ex: let our stack is: 1 2 3 4 (1 is at bottom).
function Call is will
I corrected in function InsertAtBottom :In my code isntead of
(!IsEmptyStack) use IsEmptyStack
On Fri, Jun 15, 2012 at 10:49 AM, Navin Kumar algorithm.i...@gmail.comwrote:
@all:
In my code isntead of (!IsEmptyStack) use IsEmptyStack
Logic :
First pop the all element and then start putting
@utsav u haven't initialized match anywhere so ur algo fails
On Thu, Jun 7, 2012 at 2:50 AM, utsav sharma utsav.sharm...@gmail.comwrote:
i think it can be solved using DP
word=bcdf take hash of word h[b]=1 h[c]=2 h[d]=3 h[f]=4
given 2d matrix m[][]=
{b c b e f g h
b c d f p o u
d f d
WAP to find a word in a 2D array. The word can be formed on
row/col/diagnal/reverse diagnal
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post
i did this question long time back
well simple brute force check can be doneyou can keep one flag
matrix of same size to avoid necessary recursion.
On 6/6/12, Ashish Goel ashg...@gmail.com wrote:
WAP to find a word in a 2D array. The word can be formed on
row/col/diagnal/reverse
i think it can be solved using DP
word=bcdf take hash of word h[b]=1 h[c]=2 h[d]=3 h[f]=4
given 2d matrix m[][]=
{b c b e f g h
b c d f p o u
d f d f g k p }
take another matrix match[][]
if( h[ m[i][j] ] 0 ) //if this char is in word then
{a=h[ m[i][j] ];
if (match[i-1][j] ==a-1
here is the question ans solution with proper explanation
http://www.geeksforgeeks.org/archives/11604
--
Amol Sharma
Third Year Student
Computer Science and Engineering
MNNIT Allahabad
http://gplus.to/amolsharma99
whats problem with the approch provided by navin
http://k2code.blogspot.in/2011/09/deleting-node-in-singly-linked-list-if.html
it seems much simpler ...is there any test case for which it wont work ??
On Mon, Jun 4, 2012 at 3:25 PM, Amol Sharma amolsharm...@gmail.com wrote:
here is the
] MS Question: WAP to find files in a
directory/subdirectories
i wrote this program in college labbut used shell script to
simulate ls -r functionality.
now to do in c or java .. we only need to knw about the libraries to use.
On 6/3/12, Ashish Goel ashg...@gmail.com wrote:
ls-r implementation
ls-r implementation needed...
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
--
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
i wrote this program in college labbut used shell script to
simulate ls -r functionality.
now to do in c or java .. we only need to knw about the libraries to use.
On 6/3/12, Ashish Goel ashg...@gmail.com wrote:
ls-r implementation needed...
Best Regards
Ashish Goel
Think positive and
#include stdio.h
#include stdlib.h
#include sys/types.h
#include dirent.h
#include unistd.h
#include ctype.h
#include string.h
void dirfun(char *);
int main()
{
char *home=/home/navin/temp/;
dirfun(home);
return 0;
}
void dirfun(char *path)
{
struct dirent
you can set your directory path in this line
char *home=/home/navin/temp/;
On Sun, Jun 3, 2012 at 11:26 AM, Navin Kumar algorithm.i...@gmail.comwrote:
#include stdio.h
#include stdlib.h
#include sys/types.h
#include dirent.h
#include unistd.h
#include ctype.h
#include string.h
void
1- read all elements of list into stack
2- max = stak.pop()
3- if stack.empty() goto 7
4- next=stack.pop()
5- if next max then max=next
else delete next from list
6- repeat from 3
7- end!
Regards,
On Thu, May 31, 2012 at 9:45 PM, atul anand atul.87fri...@gmail.com wrote:
@navin : +1
On
the LL is unsorted, is there any better solution that this?
struct node* deleteNodes(struct node *pHead, struct node *pPrev)
{
struct node *pLL = *pHead;
if (!pLL) return NULL;
struct node *pCurr = pLL;
struct node *pRest = deleteNodes(pCurr-next, pCurr);
if (!pRest) return pCurr;
@Ashish : please clarify this ques...
delete a node in SLL if it is less than *any* of the succesor node ..
1 2 8 10 3 4 7 12
delete 1,2,8,10,3,4,7
ouput will be single node i.e 12
dats what question asks?
On Thu, May 31, 2012 at 2:16 PM, Ashish Goel ashg...@gmail.com wrote:
the LL is
yes
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
On Thu, May 31, 2012 at 2:34 PM, atul anand atul.87fri...@gmail.com wrote:
@Ashish : please clarify this ques...
delete a node in SLL if it is less than *any* of the succesor node ..
1 2 8 10
then i guess ...it can be done using stack..with O(n) complexity..
it is similar to finding next greater element
http://www.geeksforgeeks.org/archives/8405
element in the stack at the end of the algo...are the element which will
remain in the linked list . if stack is not empty then keep
that is what i have done by using recursion=stack.
my code has problem, after free(pCurr);, i should have return pRest;
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
On Thu, May 31, 2012 at 4:37 PM, atul anand atul.87fri...@gmail.com wrote:
then
I think the easiest method to do this problem is this:
http://k2code.blogspot.in/2011/09/deleting-node-in-singly-linked-list-if.html
On Thu, May 31, 2012 at 5:58 PM, Ashish Goel ashg...@gmail.com wrote:
that is what i have done by using recursion=stack.
my code has problem, after
if i am getting this questions correctly then we have to delete the element
till its next is not null ??
please comment if i am wrong ?
On Thu, May 31, 2012 at 5:58 PM, Ashish Goel ashg...@gmail.com wrote:
that is what i have done by using recursion=stack.
my code has problem, after
@navin : +1
On 5/31/12, Navin Kumar algorithm.i...@gmail.com wrote:
I think the easiest method to do this problem is this:
http://k2code.blogspot.in/2011/09/deleting-node-in-singly-linked-list-if.html
On Thu, May 31, 2012 at 5:58 PM, Ashish Goel ashg...@gmail.com wrote:
that is what i have
Implement a method to perform basic string compression using the counts of
repeated characters.(inplace)
eg:- input: aaabcdef
output:3a5b1c1d1e1f.
what should be my approach to this problem
if i calculate the size of array required to store the output string
and start from the last of
First we divide the large memory into some chunks and we hash them. For
each chunk, we need hash function.
If a thread accesses a memory location, we find which chunk of address it
is accessing, then we hash based on memory location. We can easily identify
what are all threads are accessing a
MS IDC interview question:
Given a memory location say from 0 - 1023. Now there are many threads that
are reading and writing in this memory locations at any time 0t 1t 2t ...
and so on.
For ex a thread no.4 is writing to memory location 512 at time 3t.
So we get a quadruple {4,512,W,3t}.
Say LL is
1-2-3-4-5-6-7-8
Then u need to return
7-8-5-6-3-4-1-2
U cant swap the values U have to rearrange the ptr...
--
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
wat if u have odd no of nodes
On Tue, Jan 24, 2012 at 12:00 AM, atul anand atul.87fri...@gmail.comwrote:
one simple way would be using stacks.
push node,node-next;
then pop() , and reversing the pointers.
On Mon, Jan 23, 2012 at 11:46 PM, Ankur Garg ankurga...@gmail.com wrote:
Say LL is
node *ptr =head;
//function call is reverse(head,NULL)
void reverse(node *ptr, node *follow)
{
if(ptr-next!=NULL ptr-next-next!=NULL)
reverse(ptr-next-next,ptr);
else
if(ptr-next!=NULL ptr-next-next==NULL)
{
ptr-next-next=follow;
head=ptr;
}
Well for odd cases its lile this
1 -2-3-4-5
4-5-2-3-1
Also u have to do this in single pass..U can use recursion though
On Tue, Jan 24, 2012 at 12:18 AM, Arun Vishwanathan
aaron.nar...@gmail.comwrote:
node *ptr =head;
//function call is reverse(head,NULL)
void reverse(node *ptr, node
struct node* revll(struct node* root)
{
return reverse(root,NULL);
}
struct node* reverse(struct node* head,struct node* prev)
{
struct node* temp1;
if(head-next==NULL)
{
head-next=prev;
return head;
}
else
{
temp1=reverse(head-next,head);
head-next=prev;
return temp1;
}
}
--
You received this
Assumption here is that we can use 4K memory other than considering
the actual elements storage memory.
we were given the range of elements.. we can use count sort.
for first case, all elements are unique -- we can use 27000 bits to
represent the corresponding numbers== takes 3375 Bytes 4KB.
for
Given large number of elements. All elements belong to range 1 to 27000.
First case no elements repeated and second case elements are repeated.
memory capacity is 4k. How to sort efficiently?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To
@himanshu thnx..:)
Regards,
PAYAL GUPTA,
3rd YR ,CSE,
NIT-BHOPAL.
On Fri, Jan 13, 2012 at 9:42 PM, Himanshu Neema
potential.himansh...@gmail.com wrote:
Let a color below represent a single character in UTF-8 encoding ,
which means that each color can span multiple bytes , In example below I
@Himanshu
Nice idea..that shud do..but how do we code that ?
regards
Ankur
On Sat, Jan 14, 2012 at 2:23 PM, payal gupta gpt.pa...@gmail.com wrote:
@himanshu thnx..:)
Regards,
PAYAL GUPTA,
3rd YR ,CSE,
NIT-BHOPAL.
On Fri, Jan 13, 2012 at 9:42 PM, Himanshu Neema
Let a color below represent a single character in UTF-8 encoding ,
which means that each color can span multiple bytes , In example below I
denote one byte by one english character . i.e.
'a' or 'b' or 'c' ,etc. below takes one byte :
Let the string is :
x abc def gh ij klmn
now to reverse this
Is there anything called in-place reversal ??
UTF-8 is only encoding similar to ASCII but with a huge charecter set.
So normal string reversal would work fine..
On Thu, Jan 12, 2012 at 2:02 AM, Ankur Garg ankurga...@gmail.com wrote:
How to do this
Write a function to reverse a UTF-8 encoded
Hi
Normal string will not work I think. Because it is avriable length encoding
scheme.
On Fri, Jan 13, 2012 at 11:11 AM, b.kisha...@gmail.com b.kisha...@gmail.com
wrote:
Is there anything called in-place reversal ??
UTF-8 is only encoding similar to ASCII but with a huge charecter set.
So
How to do this
Write a function to reverse a UTF-8 encoded string in-place ??
--
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 group, send email to
if element is 0 in matrix then entire row and column should be set to 0
i got this from sumwhr
void makeRowColZero(int (*a)[COL])
{
int i, j, k;
k = 0;
for(i = 0; i ROW; i++)
for(j = k; j COL; j++)
{
if(0 ==
convert bst to doubly linked list inorder and find middle element using slow
and fast pointer concept
On Tue, Sep 27, 2011 at 2:18 PM, Ankur Garg ankurga...@gmail.com wrote:
I was thinking of making the tree balanced with equal no of nodes in left
and right subtree
Median will be
I was thinking of making the tree balanced with equal no of nodes in left
and right subtree
Median will be root in this case
Regards
Ankur
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
do the inorder traversal as soon as reached at n/2th element that will be
median.
--
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 group, send email to
@Anshu
Will u be using extra space to store ur nodes in traversal ?
On Tue, Sep 27, 2011 at 2:22 PM, anshu mishra anshumishra6...@gmail.comwrote:
do the inorder traversal as soon as reached at n/2th element that will be
median.
--
You received this message because you are subscribed to
keep a global pointer and a global variable check=0
do inorder traversal..instead of printing the value do
if(check==0)
save pointer
check==1
else
check==0;
correct me if m wrong
On Tue, Sep 27, 2011 at 2:22 PM, anshu mishra anshumishra6...@gmail.comwrote:
do the
int bstMedian(node *root, int n, int x)
{
if (node-left) return bstMedian(root-left, n, x);
x++;
if (x == n/2) return node-val;
if (node-right) return bstMedian(root-right, n, x);
}
call bstMedian(root, n, 0);
--
You received this message because you are subscribed to the Google
Saw this question in one of the algo communities.
Amazon telephonic interview question on Matrix
Input is a matrix of size n x m of 0's and 1's. eg:
1 0 0 1
0 0 1 0
0 0 0 0
If a location has 1; make all the elements of that row and column = 1. eg
1 1 1 1
1 1 1 1
1 0 1 1
Solution should be with
1 - 100 of 190 matches
Mail list logo