@sunny: right thanks for correcting
On Wed, Jul 13, 2011 at 11:33 AM, sunny agrawal sunny816.i...@gmail.comwrote:
@Aniket Dutta
Solution for your case will be 96
Algorithm Posted by Oppilas will do and is O(n).
On Wed, Jul 13, 2011 at 11:28 AM, Aniket Dutta aniketdutt...@gmail.comwrote:
Oppalis algo-
Please let me know if there is a bug in it.
http://www.ideone.com/u1m07
On Wed, Jul 13, 2011 at 11:36 AM, Aniket Dutta aniketdutt...@gmail.comwrote:
@sunny: right thanks for correcting
On Wed, Jul 13, 2011 at 11:33 AM, sunny agrawal
sunny816.i...@gmail.comwrote:
@Aniket
int maxsum(NODEPTR root)
{
if(root==NULL)
return 0;
else
return MAX(maxsum(root-left),maxsum(root-right))+root-data;
}
This should work.
Please comment.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
Guys i always have this doubt.Please tell me whether stack frames allocated
for each recursive call will be cleared if we return in the middle of a
recursive call?
On Tue, Jul 12, 2011 at 10:22 PM, Don dondod...@gmail.com wrote:
// Similar to other suggestions, but without tail recursion.
ptr
I am looking for a code which can add without using + sign
i searched the net and found the following code..can anyone explain me
whats happening in this ??
#includestdio.h
#includeconio.h
int main()
{
int a=3000,b=20,sum;
char *p;
p=(char *)a;
sum= (int)p[b]; //adding a b
printf(Answer is
if someone has better idea...then please suggest that.
plz explain how this is calculating sum -- sum= (int)p[b];
On Wed, Jul 13, 2011 at 1:50 PM, nicks crazy.logic.k...@gmail.com wrote:
I am looking for a code which can add without using + sign
i searched the net and found the
how to find lrs efficiently
--
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
we are basically assigning address value a to a char pointer p..(the
reason y char pointer is used u will get to know it at the end)
we know p[b] means *(p+b)then p[b] means *(p+b) i.e. p+b i.e a+b
we used char pointer to increment it one by one..had we used int pointer..
it wud have
a better idea is use this:
int a=9,b=4;
int sum=printf(%*s%*s,a,,b,);
printf(%d\n,sum);
On Wed, Jul 13, 2011 at 1:52 PM, nicks crazy.logic.k...@gmail.com wrote:
if someone has better idea...then please suggest that.
plz explain how this is calculating sum -- sum= (int)p[b];
On Wed,
thnx piyush,anika for explanation
On Wed, Jul 13, 2011 at 1:58 PM, Anika Jain anika.jai...@gmail.com wrote:
a better idea is use this:
int a=9,b=4;
int sum=printf(%*s%*s,a,,b,);
printf(%d\n,sum);
On Wed, Jul 13, 2011 at 1:52 PM, nicks crazy.logic.k...@gmail.com wrote:
if someone has
You can try this also
do
{
sum = a ^ b;
carry = a b;
a = sum;
b = carry;
}while (carry!=0);
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
https://groups.google.com/d/msg/algogeeks/-/KoeFGWuM71IJ.
On Wed, Jul 13, 2011 at 2:22 PM, Amit Gupta amit070...@gmail.com wrote:
You can try this also
do
{
sum = a ^ b;
carry = a b;
*carry = 0x1u;*
a = sum;
b = carry;
}while (carry!=0);
I think one step is missing here, no? (I have added in bold)
--
--
You received this message
Its basically addition using pointer arithmatics. check for array indexing.
On Wed, Jul 13, 2011 at 1:50 PM, nicks crazy.logic.k...@gmail.com wrote:
I am looking for a code which can add without using + sign
i searched the net and found the following code..can anyone explain me
whats
Can you explain how its working?
On Wed, Jul 13, 2011 at 1:58 PM, Anika Jain anika.jai...@gmail.com wrote:
a better idea is use this:
int a=9,b=4;
int sum=printf(%*s%*s,a,,b,);
printf(%d\n,sum);
On Wed, Jul 13, 2011 at 1:52 PM, nicks crazy.logic.k...@gmail.com wrote:
if someone has
Hi Guys,
I have a O(n) solution for this problem:
/*
* Input: my name is ram
* Output: ram is name my
* Approach: Divide the string into tokens and store the token pointers on a
* stack. Pull them up to display output.
* */
#include string.h
#define MAX_WORDS_PER_STRING 100
#define
On Wed, Jul 13, 2011 at 1:40 PM, sameer.mut...@gmail.com
sameer.mut...@gmail.com wrote:
Guys i always have this doubt.Please tell me whether stack frames allocated
for each recursive call will be cleared if we return in the middle of a
recursive call?
In normal condition, the return
Hello,
My implementation of a solution: https://gist.github.com/1080007
Cheers
On Jul 11, 5:31 pm, vigneshr rvignesh1...@gmail.com wrote:
@Harsha, Yes!, the bottom up approach is the best and avoids lot of
repeated calculations.
Cheers,
Vignesh
On Jul 11, 10:13 am, Harshal
Check the last post of this
http://groups.google.com/group/algogeeks/browse_thread/thread/95a593375c62c31d/bf5fab1c88f4b491?lnk=raot#bf5fab1c88f4b491
Thanks
Shashank Mani
Computer Science
Birla Institute of Technology Mesra
--
You received this message because you are subscribed to the Google
binary equivalent of 5.2 is
101.0011001100110011001100110011(nonterminating)..
now it is actually stored in normalised frorm in 32 bits..
like this
--1 bit for sign8 bits for exponent-23 bits for
fraction--
this is from higher order byte to lower order for little endian..
@vaibhav: no it wont coz its printing empty strings.. nothing will be
printed
On Wed, Jul 13, 2011 at 4:42 PM, vaibhav shukla vaibhav200...@gmail.comwrote:
@anika : ur ans will give the sum but will also leave that much amount of
space before printing the sum
one betther idea is to use
@ vaibhav: ohh sorry, ya its leaving the columns..
so we can do
int a=9,b=4;
int sum=printf(%*s%*s,a,,b,);
printf(\r%d\n,sum);
On Wed, Jul 13, 2011 at 6:09 PM, Anika Jain anika.jai...@gmail.com wrote:
@vaibhav: no it wont coz its printing empty strings.. nothing will be
printed
On Wed, Jul
:D :D ;)
On Wed, Jul 13, 2011 at 6:11 PM, Anika Jain anika.jai...@gmail.com wrote:
@ vaibhav: ohh sorry, ya its leaving the columns..
so we can do
int a=9,b=4;
int sum=printf(%*s%*s,a,,b,);
printf(\r%d\n,sum);
On Wed, Jul 13, 2011 at 6:09 PM, Anika Jain
@dev: good buudy.it is working correctlybut can u explain
it what it is doing...it is really messy.:(
On Jul 10, 4:42 pm, Dave dave_and_da...@juno.com wrote:
@Anurag:
Seehttp://groups.google.com/group/algogeeks/msg/d90353c759125384?hl=en.
Dave
On Jul 10, 1:14 am,
Suppose that the left subtree as well as the right subtree is a BST.
The current node also forms a BST, if the predecessor of current node
is less than current node and the successor of current node is greater
than current node. Incorporating these two checks require 2*log(n). So
the total
@Agyat: The code builds up the number one bit at a time. It finds the
smallest i such that the binomial coefficient i-choose-k is not less
than n. This says that there are at least n combinations of i bits
taken k at a time. In other words, the number must be an i-bit number.
Thus, since bits are
On 12/07/11 16:15, bittu wrote:
John You Can Use MinHeap
here is the algo
1) Build a Min Heap MH of the first k elements (arr[0] to arr[k-1]) of
the given array. O(k)
2) For each element, after the kth element (arr[k] to arr[n-1]),
compare it with root of MH.
a) If the element is greater than
Shouldn't the value of 1100 be -64
On Wed, Jul 13, 2011 at 4:53 PM, Anika Jain anika.jai...@gmail.com wrote:
binary equivalent of 5.2 is
101.0011001100110011001100110011(nonterminating)..
now it is actually stored in normalised frorm in 32 bits..
like this
--1 bit for sign8
I agree with anonymous procrastination
On Wed, Jul 13, 2011 at 12:38 PM, anonymous procrastination
opamp1...@gmail.com wrote:
int maxsum(NODEPTR root)
{
if(root==NULL)
return 0;
else
return MAX(maxsum(root-left),maxsum(root-right))+root-data;
}
This should work.
Please comment.
--
sorry its 0100 not 1100 coz 5.2 is a positive no. so sign bit is 0
On Wed, Jul 13, 2011 at 7:58 PM, Piyush Kapoor pkjee2...@gmail.com wrote:
Shouldn't the value of 1100 be -64
On Wed, Jul 13, 2011 at 4:53 PM, Anika Jain anika.jai...@gmail.comwrote:
binary equivalent of 5.2
If we need to find the maximum sum the above code is fine.
But from the subject it appears we need to print the path, which contains
the maximum sum, as well.
Regards,
Sandeep Jain
On Wed, Jul 13, 2011 at 8:01 PM, Piyush Kapoor pkjee2...@gmail.com wrote:
I agree with anonymous
No. It is unsigned. -- Dave
On Jul 13, 9:28 am, Piyush Kapoor pkjee2...@gmail.com wrote:
Shouldn't the value of 1100 be -64
On Wed, Jul 13, 2011 at 4:53 PM, Anika Jain anika.jai...@gmail.com wrote:
binary equivalent of 5.2 is
101.0011001100110011001100110011(nonterminating)..
why is the order of numbers reversed?
On Wed, Jul 13, 2011 at 8:07 PM, Anika Jain anika.jai...@gmail.com wrote:
sorry its 0100 not 1100 coz 5.2 is a positive no. so sign bit is 0
On Wed, Jul 13, 2011 at 7:58 PM, Piyush Kapoor pkjee2...@gmail.comwrote:
Shouldn't the value of
how to remove duplicates from a linked list?? is it mandatory to sort the
list first?l
--
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
If you are willing to leave out some space,hashing will do.
For sorting merge sort may be the best for linked list.For an
implemenatation check here
http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html
http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html(Quick
sort
what are the constraints ?
if none then it could be done easily. O(N^2) solution
On Wed, Jul 13, 2011 at 8:10 PM, Anika Jain anika.jai...@gmail.com wrote:
how to remove duplicates from a linked list?? is it mandatory to sort the
list first?l
--
You received this message because you are
@dumanshu check it
Algo is simply start putting elemnt in bigger array by comparing then
from last logic is same as merge part of merg sort :)
void merge(int[] a, int[] b, int n, int m)
{
int k = m + n - 1; // Index of last location of array b
int i = n - 1; // Index of last element in
agree with saurabh.merge sort will be the best.using sorting problem
can be solved in O(nlogn)
else use hashing to solve in O(n)
@shady.ya that would be most obvious solution can be done easily in
O(n^2).
On Wed, Jul 13, 2011 at 8:36 PM, shady sinv...@gmail.com wrote:
what are the
@nicks so many problems could be solved in O(n) but it is very difficult to
find a hashing function where there is no collision...
and if we sort the list, we are modifying the list... which lets assume is
not allowed. then what to do ?
suppose even if we know the index at which there
@shady...if modfying is not allowedin that case i think O(n^2) is the
only option left with us...sorting can't be used in that case...
On Wed, Jul 13, 2011 at 9:01 PM, shady sinv...@gmail.com wrote:
@nicks so many problems could be solved in O(n) but it is very difficult to
find a hashing
@sandeep : then can we just store the nodes in the array.. and as soon as we
reach the leaf ,we print the array . what say ?
On Wed, Jul 13, 2011 at 8:08 PM, Sandeep Jain sandeep6...@gmail.com wrote:
If we need to find the maximum sum the above code is fine.
But from the subject it appears we
start from the end of both the arrays... and try simple merge process not
from the start but from where the last element is... and keep inserting the
greater element at the end of the larger array.
On Wed, Jul 13, 2011 at 8:41 PM, bittu shashank7andr...@gmail.com wrote:
@dumanshu check it
@Vaibhav: How do you intend to populate the array?
Regards,
Sandeep Jain
On Wed, Jul 13, 2011 at 9:45 PM, vaibhav shukla vaibhav200...@gmail.comwrote:
@sandeep : then can we just store the nodes in the array.. and as soon as
we reach the leaf ,we print the array . what say ?
On Wed, Jul
For more clarificationtry this :-
int i=1,j=1,k=1,l;
l= ++i || j++ k++;
printf(%d %d %d %d,i,j,k,l);
o/p will be 2 1 1 1
because as vaibhav wrote the equation evaluate as l= ++i || (j++ k++);
only ++i evaluate not other two increments :)
On Sun, Jul 10, 2011 at 11:31 PM, rShetty
it is not unsigned its signed but positive thts y it is 0..
the order isnt reversed.. look at the code, the code 1st prints lowest order
byte then next and then next and then highest soo output is 102 102 -90 64
On Wed, Jul 13, 2011 at 8:08 PM, Piyush Kapoor pkjee2...@gmail.com wrote:
why is
@Bittu, Vaibhav
Can you please illustrate your algo for below arrays.
Array1 - {1, 3, 5, 7}
Array2 - {0,0,0,2,0,4,6,8}
Thanks,
- Ravindra
On Wed, Jul 13, 2011 at 9:47 PM, vaibhav shukla vaibhav200...@gmail.comwrote:
start from the end of both the arrays... and try simple merge process
has higher precedence than ||
but why does j and k didn't increase after the statement
l= ++i || j++ k++;
got executed ?
On Wed, Jul 13, 2011 at 10:07 PM, sagar pareek sagarpar...@gmail.comwrote:
For more clarificationtry this :-
int i=1,j=1,k=1,l;
l= ++i || j++ k++;
printf(%d %d %d
@Ravindra: Since both the array contain m elements, you can assume that all
elements lie from index [0] to index [m-1]
However, because in your example we can consider 0, as a valid value of the
sorted array.
PS: Still, if you are suggesting that we should not consider 0 as a value.
Then you can
I think it is machine dependent and current output is for a little endian
machine
and output should be reverse for a big endian machine
On Wed, Jul 13, 2011 at 10:18 PM, Anika Jain anika.jai...@gmail.com wrote:
it is not unsigned its signed but positive thts y it is 0..
the order isnt
@shady : lazy evaluation if first condition in OR is true... second
condition wont be evaluated
On Wed, Jul 13, 2011 at 10:21 PM, shady sinv...@gmail.com wrote:
has higher precedence than ||
but why does j and k didn't increase after the statement
l= ++i || j++ k++;
got executed ?
Because ++i returns non -ve i.e. true,
and since || operator exhibits short circuit. There was no need to evaluate
j++ k++
Regards,
Sandeep Jain
On Wed, Jul 13, 2011 at 10:21 PM, shady sinv...@gmail.com wrote:
has higher precedence than ||
but why does j and k didn't increase after the
Because of short-circuit evaluation of boolean operators. As soon as
the expression is known to be true, no further evaluation is needed.
In this case ++i is true, and the result of true || anything is true.
Thus anything need not be evaluated, and is not in C. Similarly,
short-circuit evaluation
ya thts ryt, for big endian it will be 64 -90 102 102
On Wed, Jul 13, 2011 at 10:22 PM, sunny agrawal sunny816.i...@gmail.comwrote:
I think it is machine dependent and current output is for a little endian
machine
and output should be reverse for a big endian machine
On Wed, Jul 13, 2011 at
@dave,vaibhav and sandeep
thanks a lot... completely missed that part :D
On Wed, Jul 13, 2011 at 10:29 PM, Dave dave_and_da...@juno.com wrote:
Because of short-circuit evaluation of boolean operators. As soon as
the expression is known to be true, no further evaluation is needed.
In this case
@Sandeep,
If we do compaction then it becomes the same algo what Ankit suggested
earlier. Compaction will require 2 pass on the bigger array. Can we do it in
a single pass?
P.S. - I can not say for sure if doing it in one pass is really feasible. I
am still trying to work it out :-).
Thanks,
-
Will u guyz pls tell me frm where do u study terms like endian ,it is a
pity i had to google it :( :(
On Wed, Jul 13, 2011 at 10:30 PM, Anika Jain anika.jai...@gmail.com wrote:
ya thts ryt, for big endian it will be 64 -90 102 102
On Wed, Jul 13, 2011 at 10:22 PM, sunny agrawal
@Ravindra: Dude, so far in this question, I've always seen 2nd array to
contain all elements on one side of the array, as this avoids any
constraints on the values allowed within the array.
Regards,
Sandeep Jain
On Wed, Jul 13, 2011 at 10:53 PM, ravindra patel
ravindra.it...@gmail.comwrote:
On Wed, Jul 13, 2011 at 11:00 PM, Sandeep Jain sandeep6...@gmail.comwrote:
@Ravindra: Dude, so far in this question, I've always seen 2nd array to
contain all elements on one side of the array, as this avoids any
constraints on the values allowed within the array.
I am not saying that what I
int maxsum(NODEPTR root)
{
if(root==NULL)
return 0;
else
{
if((maxsum(root-left)maxsum(root-right))
printf(%d,root-left);
else
printf(%d,root-right);
return MAX(maxsum(root-left),maxsum(root-right))+root-data;
}
}
--
You received this message because you are subscribed to the Google Groups
I'm not sure what you're asking. The whole string is read with
fgets(). The first while loop skips whitepace. Then the second one
looks for the end of a word.
On Jul 12, 11:43 pm, nicks crazy.logic.k...@gmail.com wrote:
@saurabh why are you reading the string character by
computer organization carl hamacher. computer system architecture by Morris
Mano. Computer organization and architecture by william stallings.. if u
dont have these refer wikipedia.
On Wed, Jul 13, 2011 at 10:59 PM, Piyush Kapoor pkjee2...@gmail.com wrote:
Will u guyz pls tell me frm where do u
thanks,i hv just entered 2nd year,so most probably i will study this
year
--
*Regards,*
*Piyush Kapoor,*
*CSE-IT-BHU*
--
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
correction : ans should be :)
10
\
15
/ \
A car is traveling at a uniform speed.The driver sees a milestone
showing a 2-digit number. After traveling for an hour the driver sees
another milestone with the same digits in reverse order.After another
hour the driver sees another milestone containing the same two digits.
What is the average
http://www.geekinterview.com/question_details/56715
I think you missed zero :)
On Thu, Jul 14, 2011 at 12:20 AM, shiv narayan
narayan.shiv...@gmail.com wrote:
A car is traveling at a uniform speed.The driver sees a milestone
showing a 2-digit number. After traveling for an hour the driver sees
Ans should be 45km/hr. :)
--
Regards
UDIT
DU- MCA
--
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
initially he saw say xy then he saw yx now what next does he
see...containing only x and y??
Please clarify your question..
On Thu, Jul 14, 2011 at 12:59 AM, udit sharma sharmaudit...@gmail.comwrote:
Ans should be 45km/hr. :)
--
Regards
UDIT
DU- MCA
--
You received this
1st: xy
2nd: yx
3rd: x0y
--
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,
can some body tell me that:
void swap(node *p,node *q)
{
node *t;
t=p;
p=q;
q=t;
}
void mirror(node *p)
{
if (p==NULL)
return;
else
{mirror(p-r);
mirror(p-l);
swap(p-r,p-l);
}
}
in this the swapping is occuring but if i do :
void
swap(char **a,char **b)
{
char *t=*a;
*a=*b;
*b=t;
}
#define wd 3
int main()
{
char *r[wd];
char *str=ram is good;
//splite requiere O(n) where n is number of charecter
int i=0;
int k=0;
while(str[i]!='\0')
{
char arr[10],j=0;
while(str[i]!='
Relation comes out as : y=6x
so x=1 ans y=6.
so 1st: 16 (say km)
2nd: 61
3rd: 106
av. speed=(106-16)/2=45 km/hr
On Thu, Jul 14, 2011 at 1:13 AM, Siddharth kumar
siddhartha.baran...@gmail.com wrote:
1st: xy
2nd: yx
3rd: x0y
--
You received this message because you are subscribed to the
u need a pointer to a pointer to swap the pointers...
On Thu, Jul 14, 2011 at 1:21 AM, Anika Jain anika.jai...@gmail.com wrote:
can some body tell me that:
void swap(node *p,node *q)
{
node *t;
t=p;
p=q;
q=t;
}
void mirror(node *p)
{
if (p==NULL)
Its working I guess in both the cases...
On 7/14/11, Anika Jain anika.jai...@gmail.com wrote:
can some body tell me that:
void swap(node *p,node *q)
{
node *t;
t=p;
p=q;
q=t;
}
void mirror(node *p)
{
if (p==NULL)
return;
else
{mirror(p-r);
by using swap function is pointer to a pointer used then??
On Thu, Jul 14, 2011 at 1:36 AM, Piyush Kapoor pkjee2...@gmail.com wrote:
u need a pointer to a pointer to swap the pointers...
On Thu, Jul 14, 2011 at 1:21 AM, Anika Jain anika.jai...@gmail.comwrote:
can some body tell me that:
n sorry i have wriiten it in c++ not c..
On Thu, Jul 14, 2011 at 1:44 AM, Anika Jain anika.jai...@gmail.com wrote:
by using swap function is pointer to a pointer used then??
On Thu, Jul 14, 2011 at 1:36 AM, Piyush Kapoor pkjee2...@gmail.comwrote:
u need a pointer to a pointer to swap the
@anika:can u please explain the meaning of this line..
so i here get an exponent of 2 as 2 here.. now in exponent 8 bits this
exponent is stored as 127+exponent so here it becomes 1001..
On Wed, Jul 13, 2011 at 11:44 PM, Piyush Kapoor pkjee2...@gmail.com wrote:
thanks,i hv just entered 2nd
As in base 10 we say 552.5 is same as 5.525 *10^2 , here 2 is the exponent
of base 10.. so similarly in binary nos. for base 2 here if i make
101.00110011.. to 1.0100110011.. *2^2 my exponent is 2.. now in storage of
floats exponent is stored as exponent +127 i.e here 2 +127 so we get
1001
someone¿
On Jul 7, 6:44 pm, rgap rgap...@gmail.com wrote:
Hi.. can someone tell me about the Computing Laboratory you have on
your faculty of computer science, what about the software, hardware
there.
Please i want to clarify my one doubts.
Thanks in advance...
--
You received this message
Perl to reverse words in stdin:
print join(' ', reverse(split(/\s+/, )))
On Jul 7, 5:18 am, Vishal Thanki vishaltha...@gmail.com wrote:
Off Topic:
Sorry for the diversion, but I was just wondering how easy it has
become to code in languages other than c. Here is the code i wrote for
the
For Problem 1, scanf tries to read 8 bytes from console (2 interger
due to %d) and it starts writing in memory from right to left. since
the variable are defined as short only two bytes will be stored.
bytes read by scanf
0 0 0 1 0 0 0 1
from right to left first 2 bytes that will be stored to b
in second problem a:1 and b:3 means default initialization but not in c it
is D programming language but u may b trying to compile it with c complier
that's why it is showing wrong result..if u will compile it with D
language compiler than it will print 6 and 2.and if u will not
space o(2n)
int LSM()
{
int a[] = {2,-8,-3,1,2};
int b[50],b1[50];
int n = sizeof(a)/sizeof(a[0]);
int i=0;
b[0]=a[0];
for(i=1;in;i++)
{
if(b[i-1]==0)
b[i]=a[i];
else
b[i]*=a[i];
}
b1[n-1] = a[n-1];
There is nothing wrong going wrong in the code shilpa.
It specifies bit field
a has now only 1 bit
b has 2 bit.
when u write t.a=6=(0110) it is stored as 0.
while when u write t.b=2 it is stored as 10 which in 2's complement its -2.
check size of t if you doubt me.
On Thu, Jul 14, 2011 at 9:11
@saurabh why in 2's complement form ?
On Thu, Jul 14, 2011 at 9:21 AM, saurabh singh saurab...@gmail.com wrote:
There is nothing wrong going wrong in the code shilpa.
It specifies bit field
a has now only 1 bit
b has 2 bit.
when u write t.a=6=(0110) it is stored as 0.
while when u
For problem two the structure is bit field structure
a:1 means only one lower order bit will be stored
b:2 means only two lower order bits will be stored
since both are defined as int (signed)
t.b = 6 means 110, but 10 will be stored to b and being signed
interger its value become -2
t.b = 7
@saurabh .u r right it is correct but thing i have written is also
correct in D language it is initialization of elements of a structure
but the correct ans for this question will be yours..
On Thu, Jul 14, 2011 at 9:21 AM, saurabh singh saurab...@gmail.com wrote:
There is nothing
because your type is int (signed) and not unsigned..make it unsigned
you will understand why is like this!
On Thu, Jul 14, 2011 at 9:27 AM, John Hayes agressiveha...@gmail.com wrote:
@saurabh why in 2's complement form ?
On Thu, Jul 14, 2011 at 9:21 AM, saurabh singh saurab...@gmail.com
thnx all...i finally got it :)
On Thu, Jul 14, 2011 at 9:30 AM, sanjay ahuja sanjayahuja.i...@gmail.comwrote:
because your type is int (signed) and not unsigned..make it unsigned
you will understand why is like this!
On Thu, Jul 14, 2011 at 9:27 AM, John Hayes agressiveha...@gmail.com
thanks i got it...
On Thu, Jul 14, 2011 at 9:13 AM, surender sanke surend...@gmail.com wrote:
space o(2n)
int LSM()
{
int a[] = {2,-8,-3,1,2};
int b[50],b1[50];
int n = sizeof(a)/sizeof(a[0]);
int i=0;
b[0]=a[0];
for(i=1;in;i++)
{
if(b[i-1]==0)
By the way I am no master of D but isn't it compilation error?
D was made to imitate java concept of importing librariesSo its a
compile error anyway,:)
On Thu, Jul 14, 2011 at 9:30 AM, sanjay ahuja sanjayahuja.i...@gmail.comwrote:
because your type is int (signed) and not unsigned..make it
if you have any doubt than run it i have done so..it is running
On Thu, Jul 14, 2011 at 9:38 AM, saurabh singh saurab...@gmail.com wrote:
By the way I am no master of D but isn't it compilation error?
D was made to imitate java concept of importing librariesSo its a
compile error
1. Write the code for this
input: 1
output:
{}
input: 2
output:
{}{}
{{}}
input: 3
output:
{}{}{}
{{}}{}
{}{{}}
--
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
hey i got doubt regarding 3rd output, r n't u missing {{}{}} case??
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
https://groups.google.com/d/msg/algogeeks/-/GuA-rEq4-kYJ.
To post to this group, send
Describe an optimal algorithm to find the second minimum number in an
array of numbers. What is the exact number of comparisons required in
the worst case? Note that they didn't ask the order in Big-Oh
notation. They wanted the exact number of comparisons.
--
You received this message because
@rogu3 ..it is an asked question of amazon their is no correction in it. it
is written here as it asked
On Thu, Jul 14, 2011 at 10:18 AM, rogu3 manikanta...@gmail.com wrote:
hey i got doubt regarding 3rd output, r n't u missing {{}{}} case??
--
You received this message because you are
n+lgn-2 no of comparisions will do
On Thu, Jul 14, 2011 at 10:19 AM, shiv narayan narayan.shiv...@gmail.comwrote:
Describe an optimal algorithm to find the second minimum number in an
array of numbers. What is the exact number of comparisons required in
the worst case? Note that they didn't
On Wed, Jul 13, 2011 at 7:32 AM, Gene gene.ress...@gmail.com wrote:
You can recognize a word W, recur to print the rest of the words in
reverse, then print W:
#include stdio.h
#include string.h
void print_words_in_reverse(char *s)
{
char *e;
while (isspace(*s)) s++;
if (*s == '\0')
On Thu, Jul 14, 2011 at 10:18 AM, rogu3 manikanta...@gmail.com wrote:
hey i got doubt regarding 3rd output, r n't u missing {{}{}} case??
Yes it will be. I guess can assume it safely :)
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To
Try this:
http://ideone.com/PTDCG
On Thu, Jul 14, 2011 at 10:22 AM, shilpa gupta shilpagupta...@gmail.comwrote:
@rogu3 ..it is an asked question of amazon their is no correction in it. it
is written here as it asked
On Thu, Jul 14, 2011 at 10:18 AM, rogu3 manikanta...@gmail.com wrote:
Hey Guys, plz help me in getting these 2 C output problems
*PROBLEM 1.*
*
*
*#*includestdio.h
int main()
{
short int a,b,c;
scanf(%d%d,a,b);
c=a+b;
printf(%d,c);
return 0;
}
INPUT-
1 1
OUTPUT
1
i am not getting why 1 is coming in the output.what difference is using
short making in the code
Hey Guys, plz help me in getting these 2 C output problems
*PROBLEM 1.*
*
*
*#*includestdio.h
int main()
{
short int a,b,c;
scanf(%d%d,a,b);
c=a+b;
printf(%d,c);
return 0;
}
INPUT-
1 1
OUTPUT
1
i am not getting why 1 is coming in the output.what difference is using
short making in the code
1 - 100 of 104 matches
Mail list logo