Given a number N, generate a sequence S such that
S[ 0 ] = N
S[ i+1 ] = (3 * S[ i ] + 1) / 2 if S[ i ] is odd,
= S[ i ] / 2, if S[ i ] is even,
till you reach 1.
For example for N = 5, the sequence is 5, 8, 4, 2, 1
Given two numbers 20 and 35, generate the sequence S for A
and B, and find the
ans.20
On Thu, Jul 26, 2012 at 11:09 PM, Ali Ahmad Ansari
ali.ahamad.ans...@gmail.com wrote:
Given a number N, generate a sequence S such that
S[ 0 ] = N
S[ i+1 ] = (3 * S[ i ] + 1) / 2 if S[ i ] is odd,
= S[ i ] / 2, if S[ i ] is even,
till you reach 1.
For example for N = 5, the
20
Thank you,
Have a great day !!
* With Regards,
*
*
Manish Patidar.*
On Thu, Jul 26, 2012 at 11:11 PM, payal gupta gpt.pa...@gmail.com wrote:
ans.20
On Thu, Jul 26, 2012 at 11:09 PM, Ali Ahmad Ansari
ali.ahamad.ans...@gmail.com wrote:
Given a
+ Manish Patidar
On Thu, Jul 26, 2012 at 10:14 PM, Manish Patidar manishpatidar...@gmail.com
wrote:
20
Thank you,
Have a great day !!
* With Regards,
*
*
Manish Patidar.*
On Thu, Jul 26, 2012 at 11:11 PM, payal gupta gpt.pa...@gmail.com wrote:
thanks:)
--
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
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this
i.p: v
o/p 5
i/p ix
o/p:9
--
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
algogeeks+unsubscr...@googlegroups.com.
For more options,
/Convert roman to decimal
#includestdio.h
int convert(char *s, int len)
{
int i = 0, d = 0, prev = 0;
for(;i len; i++)
{
switch(*(s+i))
{
case 'i': d += 1;
break;
case 'v': if(i!=0 *(s+prev) == 'i')
{
d = d + 5 - 2;
}
else
Use hashing like counting sort...
On Wed, Sep 14, 2011 at 11:20 AM, raj raji20.pat...@gmail.com wrote:
program to find the top 3 repeating number from the given array
eg
You r given an array and u have to find out the top 3 repeated
numbers.
for ex: GAURAV[]={20,8,3,7,8,9,20,6,4,6,20,8,20}
with space O(n) and time O(n), we can trace the whole array and maintain the
freq of each number and by one more trace with using 3 variables , we
can find top 3
On Wed, Sep 14, 2011 at 11:20 AM, raj raji20.pat...@gmail.com wrote:
program to find the top 3 repeating number from the
heap construction ...
On Wed, Sep 14, 2011 at 4:44 PM, bharatkumar bagana
bagana.bharatku...@gmail.com wrote:
with space O(n) and time O(n), we can trace the whole array and maintain
the freq of each number and by one more trace with using 3 variables ,
we can find top 3
On
find the frequencies of each alphabet ... n store it in an array
corressponding to the ascii value of the alphabet as a index of array ... n
store its count ... then sort the array in decreasing order ... and return
the top 3 index value of the array in integer form
--
Parag Khanna
B.tech
Create a structure
with num,count(of num) and link
parse the array and create nodes (nodes are created with id=num).
when the no of nodes == 3 print the nodes data and count.
On Wed, Sep 14, 2011 at 5:13 PM, parag khanna khanna.para...@gmail.comwrote:
find the frequencies of each alphabet ...
program to find the top 3 repeating number from the given array
eg
You r given an array and u have to find out the top 3 repeated
numbers.
for ex: GAURAV[]={20,8,3,7,8,9,20,6,4,6,20,8,20}
so the output will be: 20 is repeated 4 times 8 is repeated 3 times 6
is repeated 2 times.
--
You received
write a program to reverse the words in a give string.
also state the time complexity of the algo.
if the string is i am a programmer
the output should be programmer a am i
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this
reverse(string,n) // do it in place
p = str;
for(i=0;ilength(str);i++)
{
if(str[i] == '\0' || str[i] == ' ')
{
reverse(p,len);
p = p+len+1;
len = 0;
}
else
len++;
}
On Mon, Aug 15, 2011 at 4:48 PM, programming love
love.for.programm...@gmail.com wrote:
string str = i am a programmer
for(int i = 0; i str.size()/2; i ++)
swap(str[i], str[str.size()-i-1]);
time complexity O(n)
On Mon, Aug 15, 2011 at 6:39 PM, sukran dhawan sukrandha...@gmail.comwrote:
reverse(string,n) // do it in place
p = str;
for(i=0;ilength(str);i++)
{
@ MeHdi : Please read the problem properly yaar. You are just reversing the
string by characters, not by words.
On 15 August 2011 20:34, MeHdi KaZemI mehdi.kaze...@gmail.com wrote:
string str = i am a programmer
for(int i = 0; i str.size()/2; i ++)
swap(str[i], str[str.size()-i-1]);
On 15 August 2011 16:48, programming love love.for.programm...@gmail.comwrote:
write a program to reverse the words in a give string.
also state the time complexity of the algo.
It has already been discussed on the list a few days ago
if the string is i am a programmer
the output should
method 1:
algo:
step 1 :reverse entire string .. (letter by letter)
step 2: take two pointers ... keep first pointer at the starting of the word
... keep incrementing the second pointer , till space hits.. then , swap
first pointer and second pointere data , by incrementing first pointer , and
@gopi: Each word is being accessed thrice.
1. reverse string
2. set pointers to beginning n end of string
3. reverse the word.
If this is the came is the complexity O(n)??
It's a very good algo nevertheless :)
On Mon, Aug 15, 2011 at 9:16 PM, *$* gopi.komand...@gmail.com wrote:
method 1:
First reverse the senetence word by word and then reverse the whole
stringthat will be easier
On Mon, Aug 15, 2011 at 4:48 PM, programming love
love.for.programm...@gmail.com wrote:
write a program to reverse the words in a give string.
also state the time complexity of the algo.
if
http://geeksforgeeks.org/?p=7150
that will clear you very well.i'm sure...
On Mon, Aug 15, 2011 at 4:48 PM, programming love
love.for.programm...@gmail.com wrote:
write a program to reverse the words in a give string.
also state the time complexity of the algo.
if the string is i am a
can u pls convert this algorithm into an executable code in c++ which
can find the max and min element of an array in recursive method using
divide and conquer strategy...
int a[N]; // array
int maxmin (A[])
{
Split A into two parts: A1, A2;
(max1,min1) = maxmin(A1);
(max2,min2) =
WAP or Algo That will check whether the memory allotted to the program
at the initial and the memory returned to the system is same or not.
Thanks Regards
Shashank Mani
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group,
Q) can anyboy find me the solution to this problem
Given an integer N and an another integer n we have to write a program
to find the remainder of the following problems
(1! + 2! + 3! + 4! + . + N!)mod(n)
N=100
n=1000;
please help me write a program for this problem
Let me try. Any thing involving n would leave no remainder.
so (1 + 2 ! + ... + n ! + + N !) mod n = (1 + 2 ! + ... + (n-1)! ) mod
n
This should be computed from a loop. I don't know how to reduce it further.
Ashim.
On Wed, Dec 8, 2010 at 6:49 PM, ankit sablok ankit4...@gmail.com wrote:
@Ashim
with a check that N =n
N can also be less than n
On Wed, Dec 8, 2010 at 6:57 PM, Ashim Kapoor ashimkap...@gmail.com wrote:
Let me try. Any thing involving n would leave no remainder.
so (1 + 2 ! + ... + n ! + + N !) mod n = (1 + 2 ! + ... + (n-1)! )
mod n
This should be
27 matches
Mail list logo