[algogeeks] Help solving this problem

2015-11-27 Thread mohit choudhary
Given an undirected graph G = (V, E), for any subset of nodes S ⊆ V we can
construct a graph Gs from G by removing all nodes in S together with their
incident edges. In the critical node problem (CNP), we are given an integer
1 ≤ k ≤ |V | and need to find a subset S of size k such that the graph Gs
has the minimum pair-wise connectivity. Here pairwise connectivity of a
graph is defined as the number of pairs of connected vertices in the graph


*Input*: The file “cnp.in” includes multiples lines. The first line
contains three integers 1 ≤ n ≤ 1000, 1 ≤ m ≤ 10 and 1 ≤ k ≤ n that
correspond to the number of nodes, edges, and the size of S. Each of the
following m lines contain two integers u and v, separated by one space, to
denote an edge from u to v. Nodes are numbered from 1 to n.
*Output*: The file “cnp.out” contains exactly 2 lines. The first line
contains an integer P that is the minimum pairwise connectivity of GS. The
second line contains exactly k integers which are the id of the nodes in S.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.


Re: [algogeeks] Re: can we check a number has last digit 5 or not using bitwise operator.

2012-10-11 Thread mohit mishra
@ Dev Thanx.

On Thu, Oct 11, 2012 at 1:25 AM, Dave dave_and_da...@juno.com wrote:

 @Mohit: The decimal representation of a number ends in 5 if its low order
 bit is 1 and it is divisibile by 5.

 An algorithm using bitwise operations to check for divisibility by 5 is
 given at
 https://groups.google.com/d/msg/algogeeks/I5HWmwKW_ks/n38FWJSd0l8J.

 It probably is not as fast as (n  1)  (n % 5 == 0), though.

 Dave

 On Wednesday, October 10, 2012 4:06:28 AM UTC-5, mohit mishra wrote:


  --
 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/-/bRupe9F1MUIJ.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.



[algogeeks] can we check a number has last digit 5 or not using bitwise operator.

2012-10-10 Thread mohit mishra


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Number of arrangements

2012-09-07 Thread mohit mishra
I think answer would be 6C3*3!. ie 120.

On Fri, Sep 7, 2012 at 10:20 AM, Navin Kumar algorithm.i...@gmail.comwrote:

 @tendua: Answer will be 6C3 x 3! .

 For example: If 5 letters are given then you can get only 10 combination
 of different letter = 5C3

 ABC
 ABD
 ABE
 BCD
 BCE
 CDE
 ACD
 ACE
 ADE
 BDE

 now each of these can be arranged in 3! ways. So final answer will be : 120


 On Fri, Sep 7, 2012 at 1:11 AM, tendua bharat.kra...@gmail.com wrote:


 http://placement.freshersworld.com/placement-papers/Persistent-/Placement-Paper-Whole-Testpaper-1884
 question no. 4 in 5th section


 On Thursday, September 6, 2012 4:40:08 PM UTC+5:30, isandeep wrote:

 Can you send the link to the question.

 On Thu, Sep 6, 2012 at 4:35 PM, tendua bharat...@gmail.com wrote:

 from the six elements, we could choose any three in C(6,3) ways which
 is 20 and then permute all the three elements so it will be multiplied by
 3! which is 6. Hence, 20*6 = 120. We still have to multiply it by 3 to get
 360 but I'm not getting why?


 On Thursday, September 6, 2012 3:54:11 PM UTC+5:30, atul007 wrote:

 seems output should be 20.

 On Thu, Sep 6, 2012 at 3:26 PM, tendua bharat...@gmail.com wrote:

 from the set {a,b,c,d,e,f} find number of arrangements for 3
 alphabets with no data repeated?
 Answer given is 360. but 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/
 **ms**g/algogeeks/-/E4U2XlfkvgMJhttps://groups.google.com/d/msg/algogeeks/-/E4U2XlfkvgMJ
 .
 To post to this group, send email to algo...@googlegroups.com.
 To unsubscribe from this group, send email to algogeeks+...@**
 googlegroups.com**.

 For more options, visit this group at http://groups.google.com/**
 group**/algogeeks?hl=enhttp://groups.google.com/group/algogeeks?hl=en
 .


  --
 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/-/VMO1othQRcQJhttps://groups.google.com/d/msg/algogeeks/-/VMO1othQRcQJ
 .

 To post to this group, send email to algo...@googlegroups.com.
 To unsubscribe from this group, send email to algogeeks+...@**
 googlegroups.com.
 For more options, visit this group at http://groups.google.com/**
 group/algogeeks?hl=en http://groups.google.com/group/algogeeks?hl=en.


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

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.



[algogeeks] Re: Search an element in a sorted and pivoted array

2012-08-29 Thread mohit
1.) Find the pivot point. to find pivot  – for a sorted (in increasing 
order) and pivoted array, pivot element is the only only element for which 
next element to it is smaller than it. 
2.) divide the array into two subarray and apply binary search.
for calling binary search in two subarray - if the element is greater than 
the first element : search (binary seach) in left subarray else in right 
subarray.

example array : 123456
pivoted array : 345612

complexity :O(logn) where n are the number of elements

   


On Tuesday, August 28, 2012 11:26:03 PM UTC+5:30, rahul sharma wrote:

 plz provide me algo for this,thnx 

-- 
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/-/oPmnJQ8tEGwJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] direct i online round

2012-08-20 Thread mohit choudhary
Scan first array check repeated values as in example( rt_triangle(4, {0,
-1, -1, 1}, {1, -2, 1, -2}))
-1,-1 is repeated twice at  indices in array respectively 1and 2.
now in second y-axis array check values at indices given by first array (in
above example these values are -2 and 1 respectively)
check for repetition  of these values in second array and for each repition
increment the count .in example -2 and 1 both are repeated so count becomes
2.
return count.
for this example answer is 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.



[algogeeks] Re: MICROSOFT QUESTION

2012-08-16 Thread mohit

here are the steps :
1) Construct a temporary array left[] such that left[i] contains product of 
all elements on left of A[i] excluding A[i].
2) Construct another temporary array right[] such that right[i] contains 
product of all elements on on right of A[i] excluding A[i].
3) To get OUT[], multiply left[] and right[]. 

time complexity : O(n)

On Thursday, August 16, 2012 2:26:58 PM UTC+5:30, ram wrote:


 Hi,

This is a microsoft question asked in our campus previous year. Anyone 
 having idea please share it here...

Given an array of n elements A[n]. Write a program to create a new 
 array OUT[n], 

 which has its elements as multiplication of all the elements in the 
 input array A[n] except that element (i.e.) OUT[2] = A[0] * A[1] * A[3] * ? * 
 A[n-1]. 
  Constraint is one should not use division operator.



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



[algogeeks] Re: MICROSOFT QUESTION

2012-08-16 Thread mohit
yeah we can do it without using an extra array too. first calculating the 
product of elements on its left and putting in OUT[] and then multiplying 
with the product of elements on its right . no auxiliary space used.


On Thursday, August 16, 2012 2:26:58 PM UTC+5:30, ram wrote:


 Hi,

This is a microsoft question asked in our campus previous year. Anyone 
 having idea please share it here...

Given an array of n elements A[n]. Write a program to create a new 
 array OUT[n], 

 which has its elements as multiplication of all the elements in the 
 input array A[n] except that element (i.e.) OUT[2] = A[0] * A[1] * A[3] * ? * 
 A[n-1]. 
  Constraint is one should not use division operator.



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



[algogeeks] Re: Microsoft Interview Question

2012-06-29 Thread mohit
+1 naveen

On Thursday, June 28, 2012 8:29:26 PM UTC+5:30, Navin Gupta wrote:

 Keep two pointers - one at start of the array and other at end of the 
 array 
 Now current points to start of the array 
 If current is negative , increment current
 If current is positive , swap it with the element at end and decrement 
 current and end both 
 If current = end , then break.

 Navin Kumar Gupta
 Final Year, B.Tech (Hons.)
 Computer Science  Engg.
 National Institute of Technology,Jamshedpur
 Mobile - 8285303045


-- 
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/-/hTWp_UkuDc8J.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Is max distance between two leaves(diameter) in a tree is equal to max distance between any two node in that tree??

2012-06-25 Thread Mohit Khanna
What would be the diameter in case of a left skewed or right skewed tree?


On Mon, Jun 25, 2012 at 12:48 PM, atul anand atul.87fri...@gmail.comwrote:

 consider a case where tree is right skewed or left skewed , in dat case
 max distance b/w two node found are root and leftmost or rightmost
 node(left  or right skewed) . so its not alwayzz true

 On Sun, Jun 24, 2012 at 5:08 PM, Navin Kumar algorithm.i...@gmail.comwrote:


  --
 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/-/xM3mGdcfvi4J.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.



[algogeeks] Amazon Interview Question

2012-06-14 Thread Mohit Rathi
Hi,

*There are two arrays of length 100 each. Each of these has initially n
(n=100)
elements. First array contains names and the second array contains numbers
such that ith name in array1 corresponds to ith number in array2.
Write a program which asks the user to enter a name, finds it in array1,*

*a. if it exists, then print the corresponding number in array2,
b. else ask the user to input its associated number and add the number and
name to array2 and array1 respectively, and update the size of list*

I can think of solving it through linear walk to the array. Anyone with
more optimized algorithm like BST or HashTable?

comments are welcome


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.



Re: [algogeeks] Amazon Interview Question

2012-06-14 Thread Mohit Rathi
arr1 = [abc,xyz,lmn,def]
arr2 = [3,6,2,8]

if user enters xyz then 6 will be printed
else
if xyz doesn't exist in arr1 then ask for a number and add them in
respective arrays(name in arr1 and number in arr2).

Hope it helps

On Thu, Jun 14, 2012 at 3:58 PM, utsav sharma utsav.sharm...@gmail.comwrote:

 example pls...

 On Thu, Jun 14, 2012 at 1:01 PM, Mohit Rathi mohit08...@iiitd.ac.inwrote:

 Hi,

 *There are two arrays of length 100 each. Each of these has initially n
 (n=100)
 elements. First array contains names and the second array contains numbers
 such that ith name in array1 corresponds to ith number in array2.
 Write a program which asks the user to enter a name, finds it in array1,*

 *a. if it exists, then print the corresponding number in array2,
 b. else ask the user to input its associated number and add the number and
 name to array2 and array1 respectively, and update the size of list*

 I can think of solving it through linear walk to the array. Anyone with
 more optimized algorithm like BST or HashTable?

 comments are welcome


 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.




 --
 Utsav Sharma,
 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.




-- 
Mohit Rathi
4th year, B.Tech (IT)
IIIT-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.



Re: [algogeeks] Differentiate the following declarations.

2012-06-06 Thread mohit mishra
In const char *a; and char const *a;both represent the same thing.
i.e. the string whose address is store in pointer a is not changeable,but
the pointer a can store address of another string
if const char *a =Hello;  /*string is fixed pointer is not*/
then *a='A';/*Error*/
 a=Hi;  /*Work*/

char *const a=Hello;/*pointer is fixed string is not*/
then *a='A'; /*Work*/
 a=Hi; /*Error*/




On Thu, Jun 7, 2012 at 8:39 AM, shiva@Algo shiv.jays...@gmail.com wrote:

 const char *a and char const *a are equivalent and 'a' can point to any
 variable(even that is not constant) but the thing 'a' points to cannot be
 changed and dont need initialisation

 const chat * a;//legal
 char c='b';//legal
 a=b;//legal
 *a='d';//illegal
 c='d';//legal

 but
 char * const a --represents  a is constatnt pointer  that points to a
 char.so, It needs an initialisation that will be unchanged for its life
 time.

 char c='b';
 char * const a=c;
 *a='d';//legal
 char d='e';
 a=d;//illegal



 On Thu, Jun 7, 2012 at 1:22 AM, g4ur4v gauravyadav1...@gmail.com wrote:


 1. const char *a;
 2. char* const a;
 3. char const *a;

 For each of the above, which operation below is legal and which is
 not?

 *a='F'
 a =Hi

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.



Re: [algogeeks] Datastructure and algorithms book

2012-06-05 Thread mohit mishra
Introduction To Algorithms By Clifford Stein, Thomas H Cormen, Ronald L
Rivest, Charles E Leiserson






On Tue, Jun 5, 2012 at 12:32 PM, arun prakash arunslb...@gmail.com wrote:

 Can anyone pls mail me good datastrucutre and algo books..or any link to
 download those books..thanks in advance

 --
 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/-/S3oFJ1RDgZ8J.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.



Re: [algogeeks] Recursion and Rooted Binary Trees

2012-05-02 Thread mohit mishra
just check first for the right child of node if (right*[**x**]** ≠* NIL ) and
then first call print method for right child

Algorithm 3 Print(x)

1: if (*x **≠* NIL) then

2:  print *colour **[**x**]*

3:  if (right*[**x**]** ≠* NIL) then

4:   Print (right*[**x**]**)*

5:   Print(left*[**x**]*)

6: end if

7: end if






On Tue, May 1, 2012 at 3:44 PM, atul anand atul.87fri...@gmail.com wrote:

 assignment is not at all tough , i guess you should understand recursion
 to solve these question.
 for eg : in question 4.1 : you just need to swap line number 4 and line
 number 5 to get the solution.

 in question 4.2 , you are given code for counting total number of nodes in
 the tree and for counting total number of leaves in the tree.
 soo dont you think all information is given and you just need to
 logically think to find the answer . read about what are internal nodes and
 after understanding it see what all question providing you , i hope you can
 get 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.



Re: [algogeeks] thanx to all

2012-02-28 Thread mohit mishra
congrats :-)

On Wed, Feb 29, 2012 at 10:56 AM, shady sinv...@gmail.com wrote:

 congrats :)
 keep participating and keep learning.


 On Wed, Feb 29, 2012 at 9:19 AM, atul anand atul.87fri...@gmail.comwrote:

 congo :)


 On Wed, Feb 29, 2012 at 5:30 AM, Varun Nagpal varun.nagp...@gmail.comwrote:

 cool


 On Tue, Feb 28, 2012 at 9:22 PM, Ravi Ranjan ravi.cool2...@gmail.comwrote:

 hey Geeks thanx a lot .. for the valuable information in the
 discussions

 i got selected in Yatra.com (R n D profile)

 thanx a lot for the algorithms explained by to guys

 THANX A LOT

 :D:D:D: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.


  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.



Re: [algogeeks] NIT Kurukshetra presents Online programming contest- ENCODER

2012-02-22 Thread Mohit Goel
check it now ... register your team  and engage  in codewar ..

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: convert into palindrome

2011-12-15 Thread Mohit kumar lal
@Lucifer- thnks got ur logic...:)

On Thu, Dec 15, 2011 at 12:07 PM, Lucifer sourabhd2...@gmail.com wrote:

 Correction:

 for NAN :
 N(IT)A + TI + N = NITATIN


 On Dec 15, 11:33 am, Lucifer sourabhd2...@gmail.com wrote:
  @topcoder..
 
  String: NITAN
 
  RevStr: NATIN
 
  LCS ( NITAN, NATIN) = { NIN , NAN }
 
  Here all we care about the count which is 2. Hence, 2 additions would
  be required to convert it into a palindrome..
 
  The possible palindromes would be:
  for NIN :
  N + AT + I(TA)N = NATITAN
 
  for NAN :
  N + TI+ A(IT)N = NATITAN
 
  On Dec 15, 11:24 am, top coder topcode...@gmail.com wrote:
 
 
 
 
 
 
 
   @Mohit
 
   Suppose for example
 
   String: NITAN
   LCS(Longest Common Subsequence) : NIN
 
   How do you get the palindrome with it?
 
   On Dec 15, 3:47 am, Lucifer sourabhd2...@gmail.com wrote:
 
@Mohit
 
I think what he meant is 2* strlen(Input String) - 2* (Length of
LCS)
 
On Dec 15, 3:44 am, Mohit kumar lal kumarmohit...@gmail.com wrote:
 
 @saurabh-as by the above example LCS of HELLO and its inverse
 would be
 LL and how can we form the word HELLOLLEH with it ...
 and is your ans for the word NITAN is NITATIN ...?
 
 On Wed, Dec 14, 2011 at 8:39 PM, saurabh singh 
 saurab...@gmail.com wrote:
  Find the LCS of string with its reverse
 
  On Wed, Dec 14, 2011 at 8:33 PM, top coder topcode...@gmail.com
 wrote:
 
  Given a word, convert it into a palindrome with minimum
 addition of
  letters to it. letters can be added anywhere in the word.
 
  . for eg if hello is given, result should be hellolleh
 
  --
  You received this message because you are subscribed to the
 Google Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com
 .
  To unsubscribe from 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.
 
 --
 Mohit kumar lal
 rit2009014
 IIIT ALLAHABAD
 contact@9454681805
 kumarmohit...@gmail.com
 mohitkumar...@yahoo.com
 rit2009...@iiita.ac.inhttp://
 profile.iiita.ac.in/rit2009014-Hidequoted text -
 
- Show quoted text -

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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 kumar lal
rit2009014
IIIT ALLAHABAD
contact@9454681805
kumarmohit...@gmail.com
mohitkumar...@yahoo.com
rit2009...@iiita.ac.in
http://profile.iiita.ac.in/rit2009014

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] convert into palindrome

2011-12-14 Thread Mohit kumar lal
@saurabh-as by the above example LCS of HELLO and its inverse would be
LL and how can we form the word HELLOLLEH with it ...
and is your ans for the word NITAN is NITATIN ...?
On Wed, Dec 14, 2011 at 8:39 PM, saurabh singh saurab...@gmail.com wrote:

 Find the LCS of string with its reverse


 On Wed, Dec 14, 2011 at 8:33 PM, top coder topcode...@gmail.com wrote:

 Given a word, convert it into a palindrome with minimum addition of
 letters to it. letters can be added anywhere in the word.

 . for eg if hello is given, result should be hellolleh

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.




-- 
Mohit kumar lal
rit2009014
IIIT ALLAHABAD
contact@9454681805
kumarmohit...@gmail.com
mohitkumar...@yahoo.com
rit2009...@iiita.ac.in
http://profile.iiita.ac.in/rit2009014

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Sub-array problem

2011-11-29 Thread Mohit kumar lal
here it is similar type of question i found on spoj ,it asks only for the
sum

http://www.spoj.pl/problems/HOTELS/

but it is giving TLE in O(n^2)..

On Tue, Nov 29, 2011 at 5:51 PM, Nitin Garg nitin.garg.i...@gmail.comwrote:

 cant think of anything better than O(N^2). Are you sure there exists such
 algo?

 On Tue, Nov 29, 2011 at 2:55 AM, Mohit kumar lal 
 kumarmohit...@gmail.comwrote:

 Given a array of positive integers ,You have to find the largest sum
 possible from consecutive sub-array but sum should be less than or equal to
 K and also find that sub-array. Ex- array={2,1,3,4,5} k=12,
  ans-12, sub-array={3,4,5}

 Firstly i tried with brute-force and then i also tried to solve it by DP
 but complexity were same ( O(n^2)) so plz try to provide a solution for
 O(nlgn) or O(n).

 --
 Mohit kumar lal

 IIIT ALLAHABAD

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Nitin Garg

 Personality can open doors, but only Character can keep them open

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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 kumar lal
rit2009014
IIIT ALLAHABAD
contact@9454681805
kumarmohit...@gmail.com
mohitkumar...@yahoo.com
rit2009...@iiita.ac.in
http://profile.iiita.ac.in/rit2009014

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Sub-array problem

2011-11-28 Thread Mohit kumar lal
Given a array of positive integers ,You have to find the largest sum
possible from consecutive sub-array but sum should be less than or equal to
K and also find that sub-array. Ex- array={2,1,3,4,5} k=12,
 ans-12, sub-array={3,4,5}

Firstly i tried with brute-force and then i also tried to solve it by DP
but complexity were same ( O(n^2)) so plz try to provide a solution for
O(nlgn) or O(n).

-- 
Mohit kumar lal

IIIT ALLAHABAD

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: Median of 2D matrix

2011-11-06 Thread mohit verma
@Gene
As i said in my earlier post right to left diagonal partitions the martix
into 2 equal number of elements. So now the median must be in this
diagonal. Now our focus is on finding median of this diagonal only.
I think this works fine. Can u give some test case for which it fails?

On Sun, Nov 6, 2011 at 3:02 AM, Gene gene.ress...@gmail.com wrote:

 Unfortunately this isn't true. See the example I gave earlier:

 1 2 3
 2 4 5
 3 4 6

 Thje median is 3.

 1 2 2 3 3 4 4 5 6

 Niether one of the 3's lies on the diagonal.

 When you pick any element P on the diagonal, all you know is that
 anything to the right and downward is no less than P and everything to
 the left and upward is no greater.  This leaves the upper right and
 lower left rectangles of the matrix unrelated to P.

 On Nov 5, 3:51 am, ankit agarwal ankit.agarwal.n...@gmail.com wrote:
  Hi,
 
  I think the median will always lie on the diagonal
  a[n][1]  a[1][n]
  because the elements on the LHS making the upper triangle will
  always be less than or equal to the elements on the diagonal
  and the RHS, elements in the lower triangle will be greater than or
  equal to them.
 
  so sort the diagonal and find the middle element, that will be the
  median.
 
  Thanks
  Ankit Agarwal
 
  On Nov 5, 1:29 am, Gene gene.ress...@gmail.com wrote:
 
 
 
   Here's an idea.  Say we pick any element P in the 2D array A and use
   it to fill in an N element array X as follows.
 
   j = N;
   for i = 1 to N do
 while A(i, j)  P do
j = j - 1;
 end;
 X(i) = j;
   end;
 
   This algorithm needs O(N) time.
 
   The elements of X split each row with respect to P. That is, for each
   i = 1 to N,
 
 A(i, j) = P if 0  j = X(i),A(i,j)  P if X(i)  j = N.
 
   Now the strategy is to create two length N arrays a = [0,0,...0]; and
   b = [N,N,...]. We'll maintain the invariant that a[i]  Median = b[i]
   for some i.  I.e, they bracket the median.
 
   We define functions L(a) = sum_i( a(i) ) and R(b) = sum_i( N -
   b(i) ).  These tell us how many elements there are left and right of
   the bracket.
 
   Now reduce the bracket as in binary search:  Guess a value P, compute
   X.  If L(X) = R(X), set b = X else set a = X.
 
   Keep guessing new P values in a way that ensures we reduce the number
   of elements between a and b by some fixed fraction.  If we can do
   that, we'll get to 1 element in O(N log N) time.
 
   The remaining problem is picking good P's. Certainly the first time is
   easy. Just take A(N/2, N/2). This has approximately (at least) N^2/4
   elements larger than it and N^2/4 smaller due to the sorted rows and
   columns.  This is what we need to get O(N log N) performance.
 
   But after the first split, things get trickier. The area between a and
   b takes on the shape of a slash / /, so you can't just pick a P that
   moves a and b together by a fixed fraction of remaining elements.
 
   Not to worry!  You can quickly look up the (at most) N row medians in
   the bracket, i.e.
 
 { A(i, (a[i] + b[i] + 1) / 2) | a[i]b[i] , i = 1 to N }
 
   and use the well known O(N) median selection algorithm to get a median
   of this. This has the quality we want of being somewhere roughly in
   the middle half of the remaining elements. The logic is the same as
   the selection algorithm itself, but in our case the rows are pre-
   sorted.
 
   In all, each partitioning step requires O(N), and a fixed fraction
   (about 1/2) of the elements will be eliminated from the bracket with
   each step. Thus O(log n) steps will be needed to bring the bracket to
   size 1 for an overall cost of O(N log N).
 
   I don't doubt that there's a simpler way, but this one seems to work.
   Anyone see problems?
 
   On Nov 3, 3:41 pm, sravanreddy001 sravanreddy...@gmail.com wrote:
 
any better solution than O(N^2) in worst case?
How do we take advantage of sorting and find in O(N lg N)- Hide
 quoted text -
 
  - Show quoted text -

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: Re: Re: [algogeeks] Re: Modular arithmetic + Combinatorics

2011-11-05 Thread mohit verma
@ Dave

I think your solution wont work for the cases like  (MAX_INT)  C
(MAX_INT-1).

On Thu, Nov 3, 2011 at 10:20 PM, vaibhavmitta...@gmail.com wrote:

 correction: if P is prime

 VM
 NSIT, Dwarka


 On , vaibhavmitta...@gmail.com wrote:
  Use Lucas Theorem is P is prime.
 
  VM
  NSIT, Dwarka
 
  On , Dipit Grover dipitgro...@gmail.com wrote:
   Thats really cool! Thanks Dave :)
  
  
  
  
   --
  
   You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
  
   To post to this group, send email to algogeeks@googlegroups.com.
  
   To unsubscribe from 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

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: Re: Re: [algogeeks] Re: Modular arithmetic + Combinatorics

2011-11-05 Thread mohit verma
@ myself
Dave's solution works fine. I should have close look at it.

On Sat, Nov 5, 2011 at 12:17 PM, mohit verma mohit89m...@gmail.com wrote:

 @ Dave

 I think your solution wont work for the cases like  (MAX_INT)  C
 (MAX_INT-1).


 On Thu, Nov 3, 2011 at 10:20 PM, vaibhavmitta...@gmail.com wrote:

 correction: if P is prime

 VM
 NSIT, Dwarka


 On , vaibhavmitta...@gmail.com wrote:
  Use Lucas Theorem is P is prime.
 
  VM
  NSIT, Dwarka
 
  On , Dipit Grover dipitgro...@gmail.com wrote:
   Thats really cool! Thanks Dave :)
  
  
  
  
   --
  
   You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
  
   To post to this group, send email to algogeeks@googlegroups.com.
  
   To unsubscribe from 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




-- 
Mohit

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: Designing Data Structure

2011-11-05 Thread mohit verma
@ Gene : I think your remove() function takes O(n) time in case if all n
numbers hash to same bucket.

Could you please elaborate on unbiased_hash() function?

  Can't we do it like this : rand() % TABLE_SIZE coz rand()  generates
uniformly distribution of numbers.

On Fri, Nov 4, 2011 at 1:47 AM, Gene gene.ress...@gmail.com wrote:

 Often you can get optimal performance with unusual combinations of
 operations by combining data structures. Here you can get O(1) for all
 operations by combining a hash table and a bag of pointers in an
 array. The hash table references bag elements by index, and the bag
 elements point back at hash table entries.  Random lookups occur in
 the bag array.  Here is a quick C toy to show what I mean.  There are
 other possible implementations.

 #include stdio.h
 #include stdlib.h

 typedef struct key_pair_s {
  struct key_pair_s *next;
  unsigned value, bag_index;
 } KEY_PAIR;

 typedef struct table_s {
  KEY_PAIR *buckets[1007], *bag[1];
  unsigned size;
 } TABLE;

 #define ARRAY_SIZE(A) (sizeof A/sizeof *A)

 void init_table(TABLE *table)
 {
  unsigned i;
  for (i = 0; i  ARRAY_SIZE(table-buckets); i++)
table-buckets[i] = NULL;
  table-size = 0;
 }

 unsigned hash(unsigned key)
 {
  return key % ARRAY_SIZE(((TABLE*)42)-buckets);
 }

 int Remove(TABLE *table, int value)
 {
  KEY_PAIR *p, *q;
  unsigned h = hash(value);
  for (q = NULL, p = table-buckets[h]; p; q = p, p = p-next)
if (p-value == value) {
  if (q)
q-next = p-next;
  else
table-buckets[h] = p-next;
  // Move last element into hole in bag. Update hash table.
  q = table-bag[--table-size];
  table-bag[p-bag_index] = q;
  q-bag_index = p-bag_index;
  free(p);
  return 1;
}
  return 0;
 }

 void Insert(TABLE *table, int value)
 {
  // Put a new key pair in the hash table.
  KEY_PAIR *p = malloc(sizeof *p);
  unsigned h = hash(value);
  p-next = table-buckets[h];
  table-buckets[h] = p;
  p-value = value;

  // Allocate a new bag element for this pair.
  p-bag_index = table-size++;
  table-bag[p-bag_index] = p;
 }

 #define N_RAND (RAND_MAX + 1)

 unsigned unbiased_rand(unsigned n)
 {
  unsigned r, m = N_RAND - N_RAND % n;
  do r = rand(); while (r = m);
  return r % n;
 }

 void GetRandomElement(TABLE *table, unsigned *value)
 {
  if (table-size  0)
*value = table-bag[unbiased_rand(table-size)]-value;
 }

 void Print(TABLE *table)
 {
  unsigned i;

  printf(table:);
  for (i = 0; i  table-size; i++)
printf( %u, table-bag[i]-value);
  printf(\n);
 }

 int main(void)
 {
  TABLE table[1];
  unsigned i, values[10];
  char cmd;

  init_table(table);
  for (i = 0; i  ARRAY_SIZE(values); i++) {
values[i] = rand();
Insert(table, values[i]);
  }

  for (;;) {
Print(table);
printf(cmd [arg] );
scanf( %c, cmd);
switch(cmd) {
  case 'i':
scanf(%u, i);
Insert(table, i);
printf(Inserted %u\n, i);
break;
  case 'r':
scanf(%u, i);
if (Remove(table, i))
  printf(Removed %u\n, i);
else
  printf(Couldn't find %u\n, i);
break;
  case 'g':
i = 0;
GetRandomElement(table, i);
printf(Random element: %u\n, i);
break;
  case 'q':
return 0;
  default:
printf(Unknown command\n);
break;
 }
  }
 }

 On Nov 2, 4:52 pm, shady sinv...@gmail.com wrote:
  does anyone knows how much is the complexity of operations erase and
  pop_back in case of Vector(STL)
  what would you choose :
 
  Design a data structure where the following 3 functions are optimised:
 
  1. Insert(n)
  2. GetRandomElement()
  3. Remove(n)
 
  Write a class, and implement the functions. Give complexity of each of
 these
 
  what would you choose, insertion can always be done in O(1), but what
 about
  getrandomelement() if we use simple arrays than for those
 
  1. - O(1)
 
  2. - O(1)
 
  3. - O(n)

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: Binary tree to BST

2011-11-05 Thread mohit verma
another way is : convert binary tree to link list , sort the list and using
divide  and conquer approach create the BST.

From link list to BST : find mid of sorted link list , make it root node
and put left of it to recursive(list,start,mid-prev) and
root-right=recursive(list,mid-next,last);

Let me know if something is wrong in this approach.

On Sat, Nov 5, 2011 at 3:48 PM, ankit agarwal
ankit.agarwal.n...@gmail.comwrote:

 I think it's the only way as you need to traverse the entire binary
 tree to do it.

 On Oct 31, 9:45 pm, Ankuj Gupta ankuj2...@gmail.com wrote:
  How to convert a Binary tree to BST ? Naive way is to create each node
  of  Binary tree one by one and keep on creating the BST.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Social graph labeling

2011-11-04 Thread mohit verma
Hi guys,

Social sites like facebook or linkedin must be having some vertex labelling
techniques. I cant' imagine what labelling they use since there are
trillions of nodes in there network ( coz simple
integer or alphanumeric labelling will not be efficient enough as far as i
think).

Can someone put some light on this topic?

-- 
Mohit

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: Median of 2D matrix

2011-11-04 Thread mohit verma
I think this can be done in O(n) time simply by finding the median of
elements at DIAGNOL starting from right corner to left corner.
Coz as elements are sorted row-wise and column-wise , it implies that
elements below this diagonal are all greater than elements on this diagonal
and all above this are smaller. So say for above example :
  3 34 , means median is 3.

On Sat, Nov 5, 2011 at 1:59 AM, Gene gene.ress...@gmail.com wrote:

 Here's an idea.  Say we pick any element P in the 2D array A and use
 it to fill in an N element array X as follows.

 j = N;
 for i = 1 to N do
  while A(i, j)  P do
 j = j - 1;
  end;
  X(i) = j;
 end;

 This algorithm needs O(N) time.

 The elements of X split each row with respect to P. That is, for each
 i = 1 to N,

  A(i, j) = P if 0  j = X(i),A(i,j)  P if X(i)  j = N.

 Now the strategy is to create two length N arrays a = [0,0,...0]; and
 b = [N,N,...]. We'll maintain the invariant that a[i]  Median = b[i]
 for some i.  I.e, they bracket the median.

 We define functions L(a) = sum_i( a(i) ) and R(b) = sum_i( N -
 b(i) ).  These tell us how many elements there are left and right of
 the bracket.

 Now reduce the bracket as in binary search:  Guess a value P, compute
 X.  If L(X) = R(X), set b = X else set a = X.

 Keep guessing new P values in a way that ensures we reduce the number
 of elements between a and b by some fixed fraction.  If we can do
 that, we'll get to 1 element in O(N log N) time.

 The remaining problem is picking good P's. Certainly the first time is
 easy. Just take A(N/2, N/2). This has approximately (at least) N^2/4
 elements larger than it and N^2/4 smaller due to the sorted rows and
 columns.  This is what we need to get O(N log N) performance.

 But after the first split, things get trickier. The area between a and
 b takes on the shape of a slash / /, so you can't just pick a P that
 moves a and b together by a fixed fraction of remaining elements.

 Not to worry!  You can quickly look up the (at most) N row medians in
 the bracket, i.e.

  { A(i, (a[i] + b[i] + 1) / 2) | a[i]b[i] , i = 1 to N }

 and use the well known O(N) median selection algorithm to get a median
 of this. This has the quality we want of being somewhere roughly in
 the middle half of the remaining elements. The logic is the same as
 the selection algorithm itself, but in our case the rows are pre-
 sorted.

 In all, each partitioning step requires O(N), and a fixed fraction
 (about 1/2) of the elements will be eliminated from the bracket with
 each step. Thus O(log n) steps will be needed to bring the bracket to
 size 1 for an overall cost of O(N log N).

 I don't doubt that there's a simpler way, but this one seems to work.
 Anyone see problems?

 On Nov 3, 3:41 pm, sravanreddy001 sravanreddy...@gmail.com wrote:
  any better solution than O(N^2) in worst case?
  How do we take advantage of sorting and find in O(N lg N)

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Dp solution for this problem?

2011-10-31 Thread mohit verma
I knew this could be done using Min Path finding algo. But what about DP
for this problem , guys?

On Mon, Oct 31, 2011 at 3:49 AM, SAMM somnath.nit...@gmail.com wrote:

 This can be done using the Dijkstra's algorithm , Start frm the source
 frm the Destination (In this example from (2 2)) . You need to
 consider the index of the array as the the vertices and the weigjht as
 the the value for the movement from the present vertex to it's
 connecting neighbour ..

 On 10/31/11, mohit verma mohit89m...@gmail.com wrote:
  Given a matrix you have to find the shortest path from one point to
 another
  within the matrix. The cost of path is all the matrix entries on the way.
  You can move in any direction (up, down, left, right, diagonally)
 
  e.g.
 
  5 9 10 1
  3 7 4 4
  8 2 1 9
 
  So shortest path from (0,0) to (2,2) is (0,0)--(1,1)---(2,2). Path cost -
  5+3+2+1=11
 
  I dont think some DP solution exist for this problem.Can it be?
 
 
  --
  Mohit
 
  --
  You received this message because you are subscribed to the Google Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 


 --
 Somnath Singh

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: Unique partition

2011-10-31 Thread mohit verma
Hi SAMM,

The above code is not clear enough to understand  . Sorry for that.
My idea was , like for above example : map will contain frequency of all
distinct elements.

so  freq[1] = 6
 freq[3]= 1
freq[5]=1
   freq[6]=1

Now for n=9 and k=3
 P1={1,3,5};
and now after this partition frequency of each element gets reduced by
1.Now you can eliminate elements having 0 frequency or just skip them.

In second run
P2={1,6,1}

and P3={1,1,1}.


On Mon, Oct 31, 2011 at 4:20 AM, SAMM somnath.nit...@gmail.com wrote:

 Ur algo will not work for this case :-

 1 1 1 1 1 1 3 5 6    For the array .. And for K=3

 Ur algo will give  (1 1 1) (1 1 1 ) (3 5 6)

 On 10/30/11, mohit verma mohit89m...@gmail.com wrote:
  sort the array : O(nlogn)
 
  keep an array/map containing frequency of each element in sorted array :
  O(n)
 
  v[n/k][k] - 2-D array of ints  containing final partitions.
 
  for i=1 to n/k
 {
   int count=0;
   for(j=0;jn  count  k;j++)
 { if(  freq(a[i])==0) continue; //say array is used
 v[i][count]=a[i];
 freq(a[i])--; //just an idea , not actual implementation
  count++;
 }
  }
 
  you can improve internal for loop by using map : if  freq[a[i]] becomes 0
  delete the node from array.
  On Sun, Oct 30, 2011 at 10:35 PM, SAMM somnath.nit...@gmail.com wrote:
 
  No there is no such condition ...just hav to make sure all the
  partitions are unique .
  The partitions can hav some elements ( K) in common but not the
  entire elements in a partition (Should be UNIQUE) .
 
  On 10/30/11, sunny agrawal sunny816.i...@gmail.com wrote:
   Is there any condition like all sets should have same no. Of elements
  
   On 10/30/11, SAMMM somnath.nit...@gmail.com wrote:
   But how does it ensure tht the elements been  removed wouldnot give
   the same set again 
  
   --
   You received this message because you are subscribed to the Google
  Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
  
  
   --
   Sunny Aggrawal
   B.Tech. V year,CSI
   Indian Institute Of Technology,Roorkee
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
 
 
  --
  Somnath Singh
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from 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
 
  --
  You received this message because you are subscribed to the Google Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 


 --
 Somnath Singh

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: Unique partition

2011-10-31 Thread mohit verma
yeah , my algo wont work for these cases :(.

On Mon, Oct 31, 2011 at 6:32 PM, sunny agrawal sunny816.i...@gmail.comwrote:

 @Mohit
 that will also not work
 example: {1,1,1,2,2,2,3,3,3}

 i think all the methods that try to fill the matrix(considering k sets as
 k rows) either horizontally or vertically will fail
 we need to fill these both horizontally and vertically at the same time
 depending upon the frequency of elements.



 On Mon, Oct 31, 2011 at 6:16 PM, mohit verma mohit89m...@gmail.comwrote:

 Hi SAMM,

 The above code is not clear enough to understand  . Sorry for that.
 My idea was , like for above example : map will contain frequency of all
 distinct elements.

 so  freq[1] = 6
  freq[3]= 1
 freq[5]=1
freq[6]=1

 Now for n=9 and k=3
  P1={1,3,5};
 and now after this partition frequency of each element gets reduced by
 1.Now you can eliminate elements having 0 frequency or just skip them.

 In second run
 P2={1,6,1}

 and P3={1,1,1}.


 On Mon, Oct 31, 2011 at 4:20 AM, SAMM somnath.nit...@gmail.com wrote:

 Ur algo will not work for this case :-

 1 1 1 1 1 1 3 5 6    For the array .. And for K=3

 Ur algo will give  (1 1 1) (1 1 1 ) (3 5 6)

 On 10/30/11, mohit verma mohit89m...@gmail.com wrote:
  sort the array : O(nlogn)
 
  keep an array/map containing frequency of each element in sorted array
 :
  O(n)
 
  v[n/k][k] - 2-D array of ints  containing final partitions.
 
  for i=1 to n/k
 {
   int count=0;
   for(j=0;jn  count  k;j++)
 { if(  freq(a[i])==0) continue; //say array is used
 v[i][count]=a[i];
 freq(a[i])--; //just an idea , not actual implementation
  count++;
 }
  }
 
  you can improve internal for loop by using map : if  freq[a[i]]
 becomes 0
  delete the node from array.
  On Sun, Oct 30, 2011 at 10:35 PM, SAMM somnath.nit...@gmail.com
 wrote:
 
  No there is no such condition ...just hav to make sure all the
  partitions are unique .
  The partitions can hav some elements ( K) in common but not the
  entire elements in a partition (Should be UNIQUE) .
 
  On 10/30/11, sunny agrawal sunny816.i...@gmail.com wrote:
   Is there any condition like all sets should have same no. Of
 elements
  
   On 10/30/11, SAMMM somnath.nit...@gmail.com wrote:
   But how does it ensure tht the elements been  removed wouldnot give
   the same set again 
  
   --
   You received this message because you are subscribed to the Google
  Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
  
  
   --
   Sunny Aggrawal
   B.Tech. V year,CSI
   Indian Institute Of Technology,Roorkee
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
   http://groups.google.com/group/algogeeks?hl=en.
  
  
 
 
  --
  Somnath Singh
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from 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
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 


 --
 Somnath Singh

 --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Sunny Aggrawal
 B.Tech. V year,CSI
 Indian Institute Of Technology,Roorkee

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from

Re: [algogeeks] Dp solution for this problem?

2011-10-31 Thread mohit verma
thnx all

On Mon, Oct 31, 2011 at 10:13 PM, Vandana Bachani vandana@gmail.comwrote:

 Hi Mohit,
 Bellman-Ford algorithm is a dynamic programming algorithm but u need it
 only if dijkstra's SP wont solve the problem... and Dijkstra's algo works
 only for +ve weights. So if u r sure that there maybe negative weights then
 you will need to use bellmann ford which is a DP algo.


 On Mon, Oct 31, 2011 at 7:40 AM, mohit verma mohit89m...@gmail.comwrote:

 I knew this could be done using Min Path finding algo. But what about DP
 for this problem , guys?

 On Mon, Oct 31, 2011 at 3:49 AM, SAMM somnath.nit...@gmail.com wrote:

 This can be done using the Dijkstra's algorithm , Start frm the source
 frm the Destination (In this example from (2 2)) . You need to
 consider the index of the array as the the vertices and the weigjht as
 the the value for the movement from the present vertex to it's
 connecting neighbour ..

 On 10/31/11, mohit verma mohit89m...@gmail.com wrote:
  Given a matrix you have to find the shortest path from one point to
 another
  within the matrix. The cost of path is all the matrix entries on the
 way.
  You can move in any direction (up, down, left, right, diagonally)
 
  e.g.
 
  5 9 10 1
  3 7 4 4
  8 2 1 9
 
  So shortest path from (0,0) to (2,2) is (0,0)--(1,1)---(2,2). Path
 cost -
  5+3+2+1=11
 
  I dont think some DP solution exist for this problem.Can it be?
 
 
  --
  Mohit
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 


 --
 Somnath Singh

 --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Vandana Bachani
 Graduate Student, MSCE
 Computer Science  Engineering Department
 Texas AM University, College Station

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: What Data Structure to use ?

2011-10-31 Thread mohit verma
One (compressed-optional) prefix trie with each course ptrs to students and
another prefix tree for students having ptrs to courses. Guaranteed O(m)
search time instead of O(n*m) if using hash table where m avg size of word
at hand to be compared to n nodes.

On Sun, Oct 30, 2011 at 7:31 PM, WgpShashank shashank7andr...@gmail.comwrote:

 We Will Use Closed Addressing or Open hashing based approach which called
 saperate chaining and i think it will be sufficient solve it .isn't it
 Here is Approach.

 Let we have m students  n course . Each student  course have unique ID 
 identified by it as well.we can use Associate data structure because
 here we need to maintin the relationship between students  course.
 HashTable or HashMap seems to be good fit in case of choosing the data
 structures.We Will Use Closed Addressing or Open hashing based approach
 which called saperate chaining.Hash table has two filed in each slot key
  pair.Each slot of the HashTable has studentid or course id as key and a
 pointer to a linked list that contains the value when key hashed to the
 same location. e.g. Using this approach Whenever collsion occurs in any
 hashtable e.g. if one student can have more courses they will added to
 linked list (value part ) pointed by pointer from hash table thus
 collision will also resolved .similerly can be done for course
 hashTable.where following
 operation plays important roles.

 1.Lookup requires scanning the list for an entry with the given key. O(n)
 2.Insertion requires adding a new entry record to either end of the list
 belonging to the hashed slot. O(1) or O(n)
 3.Deletion requires searching the list and removing the element.O(n)

 Instead of a list, one can use any other data structure that supports the
 required operations. For example, by using a self-balancing (AVL or RB)
 Tree with worst-case time of common hash table operations (insertion,
 deletion, lookup) can be brought down to O(log n) rather than O(n).
 However, this approach is only worth the trouble and extra memory if one
 expects to have many entries hashed to the same slot

 1.Lookup requires scanning the tree for an entry with the given key we
 have to trace whole tree upto depth in case of self balancing tree its
 O(logn)
 2.Insertion requires adding a new entry record to end of the list
 belonging to the hashed slot.Again we have to search place to insert.
 3.Deletion requires searching the list and removing the element.Again we
 have to search whole tree which takeso O(logn) again.

 Let me know if anything wrong or better have u in mind ?

 Thanks
 Shashank Mani
 Computer Science
 BIrla Institute of Technology Mesra.

 --
 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/-/Db5pSD-useoJ.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: What Data Structure to use ?

2011-10-31 Thread mohit verma
@shashank , i agree.

To reduce this overhead  , we can implement prefix trie in bit-form or DAWG
or lots of compression techniques are there at the cost of complex coding.

On Tue, Nov 1, 2011 at 12:35 AM, WgpShashank shashank7andr...@gmail.comwrote:

 @Mohit Space Overhead Will be more if m,n are large isn't it ?


 Shashank

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

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: Unique partition

2011-10-30 Thread mohit verma
sort the array : O(nlogn)

keep an array/map containing frequency of each element in sorted array :
O(n)

v[n/k][k] - 2-D array of ints  containing final partitions.

for i=1 to n/k
   {
 int count=0;
 for(j=0;jn  count  k;j++)
   { if(  freq(a[i])==0) continue; //say array is used
   v[i][count]=a[i];
   freq(a[i])--; //just an idea , not actual implementation
count++;
   }
}

you can improve internal for loop by using map : if  freq[a[i]] becomes 0
delete the node from array.
On Sun, Oct 30, 2011 at 10:35 PM, SAMM somnath.nit...@gmail.com wrote:

 No there is no such condition ...just hav to make sure all the
 partitions are unique .
 The partitions can hav some elements ( K) in common but not the
 entire elements in a partition (Should be UNIQUE) .

 On 10/30/11, sunny agrawal sunny816.i...@gmail.com wrote:
  Is there any condition like all sets should have same no. Of elements
 
  On 10/30/11, SAMMM somnath.nit...@gmail.com wrote:
  But how does it ensure tht the elements been  removed wouldnot give
  the same set again 
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
 
 
  --
  Sunny Aggrawal
  B.Tech. V year,CSI
  Indian Institute Of Technology,Roorkee
 
  --
  You received this message because you are subscribed to the Google Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 


 --
 Somnath Singh

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Dp solution for this problem?

2011-10-30 Thread mohit verma
Given a matrix you have to find the shortest path from one point to another
within the matrix. The cost of path is all the matrix entries on the way.
You can move in any direction (up, down, left, right, diagonally)

e.g.

5 9 10 1
3 7 4 4
8 2 1 9

So shortest path from (0,0) to (2,2) is (0,0)--(1,1)---(2,2). Path cost -
5+3+2+1=11

I dont think some DP solution exist for this problem.Can it be?


-- 
Mohit

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: Modular arithmetic

2011-10-29 Thread mohit verma
You can do something like this:

( n* alpha)  * ( m*alpha) *p

where 0alpha1  which maps product onto (0,1) interval. You can use
golden ration instead.

On Sat, Oct 22, 2011 at 9:45 PM, Aamir Khan ak4u2...@gmail.com wrote:



 On Sat, Oct 22, 2011 at 9:04 PM, Mad Coder imamadco...@gmail.com wrote:



 Can anyone explain why ((n%p)*(m%p))%p will give wrong answer ?

 Lets say, n = 10^15 , m = 10^15   and p = 10^18

 So,
 n%p = 10^15
 m%p = 10^15

 And the intermediate result (n%p)*(m%p) will overflow the long long range.

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Aamir Khan | 3rd Year  | Computer Science  Engineering | IIT Roorkee


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: Find all possible combination of integers for a given sum

2011-10-28 Thread mohit verma
ohh , the number can repeat itself. I dint notice that.

On Fri, Oct 28, 2011 at 4:02 PM, mohit verma mohit89m...@gmail.com wrote:

 something like this :

 for(int i=0;temp=sum , isum/2;i++)
 { temp=temp-i;
 for(int j=i+1;jtemp;j++)
  couti j temp-j\n;
 }

 But there is a problem with code :
  like for sum 7 , repeated cases are 0 3 4 and 0 4 3.

 On Thu, Oct 27, 2011 at 7:46 PM, rj7 r4ra...@gmail.com wrote:

 @Nitin Garg well if negatives are included there would be infinite
 number of solutions
 right?

 and we can start we start with dividing the sum by combinations.
 Atleast one number must be greater than sum/combination..
 Am not sure it this is same as that subset manipulation...
 pls post the algo for that recursion method!

 On Oct 27, 12:21 am, Nitin Garg nitin.garg.i...@gmail.com wrote:
  Are we talking about only positive integers here?
 
  On Wed, Oct 26, 2011 at 11:33 PM, Vaibhav Mittal
  vaibhavmitta...@gmail.comwrote:
 
 
 
 
 
 
 
 
 
   +1 Prem
   @ligerdave : I knew about the recursion method..but can u throw some
 light
   on the pointer based method..(with a small example maybe)..
   Specifically I wanted to know the implementation part and the running
 time
   of the algorithm.
 
   On Wed, Oct 26, 2011 at 8:33 PM, ligerdave david.c...@gmail.com
 wrote:
 
   @meng You already have the pattern figured out. each time subtract 1
   from the lowest digit and add to higher digit(only once), until the
   lowest digit equals to closest higher digit. the selection of which
   number to start could be figured out with given parameters sum and
   combination
 
   @Prem, no recursion needed here. it make it more complex than
   necessary. one loop with a pointer should be able to resolve this
 
   On Oct 24, 6:28 pm, Meng Yan mengyan.fu...@gmail.com wrote:
Hi, my question is
 
given sum=N and combination constraint=M (the number of elements),
 how
   to
find all possible combinations of integers?
 
For example, given sum=6, combination=3; how to get the result as
   following:
1+1+4;
1+2+3;
2+2+2;
 
We don't care about order of the elements, which means 1+1+4 and
 1+4+1
   are
considered as same combination.
 
Thanks a lot!
 
Meng
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from 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.
 
  --
  Nitin Garg
 
  Personality can open doors, but only Character can keep them open

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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*




-- 

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



Re: [algogeeks] Re: Find all possible combination of integers for a given sum

2011-10-28 Thread mohit verma
something like this :

for(int i=0;temp=sum , isum/2;i++)
{ temp=temp-i;
for(int j=i+1;jtemp;j++)
couti j temp-j\n;
}

But there is a problem with code :
 like for sum 7 , repeated cases are 0 3 4 and 0 4 3.

On Thu, Oct 27, 2011 at 7:46 PM, rj7 r4ra...@gmail.com wrote:

 @Nitin Garg well if negatives are included there would be infinite
 number of solutions
 right?

 and we can start we start with dividing the sum by combinations.
 Atleast one number must be greater than sum/combination..
 Am not sure it this is same as that subset manipulation...
 pls post the algo for that recursion method!

 On Oct 27, 12:21 am, Nitin Garg nitin.garg.i...@gmail.com wrote:
  Are we talking about only positive integers here?
 
  On Wed, Oct 26, 2011 at 11:33 PM, Vaibhav Mittal
  vaibhavmitta...@gmail.comwrote:
 
 
 
 
 
 
 
 
 
   +1 Prem
   @ligerdave : I knew about the recursion method..but can u throw some
 light
   on the pointer based method..(with a small example maybe)..
   Specifically I wanted to know the implementation part and the running
 time
   of the algorithm.
 
   On Wed, Oct 26, 2011 at 8:33 PM, ligerdave david.c...@gmail.com
 wrote:
 
   @meng You already have the pattern figured out. each time subtract 1
   from the lowest digit and add to higher digit(only once), until the
   lowest digit equals to closest higher digit. the selection of which
   number to start could be figured out with given parameters sum and
   combination
 
   @Prem, no recursion needed here. it make it more complex than
   necessary. one loop with a pointer should be able to resolve this
 
   On Oct 24, 6:28 pm, Meng Yan mengyan.fu...@gmail.com wrote:
Hi, my question is
 
given sum=N and combination constraint=M (the number of elements),
 how
   to
find all possible combinations of integers?
 
For example, given sum=6, combination=3; how to get the result as
   following:
1+1+4;
1+2+3;
2+2+2;
 
We don't care about order of the elements, which means 1+1+4 and
 1+4+1
   are
considered as same combination.
 
Thanks a lot!
 
Meng
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from 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.
 
  --
  Nitin Garg
 
  Personality can open doors, but only Character can keep them open

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.



Re: [algogeeks] Re: Directi Questions - needed answers

2011-10-28 Thread mohit verma
@ankur -  Ans-9 how can it be  log n. The heap given is Max heap. I think it
should be O(n) using array or tree traversal (as heap is implemented)
keeping current min at hand. Correct  me if m wrong.

On Sat, Oct 15, 2011 at 12:14 PM, shady sinv...@gmail.com wrote:

 already been answered... :-/
 but have to say you are damn quick...


 On Sat, Oct 15, 2011 at 12:03 PM, Bittu Sarkar bittu...@gmail.com wrote:

 Q7. Correct answer is 12km west and 12km south for sure!!


 On 21 September 2011 13:28, Nitin Garg nitin.garg.i...@gmail.com wrote:

 Ohh i totally missed that line.
 Thanx a lot :)


 On Wed, Sep 21, 2011 at 10:46 AM, pankaj agarwal 
 agarwal.pankaj.1...@gmail.com wrote:

 @Nitin Garg

 Question 6 -

 i agree that greater the sum is and greater the probability to getting
 it.
 but in given question if sum100 then rolling is stopped
 so for

 P(106)=P(100)*1/6
 P(105)=P(100)*1/6+P(99)*1/6
 .
 .
 .
 P(101)=P(100)*1/6+P(99)*(1/6)+P(98)*(1/6)+P(97)*(1/6)+..+P(95)*(1/6)

 now P(101) is more

 cleare me if something is wrong.



 On Mon, Sep 19, 2011 at 1:35 PM, Nitin Garg 
 nitin.garg.i...@gmail.comwrote:

 Question 6 -
 Intuitively you can see that the greater the sum is, the greater the
 favorable events in sample space.

 e.g. - sum = 1 .. cases {(1)}   Pr = 1/6
 sum = 2 cases {(2),(1,1)}   Pr = 1/6 + 1/36
 sum = 3cases {(3),(2,1)(1,2)(1,1,1)}  Pr = 1/6 + 1/36 +1/36
 + 1/216


 for a more formal proof, look at the recursion -


 P(k) = (P(k-6) + P(k-5) + P(k-4)... P(k-1)))/6

 where P(0) = 1, P(i) = 0  for i0

 Base case -
 P(2)  P(1)

 Hypothesis -

 P(i)  P(i-1) for  all i = k

 To prove
 P(k+1)   P(k)

 Proof
 P(k+1) - P(k) = (P(k) - P(k-6))/6  0






  --
  Pankaj Agarwal
  Communication and Computer Engineering
  LNMIIT,jaipur

  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Nitin Garg

 Personality can open doors, but only Character can keep them open

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Bittu Sarkar
 5th Year Dual Degree Student
 Department of Computer Science  Engineering
 Indian Institute of Technology Kharagpur


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Intersection of arrays

2011-10-27 Thread mohit verma
I think , in the worst case this hashing technique 'll take O(n^(k-1)) time?
so i wud stick with sorting idea with confirm : O(mlogm) + O(m) time
complexity where m is avg length of arrays.


On Tue, Oct 25, 2011 at 6:02 PM, kumar raja rajkumar.cs...@gmail.comwrote:

 Dheeraj can u please tell me how to keep track count for an element ,in
 hash table.
 I want the exact structure of the hash table
 The hash function uses the input as the elements value ,and stores it in
 some slot by computing hash function..then where is the question of
 storing count for that number.

 I am pretty much confused with this hashing and how these details are
 exactly implemented in STL hash map class.

 On 24 October 2011 23:32, Dheeraj Sharma dheerajsharma1...@gmail.comwrote:

 use hashing..
 let the no. of array be 1 to K
 increment the count of element for that array..(in hash table) only if its
 count value in hash table is one less then the array no.(which means
 that..it is present in all the arrays..preceding it)
 now search the hash table..in which element count is equal to K


 On Tue, Oct 25, 2011 at 11:47 AM, kumar raja rajkumar.cs...@gmail.comwrote:

 Find intersection of K unsorted array of N elements each. Intersection
 consists of elements that appear in all the K arrays.

 what data structure is useful here??

 --
 Regards
 Kumar Raja
 M.Tech(SIT)
 IIT Kharagpur,
 10it60...@iitkgp.ac.in


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 *Dheeraj Sharma*


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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
 Kumar Raja
 M.Tech(SIT)
 IIT Kharagpur,
 10it60...@iitkgp.ac.in


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.



Re: [algogeeks] Re: Find the later version

2011-10-12 Thread mohit verma
WE CAN USE RADIX SORT TO FIND THE MAX VERSION :TRAVERSING FROM LEFT TO RIGHT
(RADIX WILL BE NUMBERS BETWEEN THE POINTS).
It will reduce the search space too.


On Tue, Oct 11, 2011 at 1:58 AM, sumit kumar pathak
sumitkp1...@gmail.comwrote:

 *
 *regards
 - Sumit Kumar Pathak
 (Sumit/ Pathak/ SKP ...)
 *Smile is only good contagious thing.*
 *Spread it*!



 On Tue, Oct 11, 2011 at 11:22 AM, DIPANKAR DUTTA 
 dutta.dipanka...@gmail.com wrote:

 what's happen if the versions are not in same length..

 For example

 v1: 1.1.1.133.2
 v2: 1.2
 v3: 1.2.3.4..333
 v4: 1.2.3.4.5554.222
 v5: 1.3.2.2.2.2.2.2.2.2.2.2.2.2

 It implies we must be scan from left side one by one ...

 In general the we make a some sort of lexical comparison where each
 character is a number and separated by number ..

  the problem definition is as :

 let V1,V2,V3 ...Vn be the n version

 let S={1,2,3...n} ,index=0

 Latest[S,index]= return Vi if { Max(ALL Vi[k] where i belongs to S )}
 is a singleton, else
  =  return Latest[ set of all index belongs to  { Max(ALL
 Vi[k] where i belongs to S )}, index+1 ]





 On 10/11/11, Dave dave_and_da...@juno.com wrote:
  @Karen: It is more complicated than scanning character by character.
  E.g., 1.10.3 is older than 1.9.7. I think


 snip

 you need to parse the
  numbers between the dots and compare them

 /snip

 simple, easier and correct way.
 points:
   -  compare left to right (ofcourse) each version being vector of numbers
   - for diffrent size, assume extra ones to be zero while comapring (no
 need to store trailing zeros)



  one by one. Thus, in the
  above example, 1 compares equal to 1, so you keep scanning. Then 10
  compares greater than 9 so the first string is number of the newer
  version. I did this many years ago in a csh install script for a unix
  product.
 
  Dave
 
  On Oct 10, 9:52 pm, bagaria.ka...@gmail.com
  bagaria.ka...@gmail.com wrote:
  Given two strings describing the version of a particular software need
 to
  find the later version.
 
  For eg.
  1st string = 1.2.4.5
  2nd string=1.2.3.5
 
  1st string is the later one.
 
  Can be done using traversing the string and comparing each character
 one
  after the another. Looking for a better solution with lesser
 complexity.
 
  --
  Thanks and Regards
 
  *Karan Bagaria*
  *MCA Final Year*
  Training and Placement Representative
  *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.
 
 


 --
 Thanks and Regards,
 --
 **DIPANKAR DUTTA
 Software Development Engineer
 Xen Server - OpenStack Development Team (DataCenter and Cloud)

 Citrix RD India Pvt Ltd
 69/3, Millers Road, Bangalore – 560052
 Phone: +91 8147830733
 Office: Extn: 16429
 Email: dipankar.du...@citrix.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.




-- 

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



Re: [algogeeks] Qualcomm

2011-09-24 Thread mohit mittal
Hello yar,
Please share the written paper format and interview questions.
If dont want to display openly, plz share with my id mohitm.1...@gmail.com.

It will be of great help to me.

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



[algogeeks] Queries regarding Summer(2012) internship

2011-09-23 Thread Mohit kumar lal
Hello everyone,.
I am 3rd yr student from IIIT Allahabad,i want to know what
companies I can apply for summer(2012) internship and what is the process
for applying in these companies.My CGPI is around 8.Please reply as soon as
possible.
-- 
Mohit kumar lal
rit2009014
IIIT ALLAHABAD
contact@9454681805
kumarmohit...@gmail.com
mohitkumar...@yahoo.com
rit2009...@iiita.ac.in
http://profile.iiita.ac.in/rit2009014

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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 WRITTEN IN VASAVI

2011-09-14 Thread mohit verma
take an array containing all original upper-case  letters and their smaller
case letters and now the problem is reduced to print all substrings
containing length of original string.

On Wed, Sep 14, 2011 at 8:55 PM, teja bala pawanjalsa.t...@gmail.comwrote:


 //dis one works check it out..

 #includectype.h
 #includestdio.h
 #includestring.h
 #includeassert.h
 void toggler(char* x, int pos)
 {
   if(pos==0){ printf(%s\n,x); return; }
 //  printf(String is now: %s\n,x);
   x[pos-1] = toupper(x[pos-1]);
   toggler(x, pos-1);
   x[pos-1] = tolower(x[pos-1]);
   toggler(x, pos-1);
 return;
 }
 int main(void){
   char str[500];
   scanf(%s,str);
   toggler(str, strlen(str));
   return 0;
 }

 On Wed, Sep 14, 2011 at 7:22 PM, Dave dave_and_da...@juno.com wrote:

 @Teja: Oops. I was wrong. By the time I fix my conceptual error, the
 code is no shorter than Anshu's.

 Dave

 On Sep 14, 8:14 am, teja bala pawanjalsa.t...@gmail.com wrote:
  @DAVE
 
  dis was the o/p for ur prog.
 
  aBC
  abC
  abC
  abc
  abc
  abc
  abc
  abc
 
  #includeiostream.h
  main()
  {
  int i, n = 3;
  char *s=ABC;
  for( i = 0 ; i  (1n) ; ++i )
  {
   s[i^(i1)] ^= 'a' ^ 'A';
   cout  s  endl;
 
 
 
  }
  }- Hide quoted text -
 
  - Show quoted text -

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.



[algogeeks] Paypal

2011-09-10 Thread mohit mittal
Has anyone recently attended the placement procedure for paypal.
Like how is it?

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



[algogeeks] Implementing a grep

2011-09-10 Thread mohit mittal
If i have to code the functioning of grep
what data structure is recommended for implementing it.

I was thinking may be using trie with each node having a vector list of line 
numbers in which they appear.
Is it the correct one or is there any better solution to 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/-/TnrBS2wCopMJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Paypal

2011-09-10 Thread mohit mittal
around 25th
65 
arnd 8

-- 
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/-/7FtN8hsesrgJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: Need algorithm asap

2011-09-07 Thread mohit verma
call it as : bipartition(a,-1,2) . coz at the very first time k is  being
incremented so it needs intiiale value -1.

On Sat, Sep 3, 2011 at 8:46 PM, Siddhartha Banerjee thefourrup...@gmail.com
 wrote:

 please check out the code,  doesnt give right solution on running...
 or perhaps i missed something... how should you call your function? if
 array is a={1,2,3} you call from main function as
 bipartition(a,0,2), right???

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.



[algogeeks] os

2011-09-07 Thread Mohit Goel
How many processes are created in this snippet?
Main()
{
Fork();
Fork()  fork () || fork ();
Fork ();
}

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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

2011-09-07 Thread Mohit Goel
a. 15
b. 19
c. 21
d. 27
e. 31
these are the only options.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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

2011-09-07 Thread Mohit Goel
20 is not in option ..so whats 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.



Re: [algogeeks] os

2011-09-07 Thread Mohit Goel
thnks everyone...

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] explain the output..!!

2011-09-05 Thread Mohit Goel
1) #include stdio.h
   #include stdlib.h

   #define SIZEOF(arr) (sizeof(arr)/sizeof(arr[0]))

   #define PrintInt(expr) printf(%s:%d\n,#expr,(expr))
   int main ()
  {
   /* The powers of 10 */
   int pot[] = {
0001,0010,0100,1000

   };
   int i;

   for(i=0;iSIZEOF(pot);i++)
   PrintInt(pot[i]);
   return 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.



Re: [algogeeks] explain the output..!!

2011-09-05 Thread Mohit Goel
got it ..!! thnks everyone

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] determine error..!!

2011-09-05 Thread Mohit Goel
1) #include stdio.h
   #define PrintInt(expr) printf(%s : %d\n,#expr,(expr))
   int max(int x, int y)
  {
   (x  y) ? return x : return y;
  }

   int main ()
  {
   int a = 10, b = 20;
PrintInt(a);
PrintInt(b);
PrintInt(max(a,b));
  }

2#include stdio.h
  void foo(const char **p) { }
   int main (int argc, char **argv)
  {
 foo(argv);
return 0;
  }
i  think sending a normal pointer to a function
requiring const pointer does not give any warning..but it still giving an
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.



Re: [algogeeks] MICROSOFT

2011-09-04 Thread mohit verma
int funkth(node *root,int k)
{

   queuenode * q;
 q.insert(root);
node *temp;
  while(!q.empty())
{
  temp=q.top();
  q.pop();
  if(temp-l) q.insert(temp-l);
  if(temp-r) q.insert(temp-r);
  makeheapk(temp-value);  //make  minheap of size k
   }
   return topheap();   //return top element of heap
}

any corrections please?
 On Sun, Sep 4, 2011 at 10:20 AM, sukran dhawan
sukrandha...@gmail.comwrote:

 for bst
 step 1 :count the number of nodes in a tree
 step2: traverse in inorder.after each node visit decrement n. if n == k
 then the result

 On Sun, Sep 4, 2011 at 12:33 AM, teja bala pawanjalsa.t...@gmail.comwrote:

 //Asked in MS please help me with the coding or Give an algorithm


 Write code to return the kth largest element in a tree ... function
 prototype is int fucnkth(node *root,int k)

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.



Re: [algogeeks] MICROSOFT

2011-09-04 Thread mohit verma
it would be better if we insert values in array in while loop and then
outside call  makeheapk() and then return topheap();
this will reduce the heap making complexity.
On Sun, Sep 4, 2011 at 2:29 PM, mohit verma mohit89m...@gmail.com wrote:

 int funkth(node *root,int k)
 {

queuenode * q;
  q.insert(root);
 node *temp;
   while(!q.empty())
 {
   temp=q.top();
   q.pop();
   if(temp-l) q.insert(temp-l);
   if(temp-r) q.insert(temp-r);
   makeheapk(temp-value);  //make  minheap of size k
}
return topheap();   //return top element of heap
 }

 any corrections please?

  On Sun, Sep 4, 2011 at 10:20 AM, sukran dhawan 
 sukrandha...@gmail.com wrote:

 for bst
 step 1 :count the number of nodes in a tree
 step2: traverse in inorder.after each node visit decrement n. if n == k
 then the result

 On Sun, Sep 4, 2011 at 12:33 AM, teja bala pawanjalsa.t...@gmail.comwrote:

 //Asked in MS please help me with the coding or Give an algorithm


 Write code to return the kth largest element in a tree ... function
 prototype is int fucnkth(node *root,int k)

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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*




-- 

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



Re: [algogeeks] Tejas networks

2011-09-04 Thread mohit verma
Q3 -
possible approaches -

if the tree is simply - i think we need to store two traversals inorder and
preorder in file.
otherwise in case of BST preorder traversal is sufficient to recreate the
tree.

for general tree - do a breadth first traversal and for each node next to it
put its parent value (assuming repeated values not allowed in tree). while
recreating the tree read two values at a time from file and attach the node
to its parent.

On Sun, Sep 4, 2011 at 2:54 PM, sukran dhawan sukrandha...@gmail.comwrote:



 -- Forwarded message --
 From: sukran dhawan sukrandha...@gmail.com
 Date: Sun, Sep 4, 2011 at 2:53 PM
 Subject: Re: [algogeeks] Tejas networks
 To: algogeeks@googlegroups.com


 reverse a linked list

 void reverse(struct node ** head)
 {
 struct node * last,*temp;

 last = *head;
 while(last-next != null)
 last = last-next;

 while(*head != last)
 {
 temp = *head;
 *head = (*head)-next;
 temp-next = last-next;
 last-next = temp
 }
 }

 On Sun, Sep 4, 2011 at 2:46 PM, Anup Ghatage ghat...@gmail.com wrote:

 Could you please give an example for question 3?

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.



Re: [algogeeks] Re: character count in array

2011-09-04 Thread mohit verma
hey guys
why hashing?
can't we simply sort the array of characters in-place - space complexity
O(1) .
and then simply rearrange the array in-place with character+frequency.

On Sun, Sep 4, 2011 at 3:13 PM, bharatkumar bagana 
bagana.bharatku...@gmail.com wrote:

 +1 rahul and +1 ankuj


 On Sat, Sep 3, 2011 at 11:37 AM, icy` vipe...@gmail.com wrote:

 Just use a hash to count frequency of something;  e.g. in ruby:
 ar= %w(a a b c a b b c d e a d e f)
 freq=Hash.new(0)
 ar.each {|c| freq[c]+=1}
 p freq

 #output
 #{a=4, b=3, c=2, d=2, e=2, f=1}

 you could only do it in place in O(1) only if your input array is
 already  2*(number of all possible characters) size, but you didnt
 mention size of input array.  For example, what if input was just
 [a,b,c,d,e]  ?  The size is 5.You cant just convert the input
 into  [a,1,b,1,c,1,d,1,e,1] without increasing the size to 10.   So
 hash is the better method.

 On Sep 3, 11:04 am, Ankuj Gupta ankuj2...@gmail.com wrote:
  if for all inputs you array remains of same size we can take it as
  constant space
 
  On Sep 3, 7:49 pm, rajul jain rajuljain...@gmail.com wrote:
 
 
 
 
 
 
 
   @ankuj  just want to clarify that in hashing method we require array
 of
   fixed size let say arr[26] , so is it considered as constant space or
 not?
 
   On Sat, Sep 3, 2011 at 8:02 PM, siddharam suresh 
 siddharam@gmail.comwrote:
 
sol already posted please search old thread
Thank you,
Sid.
 
On Sat, Sep 3, 2011 at 8:01 PM, Ankuj Gupta ankuj2...@gmail.com
 wrote:
 
If we take our input to be characters a-z ans A-Z then we require
fixed space which can be treated as O(1).
On Sep 3, 7:10 pm, teja bala pawanjalsa.t...@gmail.com wrote:
 this 'll work if u i/p the string in dis manner
 aaabbcc(consecutive same)
 a3b2c2
 
 #includestdio.h
 #includeconio.h
 main()
 {
 int x=1,i=0;
 char a[100];
 gets(a);
 while(a[i]!='\0')
 {
  while(a[i]==a[i+1])
  {
 x++;
 i++;
  }
  printf(%c%d,a[i],x);
  x=1;
  i++;
  }
 getchar();
 
 }
 
--
You received this message because you are subscribed to the Google
 Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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
 *BharatKumar Bagana*
 **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar
 *
 Mobile +91 8056127652*
 bagana.bharatku...@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.




-- 

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



Re: [algogeeks] Re: Need algorithm asap

2011-09-03 Thread mohit verma
Here is my soluion .
void bipartition(int a[],int p,int max)
{

if(p==max){return ;}

p++;

for(int i=p;imax;i++)
   {
   if(result[i]==1)   continue;
  result[i]=1;
 print_bipartition(result,a,max);
 bipartition(a,i,max);
 result[i]=0;

   }
}

void print_bipartition(int result[],int a[],int max)
{
printf({);
for(int k=0;kmax;k++)
 if(result[k]==1)
  printf(%d ,a[k]);
printf(} \t);
 printf({);
for(int k=0;kmax;k++)
if(result[k]==0)
  printf(%d ,a[k]);
printf(}\n);
return ;
}

Can someone help me reduce the time complexity?

On Sat, Sep 3, 2011 at 10:07 AM, Siddhartha Banerjee 
thefourrup...@gmail.com wrote:

 no of valid bipartitions are 2^n, thats what he meant I guess... ( if you
 do not want null set as one of the partitions then subtract 1 from
 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.




-- 

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



Re: [algogeeks] Re: Need algorithm asap

2011-09-03 Thread mohit verma

 this line is unnecessary



 if(result[i]==1)   continue;


I think this algo is good enough. But any improvements?


-- 

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



Re: [algogeeks] MICROSOFT

2011-09-03 Thread mohit verma
create a binary search tree by scanning the whole array and if the value
already exists increase count field in that node O(nlogn). Now traverse the
tree in any order by creating another tree with kery - count. O(nlogn).
Doing reverse inorder traversal print value field of each node count number
of times O(n).

overall complexity - O(nlogn)+O(nlogn)+O(n) = O(nlogn).

On Sat, Sep 3, 2011 at 11:16 PM, Siddhartha Banerjee 
thefourrup...@gmail.com wrote:

 perhaps we can make it O(mlogm), m= no of distinct elements... just create
 a hash table and store the count of the number of time elements occur...
 O(n), now sort the m elements and proceed as above...
 it is obviously not possible to do it faster than O(mlogm), where m = no of
 distinct elements...
 so order = O(n+mlogm)=O(mlogm)(???, assuming m!n)

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.



Re: [algogeeks] MICROSOFT

2011-09-03 Thread mohit verma
Ohh my bad. the complexity should be
O(nlogn) + O(mlogm) +O(m) = O(tlogt) where t=max(m,n)

On Sat, Sep 3, 2011 at 11:46 PM, mohit verma mohit89m...@gmail.com wrote:

 create a binary search tree by scanning the whole array and if the value
 already exists increase count field in that node O(nlogn). Now traverse the
 tree in any order by creating another tree with kery - count. O(nlogn).
 Doing reverse inorder traversal print value field of each node count number
 of times O(n).

 overall complexity - O(nlogn)+O(nlogn)+O(n) = O(nlogn).


 On Sat, Sep 3, 2011 at 11:16 PM, Siddhartha Banerjee 
 thefourrup...@gmail.com wrote:

 perhaps we can make it O(mlogm), m= no of distinct elements... just create
 a hash table and store the count of the number of time elements occur...
 O(n), now sort the m elements and proceed as above...
 it is obviously not possible to do it faster than O(mlogm), where m = no
 of distinct elements...
 so order = O(n+mlogm)=O(mlogm)(???, assuming m!n)

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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*




-- 

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



Re: [algogeeks] MICROSOFT

2011-09-03 Thread mohit verma
@dheeraj - for count sort we need to know the range the numbers are in.
Otherwise how will u initialize array keeping count?

On Sun, Sep 4, 2011 at 12:03 AM, Dheeraj Sharma dheerajsharma1...@gmail.com
 wrote:

 count sort in reverse order would help i guess :)


 On Sat, Sep 3, 2011 at 11:49 PM, mohit verma mohit89m...@gmail.comwrote:

 Ohh my bad. the complexity should be
 O(nlogn) + O(mlogm) +O(m) = O(tlogt) where t=max(m,n)


 On Sat, Sep 3, 2011 at 11:46 PM, mohit verma mohit89m...@gmail.comwrote:

 create a binary search tree by scanning the whole array and if the value
 already exists increase count field in that node O(nlogn). Now traverse the
 tree in any order by creating another tree with kery - count. O(nlogn).
 Doing reverse inorder traversal print value field of each node count number
 of times O(n).

 overall complexity - O(nlogn)+O(nlogn)+O(n) = O(nlogn).


 On Sat, Sep 3, 2011 at 11:16 PM, Siddhartha Banerjee 
 thefourrup...@gmail.com wrote:

 perhaps we can make it O(mlogm), m= no of distinct elements... just
 create a hash table and store the count of the number of time elements
 occur... O(n), now sort the m elements and proceed as above...
 it is obviously not possible to do it faster than O(mlogm), where m = no
 of distinct elements...
 so order = O(n+mlogm)=O(mlogm)(???, assuming m!n)

  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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*




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




 --
 *Dheeraj Sharma*
 Comp Engg.
 NIT Kurukshetra
 +91 8950264227


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.



Re: [algogeeks] Amazon - Interview Qn

2011-08-31 Thread Mohit kumar lal
SWAP Nth node's value with 1st node's value and N+1th node's value with last
node's value.We can do this by maintaining 3 pointer 1st one pints to start
node,2nd one points to Nth node and 3rd one points to last node...:)

On Wed, Aug 31, 2011 at 11:15 AM, Avinash Dharan avinashdha...@gmail.comwrote:

 That would work dheerjaj. Only thing is links reassignment should be taken
 care of.


 On Wed, Aug 31, 2011 at 10:40 AM, Dheeraj Sharma 
 dheerajsharma1...@gmail.com wrote:

 remove the 'n' nodes from the beginning..push in the stack..pop them up
 and insert at the end of linked list..till the stack becomes empty..do this
 for(m/n) times..m is length of list..
 correct me if  i am wrong


 On Wed, Aug 31, 2011 at 6:57 AM, Reynald Suz reynaldsus...@gmail.comwrote:

 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


 --
 Regards
 Reynald Reni
 Masters in Software Engineering
 CIT - 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.




 --
 *Dheeraj Sharma*
 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.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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 kumar lal
rit2009014
IIIT ALLAHABAD
contact@9454681805
kumarmohit...@gmail.com
mohitkumar...@yahoo.com
rit2009...@iiita.ac.in
http://profile.iiita.ac.in/rit2009014

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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 Qn

2011-08-31 Thread Mohit kumar lal
@akshat- can you provide any example or code for your idea...tht would help
me to understand your method in a better way..

On Wed, Aug 31, 2011 at 12:18 PM, Akshat Sapra sapraaks...@gmail.comwrote:



 This would take so much of memory and CPU computations. This question can
 be done very easily if you have n then at the junction you can store pointer
 to n-1th node and pointer to n+1th node. Then you have to just print from
 n-1th node to 0th node and then print from node.size()th to n+1th
 node!!!


 --


 Akshat Sapra
 Under Graduation(B.Tech)
 IIIT-Allahabad(Amethi Campus)
 --
 sapraaks...@gmail.com
 akshatsapr...@gmail.com
 rit2009...@iiita.ac.in
 sapraaks...@facebook.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.




-- 
Mohit kumar lal
rit2009014
IIIT ALLAHABAD
contact@9454681805
kumarmohit...@gmail.com
mohitkumar...@yahoo.com
rit2009...@iiita.ac.in
http://profile.iiita.ac.in/rit2009014

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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 Qn

2011-08-31 Thread Mohit kumar lal
I am really sorry to dissapoint you akshat but Question clearly says that it
is a singly linked list.So, it would be difficult for us to store n-1th
node's pointer with your method .

On Wed, Aug 31, 2011 at 12:37 PM, Akshat Sapra sapraaks...@gmail.comwrote:

 I have provided you the solution and I think you are experienced enough to
 make the solution yourself but I can provide you a Pseudocode.

 //Solution for Doubly linked list

 Inverse(node *start, node *end) {
  print(end);
 }

 print(node *start,node *end) {
   do {
print(end-data);
end = end-next;
}
while ( end != start )
 }

 call the functions two times
 inverse(0th node,n-1th node);
 inverse(nth node, list.size()th node);

 --


 Akshat Sapra
 Under Graduation(B.Tech)
 IIIT-Allahabad(Amethi Campus)
 --
 sapraaks...@gmail.com
 akshatsapr...@gmail.com
 rit2009...@iiita.ac.in
 sapraaks...@facebook.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.




-- 
Mohit kumar lal
rit2009014
IIIT ALLAHABAD
contact@9454681805
kumarmohit...@gmail.com
mohitkumar...@yahoo.com
rit2009...@iiita.ac.in
http://profile.iiita.ac.in/rit2009014

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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 - Coding Round-2 Qn

2011-08-31 Thread mohit verma
maintain two arrays: one for flags of nodes - true if both of the children
nodes satisfy bst condition otherwise false is not. Do it in BFS manner.If
after bst condition check, false set for a node then dont parse it down. And
for true nodes check down the subtrees and put flags flags till get true or
leaf node.

Now while traversing keep an array of parent nodes of each traversed node
whether it is false or true. After complete traversal of tree, for each
false nodes , in parent array put all ancestors of it to  NULL . The
remaining non-NULL nodes in parent array are Binary search subtrees.

Traversing only once. time : O(n) and space : n+n =O(n) again.

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

 WAP, Given a Binary Tree, find a sub-tree which is a Binary Search
 Tree. Optimize for space  Time

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.



Re: [algogeeks] Re: finding duplicates

2011-08-31 Thread mohit verma
@ dave- commplexity of radix sort is = O(n log n). so better use heap sort.

On Wed, Aug 31, 2011 at 4:07 PM, Dave dave_and_da...@juno.com wrote:

 @Bharatkumar: You've tacitly assumed that the data values are in the
 range 0 to n-1. That's not given in the problem statement.

 Dave

 On Aug 31, 1:16 am, bharatkumar bagana bagana.bharatku...@gmail.com
 wrote:
  bitset n   duplicates;// n- bit space..
  for(int i=0;in;i++)
  {
 if(duplicates[array[i]] ==1)
   print duplicate...
 else duplicate[array[i]]=1;}
 
  there is no comparison between any 2 numbers O(n) time .space is
  O(n)bits ...
 
 
 
 
 
  On Tue, Aug 30, 2011 at 5:18 PM, Dave dave_and_da...@juno.com wrote:
   Replying to myself... A radix sort takes O(n) extra space.
 
   Dave
 
   On Aug 30, 1:49 pm, Dave dave_and_da...@juno.com wrote:
@Kamakshii: With O(1) extra space, it can be done with O(n)
comparisons. Do a radix sort on the input (no comparisons), and then
check adjacent numbers for equality.
 
Dave
 
On Aug 30, 1:34 pm, Kamakshii Aggarwal kamakshi...@gmail.com
 wrote:
 
 develop an algorithm to find duplicates in a list of numbers
 without
   using a
 binary tree..if there are n distinct numbers in the list ,how many
   times
 must two numbers be compared for equality in your algorithm?what if
 all
 numbers are equal?
 
 --
 Regards,
 Kamakshi
 kamakshi...@gmail.com- Hide quoted text -
 
- Show quoted text -
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from 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
  *BharatKumar Bagana*
  **http://www.google.com/profiles/bagana.bharatkumar
 http://www.google.com/profiles/bagana.bharatkumar
  *
  Mobile +91 8056127652*
  bagana.bharatku...@gmail.com- Hide quoted text -
 
  - Show quoted text -

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.



Re: [algogeeks] Re: finding duplicates

2011-08-31 Thread mohit verma
=O(nlog n) for random k.

On Wed, Aug 31, 2011 at 9:15 PM, mohit verma mohit89m...@gmail.com wrote:

 @ dave- commplexity of radix sort is = O(n log n). so better use heap
 sort.


 On Wed, Aug 31, 2011 at 4:07 PM, Dave dave_and_da...@juno.com wrote:

 @Bharatkumar: You've tacitly assumed that the data values are in the
 range 0 to n-1. That's not given in the problem statement.

 Dave

 On Aug 31, 1:16 am, bharatkumar bagana bagana.bharatku...@gmail.com
 wrote:
  bitset n   duplicates;// n- bit space..
  for(int i=0;in;i++)
  {
 if(duplicates[array[i]] ==1)
   print duplicate...
 else duplicate[array[i]]=1;}
 
  there is no comparison between any 2 numbers O(n) time .space is
  O(n)bits ...
 
 
 
 
 
  On Tue, Aug 30, 2011 at 5:18 PM, Dave dave_and_da...@juno.com wrote:
   Replying to myself... A radix sort takes O(n) extra space.
 
   Dave
 
   On Aug 30, 1:49 pm, Dave dave_and_da...@juno.com wrote:
@Kamakshii: With O(1) extra space, it can be done with O(n)
comparisons. Do a radix sort on the input (no comparisons), and then
check adjacent numbers for equality.
 
Dave
 
On Aug 30, 1:34 pm, Kamakshii Aggarwal kamakshi...@gmail.com
 wrote:
 
 develop an algorithm to find duplicates in a list of numbers
 without
   using a
 binary tree..if there are n distinct numbers in the list ,how many
   times
 must two numbers be compared for equality in your algorithm?what
 if all
 numbers are equal?
 
 --
 Regards,
 Kamakshi
 kamakshi...@gmail.com- Hide quoted text -
 
- Show quoted text -
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from 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
  *BharatKumar Bagana*
  **http://www.google.com/profiles/bagana.bharatkumar
 http://www.google.com/profiles/bagana.bharatkumar
  *
  Mobile +91 8056127652*
  bagana.bharatku...@gmail.com- Hide quoted text -
 
  - Show quoted text -

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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*




-- 

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



Re: [algogeeks] graph

2011-08-31 Thread mohit verma
@ MAC , i think it was not right to inspect common nodes in different
cycles.

say  in the above picture the two inner nodes of inner cycle are out side
the bigger cycle (towards A) then co-ordinates of the inner  cycle will
change and no cycle nested but having common nodes.

On Wed, Aug 31, 2011 at 9:13 PM, MAC macatad...@gmail.com wrote:

 it was loops sharing common edges ,, (i said find all cycles and see if
 there is some cycles having coomon nodes between them  and he was not happy
 )



 On Wed, Aug 31, 2011 at 8:54 PM, Piyush Grover 
 piyush4u.iit...@gmail.comwrote:

 loop within a loop, what exactly that means??
 Nee to consider the planarity or two loops sharing common edge/s??


 On Wed, Aug 31, 2011 at 8:46 PM, MAC macatad...@gmail.com wrote:

 Q  The question asked in interview of a startup : suppose you have a
 graph as shown bellow : please see the attachment . The red dots are graph
 vertexes ( you can see 1 vertex alone , aloof )
  so you can see there are 2 cycles one inside another . How will you find
 such a scenario in a graph i.e. a cycle within a cycle.

 When i couldn't answer he asked how will you find strongly conected
 components of a graph (since it was follow up it MIGHT be related to
 solution but thought its good to share )


 any thoughts on these 2 questions
 --
 thanks
 --mac

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.




 --
 thanks
 --mac

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.



Re: [algogeeks] Re: finding duplicates

2011-08-31 Thread mohit verma
Is anything specific about digits of numbers given in above question? If no
then as i said
Yeah coz we compare the radix part in radix sort , so can't say exactly we
are comparing the numbers (but portion of it)

On Wed, Aug 31, 2011 at 9:27 PM, Dave dave_and_da...@juno.com wrote:

 @Mohit: No. Radix sort on a fixed data type is O(n) in time, and uses
 no data comparisons.

 Dave

 On Aug 31, 10:45 am, mohit verma mohit89m...@gmail.com wrote:
  @ dave- commplexity of radix sort is = O(n log n). so better use heap
 sort.
 
 
 
 
 
  On Wed, Aug 31, 2011 at 4:07 PM, Dave dave_and_da...@juno.com wrote:
   @Bharatkumar: You've tacitly assumed that the data values are in the
   range 0 to n-1. That's not given in the problem statement.
 
   Dave
 
   On Aug 31, 1:16 am, bharatkumar bagana bagana.bharatku...@gmail.com
   wrote:
bitset n   duplicates;// n- bit space..
for(int i=0;in;i++)
{
   if(duplicates[array[i]] ==1)
 print duplicate...
   else duplicate[array[i]]=1;}
 
there is no comparison between any 2 numbers O(n) time .space
 is
O(n)bits ...
 
On Tue, Aug 30, 2011 at 5:18 PM, Dave dave_and_da...@juno.com
 wrote:
 Replying to myself... A radix sort takes O(n) extra space.
 
 Dave
 
 On Aug 30, 1:49 pm, Dave dave_and_da...@juno.com wrote:
  @Kamakshii: With O(1) extra space, it can be done with O(n)
  comparisons. Do a radix sort on the input (no comparisons), and
 then
  check adjacent numbers for equality.
 
  Dave
 
  On Aug 30, 1:34 pm, Kamakshii Aggarwal kamakshi...@gmail.com
   wrote:
 
   develop an algorithm to find duplicates in a list of numbers
   without
 using a
   binary tree..if there are n distinct numbers in the list ,how
 many
 times
   must two numbers be compared for equality in your
 algorithm?what if
   all
   numbers are equal?
 
   --
   Regards,
   Kamakshi
   kamakshi...@gmail.com- Hide quoted text -
 
  - Show quoted text -
 
 --
 You received this message because you are subscribed to the Google
   Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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
*BharatKumar Bagana*
**http://www.google.com/profiles/bagana.bharatkumar
  http://www.google.com/profiles/bagana.bharatkumar
*
Mobile +91 8056127652*
bagana.bharatku...@gmail.com- Hide quoted text -
 
- Show quoted text -
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from 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*- Hide quoted text -
 
  - Show quoted text -

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.



Re: [algogeeks] graph

2011-08-31 Thread mohit verma
@mac - yeah you were right.
Normally we number the vertices and forget about their co-ordinates in
programming :)

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: finding duplicates

2011-08-31 Thread mohit verma
that is what i said  in above post. By portion or radix i mean : digit if
numbers are being sorted at radix 10.

On Wed, Aug 31, 2011 at 9:43 PM, Dave dave_and_da...@juno.com wrote:

 @Mohit: As I said, a radix sort does not use data comparisons. It
 extracts digits from the sort keys and uses the digits as
 subscripts. Other than moving the data around, this is the only use
 the radix sort makes of the sort keys.

 Dave

 On Aug 31, 11:06 am, mohit verma mohit89m...@gmail.com wrote:
  Is anything specific about digits of numbers given in above question? If
 no
  then as i said
  Yeah coz we compare the radix part in radix sort , so can't say exactly
 we
  are comparing the numbers (but portion of it)
 
 
 
 
 
  On Wed, Aug 31, 2011 at 9:27 PM, Dave dave_and_da...@juno.com wrote:
   @Mohit: No. Radix sort on a fixed data type is O(n) in time, and uses
   no data comparisons.
 
   Dave
 
   On Aug 31, 10:45 am, mohit verma mohit89m...@gmail.com wrote:
@ dave- commplexity of radix sort is = O(n log n). so better use
 heap
   sort.
 
On Wed, Aug 31, 2011 at 4:07 PM, Dave dave_and_da...@juno.com
 wrote:
 @Bharatkumar: You've tacitly assumed that the data values are in
 the
 range 0 to n-1. That's not given in the problem statement.
 
 Dave
 
 On Aug 31, 1:16 am, bharatkumar bagana 
 bagana.bharatku...@gmail.com
 wrote:
  bitset n   duplicates;// n- bit space..
  for(int i=0;in;i++)
  {
 if(duplicates[array[i]] ==1)
   print duplicate...
 else duplicate[array[i]]=1;}
 
  there is no comparison between any 2 numbers O(n) time
 .space
   is
  O(n)bits ...
 
  On Tue, Aug 30, 2011 at 5:18 PM, Dave dave_and_da...@juno.com
   wrote:
   Replying to myself... A radix sort takes O(n) extra space.
 
   Dave
 
   On Aug 30, 1:49 pm, Dave dave_and_da...@juno.com wrote:
@Kamakshii: With O(1) extra space, it can be done with O(n)
comparisons. Do a radix sort on the input (no comparisons),
 and
   then
check adjacent numbers for equality.
 
Dave
 
On Aug 30, 1:34 pm, Kamakshii Aggarwal 
 kamakshi...@gmail.com
 wrote:
 
 develop an algorithm to find duplicates in a list of
 numbers
 without
   using a
 binary tree..if there are n distinct numbers in the list
 ,how
   many
   times
 must two numbers be compared for equality in your
   algorithm?what if
 all
 numbers are equal?
 
 --
 Regards,
 Kamakshi
 kamakshi...@gmail.com- Hide quoted text -
 
- Show quoted text -
 
   --
   You received this message because you are subscribed to the
 Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to
 algogeeks@googlegroups.com.
   To unsubscribe from 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
  *BharatKumar Bagana*
  **http://www.google.com/profiles/bagana.bharatkumar
http://www.google.com/profiles/bagana.bharatkumar
  *
  Mobile +91 8056127652*
  bagana.bharatku...@gmail.com- Hide quoted text -
 
  - Show quoted text -
 
 --
 You received this message because you are subscribed to the Google
   Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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*- Hide quoted text -
 
- Show quoted text -
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from 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*- Hide quoted text -
 
  - Show quoted text -

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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

[algogeeks] Let's see if U can find the bug...

2011-08-30 Thread Mohit Gupta
*1.*
/* Print armstrong numbers from 1 to 500 */
/*1st version of prgrm: I am using pow function*/
#includestdio.h
#includeconio.h
#includemath.h
int main()
{
int num=1,temp,sum,r;
while(num=500){
  sum=0;
  temp=num;
  while(temp){
r=temp%10;
sum+=pow(r,3);
temp/=10;
  }
  if(sum==num)
printf(%d\n,num);
  num++;
}
getch();
return 0;
}

It prints :
1
370
371
407

But it does not print 153 which is also armstrong number. WHY???

BUT if I change:  pow(r,3) to r*r*r in codethen it prints:
1
153
370
371
407

WHY 153 was not printed if i use pow() function???

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: Given an array A[] and a integer num. Find four no.s in the array whose sum is equal to given num.

2011-08-28 Thread Mohit Goel
This code may also work .give any counter examples...


#includeiostream
using namespace std;
void  find_sum(int num,int k,int j,int b);
 void display(int i,int j);
#define MAX 8

int res[4];   //array to store
4 numbers..
int arr[MAX] ={2,3,4,1,6,9,8,10};
int main()
{
int b,k,j,num;
coutenter desired number\n;
cinnum;
k=0;
j=b=0;
find_sum(num,k,j,b);


return 0;
}
void  find_sum(int num,int k,int j,int b)
{
int p,i;
if(k MAX)
{
if(j==3  arr[k]== num )
{
res[b]=arr[k];
display(0,b);  //FOUND 4 NUMBER ,PRINT THEM

}
else if(j == 3  arr[k]!=num)
{
for(p=k+1;pMAX;p++)
{
if(arr[p] == num)
{
res[b] =arr[p];
 display(0,b); //FOUND 4 NUMBER ,PRINT THEM

break;


}
}


}
else
{
for(i=k;iMAX;i++)
{
res[b] =arr[i];
find_sum(num-arr[i],i+1,j+1,b+1);

}
}
}
}

void display(int i,int j)
{
cout\n;
int k;
for(k=0;k=j;k++)
cout res[k];
}

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] algo ques

2011-08-28 Thread Mohit kumar lal
 we can make a BST(Binary search tree) for this problem, suppose the path is
of length 10, and currently i am on 1st platform ,then this one should be in
our root node and children of this root would be 2 and 3...Similarly we
iterate until we find 10 in every leaves of BST.Then we can easily print all
the possible paths.

On Sun, Aug 28, 2011 at 7:47 PM, prashant thorat
prashantnit...@gmail.comwrote:

 yes, u are correct!! thanks

 On Sun, Aug 28, 2011 at 7:39 PM, Kamakshii Aggarwal kamakshi...@gmail.com
  wrote:

 @prashant:
 if u remove else from this line
 else if(lenght+2 = N)
 { Printf ( --two steps --) call printPath (length+2) }
 i think then the code will work properly.
 correct me if i am wrong
 On Sun, Aug 28, 2011 at 7:01 PM, prashant thorat 
 prashantnit...@gmail.com wrote:

 sorry, pls ignore above code ..a bit modifie code

 I'm passing length  = 0


 printPath (int length)
 {
  if(lenght == N) return;
 else
 {
   if(lenght+1 = N)
  { Printf ( --one step --) call printPath (length+1) }

   else if(lenght+2 = N)
 { Printf ( --two steps --) call printPath (length+2) }

   else
return;
 }
 On Sun, Aug 28, 2011 at 6:54 PM, Kamakshii Aggarwal 
 kamakshi...@gmail.com wrote:

 what is the initial value of length that u r passing??

 On Sun, Aug 28, 2011 at 6:47 PM, prashant thorat 
 prashantnit...@gmail.com wrote:

 Hi, you can do this by recursion ,

 printPath (int length)
 {
  if(lenght == N) return;
 else
 {
   if(lenght+1 = N)  { Printf ( --one step --) call printPath
 (length+1) }
  else if(lenght+2 = N)  { Printf ( --two steps --) call printPath
 (length+2) }
 else
 return;

 }
 }
 On Sun, Aug 28, 2011 at 5:42 PM, himanshu kansal 
 himanshukansal...@gmail.com wrote:

 you have a path of N steps
 at every step, you can take onl;y 1 step or 2 steps.

 how to print all the possible paths that you can take..

 PS: please dont give the exact code.your approaches will be
 appreciated:)

 --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Yours affectionately,
 Prashant Thorat
 Computer Science and Engg. Dept,
 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.




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




 --
 Yours affectionately,
 Prashant Thorat
 Computer Science and Engg. Dept,
 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.




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




 --
 Yours affectionately,
 Prashant Thorat
 Computer Science and Engg. Dept,
 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.




-- 
Mohit kumar lal
rit2009014
IIIT ALLAHABAD
contact@9454681805
kumarmohit...@gmail.com
mohitkumar...@yahoo.com
rit2009...@iiita.ac.in
http://profile.iiita.ac.in/rit2009014

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: How to save a binary search tree space efficiently

2011-08-28 Thread mohit verma
we  can use m-way search tree to save some space. And reconstruction is
pretty simple as all of us know. any suggestions?

On Sun, Aug 28, 2011 at 10:43 PM, Dhriti Khanna dhriti0...@gmail.comwrote:

 @ Navneet: See if the tree is: 6
4   7
   3 5  8

 Then the preorder traversal is : 6 4 3 5 7 8
 And using this preorder traversal and inserting them in the tree one by
 one, we generate this exact tree.



  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.



Re: [algogeeks] Re: Print tree like a tree

2011-08-28 Thread mohit verma
if the number of levels is known - while traversing the tree in BFS order
keep a loop to print spaces in number- n/2,n/2-1,n/2-2 and so on ,before
entering at each level. Now if you find any child node empty just print a
blank space in place of its value.

On Sun, Aug 28, 2011 at 10:01 PM, Dave dave_and_da...@juno.com wrote:

 @Navneet: I suggest that you do an in-order traversal. Assign x values
 to the nodes sequentially, with y values based on the depth from the
 root. Thus, in your example, d has coordinates (0,2), b: (1,1), e:
 (2,2), a: (3,0), f: (4,2), c: (5,1), g: (6,2).

 Dave

 On Aug 28, 9:46 am, Navneet Gupta navneetn...@gmail.com wrote:
  Hope the question is clear. Basically you need to print a given tree
  such that spaces will depict the left/right relation at every level.
 
  output should be something like
  a
   b c
d   e  f   g
 
  Levels are separated by new lines. Notice that space between nodes at
  higher levels increases with the number of levels we have. Assume a
  max of 10 levels. But the algorithm should scale.
 
  --
  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.




-- 

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



Re: [algogeeks] Re: Print tree like a tree

2011-08-28 Thread mohit verma
i 've already mentioned if number of levels is known. Well for dynamic
case we can print the tree from bottom level to top using recursion and at
each increment if level after printing the values we pass back the level
number and accordingly we print space . The output will look like this-

 5  6  7  8
   2  4  2
 1  3
   9

Could someone pleases modify this solution to print tree in top-down
fashion?

On Sun, Aug 28, 2011 at 11:38 PM, Rishabbh A Dua duarish...@gmail.comwrote:

 mohit, wat if the tree is growing dynamically?

 On Sun, Aug 28, 2011 at 11:27 PM, mohit verma mohit89m...@gmail.comwrote:

 if the number of levels is known - while traversing the tree in BFS order
 keep a loop to print spaces in number- n/2,n/2-1,n/2-2 and so on ,before
 entering at each level. Now if you find any child node empty just print a
 blank space in place of its value.


 On Sun, Aug 28, 2011 at 10:01 PM, Dave dave_and_da...@juno.com wrote:

 @Navneet: I suggest that you do an in-order traversal. Assign x values
 to the nodes sequentially, with y values based on the depth from the
 root. Thus, in your example, d has coordinates (0,2), b: (1,1), e:
 (2,2), a: (3,0), f: (4,2), c: (5,1), g: (6,2).

 Dave

 On Aug 28, 9:46 am, Navneet Gupta navneetn...@gmail.com wrote:
  Hope the question is clear. Basically you need to print a given tree
  such that spaces will depict the left/right relation at every level.
 
  output should be something like
  a
   b c
d   e  f   g
 
  Levels are separated by new lines. Notice that space between nodes at
  higher levels increases with the number of levels we have. Assume a
  max of 10 levels. But the algorithm should scale.
 
  --
  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.




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




 --
 Rishabbh A Dua

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.



Re: [algogeeks] Re: Print tree like a tree

2011-08-28 Thread mohit verma
I think for that we need to re-traverse the tree - in first recursion
counting the levels and second time printing values and spaces accordingly.

On Sun, Aug 28, 2011 at 11:50 PM, mohit verma mohit89m...@gmail.com wrote:

 i 've already mentioned if number of levels is known. Well for dynamic
 case we can print the tree from bottom level to top using recursion and at
 each increment if level after printing the values we pass back the level
 number and accordingly we print space . The output will look like this-

  5  6  7  8
2  4  2
  1  3
9

 Could someone pleases modify this solution to print tree in top-down
 fashion?

 On Sun, Aug 28, 2011 at 11:38 PM, Rishabbh A Dua duarish...@gmail.comwrote:

 mohit, wat if the tree is growing dynamically?

 On Sun, Aug 28, 2011 at 11:27 PM, mohit verma mohit89m...@gmail.comwrote:

 if the number of levels is known - while traversing the tree in BFS order
 keep a loop to print spaces in number- n/2,n/2-1,n/2-2 and so on ,before
 entering at each level. Now if you find any child node empty just print a
 blank space in place of its value.


 On Sun, Aug 28, 2011 at 10:01 PM, Dave dave_and_da...@juno.com wrote:

 @Navneet: I suggest that you do an in-order traversal. Assign x values
 to the nodes sequentially, with y values based on the depth from the
 root. Thus, in your example, d has coordinates (0,2), b: (1,1), e:
 (2,2), a: (3,0), f: (4,2), c: (5,1), g: (6,2).

 Dave

 On Aug 28, 9:46 am, Navneet Gupta navneetn...@gmail.com wrote:
  Hope the question is clear. Basically you need to print a given tree
  such that spaces will depict the left/right relation at every level.
 
  output should be something like
  a
   b c
d   e  f   g
 
  Levels are separated by new lines. Notice that space between nodes at
  higher levels increases with the number of levels we have. Assume a
  max of 10 levels. But the algorithm should scale.
 
  --
  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.




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




 --
 Rishabbh A Dua

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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*




-- 

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



Re: [algogeeks] Re: Problem on overflow

2011-08-28 Thread mohit verma
if( unsigned int (a) + unsigned int (b)  0) return overflow else return
ok;

On Sun, Aug 28, 2011 at 7:23 PM, saurabh singh saurab...@gmail.com wrote:

 @avinash in that case the number will become negative,It wont remain a
 satisfactory input.Try to think logically and believe me once you get the
 logic you will relent why there is no option to delete previous
 mails...,


 On Sun, Aug 28, 2011 at 6:32 PM, Dave dave_and_da...@juno.com wrote:

 @Avinash: Give an example.

 Dave

 On Aug 28, 7:00 am, Avinash LetsUncomplicate.. avin.2...@gmail.com
 wrote:
  @dave i was saying if user input a .. he can enter aintmax then how
  to detect overflow?

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.




-- 

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



Re: [algogeeks] Adding Two no without using any operator...??

2011-08-27 Thread Mohit kumar lal
int add(int a, int b)
{
if (!a)
return b;
else
return add((a  b)  1, a ^ b);
}

On Sun, Aug 28, 2011 at 12:54 AM, sagar pareek sagarpar...@gmail.comwrote:

 yeah one option is half adder with xor and and operators

 one more solution

 http://www.ideone.com/B07bn


 On Sun, Aug 28, 2011 at 12:41 AM, Gaurav Menghani 
 gaurav.mengh...@gmail.com wrote:

 I guess you mean without using any 'arithmetic operator'. If yes, it
 can be done with XOR and AND operators.

 Not sure how it can be done otherwise, without using any kind of
 operators AT ALL.

 On Sun, Aug 28, 2011 at 12:37 AM, Brijesh brijeshupadhyay...@gmail.com
 wrote:
  How to add two nos without using any operator...?
 
  --
  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/-/MpNKzlE3UuwJ.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from 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.




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




-- 
Mohit kumar lal
rit2009014
IIIT ALLAHABAD
contact@9454681805
kumarmohit...@gmail.com
mohitkumar...@yahoo.com
rit2009...@iiita.ac.in
http://profile.iiita.ac.in/rit2009014

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] map problem

2011-08-24 Thread mohit verma
hey guys ,
i want to store 3 values in stl map  making float as key value.
I am doing something like this -
  typedef const int twoint[2];
  mapfloat,twoint mmap;
but when i try to insert using make_pair() , compiler shows some error.
could someone tell me how to include these 2 more values without using extra
map?


-- 

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



Re: [algogeeks] Re: map problem

2011-08-24 Thread mohit verma
i think u guys dint get my question . what i want to do is : (1 float and 2
intergers) in a single map entry with float key value.
 i did it this way:

typedef const int twoint[2];

mapfloat,twoint mmap;

for inserting values i dint make any make_pair() function but used the
default one like this-
twoint tint;

cintint[0]tint[1];

mmap.insert(makepair(f,tint));
but the compiler shows error. Do i need to redefine make_pair() or any other
way to store more than 2 values in map?


On Wed, Aug 24, 2011 at 10:31 PM, Nikhil Kumar nikhil.nsit...@gmail.comwrote:

 Post your pair functions ..I'm sure you're wrong there!

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.



Re: [algogeeks] Re: Doublly link list

2011-08-24 Thread Mohit kumar lal
it might cause STACK OVERFLOW for larger size of lists.

On Thu, Aug 25, 2011 at 2:04 AM, Abhishek mailatabhishekgu...@gmail.comwrote:

 in brief,
 in the next pointer put the XOR value of previous and next block address.
 when you want to access the previous node just do the XOR operation with
 next block address
 and for next node do the XOR operation with previous block address.
 it will require an extra variable to maintain either previous node address
 or next node address.

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

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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 kumar lal
rit2009014
IIIT ALLAHABAD
contact@9454681805
kumarmohit...@gmail.com
mohitkumar...@yahoo.com
rit2009...@iiita.ac.in
http://profile.iiita.ac.in/rit2009014

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: Re: [algogeeks] Re: array question

2011-08-15 Thread mohit verma
thanks guys.

On Mon, Aug 15, 2011 at 1:12 PM, Nikhil Veliath nve...@gmail.com wrote:

 Dave tu mahan hai . . .  .
 -- Forwarded message --
 From: Dipankar Patro dip10c...@gmail.com
 Date: 14 Aug 2011 23:27
 Subject: Re: [algogeeks] Re: array question
 To: algogeeks@googlegroups.com

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




 --

 ___


 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

[algogeeks] array question

2011-08-14 Thread mohit verma
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.



Re: [algogeeks] array question

2011-08-14 Thread mohit verma
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.



[algogeeks] how to find K most significant digit of a number..???

2011-08-13 Thread Mohit Goel


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Adobe Interview Question

2011-08-13 Thread Mohit Goel
there are 5 possibilities ..5th one is_12_..other as specified by
ankit...


t(1) =2  (it can directly jump to anathor bank)
t(2) =3 ( _2_,_1_,_12_)

t(3) =5...
thats how fibonnaci goes on plz correct if 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.



Re: [algogeeks] Re: Problems on Linked List

2011-08-11 Thread mohit verma
hey guys , can't it be like this without reversing list-

int rec_iterate(Node head1,Node *head2)
{
if(head1 ==NULL ) return 1;
   if(rec_iterate(head1-n,head2) == 0) return 0;
if (head1-value == (*head2)-value)
 { *head2=(*head2)-next;
return 1;
  }
  else return 0;
}

provided lists are of same length.

On Thu, Aug 11, 2011 at 1:30 AM, Don dondod...@gmail.com wrote:

 Q1: The function below reverses a linked list in place. Call it on one
 of the lists, compare the resulting list to the other list. Then call
 it again to put the list back in its original order.

 list Reverse(list head)
 {
  list T, prv, nxt;

  prv = head;
  for(T = head-next; T; T = nxt)
  {
nxt = T-next;
T-next = prv;
prv = T;
T = nxt;
  }
  head-next = 0;
  return prv;
 }

 Q2:
 delete(node *d)
 {
  if (d-next)
  {
node nxt = d-next;
d-value = nxt-value;
d-next = nxt-next;
free nxt;
  }
  else
  {
for(node p = head; p; p = p-next)
  if (p-next == d)
  {
p-next = 0;
free d;
   }
  }
 }

 On Aug 10, 1:14 pm, Piyush Kapoor pkjee2...@gmail.com wrote:
  Q1)Two linked Lists are given,i.e,their head pointers are given,and the
  problem is to check if the second one is reverse of the first one.Give
 the
  most efficient algo for it.
  Q2)A linked list is given,and one of its nodes is given.The problem is to
  delete the given node from the linked list.(The head node is not given).
  (In both of the above cases,the linked lists are singly linked lists.)
  --
  *Regards,*
  *Piyush Kapoor,*
  *2nd year,CSE
  IT-BHU*

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.



Re: [algogeeks] Design a concurrent hash table

2011-08-11 Thread mohit verma
open addressing with  fairness : going up on even collision and going down
on odd collision.

On Thu, Aug 11, 2011 at 3:45 PM, Navneet Gupta navneetn...@gmail.comwrote:

 Q. Design a concurrent hash table with as much as concurrency as possible.
 System has multiple readers and writers. System will crash if a reader or
 writer is reading or writing from a location which is being updated by some
 writer. We need to prevent crash.

 It is pretty much an open-ended question, so basically looking for
 strategies.

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




-- 

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



[algogeeks] Novell questions

2011-08-11 Thread mohit verma
Hey guys,

can anyone post some written and interview question asked by Novell?

-- 

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



Re: [algogeeks] Re: Microsoft written!!!

2011-08-10 Thread Mohit Goel
   10
 4  5
   2  7  6 11
   1 39   8 12  13   14   15


i think we should first  find the parent of the particular node ..then apply
the concept as told by Brijesh on it 

p =parent(q);
r = parent(p);
count =1;
while(p ==isright(r))
{
p=r;
r=parent(r);
count++;
if(r==root)
break;

}

if(d =right(r))
{
while(count!=0)
{
if(d-left)
d=d-left;
else d=d-right;
count--;
}
}
else return NULL;
o/p=d-value;

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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 written!!!

2011-08-10 Thread Mohit Goel
@muthu raj:
it will also come out ,when loop condition will not be statisfied.i.e when
'p' is not the right child of its parent...in such a case it will not reach
root ..
in the ex given by u   it will stop at 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.



[algogeeks] constness in c++

2011-08-08 Thread mohit verma
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.



Re: [algogeeks] constness in c++

2011-08-08 Thread mohit verma
No .. in this case it  flags error.

On Mon, Aug 8, 2011 at 7:58 PM, Dipankar Patro dip10c...@gmail.com wrote:

 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.




-- 

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



Re: [algogeeks] constness in c++

2011-08-08 Thread mohit verma
got it.. thanks guys

On Mon, Aug 8, 2011 at 8:00 PM, mohit verma mohit89m...@gmail.com wrote:

 No .. in this case it  flags error.


 On Mon, Aug 8, 2011 at 7:58 PM, Dipankar Patro dip10c...@gmail.comwrote:

 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.




 --
 
 *MOHIT VERMA*




-- 

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



  1   2   >