Re: [algogeeks] Amazon - Coding Round-2 Qn

2011-08-30 Thread Dipankar Patro
BST in a Binary tree is a repeated question.

Two things you have to find:
- Check from every node to down whether the subtree is binary or not.
- Once done check the no. of nodes in the subtree.

- Finally keep track of the max you have got so far.

On Wed, Aug 31, 2011 at 7:04 AM, Reynald reynaldsus...@gmail.com wrote:

 Question:
 Given: A singly linked list and a number 'n'.
 Write a program, that will reverse consecutive 'n' nodes in the linked
 list.
 Optimize for space and time.

 Example:
 Input:
 Linked list: A-B-C-D-E-F
 number 'n': 3

 Output:
 C-B-A-F-E-D

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: prog

2011-08-27 Thread Dipankar Patro
DBMS is Data-Base Management System. It is the concept of managing data so
that retrieval, modification, etc operations can be carried out efficiently.
It has different models for implementation.

RDMS (Relational DBMS) is a model of DBMS that uses tables to manage data.

Other models also exist, e.g. E-R, Network, Hierarchical.

On Sat, Aug 27, 2011 at 9:36 PM, Navneet navneetn...@gmail.com wrote:

 You should read chapter 1 of any good DBMS book like Ramakrishna etc.
 RDBMS is about tables(containing field values) and relations between
 them.

 A DBMS can also be maintained in simple files but RDBMS offers lot of
 advantages over file based data management.

 On Aug 27, 7:09 pm, ajit kumar raj.aji...@gmail.com wrote:
  difference bet rdbms and dbms

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: microsoft

2011-08-27 Thread Dipankar Patro
Just go through Test Your C-Skills properly for first section:

Here are some questions that I faced:

Section 1 problems. Total time 30 minutes:

1. x = x^x;
printf(%d, x);
o/p?

2. some automation-graph question. I think it was based on Automata. Not
sure though.

3. z = scanf(%d %d, x, y);
printf(%d, z);
o/p?

4. a question on double loop. o/p related.

5.
double round(double num)
{ return (int)(num+0.5)
}
will it work all the time?

6.
int main(){
char *str;
strcpy(str, junk);
scanf(%[^A Telephonic Girl], str);
printf(%s, str);
return 0;
}

4 more questions based on C only.



For Section 2, be thorough with algos.

Section 2,  Total Time 45 minutes.

1. Given an array arr[] of n integers, construct a Product Array prod[] (of
same size) such that prod[i] is equal to the product of all the elements of
arr[] except arr[i]. Solve it without division operator. Give an efficient
code.
(if you are interested, here is my solution: http://ideone.com/EaTUF ,
developed at the test time itself).

2. Test Cases of Find and Replace functionality in Notepad.

3. You have to make a package library which will do the calculation of
(a^b)mod(c), where a, b, c are very large size of 1 digits. (^- power).
Design a data structure for the numbers' storage and suggest what functions
will you be providing to user with them. Also mention the advantages of
using that DS.


All the best.

On Sat, Aug 27, 2011 at 9:33 PM, sindhu sindhu...@gmail.com wrote:

 these r some of the questions tht i remember..
 first 4 questions are 1 mark simply questions asking 2 write the
 output...each 1 mark
 4. one sql questions asking 2 write 3 queries.. learn group by and
 other clauses..
 they asked questions like find the person who owns most number of
 vehicles...sth like maximum salary..
 5.design a website question i dont remember..
 6.chess board question write a pgm 2 find minimum number of steps
 taken by knight to cover the entire 8*8 board.
 7.write a function tht converts the numbers into word format for
 numbers 1-1000 example:235=two hundred thirty five..
 8.write a  pgm to find minimum angle between the hrs hand and minutes
 hand..
 9.write test case to test multiple elevators in a multi storied
 building...

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Winshuttle Pattern and Question *Urgent*

2011-08-27 Thread Dipankar Patro
First round written - Two parts : 20 C-questions, + 5 Apti
Time 25 minutes.
C-questions - all copied from Test Your C-Skills. (literally). Just mug up
all questions from Test Your C-Skills.

Second coding round. Simple algo based,  written (15 minutes)

Interview rounds after that.

On Sun, Aug 28, 2011 at 7:57 AM, Algorithm Geek algosg...@gmail.com wrote:

 Winshuttle Procedure :

 First Round : C Aptitude, Quantitative Aptitude 30 Mins Test
 2nd :  Coding Round
 3rd : Technical Interview
 4th : Technical + HR

 Hope it helps :)

 On Sat, Aug 27, 2011 at 11:38 AM, Brijesh brijeshupadhyay...@gmail.comwrote:

 lol.. Tu bhi yahin pe?
 yaar samsung me intern he mili hai.. final offer nahi :| and btw
 winshuttle us se achhi hai shayad!

 On Aug 27, 4:08 pm, SANDEEP CHUGH sandeep.aa...@gmail.com wrote:
  @birju : Samsung nhi leni kya??
 
  On Sat, Aug 27, 2011 at 12:45 PM, Brijesh brijeshupadhyay...@gmail.com
 wrote:
 
 
 
 
 
 
 
   Can anyone please post the pattern and questions asked by winshuttle ,
   as it is coming to my college tomorrow..??
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group. To post to this group, send email
 toalgoge...@googlegroups.com.
To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: C dot

2011-08-24 Thread Dipankar Patro
C-Dot procedure (For Computers):

- First shortlist on the basis of cgpa/ %age for interviews.
- Only one round of interview, based on your resume. Discussion of projects
and questions related to mainly OS, Networking and Programming.

There is nothing as selection of Toppers only. If you are good in their
field of working and have nice %age / cpa, then you will definitely be
selected.

On Tue, Aug 23, 2011 at 7:30 PM, Yogesh Bhati ybha...@gmail.com wrote:

 can any1 tell me wat type of question are asked in TCS nd INFOSYS
 interview.

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: c question what is output?

2011-08-21 Thread Dipankar Patro
+1 to 16.

whats the confusion here?

On 21 August 2011 16:44, sagar pareek sagarpar...@gmail.com wrote:

 Arey yaar just see the my post...
 i explained it step by step :)


 On Sun, Aug 21, 2011 at 4:43 PM, Sanjay Rajpal srn...@gmail.com wrote:

 16

 8*(8-1*(8-1-1))


 Sanju
 :)



 On Sun, Aug 21, 2011 at 4:10 AM, Anjul Sharma annurocks1...@gmail.comwrote:

 is 336 the answer??

 On Aug 21, 11:10 am, SuDhir mIsHra sudhir08.mis...@gmail.com wrote:
  #includestdio.h
  #define FUNC1(i) (i*(i-1))
  #define FUNC2(i) (i==0?1:i*FUNC1(i-1))
  main()
  {
  int i=8;
 
  printf(\n%d,FUNC2(i));
 
 
 
 
 
 
 
  }

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 **Regards
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT ALLAHABAD

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] query.. amazon question

2011-08-20 Thread Dipankar Patro
@ gopi:
I think you are referring to the even number of elements in the list.
Anyhow, here is the solution to the odd number of elements.
http://ideone.com/5nmzL

Now is the problem solved?

On 20 August 2011 10:47, *$* gopi.komand...@gmail.com wrote:

 Hi,
  But as per the given problem , that constraint is not specified..

 thx,
 --Gopi


 On Sat, Aug 20, 2011 at 9:25 AM, Dipankar Patro dip10c...@gmail.comwrote:

 Fixed the problem. There was a problem with the first element positioning.

 Here is the final solution:
 http://ideone.com/XwymV

 ^^ Time complexity - O(2n)
 Space complexity O(1)

 :)
 On 20 August 2011 08:14, Dipankar Patro dip10c...@gmail.com wrote:

 http://ideone.com/ucO4d

 Total no. of elements should be even (I assume) and it is also failing
 for some test cases. Working on to zero down to the error in algo.

 On 20 August 2011 02:11, JAIDEV YADAV jaid...@gmail.com wrote:

 this was earlier in this group...
 Please see this paper: http://j.mp/rtNp4W


 On Fri, Aug 19, 2011 at 2:40 PM, Abhishek Yadav 
 abhishek30.nit...@gmail.com wrote:

 Its the same as we do merge sort where we merge the two sorted array
 into one which will require an extra array..
 Is there any algorithm for inplace mergesort...?

 On Fri, Aug 19, 2011 at 2:09 PM, sagar pareek 
 sagarpar...@gmail.comwrote:

 Can be done in O(n) time but it will need O(n) space too

 take another array of same length

 then its code will be

 for( i=0,j=0,k=n/2+1 ;i=n/2kn;  )
 {
   if(arr[i]arr[k])
 new[j++]=arr[k++];
  else
 new[j++]=arr[i++];
 }

  if(kn)
  {
while(i=n/2)
new[j++]=arr[i++]
  }
 else
 {
   while(jn)
new[j++]=arr[k++]

 }

 On Fri, Aug 19, 2011 at 12:40 AM, *$* gopi.komand...@gmail.comwrote:

 Sort an array of n positive integers containing n/2 sorted integers
 in first and second-half?
 in O(n) time complexity ..
 and space complexity should be constant


 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 **Regards
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT ALLAHABAD

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Abhishek Yadav
 Comp Engg.
 NIT Kurukshetra

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 JaiDev Yadav
 (National Yoga Champion)
 Computer Engg. Dept.
 National Institute of Technology
 Kurukshetra,Haryana

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --

 ___

 Please do not print this e-mail until urgent requirement. Go Green!!
 Save Papers = Save Trees




 --

 ___

 Please do not print this e-mail until urgent requirement. Go Green!!
 Save Papers = Save Trees

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Thx,
 --Gopi


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm

Re: [algogeeks] C-Question

2011-08-20 Thread Dipankar Patro
float is 4 bytes.
so a=3.75 will be stored in 4 bytes in memory.

the moment you have a pointer referring to the same memory location but type
cast to (char *), the pointer will refer to character i.e. 1 byte.
^^ this explains the p[0] , p[1], p[2], p[3] - 4 bytes of the 3.75

now finally the o/p
00 00 AC 40
^^ it is in little endian format. i.e the data bytes are stored in memory is
reverse format.

On 20 August 2011 11:21, Vijay Khandar vijaykhand...@gmail.com wrote:

 If the binary equivalent of 5.375 in normalised form is - 0100 
 1010  1100   

 what is the o/p of following code-
 main()
 {
 float a=5.375;
 char *p;
 int i;
 p=(char *)a;
 for(i=0;i=3;i++)
 printf(%02X,(unsigned char)p[i]);
 }

 O/P= 00 00 AC 40
 Plz, Plz  anyone explain me in detail, how this o/p is coming?
 Vijay..

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Google Question:Given a BST and a number, Find the closest node to that number in the BST.

2011-08-20 Thread Dipankar Patro
why traverse the whole tree?

at each root keep the difference in a min_diff and min_ele.
if the entered value is less root then move to left or right.
repeat above two until whole tree is checked or min_diff becomes 0.

pseudo code:

min_diff = INF; // global variables
min_ele = 0;

find_min_diff(node *root, int num)
{

 if (root == null)
 return;

// update the difference
 if(abs(root-val - num)  min_diff)
 {
  min_diff = abs(root-val - num);
  min_ele = root-val;
 }
 if ( min_diff == 0)
  return; // search is over

// proceed to next element in tree which might be closer to the num
 if ( num  root- val)
   find_min_ele(root-left, num);
 else
   find_min_ele(root-right, num);
}

^^ Complexity : O(logn)

On 20 August 2011 12:36, Abhishek Yadav algowithabhis...@gmail.com wrote:

 yes, the interviewer said that there is a solution in O(log n)


 On Sat, Aug 20, 2011 at 12:29 PM, sukran dhawan sukrandha...@gmail.comwrote:

 ur traversing the tree once so it shud be o(n).does the question demand
 0(logn) ?

 On Sat, Aug 20, 2011 at 12:27 PM, Abhishek Yadav 
 algowithabhis...@gmail.com wrote:

 what would be the complexity of your solution O(n) or O(log n)..?

  On Sat, Aug 20, 2011 at 12:19 PM, sukran dhawan sukrandha...@gmail.com
  wrote:

 traverse bst inorder and each time u encounter a node find the
 difference between the element and given element in question . if the
 absolute difference is minimum after traversing the tree that is the 
 element
 . u can getback the element using another element which keeps sign of the
 element so that original element can be obtained from diff

 On Sat, Aug 20, 2011 at 12:15 PM, Abhishek Yadav 
 algowithabhis...@gmail.com wrote:

 Given a BST and a number, Find the closest node to that number in the
 BST. Give an algorithm for that.
 Let there be binary search tree having nodes with values
 12,34,64,23,64,25,76,6 and the number given is 28, then the answer
 would be 25 as it is the closest node.

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Google Question:Given a BST and a number, Find the closest node to that number in the BST.

2011-08-20 Thread Dipankar Patro
is there anything wrong in my algo?
do tell me.

On 20 August 2011 12:56, Abhishek Yadav algowithabhis...@gmail.com wrote:

 Hey i tried it now and got to another solution
 O(log n) solution:
 1. try searching for the number , if found,return the node, otherwise, you
 will ultimately reach a leaf node say 'nd'
 2.  Now the two candidates for the answer would be
1. TreeSuccessor(nd)  2. TreePredecessor(nd)
 Now compare the original number with these two and minimum would be the
 answer.

 (TreeSuccessor and TreePredecessor are the next and previous node resp. in
 the Inorder traversal of the tree.)

 On Sat, Aug 20, 2011 at 12:46 PM, Dipankar Patro dip10c...@gmail.comwrote:

 why traverse the whole tree?

 at each root keep the difference in a min_diff and min_ele.
 if the entered value is less root then move to left or right.
 repeat above two until whole tree is checked or min_diff becomes 0.

 pseudo code:

 min_diff = INF; // global variables
 min_ele = 0;

 find_min_diff(node *root, int num)
 {

  if (root == null)
  return;

 // update the difference
  if(abs(root-val - num)  min_diff)
  {
   min_diff = abs(root-val - num);
   min_ele = root-val;
  }
  if ( min_diff == 0)
   return; // search is over

 // proceed to next element in tree which might be closer to the num
  if ( num  root- val)
find_min_ele(root-left, num);
  else
find_min_ele(root-right, num);
 }

 ^^ Complexity : O(logn)

 On 20 August 2011 12:36, Abhishek Yadav algowithabhis...@gmail.comwrote:

 yes, the interviewer said that there is a solution in O(log n)


 On Sat, Aug 20, 2011 at 12:29 PM, sukran dhawan 
 sukrandha...@gmail.comwrote:

 ur traversing the tree once so it shud be o(n).does the question demand
 0(logn) ?

 On Sat, Aug 20, 2011 at 12:27 PM, Abhishek Yadav 
 algowithabhis...@gmail.com wrote:

 what would be the complexity of your solution O(n) or O(log n)..?

  On Sat, Aug 20, 2011 at 12:19 PM, sukran dhawan 
 sukrandha...@gmail.com wrote:

 traverse bst inorder and each time u encounter a node find the
 difference between the element and given element in question . if the
 absolute difference is minimum after traversing the tree that is the 
 element
 . u can getback the element using another element which keeps sign of the
 element so that original element can be obtained from diff

 On Sat, Aug 20, 2011 at 12:15 PM, Abhishek Yadav 
 algowithabhis...@gmail.com wrote:

 Given a BST and a number, Find the closest node to that number in the
 BST. Give an algorithm for that.
 Let there be binary search tree having nodes with values
 12,34,64,23,64,25,76,6 and the number given is 28, then the answer
 would be 25 as it is the closest node.

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --

 ___

 Please do not print this e-mail until urgent requirement. Go Green!!
 Save Papers = Save Trees

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en

Re: [algogeeks] Syllogism

2011-08-20 Thread Dipankar Patro
yes, i think so

On 20 August 2011 10:52, sukran dhawan sukrandha...@gmail.com wrote:

 yes


 On Sat, Aug 20, 2011 at 10:26 AM, geek_one 
 abhishekgupta.it...@gmail.comwrote:

 Statement: Some girls are beautiful.
 Conclusion: Some girls are not beautiful.

 is the conclusion is true on the basis of Statement?

 --
 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/-/SGSGlmwYFBAJ.
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] important question on ADT

2011-08-19 Thread Dipankar Patro
(c)

On 19 August 2011 23:18, sukran dhawan sukrandha...@gmail.com wrote:

 yes c is the answer.for ex for stack the valid operations are
 push,pop,isempty,peep


 On Fri, Aug 19, 2011 at 10:57 PM, ghsjgl k ghsk...@gmail.com wrote:

 An abstract data type is
 (a) same as abstract class
 (b) a datatype that cannot be instantiated
 (c) a datatype for which only the operations defined on it can be used but
 none else
 (d) all of the above


 what is the answer 

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] query.. amazon question

2011-08-19 Thread Dipankar Patro
http://ideone.com/ucO4d

Total no. of elements should be even (I assume) and it is also failing for
some test cases. Working on to zero down to the error in algo.

On 20 August 2011 02:11, JAIDEV YADAV jaid...@gmail.com wrote:

 this was earlier in this group...
 Please see this paper: http://j.mp/rtNp4W


 On Fri, Aug 19, 2011 at 2:40 PM, Abhishek Yadav 
 abhishek30.nit...@gmail.com wrote:

 Its the same as we do merge sort where we merge the two sorted array into
 one which will require an extra array..
 Is there any algorithm for inplace mergesort...?

 On Fri, Aug 19, 2011 at 2:09 PM, sagar pareek sagarpar...@gmail.comwrote:

 Can be done in O(n) time but it will need O(n) space too

 take another array of same length

 then its code will be

 for( i=0,j=0,k=n/2+1 ;i=n/2kn;  )
 {
   if(arr[i]arr[k])
 new[j++]=arr[k++];
  else
 new[j++]=arr[i++];
 }

  if(kn)
  {
while(i=n/2)
new[j++]=arr[i++]
  }
 else
 {
   while(jn)
new[j++]=arr[k++]

 }

 On Fri, Aug 19, 2011 at 12:40 AM, *$* gopi.komand...@gmail.com wrote:

 Sort an array of n positive integers containing n/2 sorted integers in
 first and second-half?
 in O(n) time complexity ..
 and space complexity should be constant


 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 **Regards
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT ALLAHABAD

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Abhishek Yadav
 Comp Engg.
 NIT Kurukshetra

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 JaiDev Yadav
 (National Yoga Champion)
 Computer Engg. Dept.
 National Institute of Technology
 Kurukshetra,Haryana

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] query.. amazon question

2011-08-19 Thread Dipankar Patro
Fixed the problem. There was a problem with the first element positioning.

Here is the final solution:
http://ideone.com/XwymV

^^ Time complexity - O(2n)
Space complexity O(1)

:)
On 20 August 2011 08:14, Dipankar Patro dip10c...@gmail.com wrote:

 http://ideone.com/ucO4d

 Total no. of elements should be even (I assume) and it is also failing for
 some test cases. Working on to zero down to the error in algo.

 On 20 August 2011 02:11, JAIDEV YADAV jaid...@gmail.com wrote:

 this was earlier in this group...
 Please see this paper: http://j.mp/rtNp4W


 On Fri, Aug 19, 2011 at 2:40 PM, Abhishek Yadav 
 abhishek30.nit...@gmail.com wrote:

 Its the same as we do merge sort where we merge the two sorted array into
 one which will require an extra array..
 Is there any algorithm for inplace mergesort...?

 On Fri, Aug 19, 2011 at 2:09 PM, sagar pareek sagarpar...@gmail.comwrote:

 Can be done in O(n) time but it will need O(n) space too

 take another array of same length

 then its code will be

 for( i=0,j=0,k=n/2+1 ;i=n/2kn;  )
 {
   if(arr[i]arr[k])
 new[j++]=arr[k++];
  else
 new[j++]=arr[i++];
 }

  if(kn)
  {
while(i=n/2)
new[j++]=arr[i++]
  }
 else
 {
   while(jn)
new[j++]=arr[k++]

 }

 On Fri, Aug 19, 2011 at 12:40 AM, *$* gopi.komand...@gmail.com wrote:

 Sort an array of n positive integers containing n/2 sorted integers in
 first and second-half?
 in O(n) time complexity ..
 and space complexity should be constant


 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 **Regards
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT ALLAHABAD

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Abhishek Yadav
 Comp Engg.
 NIT Kurukshetra

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 JaiDev Yadav
 (National Yoga Champion)
 Computer Engg. Dept.
 National Institute of Technology
 Kurukshetra,Haryana

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --

 ___

 Please do not print this e-mail until urgent requirement. Go Green!!
 Save Papers = Save Trees




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Amazon Interview Q

2011-08-18 Thread Dipankar Patro
we can do that too.
But if I return cur then I can myself print cur, cur-next, cur-next-prev.
for verification.

On 18 August 2011 11:56, Vijay Kansal vijaykans...@gmail.com wrote:

 We should return curr-next in the last statement of ur code

 On Aug 18, 7:08 am, Dipankar Patro dip10c...@gmail.com wrote:
  A slight change in above code:
  make it
  while(cur  cur-next)
  ^^ other wise the code will crash at last element in a prefect list, with
 no
  loop.
 
  On 18 August 2011 07:36, Dipankar Patro dip10c...@gmail.com wrote:
 
 
 
 
 
 
 
 
 
   I have come up with this:
   - Use only one pointer, NODE *cur
   - initialize cur to headref
 
   - The main loop:
   while (cur)
   {
 if(cur-next-prev != cur)
break;
 cur=cur-next;
   }
   return cur;
 
   ^^ I think the code is self explanatory. It just uses the fact that at
   loop, the prev of next to current won't be current.
   e.g. A-B-C-D-E-F-C
   Though F is pointing to C, C won't be pointing back to F as the prev of
 C
   is pointing to B.
   Complexity: O(n)
 
   On 18 August 2011 04:45, payal gupta gpt.pa...@gmail.com wrote:
 
   ys...i guess i misinterpreted..the question..
   ma fault...
 
   On Thu, Aug 18, 2011 at 4:27 AM, Brijesh Upadhyay 
   brijeshupadhyay...@gmail.com wrote:
 
   At the node from where the loop just started.. anyway we could not
 use
   that logic , coz it isnt circular linked list!
 
   --
   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/-/sr4w-kPmnEsJ.
 
   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 group at
  http://groups.google.com/group/algogeeks?hl=en.
 
--
   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 group at
  http://groups.google.com/group/algogeeks?hl=en.
 
   --
 
  
 ___
 
 
   Please do not print this e-mail until urgent requirement. Go Green!!
   Save Papers = Save Trees
 
  --
 
 ___
 
 
  Please do not print this e-mail until urgent requirement. Go Green!!
  Save Papers = Save Trees

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Amazon question

2011-08-18 Thread Dipankar Patro
O(1) space means constant space. It doesn't mean you can't use extra space.
Refer here:
http://stackoverflow.com/questions/2219109/what-does-this-mean-on-steps-and-o1-space

According to the question you can definitely use a Hash Table for keeping
hit record, as it will be a constant space (provided the range of numbers is
known).

In case the range of numbers is not known, BST will be close answer. Since
only one element will be repeating, the process of making the BST can be
stopped when the first repeating element is caught. BUT, this will be O(n)
space, as the number of nodes in BST will be n-1 in worst case.

On 19 August 2011 07:59, *$* gopi.komand...@gmail.com wrote:

 only once


 On Fri, Aug 19, 2011 at 7:57 AM, saurabh singh saurab...@gmail.comwrote:

 The element is repeated only once or can be repeated k number of times??

 On Fri, Aug 19, 2011 at 7:50 AM, *$* gopi.komand...@gmail.com wrote:

 I think we are using hash , which is like extra spaace , but as per the
 question , O(s) = 1.

 Thx,
 --Gopi


 On Fri, Aug 19, 2011 at 2:15 AM, icy` vipe...@gmail.com wrote:

 #!/usr/bin/ruby -w
 #array of unsorted positive integers
 # find the [only] one that is duplicated

 arr= [97,2,54,26,67,12,1,19,44,4,29,36,67,14,93,22,39,89]
 h = Hash.new(0)

 arr.each {|n|
h[n]+=1
(puts n; break) if h[n]==2
 }

 #output
 #67

 I hope this meets the requirements ;P

 On Aug 18, 3:15 pm, *$* gopi.komand...@gmail.com wrote:
  How to find duplicate element (only one element is repeated) from an
 array
  of unsorted positive integers..
  time complexity .. O(n)
  space .. o(1).

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Thx,
 --Gopi


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT ALLAHABAD


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Thx,
 --Gopi

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Answer this !!

2011-08-18 Thread Dipankar Patro
Overriding doesn't remove the function. It just changes the function
definition.

So 2 will be the answer.

On 19 August 2011 00:33, siddharth srivastava akssps...@gmail.com wrote:



 On 19 August 2011 00:31, priya ramesh love.for.programm...@gmail.comwrote:

 it can remove methods defined in base class as well?? By overriding a
 virtual base class func??



 I don't think that overriding is considered as removing the function  from
 base class

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Regards
 Siddharth Srivastava



  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Amazon Interview Q

2011-08-17 Thread Dipankar Patro
I have come up with this:
- Use only one pointer, NODE *cur
- initialize cur to headref

- The main loop:
while (cur)
{
  if(cur-next-prev != cur)
 break;
  cur=cur-next;
}
return cur;

^^ I think the code is self explanatory. It just uses the fact that at loop,
the prev of next to current won't be current.
e.g. A-B-C-D-E-F-C
Though F is pointing to C, C won't be pointing back to F as the prev of C is
pointing to B.
Complexity: O(n)

On 18 August 2011 04:45, payal gupta gpt.pa...@gmail.com wrote:

 ys...i guess i misinterpreted..the question..
 ma fault...


 On Thu, Aug 18, 2011 at 4:27 AM, Brijesh Upadhyay 
 brijeshupadhyay...@gmail.com wrote:

 At the node from where the loop just started.. anyway we could not use
 that logic , coz it isnt circular linked list!

 --
 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/-/sr4w-kPmnEsJ.

 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Amazon Interview Q

2011-08-17 Thread Dipankar Patro
A slight change in above code:
make it
while(cur  cur-next)
^^ other wise the code will crash at last element in a prefect list, with no
loop.

On 18 August 2011 07:36, Dipankar Patro dip10c...@gmail.com wrote:

 I have come up with this:
 - Use only one pointer, NODE *cur
 - initialize cur to headref

 - The main loop:
 while (cur)
 {
   if(cur-next-prev != cur)
  break;
   cur=cur-next;
 }
 return cur;

 ^^ I think the code is self explanatory. It just uses the fact that at
 loop, the prev of next to current won't be current.
 e.g. A-B-C-D-E-F-C
 Though F is pointing to C, C won't be pointing back to F as the prev of C
 is pointing to B.
 Complexity: O(n)

 On 18 August 2011 04:45, payal gupta gpt.pa...@gmail.com wrote:

 ys...i guess i misinterpreted..the question..
 ma fault...


 On Thu, Aug 18, 2011 at 4:27 AM, Brijesh Upadhyay 
 brijeshupadhyay...@gmail.com wrote:

 At the node from where the loop just started.. anyway we could not use
 that logic , coz it isnt circular linked list!

 --
 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/-/sr4w-kPmnEsJ.

 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --

 ___

 Please do not print this e-mail until urgent requirement. Go Green!!
 Save Papers = Save Trees




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Counting

2011-08-17 Thread Dipankar Patro
How about using vertices and edges format in graphs?
- Traverse through each vertex in vertices list, and add all the edges to
the edge list if they are not already present in the edge list.
- Keep a counter to detect addition of new edges.

On 18 August 2011 01:31, Luciano Junior luciano@gmail.com wrote:

 How many different ways are there to count how many streets have in a city,
 based on the city map?
 What algorithms can be used for response this question ?

 --
 
 Luciano Soares Pinheiro Jr.
 Analista desenvolvedor Sr.

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Output?? Why??

2011-08-17 Thread Dipankar Patro
Thats new..
Its not working in C++, where as in C it works like a charm.

On 18 August 2011 08:57, vartika aggarwal vartika.aggarwa...@gmail.comwrote:

 @Aditi: That's because you haven't changed the language to 'C' (while
 working on ideone. It doesn't give an error in C)


 On Thu, Aug 18, 2011 at 8:47 AM, aditi garg aditi.garg.6...@gmail.comwrote:

 @payal: im getting compile time errors fr both the strings...
 Chk dis :http://ideone.com/BRbkf


 On Thu, Aug 18, 2011 at 4:12 AM, payal gupta gpt.pa...@gmail.com wrote:

 i modified the code a lil bit
 #includestdio.h
 #includeconio.h
 int main()
 { clrscr();
  char arr[5] = geeks;
  printf(%s\n, arr);
  char b[1]=t;
  printf(%s\n,b);
  getchar();
  return 0;
 }

 the output in dis case is somewhat diff..cud someone explain...

 On Thu, Aug 18, 2011 at 3:28 AM, Ayush Kapoor 
 ayush21011...@gmail.comwrote:

 There is no null character in this string,as its length is 5 and the
 number of characters is 5(Geeks),and printf(%s,arr) should output the
 string till the null character


 On Thu, Aug 18, 2011 at 2:40 AM, bihari kumarvive...@gmail.com wrote:

 upto null charchter..

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Ayush

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


 --
  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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Aditi Garg
 Undergraduate Student
 Electronics  Communication Divison
 NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
 Sector 3, Dwarka
 New Delhi


 --
  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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Regards

 Vartika Aggarwal
 Undergraduate Student
 IT Department
 NSIT, Dwarka

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Output?? Why??

2011-08-17 Thread Dipankar Patro
Interesting thing I came across:
http://stackoverflow.com/questions/1239938/c-accesses-an-array-out-of-bounds-gives-no-error-why

On 18 August 2011 09:39, vartika aggarwal vartika.aggarwa...@gmail.comwrote:

 Is it that there is no bounds checking in C while there is in C++ ?


 On Thu, Aug 18, 2011 at 9:27 AM, Dipankar Patro dip10c...@gmail.comwrote:

 Thats new..
 Its not working in C++, where as in C it works like a charm.

   On 18 August 2011 08:57, vartika aggarwal vartika.aggarwa...@gmail.com
  wrote:

  @Aditi: That's because you haven't changed the language to 'C' (while
 working on ideone. It doesn't give an error in C)


 On Thu, Aug 18, 2011 at 8:47 AM, aditi garg 
 aditi.garg.6...@gmail.comwrote:

 @payal: im getting compile time errors fr both the strings...
 Chk dis :http://ideone.com/BRbkf


 On Thu, Aug 18, 2011 at 4:12 AM, payal gupta gpt.pa...@gmail.comwrote:

 i modified the code a lil bit
 #includestdio.h
 #includeconio.h
 int main()
 { clrscr();
  char arr[5] = geeks;
  printf(%s\n, arr);
  char b[1]=t;
  printf(%s\n,b);
  getchar();
  return 0;
 }

 the output in dis case is somewhat diff..cud someone explain...

 On Thu, Aug 18, 2011 at 3:28 AM, Ayush Kapoor ayush21011...@gmail.com
  wrote:

 There is no null character in this string,as its length is 5 and the
 number of characters is 5(Geeks),and printf(%s,arr) should output the
 string till the null character


 On Thu, Aug 18, 2011 at 2:40 AM, bihari kumarvive...@gmail.comwrote:

 upto null charchter..

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Ayush

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


 --
  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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Aditi Garg
 Undergraduate Student
 Electronics  Communication Divison
 NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
 Sector 3, Dwarka
 New Delhi


 --
  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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Regards

 Vartika Aggarwal
 Undergraduate Student
 IT Department
 NSIT, Dwarka

 --
   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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --

 ___

 Please do not print this e-mail until urgent requirement. Go Green!!
 Save Papers = Save Trees

 --
  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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Regards

 Vartika Aggarwal
 Undergraduate Student
 IT Department
 NSIT, Dwarka

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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

Re: [algogeeks] Prime numbers

2011-08-16 Thread Dipankar Patro
Sieve's is the fastest in generating prime numbers. +1 to Sandeep and Sanjay

On 17 August 2011 08:21, Sanjay Rajpal sanjay.raj...@live.in wrote:

 Agree with Sandeep :)
 Try this link http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes.
 Hope it helps :)


 Sanjay Kumar
 B.Tech Final Year
 Department of Computer Engineering
 National Institute of Technology Kurukshetra
 Kurukshetra - 136119
 Haryana, India


 On Tue, Aug 16, 2011 at 2:28 PM, sandeep pandey 
 sandeep.masum4...@gmail.com wrote:

 try to implement sieve.
 it,s a well known algorithm to find out d prime frequently.

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] reason

2011-08-15 Thread Dipankar Patro
I think while assignment the type conversion will take place. Whether you
write it or not.
check this out: http://ideone.com/y36vj
^^ Just giving off warnings, but it is working.

On 15 August 2011 14:14, aditi garg aditi.garg.6...@gmail.com wrote:

 I think dis is bec int occupies 4 bytes while char occupies 1 byte so in
 the memory when we save as int dey are saved as 2000 3000 4000
 now whn u take a char pointer pointing to dis array and u increment it by 1
 dey will move only by 1 byte and thus u get 0...
 u can verify the result by removing char* typecast and u will get the ans
 as 2 3


 On Mon, Aug 15, 2011 at 1:59 PM, Nitin coolguyinat...@gmail.com wrote:

 #includestdio.h
 main()
 {
 int arr[3]={2,3,4};
 char *p;
 p=arr;
 p=(char *)((int *)(p));
 printf(%d,*p);
 p=(char *)((int *)(p+1));
 printf(%d,*p);
 }
 it is giving 2,0 why it is giving 0 ..??

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Aditi Garg
 Undergraduate Student
 Electronics  Communication Divison
 NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
 Sector 3, Dwarka
 New Delhi


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] mcq-os

2011-08-15 Thread Dipankar Patro
As stated by Rajeev,
2,3 are a part of process synch.

So I also think all 3

On 15 August 2011 18:35, rajeev bharshetty rajeevr...@gmail.com wrote:

 All the above 1,2,3
 Semaphores help to prevent race conditions in a program.
 They help in process synchronization by allowing multiple processes access
 to a common shared memory .
 and they also solve the problem of mutual exclusion allowing only a single
 process in a critical region at a time.

 Correct me if i am wrong.

 On Mon, Aug 15, 2011 at 6:29 PM, Kamakshii Aggarwal kamakshi...@gmail.com
  wrote:

 semaphores are used to solve the problem of?
 1.process synchronization
 2.race around
 3.mutual exclusion.

 --
 Regards,
 Kamakshi
 kamakshi...@gmail.com

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Regards
 Rajeev N B http://www.opensourcemania.co.cc

 *Winners Don't do Different things , they do things Differently*

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Non recursive preorder and postorder

2011-08-15 Thread Dipankar Patro
Consult Tanenbaum buddy. It has provided a proper in-order traversal code.
You will have to think a bit on that on your own too to get to post and pre
order.

Hint:
- Check the sequence in which the elements are pushed and popped in stack.
e.g. for pre order, print the node value as you reach any root and then push
it in stack. then move to left sub tree. repeat till NULL, then pop out the
last node pushed in, take the right sub-tree and proceed again, do till no
nodes are left and stack is empty.

On 15 August 2011 18:37, rohit raman.u...@gmail.com wrote:

 Can anyone give algorithm for non recursive preorder and postorder??

 --
 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/-/CMDjAwgewoYJ.
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Operators

2011-08-15 Thread Dipankar Patro
1 and 3, I guess.
* used in multiplication (a*b) and also in pointers(*b).
 used in bitwise operations (ab)and also as address operator(b).

Not sure about '#', haven't used much.

On 15 August 2011 18:45, aditi garg aditi.garg.6...@gmail.com wrote:

 Pick the operators whose meaning is context dependent?
 1. *
 2.#
 3.
 4.No such operator exists
 Plz gv the diff contexts if applicable...

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Algorithm

2011-08-15 Thread Dipankar Patro
For n/2 I came across a nice algo sometime back.
here is how to do it (I am providing algo):

int A[n], i,  num, freq=0;

set num = A[0] and freq= 1; // assume first number to be the n/2 times
occurring element.

from i=1 to n-1
{
 if (A[i] == num)
freq++;
 else
freq--;

 freq = (freq  0)? 0: freq; // in case freq. goes negative.

 if (freq == 0) // That means there might be any other element occurring
more than the current element.
   num = A[i];
}

if (freq)
 return num;
else
 return NULL;

How does it work:

consider this array: 9 , 9 ,1 ,1 ,5 ,1 ,1 ,9 ,1 (n = 9, n/2 = 4)
- for 1 to be the answer, its freq should be 5 or more.
- now if 1 has occurred for 5 times, means 4 times some other number has
occurred (irrespective of how many times other numbers have occurred). so
the overall extra occurrence is of 1 is 1.
run the algo (i = 1 to 8):
- i = 1 , A[i] = 9, n = 9, freq = 1 = freq++;
- i = 2 , A[i] = 1, n = 9, freq = 2 = freq --;
- i = 3,  A[i] = 1, n = 9, freq = 1 = freq -- and n is set to 1
continue till end and you will find that for n = 1, freq = 1;
so the answer will be 1.

please do tell me if you find some test case for which above algo fails.

Will be looking for a similar soln. for n/4.


On 15 August 2011 16:31, contiguous priyadee...@gmail.com wrote:

 Design an algorithm to find all elements that appear more than n/2
 times in the list. Then do it for elements that appear more than n/4
 times.

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] program puzzle

2011-08-15 Thread Dipankar Patro
@ 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]);
 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++)
 {
  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:

 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 group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
MeHdi KaZemI

   --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] string confusion

2011-08-14 Thread Dipankar Patro
@ Gaurav:
in ASCII code : '\0' is actually 0,
if you are confused with '0' and 0, first one the character and later one is
 Remember that '0' is not 0 in ASCII, rather value of '0' is 48.

So they can be used in place of each other.
[ Just expanding what Sagar is trying to say]

On 14 August 2011 14:32, sagar pareek sagarpar...@gmail.com wrote:

 arshad
 u got my point or not?


 On Sun, Aug 14, 2011 at 1:16 PM, Arshad Alam alam3...@gmail.com wrote:

 program is running smooth but I have one confusion at line number 8.
 why it is *while(s[i]!=0)* instead of *while(s[i]!='\0')*



 1.#includestdio.h
 2.#includeconio.h
 3.void main()
 4.{
 5.clrscr();
 6.char s[]=No two viruses;
 7.int i=0;
 8.while(s[i]!=0)
 9.{
 10.printf(\n%c %c,s[i],*(s+i));
 11.printf ( \n%c %c,i[s],*(i+s));
 12.i++;
 13.  }
 14.  getch();
 15.}




 Thanks  Regards
 Arshad Nadeem Alam


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 **Regards
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT ALLAHABAD

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] de shaw

2011-08-14 Thread Dipankar Patro
came across this on other forum..
http://forums.sureshkumar.net/de-shaw-placement-papers/17885-deshaw-technical-questions.html

On 13 August 2011 23:32, sukran dhawan sukrandha...@gmail.com wrote:

 MVIT ?

 On Sat, Aug 13, 2011 at 9:02 PM, Dipankar Patro dip10c...@gmail.comwrote:

 Which college?


 On 13 August 2011 20:52, ravinder s ravinderr...@gmail.com wrote:



 hi can anyone tell me the pattern of de shaw ?

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --

 ___

 Please do not print this e-mail until urgent requirement. Go Green!!
 Save Papers = Save Trees

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] array question

2011-08-14 Thread Dipankar Patro
how about binary search of each element from array 1 on array 2?

overall complexity : O(nlogn)

On 14 August 2011 18:46, mohit verma mohit89m...@gmail.com wrote:

 example:
  array 1 :: 1 2 3 4 5 6 7  8 9 10 15
  array 2::  23 34 56 13  15  57 432  348


 On Sun, Aug 14, 2011 at 6:44 PM, shady sinv...@gmail.com wrote:

 meaning ? what is a common element ? example ???

 On Sun, Aug 14, 2011 at 6:37 PM, mohit verma mohit89m...@gmail.comwrote:

 given two arrays : with all distinct elements but one element in common.
 Find the common element in optimal time.

 --
 
 *MOHIT VERMA*

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 
 *MOHIT VERMA*

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] array question

2011-08-14 Thread Dipankar Patro
@ Sagar:
What if extra space in not allowed?
I think then we have to use the binary search method...

On 14 August 2011 18:50, sagar pareek sagarpar...@gmail.com wrote:

 Hashing
 O(n+m)


 On Sun, Aug 14, 2011 at 6:48 PM, Dipankar Patro dip10c...@gmail.comwrote:

 how about binary search of each element from array 1 on array 2?

 overall complexity : O(nlogn)

 On 14 August 2011 18:46, mohit verma mohit89m...@gmail.com wrote:

 example:
  array 1 :: 1 2 3 4 5 6 7  8 9 10 15
  array 2::  23 34 56 13  15  57 432  348


 On Sun, Aug 14, 2011 at 6:44 PM, shady sinv...@gmail.com wrote:

 meaning ? what is a common element ? example ???

 On Sun, Aug 14, 2011 at 6:37 PM, mohit verma mohit89m...@gmail.comwrote:

 given two arrays : with all distinct elements but one element in
 common. Find the common element in optimal time.

 --
 
 *MOHIT VERMA*

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 
 *MOHIT VERMA*

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --

 ___

 Please do not print this e-mail until urgent requirement. Go Green!!
 Save Papers = Save Trees

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 **
 Regards
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT ALLAHABAD

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: TRee question...

2011-08-14 Thread Dipankar Patro
Sorry about the tree, didn't keep in mind about BST while drawing that.
But I think you all got the point that I was trying to point out.

On 13 August 2011 23:18, rajul jain rajuljain...@gmail.com wrote:

 see WgpShashank second point carefully
 it say successor  is parent of left node
 so solution of you BST is parent of 2 which is 4

 On Sat, Aug 13, 2011 at 7:50 PM, Anika Jain anika.jai...@gmail.comwrote:

 @ashmantak: the figure of dipankar is incorrect but his point is correct..
 for a tree like

 4
   /\
  2 10
 /   \
13
 successor of 3 shall be 4 not 2..


 On Fri, Aug 12, 2011 at 4:48 PM, ashmantak ashman...@gmail.com wrote:

 @Dipankar Patro -

 The figure u have made isn't a BST.Read the problem.
 His soln. is correct.

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: fork() question

2011-08-14 Thread Dipankar Patro
search in group archive,
this question has been discussed very deeply

On 14 August 2011 23:14, sivaviknesh s sivavikne...@gmail.com wrote:


 http://faq.programmerworld.net/networking/unix-interview-questions-answers.html

 refer 16 th ques in this site .. they ve told 2^n times..so only i asked
 whether its compiler dependent ??


 On Sun, Aug 14, 2011 at 11:12 PM, sivaviknesh s sivavikne...@gmail.comwrote:

 int main()
 {
 fork();
 fork();
 fork();
 printf(Hello world!);
 }

 ...this will print hello world 8 times...i.e . 2^n times

 but...

 int main()
 {
 fork();
 fork();
 fork();
 fork()
 printf(Hello world!);
 }

 http://ideone.com/TRKTE

 ..but this prints only 11 times
 -- and for five forks 25 times...plz tell how..or is this a prob wit
 compiler???
 Regards,
 $iva




 --
 Regards,
 $iva

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: array question

2011-08-14 Thread Dipankar Patro
@Dave nice algo. Really like it.

So the whole complexity depends on the sorting.

On 14 August 2011 22:58, Dave dave_and_da...@juno.com wrote:

 @Dipankar: If extra space is not allowed, I think the optimal solution
 is to sort the two arrays, which takes O(max(m log m, n log n)). Then
 the common element can be found in O(m + n) by a simple search that
 starts at i = j = 0 and increments the index of the lesser of a[i] and
 b[j]. Overall complexity is O(max(m log m, n log n)).

 Dave

 On Aug 14, 8:24 am, Dipankar Patro dip10c...@gmail.com wrote:
  @ Sagar:
  What if extra space in not allowed?
  I think then we have to use the binary search method...
 
  On 14 August 2011 18:50, sagar pareek sagarpar...@gmail.com wrote:
 
 
 
 
 
   Hashing
   O(n+m)
 
   On Sun, Aug 14, 2011 at 6:48 PM, Dipankar Patro dip10c...@gmail.com
 wrote:
 
   how about binary search of each element from array 1 on array 2?
 
   overall complexity : O(nlogn)
 
   On 14 August 2011 18:46, mohit verma mohit89m...@gmail.com wrote:
 
   example:
array 1 :: 1 2 3 4 5 6 7  8 9 10 15
array 2::  23 34 56 13  15  57 432  348
 
   On Sun, Aug 14, 2011 at 6:44 PM, shady sinv...@gmail.com wrote:
 
   meaning ? what is a common element ? example ???
 
   On Sun, Aug 14, 2011 at 6:37 PM, mohit verma mohit89m...@gmail.com
 wrote:
 
   given two arrays : with all distinct elements but one element in
   common. Find the common element in optimal time.
 
   --
   
   *MOHIT VERMA*
 
--
   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 group at
  http://groups.google.com/group/algogeeks?hl=en.
 
--
   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 group at
  http://groups.google.com/group/algogeeks?hl=en.
 
   --
   
   *MOHIT VERMA*
 
--
   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 group at
  http://groups.google.com/group/algogeeks?hl=en.
 
   --
 
  
 ___­
 
   Please do not print this e-mail until urgent requirement. Go Green!!
   Save Papers = Save Trees
 
   --
   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 group at
  http://groups.google.com/group/algogeeks?hl=en.
 
   --
   **
   Regards
   SAGAR PAREEK
   COMPUTER SCIENCE AND ENGINEERING
   NIT ALLAHABAD
 
--
   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 group at
  http://groups.google.com/group/algogeeks?hl=en.
 
  --
 
 ___­
 
  Please do not print this e-mail until urgent requirement. Go Green!!
  Save Papers = Save Trees

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks]

2011-08-14 Thread Dipankar Patro
@ ghsjgl:
At each step(m), the no. ways is equal to the sum of ways till m-1 and ways
till m-2.
Look at it as you have reached at m either by taking one step from m-1 or
two steps from m-2.

I hope that answers your query.

On 14 August 2011 22:26, ghsjgl k ghsk...@gmail.com wrote:

 fibonacci series...???

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: an array question

2011-08-14 Thread Dipankar Patro
Ankur, I agree with your algo.

- radix sort from least significant to most significant.
- a slight modification can be done on the appending 0 part.
when you find the a digit is absent from the number, you leave the number.
e.g
95, 87, 9, 45, 38

one's place, sort: (descending)
9, 38, 87, 95, 45

ten's place sort: (leave the number at its place if it doesn't have a ten's
place)
9, 95, 87, 45, 38

^^ I think this will work for all cases. Will require extremely good use of
pointers.

On 14 August 2011 19:16, Ankur Khurana ankur.kkhur...@gmail.com wrote:

 why will 678 come after 583 ?
 okay ., sort from least to most significant digit. append imaginary 0's at
 the end of the numbers with varying length to make them of same length


 On Sun, Aug 14, 2011 at 5:54 PM, Puneet Gautam puneet.nsi...@gmail.comwrote:

 @ankur: No its not radix sort...radix sort would give wrong answer
 when the input contains heterogeneous numbered digits in the
 array(even when going 4m msd to lsd)...
 eg:
 32,583,678,1,45,9

 Radix sort would give:
 9,583,678,45,32,1

 whereas the answer has to be:

 9,678,543,45,32,1
 and hence largest no created is 967854345321

 I think thats the way radix sort will work...

 Correct me if i m wrong...!


 On 8/14/11, Ankur Khurana ankur.kkhur...@gmail.com wrote:
  isn't it a simple question of applying radix sort from most significant
 to
  least signigicant digit and concatenating all the sorted numbers to get
 the
  largest number..
 
  On Sat, Aug 13, 2011 at 11:13 PM, Kunal Patil kp101...@gmail.com
 wrote:
 
  Let me clarify.
 
  Lets take example
  53
  147
  1471470
 
  As per algo:
  sort 5353535 , 1471471 and 1471470 lexicographically to get
 answer.
  But You are not going to compare all these simultaneously.
  Might be you will first compare 53 and 147 for lexicographical order.
 In
  this case you are not required  to calculate till max length.
  In fact while comparing two strings you will require only till
 (max(len1,
  len2)).
  (verify it !!)
  Comparing 53 and 1471470 doesn't even require till max length.
  Comparing 147 and 1471470 (co-incidentally) requires till max length.
  (worst case !)
 
 
  Consider you have only 2 strings.
  Then above code gives lexicographically largest of these two
  (This comparison is considering circular appending).
  You can now use this comparator function as parameter for sort()
 function
  in c++.
  So given set of strings as the input and this comparator function it
 will
  sort as per given criteria.
 
  I mentioned you have to append circularly till largest of all string
  length only for illustration purpose and to make understanding easier.
  Had I mentioned go on comparing each of 2 strings till max(len1,len2),
 It
  might not be grasped quickly.
  As you can see you will not always require string upto largest length
 to
  determine lexicographical order of 2 strings.
 
  I am bad at explaining things. So let me know whether this solved your
  doubt.
 
 
 
  On Sat, Aug 13, 2011 at 10:35 PM, aditi garg
  aditi.garg.6...@gmail.comwrote:
 
  @ kunal : arent we supposed to construct the string fr each number
 equal
  to the max length of any number...
  whr r v doing dat chking in dis algo?
 
 
  On Sat, Aug 13, 2011 at 10:25 PM, Kunal Patil kp101...@gmail.com
 wrote:
 
  I dont know whether this is best approach to do step 2 or not. But
 it's
  certainly good.
 
 
  //I will show for two strings s1 and s2
 
  len1 = s1.length();
  len2 = s2.length();
  ind1 = 0; //Index in the first string
  ind2 = 0; //Index in the second string
 
  while( ind1len1 ||  ind2  len2 ) //Match until both strings exhaust
 or
  function returns
  {
  if(ind1 == len1)  // String s1 has exhausted, so start over it
  ind1 = 0;
 
  if(ind2 == len2)  // String s2 has exhausted, so start over it
  ind2 = 0;
 
  for(; ind1  len1  ind2 len2; ind1++,ind2++ )
  // Go on comparing until any of the string exhausts or function
 returns
  {
  if( s1[ind1] == s2[ind2] ) //Same current char in both string so we
 need
  to match more char
  continue;
  else // mismatch
  return (s1[ind1]  s2 [ind2] );
  }
  }
 
  if (ind1==len1  ind2==len2) // same strings
  return true;
 
  //If I missed anything in the code, let me know
 
 
  On Sat, Aug 13, 2011 at 9:29 PM, aditi garg
  aditi.garg.6...@gmail.comwrote:
 
  @kunal: what is the best way to implement step 2?
 
 
  On Sat, Aug 13, 2011 at 7:33 PM, Ashish Sachdeva 
  ashish.asachd...@gmail.com wrote:
 
  @kunal: seems fine.. tried it on some cases...
 
 
  On Sat, Aug 13, 2011 at 5:17 PM, Kunal Patil
  kp101...@gmail.comwrote:
 
  Following approach should work:
 
  1)  Count max number of digit in any integer of input. Let it be
 m.
  (Thanks to dave..)
 
  2) For each int having less than m digits:
Convert it to string of length m where you append
 circularly.
For e.g. if m=5
 53 -- 53535
 100 -- 10010
 34343 -- 34343
 8 -- 8
 
  3) Now lexicographically sort all 

Re: [algogeeks] Re: Storing of data in memory (endianness)

2011-08-14 Thread Dipankar Patro
@ Aditi:
Oops. Missed that out completely. That explains the question now. Thanks for
the heads up.
Any other x86 properties that we need to know? These things are really hard
to come by.

@ Dave:
I think Aditi has pointed out my mistake.

On 14 August 2011 23:47, Dave dave_and_da...@juno.com wrote:

 @Dipankar: You are correct. The answer, like the answer to so many
 questions, is It depends.

 Dave

 On Aug 14, 1:11 pm, Dipankar Patro dip10c...@gmail.com wrote:
  Hi all,
 
  I have come across quite a few questions like
  
  What is the way in which int m = 2 will be stored in memory?
  2 0 0 0 or 0 0 0 2
  
  Doesn't the answer depend upon the machine you are working on? I mean
 both
  are perfectly possible situations if you see.
  First option is little-endian, second one is big-endian.
 
  Which one should I probably go for in case I am not provided a machine
  dependent option?
 
  Reference:http://en.wikipedia.org/wiki/Endianness#Big-endian
  --
 
 ___­
 
  Please do not print this e-mail until urgent requirement. Go Green!!
  Save Papers = Save Trees

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: an array question

2011-08-14 Thread Dipankar Patro
@ Kunal:
oh. zero is making some nice test cases. I will have to reconsider the
solution that I provided.


On 15 August 2011 01:53, Yasir yasir@gmail.com wrote:

 Not Sure! Me too looking for a solution.. :D

 So far,  Kunal's approach (Convert each string to length max_size where
 you append it circularly) seems to be working fine.  :-)

 ..and Chengjie's approach should also work, but the interviewer rejected
 this idea saying, he wants a good logic for this.  :)

  --
 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/-/sRTcLi6r_IYJ.

 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Todays PEP question

2011-08-14 Thread Dipankar Patro
3.

On 15 August 2011 01:07, rajeev bharshetty rajeevr...@gmail.com wrote:

 3 is the answer .

 do being exit controlled loop , x is incremented to 2 and then checked for
 condition which happens to be false here (22)
 So t is incremented only 3 times.


 On Mon, Aug 15, 2011 at 12:44 AM, aditi garg aditi.garg.6...@gmail.comwrote:

 3

 On Mon, Aug 15, 2011 at 12:38 AM, Adi Srikanth adisriika...@gmail.comwrote:

 int main()
 {
int x=0,t=0;

switch(x)
{
case 0: x++;
do {

case 1:t++;
case 2:t++;
case 3:t++;


x++;
} while(x2);




}
printf(%d\n,t);
return 0;

 }


 t will be wat???...3, 6 or 9

 Regards,
 Srikanth.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Aditi Garg
 Undergraduate Student
 Electronics  Communication Divison
 NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
 Sector 3, Dwarka
 New Delhi


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Regards
 Rajeev N B http://www.opensourcemania.co.cc

 *Winners Don't do Different things , they do things Differently*

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Value of base pointer VS Address of base pointer

2011-08-13 Thread Dipankar Patro
[Quote]

arr has the address to the base of an array of three int's.

arr is the address of the first element of that same array.

[/Quote]

^^ Found on web.

check the difference by printing arr+1 and arr+1. The former will skip one
element, but later will skip the whole array.
On 12 August 2011 18:41, monish001 monish.gup...@gmail.com wrote:

 Program:
 int arr[] = {12, 14, 15, 23, 45};
 printf(%u %u\n, arr, arr);

 Question: Why arr == arr ?

 Comments:
 1. arr is a variable that stores the address of location where arr[0]
 resides. Complier shows arr and arr having same value. Shouldn't arr
 be the address where arr resides?

 Thanks
 Monish

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] n*n array

2011-08-13 Thread Dipankar Patro
I think they both refer to the same in case of 2-D array.

helical can be seen as a movement in 3-D where it is spiral in two
dimensions and linear in one left out dimension.



On 13 August 2011 18:54, Kamakshii Aggarwal kamakshi...@gmail.com wrote:


 is printing a n*n array,spirally is same as printing it helically??
 or is there any difference between the two??
 --
 Regards,
 Kamakshi
 kamakshi...@gmail.com

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] what is mean by %2.3d in scanf

2011-08-13 Thread Dipankar Patro
Nice one Gaurav Menghani

On 13 August 2011 18:39, shady sinv...@gmail.com wrote:

 wonderful :)


 On Sat, Aug 13, 2011 at 6:30 PM, Rahul raikra...@gmail.com wrote:

 lol++
 Rahul


 On Sat, Aug 13, 2011 at 6:14 PM, SANDEEP CHUGH 
 sandeep.aa...@gmail.comwrote:

 lol


 On Sat, Aug 13, 2011 at 6:12 PM, Gaurav Menghani 
 gaurav.mengh...@gmail.com wrote:

 http://lmgtfy.com/?q=scanf+float+precision+format

 On Sat, Aug 13, 2011 at 5:42 PM, SuDhir mIsHra
 sudhir08.mis...@gmail.com wrote:
  e g: scanf(%2.4d,a);
 
  --
  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 group at
  http://groups.google.com/group/algogeeks?hl=en.
 



 --
 Gaurav Menghani

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] TRee question...

2011-08-12 Thread Dipankar Patro
What Deoki answered in valid for non-leaf node.

Consider this tree:
3
   / \
  4  5
 /  \
6   7

According to Deoki's answer, 7's in-order successor is 4, which not correct.
the answer should be 3.

Here is the proper method (for leaf node only), Following Deoki's answer for
non-leaf:
- keep a stack in which you keep adding the left child (if there is any) at
the node.
- in case you don't have a left child, pop the last parent. and push the
right child. Repeat above process.
- when you hit the node you are searching for and is a leaf node, then just
pop the last element from stack. That will the inorder successor.

e.g in above tree, in-order successor of 7.
from start stack will be |3|

- | 4 |  push(3-left) = 4
| 3 |

- | 6 |  push(4-left) = 6
| 4 |
| 3 |

- no left of 6, and pop 6, and check right.
- no right of 6, pop next element, i.e. 4
- push (4-right) | 7 |
  | 3 |
- Found 7 and '7' is a leaf node, thus in-order successor is pop (next
element) =  3

Hope that's clear.

On 12 August 2011 12:34, Deoki Nandan deok...@gmail.com wrote:

 if given node has right subtree then its inorder successor will be left
 most child of  given node's right child. if given node does not have right
 child the its successor will be its parent


 On Fri, Aug 12, 2011 at 11:28 AM, Priyanka Goel 
 priyankatheinvinci...@gmail.com wrote:

 How to find the in-order successor of a given node in a binary search tree
 where each node has a link to its parent. pl explain logic to solve it..
 ( Pl dnt give solution of doing in order traversal and storing it in
 array.)


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 **With Regards
 Deoki Nandan Vishwakarma

 *
 *

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] cisco

2011-08-12 Thread Dipankar Patro
I think CISCO sacked the employees in 'Flip' Deptt. (as it appears on Web).
Flip was something out of networking domain, and it failed. So CISCO is now
refocusing on their networking infrastructure and networking products that
it is famous for.

Lets hope hiring will continue the same as last year.

On 12 August 2011 23:37, Naveen Kumar naveenkumarve...@gmail.com wrote:

 @ aditya,

 Cisco is not in losses they make better profit then expected by the market
 this quarter  share rises by 16% after results.
 Moreover cisco sacked only 2200 employees and some 2-3k took VRS.



 On Fri, Aug 12, 2011 at 9:58 PM, Nanda Kishore nanda.kishore...@gmail.com
  wrote:



 On Fri, Aug 12, 2011 at 8:16 PM, siddharth srivastava 
 akssps...@gmail.com wrote:



 On 12 August 2011 19:20, aditya kumar aditya.kumar130...@gmail.comwrote:

 is CISCO cuming fr recruitment ?? they are in huge loss and they have
 sacked around 1 employees .


 well, this is what Goldman Sachs also did, but they are also doing
 recruitment.
  No company virtually ever stops recruitment. Sacking is done to fill
 space with less expensive resources (though clearly a bad indicator)


 well,cisco off campus for s/w engg had written test,followed by G.D and
 two interviews

 written test consists of 50 questions,sections coverin those questions
 were
  1.general aps,
 2.Networking
 ,3.sqa,
 4.c programmin


 On Fri, Aug 12, 2011 at 7:18 PM, sukran dhawan 
 sukrandha...@gmail.comwrote:

 can anybody tell abt the interview process in cisco ?

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Regards
 Siddharth Srivastava



  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Cheers
 Naveen Kumar

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: microsoft paper that i wrote today..

2011-08-12 Thread Dipankar Patro
@ Neeraj:
1+2+'4' will be very simple to calculate: 3+48+4 = 55

But 1+2+4 is a good question.

On 13 August 2011 06:10, Neeraj Gupta neeraj.gupta...@gmail.com wrote:

 Ques 5 might be value of 1+2+'4'
 https://ideone.com/8b91t
 Obviously if we use  , then it represents string and we can't define +
 operation with other operand being an integer.

 On Fri, Aug 12, 2011 at 11:06 PM, Anil Arya anilarya...@gmail.com wrote:

 Q.5 . [warning] initialization  makes integer from pointer without
 a cast.


 On Fri, Aug 12, 2011 at 10:56 PM, sagar pareek sagarpar...@gmail.comwrote:

 well if we write the code simply as
 #includestdio.h
  int main()
  {
  1+2+4
  }

 it gives compilation error

 if like this
 #includestdio.h
  int main()
  {
  1+2+4;
  }

 it will give warning:- no effect of code



 if like this
 #includestdio.h
  int main()
  {
 int a= 1+2+4;
 printf(%d,a);
  }
 it will give error
 cannot convert char* to int



 On Fri, Aug 12, 2011 at 10:44 PM, aditi garg 
 aditi.garg.6...@gmail.comwrote:

 wats the ans to the 5th ques??


 On Fri, Aug 12, 2011 at 8:54 PM, gaurav kumar mailmea...@gmail.comwrote:

 thanks a lot mate .


 On Aug 11, 4:51 pm, sindhu sindhu...@gmail.com wrote:
  1. write a method to find the smallest angle between two hands when
  the time is given as input???
  2. given a number between 1 to 1000 convert it to words..example
  235..it should print as two hundred thirty five..
  3. write test cases for elevator in a multistory building..
  4. a chessboard of size 64 blocks is given..a knight can move two n
  half moves at a time..how many steps will it take to cover all the 64
  blocks...and change the algorithm if the knight moves three and a
 half
  moves.
  5. what will be the result if you execute the following code segment:
  1+2+4

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Aditi Garg
 Undergraduate Student
 Electronics  Communication Divison
 NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
 Sector 3, Dwarka
 New Delhi


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 **Regards
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT ALLAHABAD

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Anil Kumar Arya
 computer science  engineering
 M.N.N.I.T Allahabad.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Quantz

2011-08-11 Thread Dipankar Patro
@ All:
So this is a trick that we eventually have to know :P

Where to find these tricks like these on web. Please share the links.

On 12 August 2011 02:12, aditi garg aditi.garg.6...@gmail.com wrote:

 @aseem: using powers of 3 we have to use both sides of the balance...bt if
 we have the constraint dat we can use only one side thn powers of 2...i hope
 its clear


 On Fri, Aug 12, 2011 at 2:02 AM, aseem garg ase.as...@gmail.com wrote:

 @Aditi: Why use powers of 2 when we can use powers of three in case of
 weights??
 Aseem



 On Fri, Aug 12, 2011 at 1:53 AM, aditi garg aditi.garg.6...@gmail.comwrote:

 @sagar  : :):)


 On Fri, Aug 12, 2011 at 1:51 AM, sagar pareek sagarpar...@gmail.comwrote:

 thanks aditi for the explanation


 On Fri, Aug 12, 2011 at 1:28 AM, aditi garg 
 aditi.garg.6...@gmail.comwrote:

 well it is like i sed fr eg dey ask u the min num of weights required
 to count all weights from 1-127
 thn the ans wud be 1 2 4 8 16 32 64 ie. 7 weights...
 similar concept fr the powers of 3 as well


 On Fri, Aug 12, 2011 at 1:15 AM, Swati Sarraf swati1...@gmail.comwrote:

 @aditi,
 Could you explain it more clearly ..



 On Thu, Aug 11, 2011 at 3:36 PM, aditi garg 
 aditi.garg.6...@gmail.com wrote:

 well dis is sm maths trick whch we shud knw...
 dis is applicable even wid multiples of 2
 fr eg if u have 1 2 4 8 u can measure any weight from 1 - 15
 if u have like 1 2 4 8 16 thn we can measure any weight from 1 -31...

 simi;larly fr 3 as well


 On Fri, Aug 12, 2011 at 12:44 AM, Swati Sarraf 
 swati1...@gmail.comwrote:

 @sagar, Could you explain how you find these five weights . I  mean
 is it a guess or any mathematical explaination it there  ??





 On Thu, Aug 11, 2011 at 3:12 PM, sagar pareek 
 sagarpar...@gmail.com wrote:

 81-27+3 =57


 On Fri, Aug 12, 2011 at 12:39 AM, Tarun Arya 
 tarun@gmail.comwrote:

 sagar...cud u pls explain d weight distribution for 57...
 Tarun

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 **Regards
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT ALLAHABAD

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 With Regards,
 Swati Sarraf

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Aditi Garg
 Undergraduate Student
 Electronics  Communication Divison
 NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
 Sector 3, Dwarka
 New Delhi


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 With Regards,
 Swati Sarraf

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Aditi Garg
 Undergraduate Student
 Electronics  Communication Divison
 NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
 Sector 3, Dwarka
 New Delhi


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 **Regards
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT ALLAHABAD

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Aditi Garg
 Undergraduate Student
 Electronics  Communication Divison
 NETAJI SUBHAS 

Re: [algogeeks] O/P

2011-08-11 Thread Dipankar Patro
The question is full of errors.
Provide the link, if you have copied it from somewhere.

On 11 August 2011 23:53, Mani Bharathi manibharat...@gmail.com wrote:

 What will be the output of the following program
 #include
 int main()
 {
 int m=10,p;
 p=incre(incre (incre (++) incre) incre)
 Printf(%d, *P);
 return 0;
 }
 incre (int m)
 {
 m+=2;
 return(m-2);
 }

 how?

 --
 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/-/58_0-nbLUacJ.
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Pointer Question

2011-08-11 Thread Dipankar Patro
b.

On 11 August 2011 23:20, arvind kumar arvindk...@gmail.com wrote:

 b.


 On Thu, Aug 11, 2011 at 11:18 PM, Mani Bharathi 
 manibharat...@gmail.comwrote:

 int(* fun()) [row][ Col];
 What should be the statement the for the above declarations
 a.fun() points to a two dimensional array
 b.pointer *fun() points to a two dimensional array
 c.pointer *fun() points to 1-dimensional array

 --
 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/-/3xkodl3aLvcJ.
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] MS question

2011-08-09 Thread Dipankar Patro
Here is my code:
http://ideone.com/deosU

Same as that of Sagar's :D
time O(n) and space O(1)


On 9 August 2011 20:25, siddharam suresh siddharam@gmail.com wrote:

 saurabh
 test my program
 please tell me if any bug is there
 Thank you,
 Siddharam



 On Tue, Aug 9, 2011 at 8:18 PM, saurabh singh saurab...@gmail.com wrote:

 The code failed for all test cases I tried.


 On Tue, Aug 9, 2011 at 8:15 PM, ankit sambyal ankitsamb...@gmail.comwrote:

 ya got it now. I misunderstood the question

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT ALLAHABAD


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] output?

2011-08-09 Thread Dipankar Patro
o/p:
It doesn't matter

Reason:
printf() returns the number of characters printed to screen.
since printf() will return 0, hence the *else* is selected.

On 9 August 2011 22:25, siddharth srivastava akssps...@gmail.com wrote:



 On 9 August 2011 22:20, tech rascal techrascal...@gmail.com wrote:

 #includestdio.h
 int main()
 {
 char ch;
 if((ch=printf()))
 printf(it matters);
 else
 printf(it doesn't matter);
 return 0;
 }


 It doesn't matter




 what will b the 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 from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Regards
 Siddharth Srivastava



  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] mcq

2011-08-08 Thread Dipankar Patro
C

On 8 August 2011 17:03, ankit sambyal ankitsamb...@gmail.com wrote:

 C

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] mcq

2011-08-08 Thread Dipankar Patro
Link-time it is :)

On 8 August 2011 19:03, DeVaNsH gUpTa devanshgupta...@gmail.com wrote:

 link time

 --
 Thanks and Regards
 *Devansh Gupta*
 *B.Tech Third Year*
 *MNNIT, Allahabad*

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] o/p

2011-08-08 Thread Dipankar Patro
relational operators give 0/1 output;
(ab) - will be either 0 or 1.
similarly (a==b) will either be 0 or 1

On 8 August 2011 18:39, Anil Arya anilarya...@gmail.com wrote:

 in expression (ab)?a:b---(ab) returns 1 if true  and  0 if
 (false) .



 On Mon, Aug 8, 2011 at 6:08 PM, dilip makwana dilipmakwa...@gmail.comwrote:

 Since test condition will always evaluate to non-zero value (which is
 considered true in c/c++) hence always first option get selected 


 On 8 August 2011 17:44, Shachindra A C sachindr...@gmail.com wrote:

 oops...I'm sorry.. the statement would evaluate to 3 + *0* ? 2 : 3 == *
 3* ? 2 : 3 == m = 2.


 On Mon, Aug 8, 2011 at 5:43 PM, Shachindra A C sachindr...@gmail.comwrote:

 @raj,
  the preprocessed file would contain m=3+(23)?2:3 AFAIK.

  So, the statement would evaluate to 3 + 1 ? 2 : 3 == 4 ? 2 : 3
 == m = 2.

  Likewise for n.


  On Mon, Aug 8, 2011 at 5:21 PM, raj kumar megamonste...@gmail.comwrote:

 3+23?2:3
 so 53 hence 2 is returned bcoz of higher precedence of + over ?
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Regards,
 Shachindra A C




 --
 Regards,
 Shachindra A C

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 *Dilip Makwana*
 VJTI
 BTech Computers Engineering
 2009-2013

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Anil Kumar Arya
 B.Tech  III year
 computer science  engineering
 M.N.N.I.T Allahabad.



  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Amazon Question

2011-08-08 Thread Dipankar Patro
1. O(n)

2. (b)


On 8 August 2011 19:24, ankit sambyal ankitsamb...@gmail.com wrote:

 Plz give the answers ...

 1. In a binary max heap containing n numbers, the smallest element can be
 found in time ??


 2. The number of total nodes in a complete balanced binary tree with n
 levels is,
   a)3^n + 1
   b)2^(n+1) - 1
   c) 2^n + 1
   d) none of above

 3. In a country where everyone wants a boy, each family continues having
 babies till they have a boy. After some time, what is the proportion of boys
 to girls in the country? (Assuming probability of having a boy or a girl is
 the same)
   a) 1:2
   b) 2:1
   c)1:1
   d)1:4


 4. A parallel program consists of 8 tasks – T1 through T8. Each task
 requires one time step to be executed on a single processor. Let X - Y
 denote the fact that task X must be executed before task Y is executed.
 Suppose only the tasks X, Y are to be executed. On any multiprocessor
 machine it would require at least 2 time steps since in the first step X
 could be executed, and Y could be executed in the next time step (since it
 requires X to complete first). Now, suppose the following dependencies exist
 between the tasks T1 – T8:

 T1 - T2

 T2 - T3

 T3 - T6

 T2 - T4

 T4 - T7

 T2 - T5

 T5 - T8

 What is the minimum number of time steps required to execute these 8 tasks
 on a 2 processor machine and a 4 processor machine?


 a)4  2

 b)5  2

 c)5  4

 d)6  2

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] constness in c++

2011-08-08 Thread Dipankar Patro
does the answer still remain same if you do the following:

const int d=1;
const int *const ptr = d;

In your version I don't see ptr pointing to a const int. It just points to
an integer, which I think can be changed.
See if the code I suggested still does the same as your version...

On 8 August 2011 19:53, mohit verma mohit89m...@gmail.com wrote:

 In c++

 int d=1;
 const int *const ptr = d;   means ptr is const ptr to const object .So
 neither ptr nor d can be changed. But

 when i do -
  d=5;
 coutd *ptr;
 the values are changed. Why is it so?
 Moreover doing something like : *ptr=5 gives error. Can someone explain
 internals here?
 --
 
 *MOHIT VERMA*

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C easy doubt

2011-08-08 Thread Dipankar Patro
Well, a here is the address where the address of the whole 2D array is
stored.

with a+1 you move over the whole array in one go. So you land up with an
address after the 2D array's last element.

On 8 August 2011 19:59, Brijesh Upadhyay brijeshupadhyay...@gmail.comwrote:

 int main()
 {
int a[3][4]={1,2,3,4,5,6,7,8,9,10,11,12};
printf(%u %u %u,a, a+1,a+1);
getch();
 }

 how a+1 is valid..?? please explain

 --
 Regards,
 Brijesh Upadhyay
 CSE , final year.
 Thapar University

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Probability Puzzle

2011-08-08 Thread Dipankar Patro
3/5.

As the question doesn't ask anything about the sequence.
Had the question been  Find the probability that all 6 are H  then it
would have been 17/80.

On 9 August 2011 04:07, Dave dave_and_da...@juno.com wrote:

 @Vinay: What if you tossed 100 consecutive heads? Would that be enough
 to convince you that you had the double-headed coin? If so, then
 doesn't tossing 5 consecutive heads give you at least an inkling that
 you might have it? Wouldn't you then think that there would be a
 higher probability of getting a head on the sixth toss than there was
 on the first toss (3/5)? Don's conditional probability answer 17/18 is
 the right answer.

 Dave

 On Aug 8, 5:04 pm, vinay aggarwal vinayiiit2...@gmail.com wrote:
  answer should be 3/5
  think like that tossing 5 times will not help you predict the outcome
  of sixth toss. Therefore that information is meaningless.

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] shift left nd right

2011-08-08 Thread Dipankar Patro
try initializing b to 2;
you will get answer 2*2*2;

On 8 August 2011 22:41, jagrati verma jagrativermamn...@gmail.com wrote:

 coz u r trying to print float of any integer value so by the memory
 representation of float it'll giv 0.0









 On Mon, Aug 8, 2011 at 10:30 PM, Shashank Jain shashan...@gmail.com
 wrote:
  oh yeah, thx karthik.
  Shashank Jain
  IIIrd year
  Computer Engineering
  Delhi College of Engineering
 
 
  On Mon, Aug 8, 2011 at 10:29 PM, Shashank Jain shashan...@gmail.com
 wrote:
 
int b;
b=22;
printf(%f, b);
  output: 0.00
  plz tell y is dat so?
  Shashank Jain
  IIIrd year
  Computer Engineering
  Delhi College of Engineering
 
 
  On Mon, Aug 8, 2011 at 10:24 PM, Gaurav Menghani
  gaurav.mengh...@gmail.com wrote:
 
  http://lmgtfy.com/?q=Bitwise+left+and+right+shift+operators
 
  On Mon, Aug 8, 2011 at 10:20 PM, Shashank Jain shashan...@gmail.com
  wrote:
   thx dipankar, its a gud 1!
   Bt tell me wat does '' and '' operators do?
   eg: 202 = 1
   can u explain nd wat is this operator called?
   Shashank Jain
   IIIrd year
   Computer Engineering
   Delhi College of Engineering
  
  
   On Mon, Aug 8, 2011 at 12:54 AM, Dipankar Patro dip10c...@gmail.com
 
   wrote:
  
   This link I think is a good one:
   http://msdn.microsoft.com/en-us/library/336xbhcz.aspx
  
   On 8 August 2011 00:37, Shashank Jain shashan...@gmail.com wrote:
  
   plz sum1 explain me shift left nd shift right operators?
   Shashank Jain
   IIIrd year
   Computer Engineering
   Delhi College of Engineering
  
   --
   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 group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
  
   --
  
  
  
 ___
  
   Please do not print this e-mail until urgent requirement. Go Green!!
   Save Papers = Save Trees
  
   --
   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 group at
   http://groups.google.com/group/algogeeks?hl=en.
  
   --
   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 group at
   http://groups.google.com/group/algogeeks?hl=en.
  
 
 
 
  --
  Gaurav Menghani
 
  --
  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 group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
 
  --
  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 group at
  http://groups.google.com/group/algogeeks?hl=en.
 

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Doubts

2011-08-08 Thread Dipankar Patro
In hierarchy M1-M2
0.97 Hit = 2x0.97 = 1.94 ns
M2 is not accessed in case of hit
0.03 Miss = 0.03x100 = 3ns (miss rate x miss penalty)

Total = 4.94ns

+1 to Aditya

so the average access time is = hit + miss = 1.94 + 100.06

On 9 August 2011 08:11, Raman raman.u...@gmail.com wrote:

 For ques 3, remember that context switch is useful in 3 situations :
  1. Multitasking (when CPU is to be switched among processes(usually
 preemptive))
  2. Interrupt Handling (different from interrupt servicing) - In this, CPU
 requests for a service (eg read from a disk) but doesnt wait for it to
 complete. On the other hand, it continues to perform sm othr task after
 sendin the req. With the help of interrupt handlers, later the CPU is
 interrupted when the task is over. Thus it req context switch
  3. Switch from user and kernel modes (though this varies with OS)



 --
 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/-/Eu2sQW7VkXQJ.

 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Doubts

2011-08-08 Thread Dipankar Patro
Sorry for the last line.. Made some error before.

On 9 August 2011 08:51, Dipankar Patro dip10c...@gmail.com wrote:

 In hierarchy M1-M2
 0.97 Hit = 2x0.97 = 1.94 ns
 M2 is not accessed in case of hit
 0.03 Miss = 0.03x100 = 3ns (miss rate x miss penalty)

 Total = 4.94ns

 +1 to Aditya

 so the average access time is = hit + miss = 1.94 + 100.06


 On 9 August 2011 08:11, Raman raman.u...@gmail.com wrote:

 For ques 3, remember that context switch is useful in 3 situations :
  1. Multitasking (when CPU is to be switched among processes(usually
 preemptive))
  2. Interrupt Handling (different from interrupt servicing) - In this, CPU
 requests for a service (eg read from a disk) but doesnt wait for it to
 complete. On the other hand, it continues to perform sm othr task after
 sendin the req. With the help of interrupt handlers, later the CPU is
 interrupted when the task is over. Thus it req context switch
  3. Switch from user and kernel modes (though this varies with OS)



 --
 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/-/Eu2sQW7VkXQJ.

 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --

 ___

 Please do not print this e-mail until urgent requirement. Go Green!!
 Save Papers = Save Trees




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] mcq

2011-08-08 Thread Dipankar Patro
ans : n + 2nk - k^2 - k


On 9 August 2011 08:43, Raman raman.u...@gmail.com wrote:

 Yes, the answer is n + 2nk - k^2 -k

 --
 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/-/-gfsoB87QO0J.

 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] what is complexity of func(p)

2011-08-08 Thread Dipankar Patro
This is a simple one:

get_power has a complexity of O(logb), since it is dividing b by 2 each time
it is called.
and the get_power func is called for p times.

the overall complexity is O(plog5) , p times O(log5)

On 9 August 2011 09:07, rohit rajuljain...@gmail.com wrote:

  int get_power(int a, int b)
 {
 if(!b)
 return 1;
 if(b%2)
  return a * get_power(a, b/2);
  return get_power(a, b/2);
  }

 int func(int p)
 { int sum = 0;
  for(int i = 1; i = p; ++i)
 {
 sum += get_power(i, 5);
 }
 return sum;

 }

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] inorder

2011-08-06 Thread Dipankar Patro
how about using the threaded binary tree?

On 6 August 2011 20:25, sagar pareek sagarpar...@gmail.com wrote:

 Sorry for typo mistake in prev solution


 2 solutions

 1.

 node* arr[100];
 int j=0;

 inorder(node * ptr)
 {
   if(ptr)
  {
  inorder(ptr-left);
 arr[j++]=ptr;
 inorder(ptr-right);
  }
 }

 u will have all the addresses in inorder fashion now its easy to watch
 any successor ...:P  :P

 2. best solution
 //considering that there is 1 more field in the structure


 typedef struct bin
 {
   struct bin* left;
   int data;
   struct bin* right;
   struct bin* succ;
  } node;



 inorder(node* ptr)
 {
   if(ptr)
   {
 static int p=0;
  inorder(ptr-left)
   if(p)  ptr-succ=prev; //here we are skipping 1st left most leaf
 because it has no successor
 p=1;
 prev=ptr;
 inorder(ptr-right);
  }
 }


 simplest and short code  :)   :):)

 anyone have  better code???

 On Sat, Aug 6, 2011 at 8:24 PM, sagar pareek sagarpar...@gmail.comwrote:

 2 solutions

 1.

 node* arr[100];
 int j=0;

 inorder(node * ptr)
 {
   if(ptr)
  {
  inorder(ptr-left);
 arr[j++]=ptr;
 inorder(ptr-right);
  }
 }

 u will have all the addresses in inorder fashion now its easy to watch
 any successor ...:P  :P

 2. best solution
 //considering that there is 1 more field in the structure


 typedef struct bin
 {
   struct bin* left;
   int data;
   struct bin* right;
   struct bin* succ;
  }


 inorder
 {
   if(ptr)
   {
 static int p=0;
  inorder(ptr-left)
   if(p)  ptr-succ=prev; //here we are skipping 1st left most leaf
 because it has no successor
 p=1;
 prev=ptr;
 inorder(ptr-right);
  }
 }


 simplest and short code  :)   :):)

 anyone have  better code???





 On Sat, Aug 6, 2011 at 6:52 PM, UTKARSH SRIVASTAV 
 usrivastav...@gmail.com wrote:

 sorry two cases only


 On Sat, Aug 6, 2011 at 6:21 AM, UTKARSH SRIVASTAV 
 usrivastav...@gmail.com wrote:

 pseudo code

three cases are possible
   1.node has left and right child
  then inorder succesor will be leftmost child of right child
 2.   node has left child and no right child or no left and right chid
  if node is left child of it's parent then inorder succesor is it's
 parent only
  if node is right child of it's parent then keep on moving upwards
 until you find a parent which is left child of it's parent
  then it will be the inorder succesorif you reach node then no
 inorder succesor

 --
 *UTKARSH SRIVASTAV
 CSE-3
 B-Tech 3rd Year
 @MNNIT ALLAHABAD*




 --
 *UTKARSH SRIVASTAV
 CSE-3
 B-Tech 3rd Year
 @MNNIT ALLAHABAD*

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 **Regards
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT ALLAHABAD




 --
 **Regards
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT ALLAHABAD

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Printf

2011-08-05 Thread Dipankar Patro
+1 to logical address.
User programs are never given access to physical address.

On 5 August 2011 17:00, muthu raj muthura...@gmail.com wrote:

 physical adress is never acessible.Those who claim physical adress pls
 support ur answers.
 *Muthuraj R
 IV th Year , ISE
 PESIT , Bangalore*




 On Fri, Aug 5, 2011 at 4:57 PM, Kamakshii Aggarwal 
 kamakshi...@gmail.comwrote:

 logical address


 On Fri, Aug 5, 2011 at 2:20 PM, Amol Sharma amolsharm...@gmail.comwrote:

 physical address i think
 --


 Amol Sharma
 Third Year Student
 Computer Science and Engineering
 MNNIT Allahabad




 On Fri, Aug 5, 2011 at 1:01 AM, amit karmakar amit.codenam...@gmail.com
  wrote:

 Some discussions here,
 http://ubuntuforums.org/showthread.php?t=316081
 and some here,
 http://groups.google.com/group/comp.lang.c/msg/21250e8fe083e4f8

 On Aug 5, 12:51 pm, Anurag Narain anuragnar...@gmail.com wrote:
  i think logical address...physical address is never accessible to user
  program
 
  @amit-can u explain why??

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Regards,
 Kamakshi
 kamakshi...@gmail.com

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Question

2011-08-05 Thread Dipankar Patro
try doing this way and tell if the program is working properly now:
for (i=0; i3; i++)
{
 scanf(%[^\n], e[i].name);
 scanf(%f, e[i].sal);
}

There is always some problem in string input using %s, don't really know why
though deeply.

On 5 August 2011 17:48, Vijay Khandar vijaykhand...@gmail.com wrote:

 But program is not working properly...


 On Fri, Aug 5, 2011 at 5:44 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote:

 Couldn't find any error.

 On Fri, Aug 5, 2011 at 5:38 PM, Vijay Khandar vijaykhand...@gmail.comwrote:

 What errors are you likely to get when you run the following program?

 #includestdio.h
 #includeconio.h
 #includestring.h
 void main()
 {
 clrscr();
 struct emp
 {
 char name[20];
 float sal;
 };
 struct emp e[10];
 int i;
 for(i=0;i=3;i++)
 scanf(%s %f,e[i].name,e[i].sal);
 getch();
 }

 Plz Explain anyone.

 Vijay..

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Nikhil Gupta
 Senior Co-ordinator, Publicity
 CSI, NSIT Students' Branch
 NSIT, New Delhi, India

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks]

2011-08-05 Thread Dipankar Patro
Try a dry run on the following linked list

1-2-3-4-5-6-Null

head is a global variable;

The recursion will take place till 6 and assign head address of 6;

then it will first change 5-6-(back to 5) [root-next-next = root]
when it will be back to 4, change 4-5-(back to 4) . at this stage the
linked list is something like this: 1-2-3-4=5-6;
[4=5 == 4-5 and 5-4]
.
.
this will continue till 1, 1-2-(back to 1)
But there is this glinch, 1 should point to NULL now, which I think is not
happening.

There is a return(root) in the final encounter.
use that like
p=reverse_recursive(head);
p-next= NULL;

I hope you get my point.

On 5 August 2011 23:33, Rajeshwar Patra rajeshwarpa...@gmail.com wrote:

 mynode* reverse_recurse(mynode *root)

 {

 if(root-next!=(mynode *)0)

 {

 reverse_recurse(root-next);

 root-next-next=root;

 return(root);

 }

 else

 {

 head=root;

 }

 }
 how does it reverses the singly linked list

 --
 *Rajeshwar Patra,*
 *MCA final year,*
 *Nit Durgapur*

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] pointer size

2011-08-04 Thread Dipankar Patro
there absolutely nothing wrong in your interpretation.
here is a link that might help : http://www.unix.org/whitepapers/64bit.html


On 4 August 2011 11:18, Shashank Jain shashan...@gmail.com wrote:

 see dipankar, i hv 64 bit OS nd processor bt i dont know abt the compiler.
 nd yeah size of int is 4 bytes. so tell me where im interpreting wrong?

 Shashank Jain
 3rd year, Computer Engg.
 Delhi College of Engineering



 On Thu, Aug 4, 2011 at 11:16 AM, Dipankar Patro dip10c...@gmail.comwrote:

 This has been a hot topic of discussion for a long time. But I found there
 are two things to look into it:

 1. a 64 bit OS is one, which has 64 bit address handling capacity. and a
 64bit processor is one which can perform operations on 64 bit data. A
 general concept that actually gets overlooked by many. Even I was confused
 with differences of 64 bit OS and Processors a while back.

 2. if a compiler by it's own doesn't support 64 bit, it might be the case
 that even if you run on a 64 bit OS, size of int will be 4 bytes (32 bit).

 I think the best way to check out is to make a code on 64 bit compiler. If
 somebody has tried it please share the results.

 On 4 August 2011 10:38, Tushar Bindal tushicom...@gmail.com wrote:

 never assume that he compiler is same as the OS you run. it may be that
 you are running a 32-bit compiler

 I think pointers have size 4bytes on 8 byte compiler also - not sure.
 someone please correct me.


 On Thu, Aug 4, 2011 at 10:26 AM, Shashank Jain shashan...@gmail.comwrote:

 the size of a pointer is showing 4 bytes in my 64-bit OS, which should
 have been 8 bytes. Correct me where i am wrong?

 Shashank Jain
 3rd year, Computer Engg.
 Delhi College of Engineering

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Tushar Bindal
 Computer Engineering
 Delhi College of Engineering
 Mob: +919818442705
 E-Mail : tushicom...@gmail.com
 Website: www.jugadengg.com


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --

 ___

 Please do not print this e-mail until urgent requirement. Go Green!!
 Save Papers = Save Trees

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] pointer size

2011-08-04 Thread Dipankar Patro
For simple answer: yes.
All must be compatible with 64 bit data/address handling.

On 4 August 2011 12:02, Shashank Jain shashan...@gmail.com wrote:

 man this is too big of a page to go thru...
 so tell as both (OS nd pro) are 64 bit why is ptr size 4 bytes?
 nd also does it depend on all 3 : OS, processor, compiler ?

 Shashank Jain
 IIIrd year
 Computer Engineering
 Delhi College of Engineering



 On Thu, Aug 4, 2011 at 11:57 AM, Dipankar Patro dip10c...@gmail.comwrote:

 there absolutely nothing wrong in your interpretation.
 here is a link that might help :
 http://www.unix.org/whitepapers/64bit.html


 On 4 August 2011 11:18, Shashank Jain shashan...@gmail.com wrote:

 see dipankar, i hv 64 bit OS nd processor bt i dont know abt the
 compiler. nd yeah size of int is 4 bytes. so tell me where im interpreting
 wrong?

 Shashank Jain
 3rd year, Computer Engg.
 Delhi College of Engineering



 On Thu, Aug 4, 2011 at 11:16 AM, Dipankar Patro dip10c...@gmail.comwrote:

 This has been a hot topic of discussion for a long time. But I found
 there are two things to look into it:

 1. a 64 bit OS is one, which has 64 bit address handling capacity. and a
 64bit processor is one which can perform operations on 64 bit data. A
 general concept that actually gets overlooked by many. Even I was confused
 with differences of 64 bit OS and Processors a while back.

 2. if a compiler by it's own doesn't support 64 bit, it might be the
 case that even if you run on a 64 bit OS, size of int will be 4 bytes (32
 bit).

 I think the best way to check out is to make a code on 64 bit compiler.
 If somebody has tried it please share the results.

 On 4 August 2011 10:38, Tushar Bindal tushicom...@gmail.com wrote:

 never assume that he compiler is same as the OS you run. it may be that
 you are running a 32-bit compiler

 I think pointers have size 4bytes on 8 byte compiler also - not sure.
 someone please correct me.


 On Thu, Aug 4, 2011 at 10:26 AM, Shashank Jain 
 shashan...@gmail.comwrote:

 the size of a pointer is showing 4 bytes in my 64-bit OS, which should
 have been 8 bytes. Correct me where i am wrong?

 Shashank Jain
 3rd year, Computer Engg.
 Delhi College of Engineering

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Tushar Bindal
 Computer Engineering
 Delhi College of Engineering
 Mob: +919818442705
 E-Mail : tushicom...@gmail.com
 Website: www.jugadengg.com


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --

 ___

 Please do not print this e-mail until urgent requirement. Go Green!!
 Save Papers = Save Trees

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --

 ___

 Please do not print this e-mail until urgent requirement. Go Green!!
 Save Papers = Save Trees

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please

Re: [algogeeks] pointer size

2011-08-04 Thread Dipankar Patro
Yeah.

On 4 August 2011 12:14, N1teesh nitee...@gmail.com wrote:

 So if either of the OS , Compiler , Processor are 32 Bit , then the size is
 bound to be 4 bytes?

 --
 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/-/vsUrO_BCMXAJ.

 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] pointer size

2011-08-04 Thread Dipankar Patro
Also, you must remember that 64 OS can never run 32 bit Processors, since it
will require a 64 bit CPU to produce a 64bit address format

On 4 August 2011 19:19, Dipankar Patro dip10c...@gmail.com wrote:

 Yeah.

 On 4 August 2011 12:14, N1teesh nitee...@gmail.com wrote:

 So if either of the OS , Compiler , Processor are 32 Bit , then the size
 is bound to be 4 bytes?

 --
 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/-/vsUrO_BCMXAJ.

 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --

 ___

 Please do not print this e-mail until urgent requirement. Go Green!!
 Save Papers = Save Trees




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Amazon Aptitude questions

2011-08-04 Thread Dipankar Patro
Kashish,
I think it won't work.

The correct is:
ls -R | grep .java

On 4 August 2011 20:17, kashish jain kashish.jain.n...@gmail.com wrote:

 answer to shell command is
 grep -r *.java

 i wanted to ask , am i right ?


 On Thu, Aug 4, 2011 at 2:16 PM, Shashank Jain shashan...@gmail.comwrote:

 whats the priority of ^ symbol?

 Shashank Jain
 IIIrd year
 Computer Engineering
 Delhi College of Engineering



 On Thu, Aug 4, 2011 at 1:52 PM, Arun Vishwanathan aaron.nar...@gmail.com
  wrote:

 there are 12 black and 12 white socks
 p(bb)+p(ww) is what we want...

 p(bb)=12/24*11/23
 p(ww)=12/24*11/23

 so it is just 2*12/24*11/23=11/23

 On Wed, Aug 3, 2011 at 9:08 PM, Prakash D cegprak...@gmail.com wrote:

 no.. it's really easy to find it out

 there are 12 black and 12 white pieces.

 let black =1  and white =0

 the possible results are 11, 00, 10, 01


 number of ways of 11 solutions=  12 * 11 =  132
 number of ways of 00 solutions = 12 * 11 = 132
 number of ways of 10 solutions = 12 * 12 = 144
 number of ways of 01 solutions = 12 * 12 = 144


 we need the prob of 10 + prob 01 ==  (144+144)/(132+ 132 + 144 + 144)

 =288/552 =  36/69 = 12/23

 I think 11/23 is wrong




 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] OS question

2011-08-04 Thread Dipankar Patro
I think the answer would be the thread calling execute will have to wait for
the executed command to exit and then it will proceed.
As for other threads, they shouldn't be affected.

Please do correct me if it is wrong.

On 4 August 2011 20:27, ankit sambyal ankitsamb...@gmail.com wrote:

 What happens when a thread calls exec ?? What happens to the other threads
 of the same process ??

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Why this is giving run time error ?

2011-08-04 Thread Dipankar Patro
You are welcome Tushar.
My suggestion is always to print the value of iter (i in this case) in a
loop if you think there is something wrong. Helps 99% of times.

On 4 August 2011 20:13, Tushar Kanta Rath tusharkanta.r...@gmail.comwrote:

 @Dipankar : thanks.i think,this is the right logic

 On Thu, Aug 4, 2011 at 11:10 AM, Dipankar Patro dip10c...@gmail.comwrote:

 Well I think the reason is very simple:
 When you enter the loop through L, the value of i is not initialized to 0,
 it is some garbage value.
 now while exiting the loop, the condition is checked for another
 iteration. Since the value of i is unknown, it might be the case that ij
 for a lot of number of times before the loop actually ends.

 But it is not a runtime error, and no infinite loop. the loop will end,
 the moment value of i becomes = j.

 On 4 August 2011 11:00, TUSHAR tusharkanta.r...@gmail.com wrote:

 #includestdio.h
 main()
 {
  int j=4,i;
  goto L;
  for(i=0;ij;i++)
  {

   L:
 printf(%d,j);
   }
 }




 why this is giving infinite loop.Runtime error ?



 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --

 ___

 Please do not print this e-mail until urgent requirement. Go Green!!
 Save Papers = Save Trees

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Tushar Kanta Rath,
 Master In Computer Application
 MNNIT, Allahabad




   --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Why cant structures be declared or defined in C but can be done in C++ ?

2011-08-04 Thread Dipankar Patro
Structures can very well be declared in C:
struct student{
char name[20];
int roll;
}s1;

Are you talking about Classes?

On 4 August 2011 23:51, Ankur Garg ankurga...@gmail.com wrote:

 Why cant structures be declared or defined in C but can be done in C++ ?


 What is the reason for this ?

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Largest Bst in a binary tree.

2011-08-04 Thread Dipankar Patro
checking for BST node is quite simple. by definition, p is a node of bst if
(p-left  p  p-right)
each node should satisfy this condition in BST. (except for the exterior
nodes)

On 5 August 2011 10:13, Aman Goyal aman.goya...@gmail.com wrote:

 @siddharam: nice approach, just a query increasing inorder traversal of
 a tree is a sufficient condition to check for a BST ?


 On Fri, Aug 5, 2011 at 10:05 AM, siddharam suresh siddharam@gmail.com
  wrote:

 my idea is go for inorder traversal find the longest sorted sequence in
 traversal thats the *'largest BST in a binary tree.'* 
 Thank you,
 Siddharam



 On Fri, Aug 5, 2011 at 10:00 AM, Aman Goyal aman.goya...@gmail.comwrote:

 while dequing  a node from the queue, how will u check whether a bst
 property is sattisfied or not ?..


 On Fri, Aug 5, 2011 at 9:49 AM, Dipankar Patro dip10c...@gmail.comwrote:

 I have some upto this much currently.
 Modify the Breadth First traversal (BFT) a bit. maintain two queues, one
 is for original traversal.

 Start from root,  BFT. when you dequeue a node, check if it satisfies
 the condition for BST. if yes add the the node to auxiliary queue, if not,
 leave it and add it's original children to the original queue in both 
 cases.
 Some further modifications can the done to have multiple auxiliary
 queues and keep track of their heights.

 What say?


 On 5 August 2011 09:40, Aman Goyal aman.goya...@gmail.com wrote:

 Yes, that can be a liable case definitely!!!


 On Fri, Aug 5, 2011 at 9:35 AM, Dipankar Patro dip10c...@gmail.comwrote:

 The question is a bit tricky.
 Is it possible that the largest BST is somewhere in deeper depth, i.e.
 it is not necessarily consisting of the root?

 On 5 August 2011 08:46, Aman Goyal aman.goya...@gmail.com wrote:

 How to find the largest BST in a binary tree.



 15
 / \
 10__ 20
 / \
 5 _7
 / \
 2_ __5
 / \/
 0 8 3

 The largest BST (may or may not include all of its descendants) from
 the above example should be:

 15
 / \
 _10 20
 /
 5


 Please do not post working code, logic/algorithm or link would be
 preferred.
 I know it will be through recursion  , still the logic part of
 recursion is not clear.. would be thankful if anyone could help.

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --

 ___

 Please do not print this e-mail until urgent requirement. Go Green!!
 Save Papers = Save Trees

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --

 ___

 Please do not print this e-mail until urgent requirement. Go Green!!
 Save Papers = Save Trees

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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

Re: [algogeeks] Largest Bst in a binary tree.

2011-08-04 Thread Dipankar Patro
if you are looking for the largest height, then the inorder approach will
work.

@ Siddharam Suresh: you are right. The question is if the inorder is sorted,
is the only necessary condition for BST?

On 5 August 2011 10:19, siddharam suresh siddharam@gmail.com wrote:

 i didnt get   *increasing inorder traversal of a tree*?
 as per my knowledge inorder traversal of BST always give sorted data/value.
 Thank you,
 Siddharam



 On Fri, Aug 5, 2011 at 10:13 AM, Aman Goyal aman.goya...@gmail.comwrote:

 @siddharam: nice approach, just a query increasing inorder traversal
 of a tree is a sufficient condition to check for a BST ?


 On Fri, Aug 5, 2011 at 10:05 AM, siddharam suresh 
 siddharam@gmail.com wrote:

 my idea is go for inorder traversal find the longest sorted sequence in
 traversal thats the *'largest BST in a binary tree.'* 
 Thank you,
 Siddharam



 On Fri, Aug 5, 2011 at 10:00 AM, Aman Goyal aman.goya...@gmail.comwrote:

 while dequing  a node from the queue, how will u check whether a bst
 property is sattisfied or not ?..


 On Fri, Aug 5, 2011 at 9:49 AM, Dipankar Patro dip10c...@gmail.comwrote:

 I have some upto this much currently.
 Modify the Breadth First traversal (BFT) a bit. maintain two queues,
 one is for original traversal.

 Start from root,  BFT. when you dequeue a node, check if it satisfies
 the condition for BST. if yes add the the node to auxiliary queue, if not,
 leave it and add it's original children to the original queue in both 
 cases.
 Some further modifications can the done to have multiple auxiliary
 queues and keep track of their heights.

 What say?


 On 5 August 2011 09:40, Aman Goyal aman.goya...@gmail.com wrote:

 Yes, that can be a liable case definitely!!!


 On Fri, Aug 5, 2011 at 9:35 AM, Dipankar Patro 
 dip10c...@gmail.comwrote:

 The question is a bit tricky.
 Is it possible that the largest BST is somewhere in deeper depth,
 i.e. it is not necessarily consisting of the root?

 On 5 August 2011 08:46, Aman Goyal aman.goya...@gmail.com wrote:

 How to find the largest BST in a binary tree.



 15
 / \
 10__ 20
 / \
 5 _7
 / \
 2_ __5
 / \/
 0 8 3

 The largest BST (may or may not include all of its descendants) from
 the above example should be:

 15
 / \
 _10 20
 /
 5


 Please do not post working code, logic/algorithm or link would be
 preferred.
 I know it will be through recursion  , still the logic part of
 recursion is not clear.. would be thankful if anyone could help.

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --

 ___

 Please do not print this e-mail until urgent requirement. Go Green!!
 Save Papers = Save Trees

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --

 ___

 Please do not print this e-mail until urgent requirement. Go Green!!
 Save Papers = Save Trees

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http

Re: [algogeeks] pointer size

2011-08-03 Thread Dipankar Patro
This has been a hot topic of discussion for a long time. But I found there
are two things to look into it:

1. a 64 bit OS is one, which has 64 bit address handling capacity. and a
64bit processor is one which can perform operations on 64 bit data. A
general concept that actually gets overlooked by many. Even I was confused
with differences of 64 bit OS and Processors a while back.

2. if a compiler by it's own doesn't support 64 bit, it might be the case
that even if you run on a 64 bit OS, size of int will be 4 bytes (32 bit).

I think the best way to check out is to make a code on 64 bit compiler. If
somebody has tried it please share the results.

On 4 August 2011 10:38, Tushar Bindal tushicom...@gmail.com wrote:

 never assume that he compiler is same as the OS you run. it may be that you
 are running a 32-bit compiler

 I think pointers have size 4bytes on 8 byte compiler also - not sure.
 someone please correct me.


 On Thu, Aug 4, 2011 at 10:26 AM, Shashank Jain shashan...@gmail.comwrote:

 the size of a pointer is showing 4 bytes in my 64-bit OS, which should
 have been 8 bytes. Correct me where i am wrong?

 Shashank Jain
 3rd year, Computer Engg.
 Delhi College of Engineering

  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Tushar Bindal
 Computer Engineering
 Delhi College of Engineering
 Mob: +919818442705
 E-Mail : tushicom...@gmail.com
 Website: www.jugadengg.com


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: reason?????????

2011-08-01 Thread Dipankar Patro
1. When you are using %u, it is for unsigned printing.

2. looking at the loop, it will run for only values of i
for(i=5  i=-1;++i;i0)
^^ the first statement here is not the conditional one.

3. since int is of 4 bytes on your system, the max positive value it will
print is power(2, 32) - 1. (4 bytes = 32 bits)

if suppose you used unsigned int, then that would have been an infinite
loop. since the condition is i=-1. each time you incremented the value of i
, it would have been between (0, 2^64-1) only.


On 2 August 2011 03:16, Dharmendra Modi dharmendra.modi...@gmail.comwrote:

 The first part initialization of for loop (i=5  i=-1) is just an
 initialization and nothing else. It is of no use in this case.

 The second part condition holds the condition which is in this case +
 +i specifying to run loop till i is non zero. You are using prefix
 operator hence it will first increment i and then test.
 If you have used i++ the loop wont even have executed single time.

 The condition ++i becomes zero when there is round of short and you
 get zero at that time the loop terminates.

 The format specifier for unsigned int is used hence positive values
 are printed.
 If the format specifier for %d is used then the results would be more
 informative.

 Hope that helps.

 On Aug 1, 11:51 pm, jagrati verma jagrativermamn...@gmail.com wrote:
  #includestdio.h
  main()
  {
  short int i=0;
  for(i=5  i=-1;++i;i0)
  printf(%u\n,i);
  printf(\n);
  return 0;}
 
 o/p is 1.
  4294967295 hw???

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: ADT

2011-08-01 Thread Dipankar Patro
No. It is a basic data type which is used to make an ADT.

I don't know whether you have gone through this link, but I think it has
explained it properly
http://www.dba-oracle.com/t_object_encapsulation_abstract.htm

On 1 August 2011 23:01, Priyanka pril...@gmail.com wrote:



 On Aug 1, 9:19 pm, pandharinath gorde pandharinath.go...@gmail.com
 wrote:
  ADT means which will come with two things...
  i.which type of value it contains
  like suppose sone adt any which will have only integer like this
  iiwhat are opeartion possible on it.
  eg stack push and pop
 
  On Mon, Aug 1, 2011 at 8:41 PM, Priyanka pril...@gmail.com wrote:
   hai can anybody tell what is abstract datatype clearly??
 
   --
   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 group at
  http://groups.google.com/group/algogeeks?hl=en.
 
  --
  Pandharinath Gorde
  +91-9620557641


 k...is integer an adt?

















 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] ADT

2011-08-01 Thread Dipankar Patro
Well,
To understand it better, do you know about data abstraction in C++?
Its the hiding of data and programs implementations and just let you know
what the program does.

Similarly ADT are similar to normal data types, with their own functions
associated with them. To use ADT you need not know how it is developed. You
just need to know how to use them.

For example STACK. You need to know only three functions to use a STACK,
push, pop, and peek. Rest you don't have to care how it is implemented and
how it is working.

I hope you get it. If you have any specific, feel free to counter question.

On 1 August 2011 20:41, Priyanka pril...@gmail.com wrote:

 hai can anybody tell what is abstract datatype clearly??

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Graph Based Problems

2011-07-26 Thread Dipankar Patro
Love your idea Navneet, but I have seen in general that Graph algos are
difficult to convert into code (at least for me!) May be that's the reason
why people are not discussing it here.

But like you pointed out we could at least point the scenarios where graph
algos can be applied. Looking forward to your set of questions for sure.

On 26 July 2011 12:25, Navneet Gupta navneetn...@gmail.com wrote:

 Hello folks,

 I have seen some of the best possible string/array/tree based problems
 being discussed on this thread but somehow i feel this group has been little
 partial towards Graph problems.

 Though, in most cases, interviewers don't ask Graph algorithms, but we, as
 algo lovers, should give due importance to graph problems.

 Hope this will give some folks some motivations to share/ask good graph
 based problems.

 I will try to come up with first set of questions to get things rolling.

 --
 Regards,
 Navneet


 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C Output

2011-07-25 Thread Dipankar Patro
Swetha,

'\' in C is used to denote a escape sequence in C strings (and also in many
other languages).
e.g '\n' is for New Line '\n' is counted as one character.
Now '\ooo' is for an ASCII in octal representation.
here is the list of all escape sequences:
http://msdn.microsoft.com/en-us/library/h21280bw(v=vs.80).aspx

So for your string : \12345s\n
here '\123' is an ASCII in octal, hence one character.
rest you know about the characters: so length = '\123'(1) + 3 + '\n'(1) = 5.

I suggest you try with other combinations with '\' and print the output.
They will definitely show some weird stuffs :)

Hope that helps.
On 25 July 2011 22:53, swetha rahul swetharahu...@gmail.com wrote:

 char *s=\12345s\n;
 printf(\n %d,strlen(s));

 The output is 5...?? But how.??

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks]

2011-07-25 Thread Dipankar Patro
Puneet,
you missed out the 'sorted' part of array. Your code works fine for
randomized array.

+1 to Manish's solution. I had the same algo :)

On 26 July 2011 00:33, Puneet Gautam puneet.nsi...@gmail.com wrote:

 let k=a+b

 run in two loops

 for(i=0;((in)  (a[i]k));i++)
  for(j=i+1;a[j]=(k-a[i]);j++)
 if(a[j]==k-a[i])
do break from both outer n inner loops;
 diplay a[i] n a[j]

 Time complexity:O(n^2) worst case
 shud take O(nlgn) on an average

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C - pre post increment

2011-07-21 Thread Dipankar Patro
Certainly Aman.

The concepts of pre and post increment still stand correct.

while (x = --x) will terminate after x = 1 and when encountered (x = --x) =
x = 0 (after testing condition). Thus, 0 will not be printed.

while (x = x--) will terminate after x = 0 and when encountered (x = x--) =
x= -1 (after testing condition). Thus, 0 will be printed.

I hope this answer is acceptable :)

On 21 July 2011 19:44, Aman Goyal aman.goya...@gmail.com wrote:

 My mistake, i forgot to initiate x.

 Sorry for the mistake. But for devc it is infinite, then  should we ignore
 that?


 On Thu, Jul 21, 2011 at 7:40 PM, poised dip10c...@gmail.com wrote:

 Both the codes work perfectly on Ubuntu 11.04. (gcc)

 first code gives 0 in output.
 second one doesn't give 0 in output.

 both work as intended.

 --
 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/-/yPBntEpz6gIJ.

 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers = Save Trees

-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.