I read that. But still it should not be compiled as per the standard.
The latest GNU C/C++ compiler correctly fails to compile this
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
@divya: u r rite.. that * should not be there
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14
On Sun, Jun 13, 2010 at 11:07 AM, divya jain
which compiler do you use?
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14
On Sun, Jun 13, 2010 at 10:46 AM, divya jain sweetdivya@gmail.comwrote:
hmm..the
what is this for...
and which conversion are you talking abt?
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14
On Sat, Jun 12, 2010 at 11:20 PM, divya
I have the following code structure
in my file myPlugin.h , i have defined this
virtual int speed();
and gave a dummy implementation in myPlugin.cpp
In another file otherPlugin.h I have included this line:
#include myPlugin.h
private:
int m_speed;
also class otherPlugin
M-speed is private and you cannot call it from outside myPlugin. (though i
did not understand what u wanted to say)
Can you write ur prob explicitly?
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
Hi
On 13 June 2010 12:26, Rohit Saraf rohit.kumar.sa...@gmail.com wrote:
M-speed is private and you cannot call it from outside myPlugin. (though i
did not understand what u wanted to say)
Can you write ur prob explicitly?
I want to use speed() and direction() defined in myPlugin.h in
Make those functions public
And even if M_speed is public of another class, it is still it another
class, you cannot just address it like m_speed in other classes.
Does it help?
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and
I meant this:
let me explain it like this.
I have *virtual int speed()* in class A.(in file A.h)
I inherited class in class B(in file B.h) as class B:public A
class B have a private member m_speed.
Now I have to return m_speed from speed() from class B as I would
instantiate an object of class B
yes.. it should... make sure your virtual function is either public or
protected but not private.
and if it doesn't can u tell me the error?
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
It gives this error:
error: prototype for ‘int B::speed()’ does not match any in class ‘B’.
Should I include this in class B(in B.h)
class B:public A
{
public:
virtual int speed(); //wouldn't this override the speed() from A ?
private:
int m_speed();
}
class A (in A.h)is defined as this
class A
Put the function speed or its declaration inside the class b. Did u forget that?
--
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14
--
You received this message
@rohit bro
http://www.mingw.org/
MinGW, a contraction of Minimalist GNU for Windows, is a port of the GNU
Compiler Collection (GCC), and GNU Binutils, for use in the development of
native Microsoft Windows applications.
From: algogeeks@googlegroups.com [mailto:algoge...@googlegroups.com]
Write a c-macro to use assembly swap opcode.
On Sat, Jun 12, 2010 at 9:35 PM, jalaj jaiswal jalaj.jaiswa...@gmail.comwrote:
write an algorithm to reverse a nibble in one pass...using bitwise
operators
--
With Regards,
Jalaj Jaiswal
+919026283397
B.TECH IT
IIIT ALLAHABAD
--
You
what is a virtualization concept ???
I am a newbie regarding the Algo Analysis. I was asked this question
recently in an interview. Please let me know if anyone of you know how to
solve this.
*Question:*
Assume You have a binary Tree (not sorted and not BST) with a specific
pattern on a
how to sort elements of stack using constant space
--
With Regards,
Jalaj Jaiswal
+919026283397
B.TECH IT
IIIT ALLAHABAD
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To
Won't we require to check recurring till at-least two complete iterations of
recurrence pattern.
Also what's the division logic are we going to use ?
In all modern day processor systems, we are likely to have a math
co/sub-processor which will efficiently crunch numbers and round them off to
our
bt the ans that sharad gave is ryt..
acc to me 1st row n 1st col of o/p shd b 2 (if size of int is 2) bt it is
1...
On 13 June 2010 12:10, Rohit Saraf rohit.kumar.sa...@gmail.com wrote:
@divya: u r rite.. that * should not be there
--
Rohit
i use tc
On 13 June 2010 13:11, ram karthik.gin...@gmail.com wrote:
@rohit bro
http://www.mingw.org/
*MinGW*, a contraction of Minimalist GNU for Windows, is a port of the
GNU Compiler Collection (GCC), and GNU Binutils, for use in the development
of native Microsoft Windows applications.
its an o/p questn..
conversion wen ur variable is long..nd u r printing using %f...i dont know
how to perform conversion from float to int long nd vice versa..
pl help
On 13 June 2010 12:12, Rohit Saraf rohit.kumar.sa...@gmail.com wrote:
what is this for...
and which conversion are you
what do you mean by sorting elements in stack ? A stack is a data structure
in which the relative position of elements depend on their order of
insertion.
If we sort elements in stack, how does it retain the property of a stack ?
If we really want that property, we will have O(n) rather than
actually when you subtract two pointers ... its get divided by the size of
the variable type its point two...
for example.. if you do .. p+1... where let say p is 200 and points to an
int type variable then p+1 is 202...(assuming int is of size 2)
so (p+1)-p..i.e 202-200 is 1 and not 2
On
this can be done using the same code as of Sharad above , the only
difference being the mask bits , we mask four bits of a nibble by the
anding with 0001 , 0010 , 0101 and 1000 .. now , we feed these into the
given number .I mean all the bits as below ..
Suppose we have a nibble as 1100 and we
it's not always possible to sort a stack in all the cases , consider the
stack 2143 and one tries to sort it feeding the elements in order , we have
now whatever popping technique we use , we cannot have a 1234 kind of
stack in order .The maximum number of permutations we can have with a stack
@ram : oh.. that cygwin thing.. why don't you use pure gcc then... why use
minimalistic one?
@divya: isn't it obsolete yet? Did not see anyone using it after I started
using a computer :D.
Do you use it because your prof's force you. If not try g++/gcc. That is
the standard the best compiler
@jalaj: exactly...
so you(@divya) are right. Sharad's ans was right but logic wasn't.
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14
On Sun, Jun 13, 2010 at 2:35
If you are not able to print the long int and that's the prob, you can use
%ld instead of %d
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14
On Sun, Jun 13, 2010
try this one..
make a level order traversal and store the elements in array... on the other
system reconstruct it using right element for the left and left element for
the right...
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to
Check the floating point representation(IEEE 754 format) in variables. There
are specific number of bits in a float variable to represent exponent,
mantissa etc.
Anurag Sharma
On Sun, Jun 13, 2010 at 1:19 PM, divya jain sweetdivya@gmail.comwrote:
its an o/p questn..
conversion wen ur
don't ever use a TC compiler , the most obsolete and mad compiler of all .
Every compiler tries to fix the bug in ur code by some way or the other
using some .Even gcc has a lot of bugs , in the sense it will return an exit
status even if returning a void , but this is on ubuntu and haven't tries
oh yes..
wen ll i stop making this stupid mistakes :(
On 13 June 2010 15:03, Rohit Saraf rohit.kumar.sa...@gmail.com wrote:
@jalaj: exactly...
so you(@divya) are right. Sharad's ans was right but logic wasn't.
--
Rohit Saraf
Second Year
wat i meant is
the ans of this questn is
10.00 0.00 3 1080263967
now my questn is y u.f_e is printing 0.00 and similarly y u.l_e is
giving this value...
On 13 June 2010 15:08, Rohit Saraf rohit.kumar.sa...@gmail.com wrote:
If you are not able to print the long int and that's the
tell the o/p of following with explanations
1. #includestdio.h
int main()
{
struct value
{
int bit1:1;
int bit3:4;
int bit4:4;
}bit;
printf(%d\n,sizeof(bit));
return 0;
}
2.
#includestdio.h
int main()
{
struct value
{
int bit1: 1;
int bit3: 4;
int bit4: 4;
} bit={1,2,2};
printf(%d %d
1. wat ll be the o/p. plz explain y?
// abc.c contains kicit 44-a gokulpeth\0 nagpur
#includestdio.h
#includestdlib.h
int main()
{
unsigned char ch;
FILE *fp;
fp=fopen(abc.c,r);
if(fp==NULL)
{
printf(unable to open the file \n);
exit(1);
}
while((ch=getc(fp))!=EOF)
In the first post the problem was that m_speed is not public also u should
access m_speed using Scope resolution operator as m_speed is not a member of
B.
class A
{
public:
virtual int speed()=0;
int m_speed;
};
class B:public A
{
public:
int speed()
{
return A::m_speed;
}
};
For ur second
For the 1st qn..
the o/p will print the code in the file and then print an infinite sequence
of empty spaces. the reason is...
In C EOF is defined to hold a value -1 which when assigned to unsigned
becomes 255. So it goes in an unending loop even after encountering the end
of file.
In second qn..
1.
i think if the total no of bits is within no of bits in a int , the
size will b same as int .
here total bits 3 32 (bits in int according to gcc, in Turbo c its 16)
so size of structure will be 4(in gcc), 2 (in TC)
if total no of bits is 40 (suppose) than size will be 8(in GCC) , 4(in TC)
Guys
Lets keep discussions in t his group limited to Algos and problems
neutral to any language.
@akshay: Request you to post these C++ language specific questions to
those language specific groups. This will not only help this group
remain confined to its core purpose but will help you get
hmm... for question number 1.. .. u can understand more easliy with the
following examlple
#includestdio.h
// 1. #includestdio.h
#pragma pack(1)
struct value
{
int a;
int bit3: 4;
int bit4: 4;
};
#pragma pack()
int main()
{
struct value bit;
printf(%d,sizeof(bit));
system(pause);
@divya
Lets keep discussions in t his group limited to Algos and problems
neutral to any language.
Request you to post these C++ / C language specific questions to those
language specific groups. This will not only help this group remain
confined to its core purpose but will help you get better
Guys
Lets keep discussions in t his group limited to Algos and problems
neutral to any language.
@divya: Request you to post these C++ language specific questions to
those language specific groups. This will not only help this group
remain confined to its core purpose but will help you get better
Guys
Lets keep discussions in t his group limited to Algos and problems
neutral to any language.
@divya: Request you to post these C++ language specific questions to
those language specific groups. This will not only help this group
remain confined to its core purpose but will help you get
in question 1... ch gets the value of EOF... so first kicit 44-a gokulpeth\0
nagpur will get printed and then the value of EOF..
question number 2 .. seems to me as nrml ...i think myfile.c only gets
closed
in question number 3..it shld be fgets(str,79,fp)
On Sun, Jun 13, 2010 at 2:49 PM,
Is it possible to check endianness of a system in C without creating
variable?
i.e. Program should not contain any variable.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To
@Souravsain : Is there any serious problem in this. Anyone can just add a
[C++] in the subject and uninterested people can make filters in gmail :)
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
you can also use http://gmplib.org/
-Manish
On Jun 11, 10:12 pm, Raj N rajn...@gmail.com wrote:
Ya thanks !!
On Fri, Jun 11, 2010 at 10:31 PM, Rohit Saraf
rohit.kumar.sa...@gmail.comwrote:
Fibonacci numbers can be calculated very efficiently
using matrix multiplications.
I hope you
thanks to all :)
@ souravsain sorry for the inconvenience
On 13 June 2010 20:01, Rohit Saraf rohit.kumar.sa...@gmail.com wrote:
@Souravsain : Is there any serious problem in this. Anyone can just add a
[C++] in the subject and uninterested people can make filters in gmail :)
sorry i pasted wrong questn unser 2..
the real question is
which file will get closed through fclose()
#includestdio.h
int main()
{
FILE *fp,*fs,*ft;
fp=fopen(a.c,r);
fs=fopen(b.c,r);
ft=fopen(c.c,r);
fclose(fp,fs,ft);
return 0;
}
3. yes it is feof..srry typed it wrong... nd fgets(str,80,fp) is
and @rohit you will get better insight into the topic by more expert
people by posting the question in right forum. I guess thats a win-win
situation for one who has the question as he is get to know more and
for people you are interested in going through C++ questions as they
will read views from
declaration of fclose in stdio.h is as fclose (FILE*);
so it has too many arguments...
On Sun, Jun 13, 2010 at 9:06 PM, divya jain sweetdivya@gmail.comwrote:
sorry i pasted wrong questn unser 2..
the real question is
which file will get closed through fclose()
#includestdio.h
int
@rohit: This is not about any serious problem, its about asking ur
self why then make different types of groups. You can also talk about
art and music by adding [art] or [music] in subject or talk about any
topic on earth. The question u need to ask is then why have different
groups. This will
I agree mass bombarding with such questions is not very good.. but one
doesn't join groups and all for getting a few doubts cleared.
Anyways, i have no problem with anything. :D
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and
hey i too have a doubt... and its just 1 ... i'll not ask c/c++ again,,,
we have a union a{
int i;
char ch[4];
}
int here is of 4 bytes.
i initialise i=512...
what value will ch[0] get the upper 8 bits or the lower 8 bits... is it big
From last few days I'm seeing the question that is coming here is not
algorithm specific.
Purpose of this group is achieved or defeated???
Thanks
Pramod Negi
On Sun, Jun 13, 2010 at 9:48 PM, jalaj jaiswal jalaj.jaiswa...@gmail.comwrote:
hey i too have a doubt... and its just 1 ... i'll not
Hello All,
What every algorithm mentioned above have some problem.
The Recursive swapping won’t work if you don’t have 2^n elements.
Same with getting the indexes, it will form a cycle.
Thanks
Pramod Negi
On Fri, Jun 11, 2010 at 7:09 PM, sharad kumar sharad20073...@gmail.comwrote:
for ques 2
Here the file *A.C* alone closed.
To close all streams we have to use *fcloseall()* function
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this
Stack can be sorted in O(n^2).
@sankalp:
Stack can always be sorted. Why do you think it cant be in some cases ?
One can think like insertion sort
algo :
1. for i in (1,n)
2. Pop up the top n-1 element and keep nth element in global variable say
hold
3. while pushing get the position for
find k th largest element in bst(inplace)
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
Hi,
Can anyone explain how to find cycle in undirected graph in O(|v|)
time and in directed graph in O(|e+v|) time?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe
Are you missing some constraint here? If it has enough space, you can
just copy elements over and sort them together.
nlogn is as good as it can get for sorting. (Unless you want to get
into sorting networks).
On Jun 12, 9:57 am, sharad sharad20073...@gmail.com wrote:
an algorithm to sort two
http://www.spoj.pl/problems/HAN01/
i implemented it using stack but am getting tle someone please help
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this
give the algorithm for toi if... the a disk can be placed on top the disk
just larger then it and on the ground..
--
With Regards,
Jalaj Jaiswal
+919026283397
B.TECH IT
IIIT ALLAHABAD
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To
give an algo to find a unique number in an array
for eg a[]={1,3,4,1,4,5,6,1,5}
here 3 is the unique number as it occur only once... moreover array contains
only 1 unique number
--
With Regards,
Jalaj Jaiswal
+919026283397
B.TECH IT
IIIT ALLAHABAD
--
You received this message because you
Can anyone tell what is Stack Space required for Quick Sort and Merge
Sort.And how in each case it can be modified.
Correct me if I am wrong on this.
Space Complexity of Merge Sort ( Not Inplace) - O(n)
Space Complexity of Quick Sort - O(1)
--
You received this message because you are
@Divya
For (3) : You are getting last line twice because of wrong usage of
feof(fp). Remember , feof() returns true after EOF file is reached and
not when EOF is read.
feof tells you end of file is reached and it can tell that only after
reading EOF and not while reading it !!
So after last line
On Sun, Jun 13, 2010 at 4:10 AM, divya jain sweetdivya@gmail.comwrote:
wat i meant is
the ans of this questn is
10.00 0.00 3 1080263967
now my questn is y u.f_e is printing 0.00 and similarly y u.l_e is
giving this value...
@ Divya:
Here 3.55 is stored as a floating point
Printf(%d,(char)2);
If this print 2 then lsb is 2, else if 0 then msb is 2
On Jun 13, 5:56 pm, debajyotisarma sarma.debajy...@gmail.com wrote:
Is it possible to check endianness of a system in C without creating
variable?
i.e. Program should not contain any variable.
--
You received this
@jalaj
Yes , this is endian ness specific. On windows/x86 linux which are
little endian, ch[0] would be lower 8 bits. On solaris/power pc which
are big endian this would be upper 8 bits. e.g.
union a temp;
temp.i = 0x12345678 //! here big end is 0x12 and little end is 0x78
then temp.ch[0] = 78
a1a2a3b1b2b3
= [a1 a2] a3 [b1 b2] b3
= [a1 a2] [b1 b2] a3 b3
= a1 a2 b1 b2 a3 b3
= a1 b1 a2 b2 a3 b3
The algo. that I put forth works. And I think Sourav's will as well.
The grouping needs to be in numbers of 4.
The total number of elements need not.
-Minotauraus.
On Jun 13, 1:46 pm, Pramod Negi
@ sharad... DO u mean the former has got unused space in which the latter
can occupy
On Sun, Jun 13, 2010 at 11:02 AM, harit agarwal agarwalha...@gmail.comwrote:
sort both arrays separetely and then perform merge operation ..it is
O(mlogm+nlog)...
--
You received this message because
here is an algo to reverse the nibble in O(n);
http://codepad.org/0NbsP5Td
On Sat, Jun 12, 2010 at 9:05 AM, jalaj jaiswal jalaj.jaiswa...@gmail.comwrote:
write an algorithm to reverse a nibble in one pass...using bitwise
operators
--
With Regards,
Jalaj Jaiswal
+919026283397
B.TECH IT
in case of undirected graph we can make use of bfs.in directed graph can
make us of topological sort.
On Mon, Jun 14, 2010 at 2:04 AM, amit amitjaspal...@gmail.com wrote:
Hi,
Can anyone explain how to find cycle in undirected graph in O(|v|)
time and in directed graph in O(|e+v|) time?
On Sun, Jun 13, 2010 at 18:36, souravsain souravs...@gmail.com wrote:
Lets keep discussions in t his group limited to Algos and problems
neutral to any language.
Yes, please.
--
http://roshan.mathews.in/
--
You received this message because you are subscribed to the Google Groups
Algorithm
In any directed graph just check if dfs has a back edge. For
undirected, check if there is a nontree edge
--
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14
--
Repeated q. Search in the group
--
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14
--
You received this message because you are subscribed to the Google Groups
Inorder traversal till u reach the kth element(If it is sorted in descending
order, otherwise go till (n-k)th element)..
On Sun, Jun 13, 2010 at 9:24 PM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote:
Repeated q. Search in the group
--
--
76 matches
Mail list logo