Re: [algogeeks] Immediate interview ASP.Net/Silverlight Developer -- NY

2011-03-10 Thread Pramod Negi
you guys going to get everone from this group only?

On Fri, Mar 11, 2011 at 12:11 AM, Sam Riley samrileyrecrui...@gmail.comwrote:

 Dear Folks,
 Wishes for the Day !!!
 We Need consultant for ASP.Net/Silverlight Developer
 Please share suitable profiles to s...@panzersolutions.com

 *Job Title   :  ASP.Net/Silverlight Developer
 Location   :  NYC, NY
 Duration  :   6 Months
 Rate   :   Market
 Local NY/NJ/CT  Only *

 ASP.Net/Silverlight Developer Needed ASAP.
 --
 Thanks and Best Regards,
 Sam Riley | Sr Technical Recruiter
 Email: s...@panzersolutions.com
 Direct: 201-710-8278

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

2010-08-08 Thread Pramod Negi
Search XoR List on Wiki

On Sun, Aug 8, 2010 at 10:19 AM, UMESH KUMAR kumar.umesh...@gmail.comwrote:

 how to convert Doubly Link list to a Singly link list without changes
 the Structure of the list if possible or not ,if possible then try to
 discus of that problem.


 thanks and Regards
 Umesh kumar

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

2010-08-07 Thread Pramod Negi
Already posted

compare pair wise i.e a[0] and a[1]a[2] and a[3]..
leave out last 4 elements...
repeated element can be found in 3 comparison for these 3 elements...

total no of comparison in worst case
(n/2+1)


Thanks
Pramod Negi

On Sat, Aug 7, 2010 at 7:14 PM, ankur bhardwaj ankibha...@gmail.com wrote:

 we can do one thing. compare first element with all others. if it matches
 with any of them, we have found our number, else leave the first number and
 now the required number is available (n/2)+1 times in the rest of the array,
 which can be found in 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 algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com.
To unsubscribe from 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] Find the duplicate

2010-08-05 Thread Pramod Negi
compare pair wise i.e a[0] and a[1]a[2] and a[3]..

leave out last 4 elements...

repeated element can be found in 3 comparison for these 3 elements...


total no of comparison in worst case
(n/2+1)

Negi

On Thu, Aug 5, 2010 at 10:55 PM, Shiv ... shivsinha2...@gmail.com wrote:

 In constant space??? How? will you please elaborate?



 On Thu, Aug 5, 2010 at 9:29 PM, dinesh bansal bansal...@gmail.com wrote:

 If I understand the question correctly... there is an array of size n
 which has n/2 distinct elements and one element is repeated n/2 times.

 For e.g.:
n = 4:   1 2 3 3
n = 61 2 3 4 4 4
n = 81 2 3 4 5 5 5 5

 So now this problem can be reduced to finding the first duplicate element
 in the array because remaining other elements will be unique. I think this
 can be done in linear time.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com.
To unsubscribe from 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] Permutation.................

2010-08-01 Thread Pramod Negi
http://pramnegi.blogspot.com/2009/11/dons-permutaion.html

Thanks
Pramod Negi

On Sun, Aug 1, 2010 at 4:30 PM, UMESH KUMAR kumar.umesh...@gmail.comwrote:

  Write a C  code for generate all possible Permutation
  as:- 1 2 3
 Total no. of Per=6
 also print all permutation
 as:- 1 2 3
1 3 2
 2 1 3
2 3 1
3 1 2
   3 2 1
 if inpute is 1 2 3 2
  total no of permutation = 12

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com.
To unsubscribe from 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 BST's

2010-07-30 Thread Pramod Negi
Follow up on Catalon Nubmer...


On Fri, Jul 30, 2010 at 10:44 AM, Amit Jaspal amitjaspal...@gmail.comwrote:

 n is clearly a number lets say 3 then BST's with 1,2,3 values as key are to
 be calculated


 On Fri, Jul 30, 2010 at 9:08 AM, Apoorve Mohan apoorvemo...@gmail.comwrote:

 @AMIT: what does n represents?


 On Fri, Jul 30, 2010 at 5:46 AM, sharad kumar aryansmit3...@gmail.comwrote:

 @amit is it BST or binary tree??cos BST is unique rite???binary tree meas
 use catalan numbers 2nCn/(n+1)!



 On Thu, Jul 29, 2010 at 9:56 PM, amit amitjaspal...@gmail.com wrote:

 Given the numbers from 1 to n, write an algorithm to find how many
 distinct binary search trees can be formed.. eg n=4, no of distinct
 bst's are 14. ??

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




 --
 yezhu malai vaasa venkataramana Govinda Govinda

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




 --
 regards

 Apoorve Mohan

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




 --
 Amit Jaspal
 Btech IT IIIT- Allahabad

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com.
To unsubscribe from 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: bits

2010-06-13 Thread Pramod Negi
From last few days I'm seeing the question that is coming here is not
algorithm specific.
Purpose of this group is achieved or defeated???


Thanks
Pramod Negi

On Sun, Jun 13, 2010 at 9:48 PM, jalaj jaiswal jalaj.jaiswa...@gmail.comwrote:

 hey i too have a doubt... and its just 1 ... i'll not ask c/c++ again,,,

 we have a union a{
int i;
char ch[4];
 }
 int here is of 4 bytes.
 i initialise i=512...
 what value will ch[0] get the upper 8 bits or the lower 8 bits... is it big
 endian or little endian dependent... please explain this ??


 On Sun, Jun 13, 2010 at 9:43 PM, Rohit Saraf 
 rohit.kumar.sa...@gmail.comwrote:

 I agree mass bombarding with such questions is not very good.. but one
 doesn't join groups and all for getting a few doubts cleared.
 Anyways, i have no problem with anything. :D

 --
 Rohit Saraf
 Second Year Undergraduate,
 Dept. of Computer Science and Engineering
 IIT Bombay
 http://www.cse.iitb.ac.in/~rohitfeb14http://www.cse.iitb.ac.in/%7Erohitfeb14


 On Sun, Jun 13, 2010 at 9:26 PM, souravsain souravs...@gmail.com wrote:

 and @rohit you will get better insight into the topic by more expert
 people by posting the question in right forum. I guess thats a win-win
 situation for one who has the question as he is get to know more and
 for people you are interested in going through C++ questions as they
 will read views from many more experts :)

 On Jun 13, 7:31 pm, Rohit Saraf rohit.kumar.sa...@gmail.com wrote:
  @Souravsain : Is there any serious problem in this. Anyone can just add
 a
  [C++] in the subject and uninterested people can make filters in gmail
 :)
 
  --
  Rohit Saraf
  Second Year Undergraduate,
  Dept. of Computer Science and Engineering
  IIT 
  Bombayhttp://www.cse.iitb.ac.in/~rohitfeb14http://www.cse.iitb.ac.in/%7Erohitfeb14
 
 
 
  On Sun, Jun 13, 2010 at 6:35 PM, souravsain souravs...@gmail.com
 wrote:
   @divya
 
   Lets keep discussions in t his group limited to Algos and problems
   neutral to any language.
 
   Request you to post these C++ / C language specific questions to
 those
   language specific groups. This will not only help this group remain
   confined to its core purpose but will help you get better insights to
   ur problem by language specific geeks there. For C++ I would
 recommend
   you to try the group
  http://groups.google.co.in/group/comp.lang.c++.moderated/topics?hl=en
 .
 
   Regards,
   Sourav
 
   On Jun 13, 2:29 pm, divya sweetdivya@gmail.com wrote:
tell the o/p of following with explanations
 
1. #includestdio.h
int main()
{
  struct value
{
int bit1:1;
int bit3:4;
int bit4:4;
 
}bit;
 
printf(%d\n,sizeof(bit));
return 0;
 
}
 
2.
#includestdio.h
int main()
{
struct value
{
int bit1: 1;
int bit3: 4;
int bit4: 4;} bit={1,2,2};
 
printf(%d %d %d\n,bit.bit1,bit.bit3,bit.bit4);
return 0;
 
}
 
3 can bit field be used in union??
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algoge...@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 algogeeks%2bunsubscr...@googlegroups­.com
   .
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.- 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 algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 With Regards,
 Jalaj Jaiswal
 +919026283397
 B.TECH IT
 IIIT ALLAHABAD

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

Re: [algogeeks] Re: ds

2010-06-13 Thread Pramod Negi
Hello All,

What every algorithm mentioned above have some problem.



The Recursive swapping won’t work if you don’t have 2^n elements.

Same with getting the indexes, it will form a cycle.



Thanks

Pramod Negi




On Fri, Jun 11, 2010 at 7:09 PM, sharad kumar sharad20073...@gmail.comwrote:

 excellent soln!!

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com.
To unsubscribe from 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] Where does OS scheduling run??

2010-05-17 Thread Pramod Negi
Hello,



There exists differnet google groups for OS related queries. Could you
please move out your discussion there.



Thanks

Pramod Negi


On Thu, May 6, 2010 at 5:34 AM, Yalla Sridhar sridhar2...@gmail.com wrote:

 yea if your processor has multiple cores or is Hyper Threading support then
 it can execute more than 1 instruction concurrently.


 On Thu, May 6, 2010 at 12:10 AM, praba garan prabagara...@gmail.comwrote:

 Windows Task Manager Performance tab shows the presence of two processors.
 Will 2 instructions be executed concurrently??

 With Regards,
 Prabagaran.



 On Wed, May 5, 2010 at 4:56 PM, Varun Nagpal varun.nagp...@gmail.comwrote:

 I guess with Virtual machines, instructions that simulate instructions
 of microprocessor are scheduled onto the real processor. But good
 question is how the scheduling of real microprocessor instructions
 done in a virtual machine. And the answer is again that its done on
 virtual processor, which essentially has all hardware components of
 real processor modeled in software. All sub-parts of this software
 representing essential hardware components, again run synchronously
 (in parallel) either at instruction accurate level or cycle accurate
 level.

 All new processor that are designed as of today, are first mostly are
 verified using simulators written in hardware description languages
 like VHDL/SystemVerilog/SystemC and then simulated either in software
 or hardware. For hardware simulation, in some cases its eventually
 possible to create them on FPGA's and verify before they are sent to
 fab lab. Its an arduous task.
 For example, you can get HDL code for free for SUN Open Sparc
 processor and can flash it on FPGA.

 So It doesn't really matter whether your processor is real or virtual,
 so you need to understand architecture principles and some digital
 electronics to  understand at hardware(VLSI ) level

 Intel x86 and now x64 are the most popular architectures. Other
 popular architectures are ARM, MIPS, SPARC, PowerPC, etc.
 You should probably read  the book: Computer Architecture, by hennrey
 Peterson


 On Tue, May 4, 2010 at 10:49 PM, praba garan prabagara...@gmail.com
 wrote:
  I think it is necessary to study the full architecture of INTEL
 MotherBoard
  to get a full picture.
  How does scheduling happen incase of Virtual Machines??
  Then how does a packet coming to the Guest OS is sent to Guest OS.
  ie, either directly to Guest OS or through Host OS.
  With Regards,
  Prabagaran.
 
 
  On Mon, May 3, 2010 at 12:25 PM, Varun Nagpal varun.nagp...@gmail.com
 
  wrote:
 
  I think its a good question and fairly complicated to explain at
  hardware(RTL) level. Anyways, let me give it a try :
 
  You suggested that only 1 instruction is executed by one processor,
  which is not true(if you have read computer architecture). Briefly,
  lets assume the instruction pipeline(assuming only single hardware
  thread) is filled with instructions from the present thread(or
  process) of execution. Assume number of pipeline stages to be 20. In
  the pipeline, 20 instructions from the current instruction control
  flow are executing synchronously on every clock tick. Depending upon
  the design of pipeline, data from registers/memory is read in
  different pipeline stages. Also there may also be many execution
  stages(ALU) before the data is written to register/memory.
 
  The OS kernel keeps a track of all the threads/processes presently
  executing, active, waiting, suspended etc. in memory in the form of a
  data structure, which is to say that it always knows the next
  thread/process it needs to schedule on to the processor. I think it
  has a compare register that stores an arbitrary number(as decided by
  kernel) of clock ticks for a time slice expiry and keeps another
  counter register to keep track of time slice expiration for present
  thread. At every clock tick, it increments the counter register and
  compares it with compare register. This summing and comparison is done
  by inserting an instruction in the current instruction flow.  The
  point is that a clock interrupt is generated whenever the values of
  the counter and the compare registers match. When this does occur, the
  next PC value,registers etc(i.e its context information) is pushed
  onto the stack and a jump is made to an area in memory storing an
  interrupt vector table. I also assume that when this jump is made, the
  OS kernel supplies some information to the jump instruction about the
  next thread to be executed. This information maybe stored in another
  dedicated register. Now by using this information and interrupt vector
  table, it can find out the memory address of next thread(ii.e next
  instruction) to be executed. The PC including other registers is then
  simply loaded with context information of the new thread.
 
  Important thing here is again that when all of this is happening, the
  pipeline may still be executing instructions from the previous

Re: [algogeeks] Why is inorder traversal necessary to reconstruct a binary tree?

2010-04-08 Thread Pramod Negi
why only Preorder and Postorder is not suffice.
consider Two Binary Tree

Root = A
Left Chid = B

Preorder: A,B
Postorder: B,A

and
Root = A
Right Child = B

Preorder: ,A,B
Postorder: B,A


for given preorder and postorder two different binary trees can be formed

Thanks
Pramod Negi


On Thu, Apr 8, 2010 at 10:53 PM, Himanshu Aggarwal
lkml.himan...@gmail.comwrote:

 For a binary tree , if we are given an inorder traversal and a
 preorder/postorder/level-order traversal, we can always reconstruct back the
 binary tree. This technique can be used to save and restore the binary tree
 efficiently.

 I have read that it is necessary to have an inorder traversal to
 reconstruct the tree. i.e. if we are given a preorder and a postorder
 traversal, the binary tree can not be reconstructed.

 Can someone help me in understanding why this is so? i.e. why is inorder
 traversal a mandatory requirement. Why can not we reconstruct the tree with
 a given preorder and a postorder

 Thanks to everyone for their suggestions and replies.

 ~Himanshu Aggarwal

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com.
To unsubscribe from 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] Finding youngest common ancestor of two nodes in a binary tree

2010-04-07 Thread Pramod Negi
could you please elucidate more??

On Wed, Apr 7, 2010 at 10:34 PM, Himanshu Aggarwal
lkml.himan...@gmail.comwrote:

 For a given binary tree, given the root and two node pointers, how can we
 find their youngest common ancestor.

 Say the node is like:

 struct node{
int data;
struct node*left, *right;
 };

 i.e the father field is not there.

 Please note that it is not a binary search tree, but just a binary tree.

 Thanks,
 Himanshu

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com.
To unsubscribe from 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 a BST into sorted doubly linked list...

2010-03-28 Thread Pramod Negi
This is the best description.

http://cslibrary.stanford.edu/109/TreeListRecursion.html

Thanks
Pramod Negi


On Sun, Mar 28, 2010 at 1:39 PM, Piyush Verma 114piy...@gmail.com wrote:

 How can we convert a BST into a sorted doubly linked list?
  i have the solution that i traverse BST in inorder traversal and
 storing elements in doubly linked list.
 anyone has any best solution.

 --
 Piyush Kumar Verma
 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 algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com.
To unsubscribe from 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: Largest span of Increasing Pair in an array

2010-03-15 Thread Pramod Negi
Hello Saurabh,

can you explain the algo??

On Sun, Mar 14, 2010 at 9:55 PM, saurabh gupta sgup...@gmail.com wrote:

 O(N)

 my @a = @ARGV;
 my ($m, $j, $k, $l) = (0, 0, 0, 0);
 my $len = 0;
 my $curr = 0;
 for (my $i = 1; $i  @a; $i++) {
 if ($a[$i] = $a[$i-1]) {
 if ($m == $k) {
 $j++;
 $l++;
 $curr++;
 $len++;
 }
 else {
 $l++;
 $curr++;
 }
 }
 else {
 if ($curr  $len) {
 $m = $k;
 $j = $l;
 $len = $curr;
 }
 $k = $l = $i;
 $curr = 0;
 }
 }
 if ($curr  $len) {
 print $k  $l;
 }
 else {
 print $m $j;

 }


 On Sun, Mar 14, 2010 at 8:49 PM, Ralph Boland rpbol...@gmail.com wrote:


 On Mar 14, 7:46 am, ASHISH MISHRA meetcoolash...@gmail.com wrote:
  @ankur how u can solve it in o(n)
  i suppose u need atleast o(n lgn)
 
  On Sun, Sep 6, 2009 at 2:52 PM, ankur aggarwal 
 ankur.mast@gmail.comwrote:
 
   o(n) is the best sol known to me..
 
   On Sun, Sep 6, 2009 at 1:54 PM, Pramod Negi negi.1...@gmail.com
 wrote:
 
   i guess sorting will do the work.
   any other constraint??
 
   On Sun, Sep 6, 2009 at 9:52 AM, p0r$h 1987.shis...@gmail.com
 wrote:
 
   Given an array of integers A[N], find the maximum value of (j-k)
 such
   that A[k] = A[j]  jk.
   I am looking for a solution with time complexity better than O(N^2).
 

 I don't know how to solve this in the claimed  O(N) time.
 However, I have coded a data structure that,
 given  j,  will find  k  in  O(log(N))  time.
 With it you can solve your problem in  O(N log N) time.
 The data structure is built in  O(N)  time and space.
 It is part of a larger data structure that I will implement
 and release as open source in a few months.

 Regards,

 Ralph Boland

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




 --
 Man goes to doctor. Says he's depressed. Says life seems harsh and cruel.
 Says he feels all alone in a threatening world where what lies ahead is
 vague and uncertain. Doctor says Treatment is simple. Great clown
 Pagliacci is in town tonight. Go and see him. That should pick you up. Man
 bursts into tears. Says But, doctor...I am Pagliacci.

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com.
To unsubscribe from 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: second highest elemt in an aary

2009-09-28 Thread Pramod Negi
It won't
try with [1,3,2]

On Mon, Sep 28, 2009 at 11:56 AM, harit agarwal agarwalha...@gmail.comwrote:

 It will take n comparisons.observe this code


 #includeiostream
 using namespace std;
 int sec_largest(int ar[],int n)
 {
 int i,max=-32767,sec_max=0;
 for(i=0;in;i++)
 {
 if(ar[i]max)
 {
 sec_max=max;
 max=ar[i];
 }
 }
 return sec_max;
 }
 main()
 {
 int n,i,res;
 coutenter number of elements\n;
 cinn;
 int ar[n];
 for(i=0;in;i++)
 cinar[i];
 res=sec_largest(ar,n);
 coutsecond largest number=resendl;

 }


 


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



[algogeeks] Re: second highest elemt in an aary

2009-09-27 Thread Pramod Negi
This will,I guss take 3N/2 comparison, for N + Lg -2.
Find Max(Winner) in N-1 (Tournament Method)
Compare Looser(fron Winner) For every Round with The Looser(from Winner) of
previous round..

_Negi


highest2=a[1];
 for(i=1;i5;i++)
  {
  if( a[i]  highest1)
  {
  highest2 = highest1;
  highest1 = a[i];
  flag++;
  }
  else if( a[i]  highest2 )
  {
  highest2 = a[i];
  flag++;
  }
  else
  flag++;
 }

 if( !flag )
  highest2 = highest1;

 printf(%d,highest2);
 }

 


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



[algogeeks] Re: swap every two bits in the byte..

2009-09-05 Thread Pramod Negi
i guess
num = ((num0xAA)1) | ((num0x55)1))
will work

Negi

On Sat, Sep 5, 2009 at 2:08 PM, Gokul spgo...@gmail.com wrote:


 how ll u swap every two bits in the a byte??? can anyone help me???
 for eg.
 consider a byte as input...
 10111010

 output should be
 01110101

 it exactly swap the two bits(no complement is takesplace here)..

 


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



[algogeeks] Re: Find an element in sorted matrix

2009-08-20 Thread Pramod Negi
I guess it is famous Younge Tableau Problem of tableau MxN and searching
can be done in O(M+N).
I doubt the problem can be solved in O(lgn) if no space constraint and no
pre-processing constraint present.

On Thu, Aug 20, 2009 at 9:42 PM, Anil C R cr.a...@gmail.com wrote:

 A more general problem is discussed in Introduction to Algorithms by
 Cormen et al
 problem 6-3, although the running time is O(n)...
 nagendra kumar wrote:
  How can we find an element in the matrix [n*n] which is sorted row
  wise and column wise in O(log 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
-~--~~~~--~~--~--~---



[algogeeks] Re: bits required to convert A to B

2009-08-16 Thread Pramod Negi
i guess XORing A and B and count the no of set bits will do.

On Sun, Aug 16, 2009 at 11:09 PM, richa gupta richa.cs...@gmail.com wrote:


 Given two integers A  B. Determine how many bits required to convert
 A to B.how to write a function int BitSwapReqd(int A, int B);

 --
 Richa Gupta
 (IT-BHU,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
-~--~~~~--~~--~--~---



[algogeeks] Re: selection problem.....

2008-04-22 Thread Pramod Negi
i didnt get what u want to so say (the bold lines)

On 4/21/08, Dave [EMAIL PROTECTED] wrote:


 Use a divide-and-conquer algorithm to find the median, rearranging the
 array so that the values less than the median precede it in the array
 and the values greater than the median follow it. So the median is a(n/
 2).* Now use the divide-and-conquer algorithm twice more to locate the
 (n/2-k)th and (n/2+k)th elements*. Finally, march out both directions
 from n/2, selecting the closest elements to a(n/2). Each of these
 operations can be done in O(n), so the total algorithm is O(n).

 Dave

 On Apr 21, 9:35 am, Algo [EMAIL PROTECTED] wrote:
  hi this is prob 9-3.7 of CLRS , anybody having a clue???
 
  Describe an O(n)-time algorithm that, given a set S of n distinct
  numbers and a positive
  integer k ≤ n, determines the k numbers in S that are closest to the
  median of S
 
  thanks in advance..
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Re: selection problem.....

2008-04-22 Thread Pramod Negi
make a partition about media as a pivot element

On 4/22/08, Varun S V [EMAIL PROTECTED] wrote:

 Hi Dave,

 Can you kindly eloborate your algorithm?
 How can we modify a single array in O(n) time, such that the median comes
 to become the n/2th element and smaller elements comes to the left side and
 larger elements comes to the right side? Kindly explain in detail.

 2008/4/22 Pramod Negi [EMAIL PROTECTED]:

  i didnt get what u want to so say (the bold lines)
 
   On 4/21/08, Dave [EMAIL PROTECTED] wrote:
 
  
   Use a divide-and-conquer algorithm to find the median, rearranging the
   array so that the values less than the median precede it in the array
   and the values greater than the median follow it. So the median is
   a(n/
   2).* Now use the divide-and-conquer algorithm twice more to locate the
   (n/2-k)th and (n/2+k)th elements*. Finally, march out both directions
   from n/2, selecting the closest elements to a(n/2). Each of these
   operations can be done in O(n), so the total algorithm is O(n).
  
   Dave
  
   On Apr 21, 9:35 am, Algo [EMAIL PROTECTED] wrote:
hi this is prob 9-3.7 of CLRS , anybody having a clue???
   
Describe an O(n)-time algorithm that, given a set S of n distinct
numbers and a positive
integer k ≤ n, determines the k numbers in S that are closest to the
median of S
   
thanks in advance..
  
 

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Re: Discussion on unique-elements-in-an-array

2007-11-09 Thread Pramod Negi
which algo sort array in O(N lgN) without extra space??

On 11/6/07, Andrey [EMAIL PROTECTED] wrote:


 dor is absolutely right

  O(N*log(N)) is straightforward.. sort the array in O(N*log(N)) and
  then remove duplicates in linear time.

 it doesn't need any extra memory.


 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Re: Discussion on unique-elements-in-an-array

2007-11-09 Thread Pramod Negi
i think if array of n elements is given and to make a heap out of it we need
O(n) space.
heap sort will surely take constant amount of auxially space if heap is
already build.

isn't it?
correct me if i m wrong..

On 11/9/07, Andrey [EMAIL PROTECTED] wrote:


 Heapsort http://en.wikipedia.org/wiki/Heapsort#Comparison_with_other_sorts

 On Nov 9, 3:54 pm, Pramod Negi [EMAIL PROTECTED] wrote:
  which algo sort array in O(N lgN) without extra space??
 
  On 11/6/07, Andrey [EMAIL PROTECTED] wrote:
 
 
 
   dor is absolutely right
 
O(N*log(N)) is straightforward.. sort the array in O(N*log(N)) and
then remove duplicates in linear time.
 
   it doesn't need any extra memory.


 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Re: Removing a set of characters from a given string

2007-10-04 Thread Pramod Negi
Use bit array rather using array of size 26

On 9/15/07, Deva R [EMAIL PROTECTED] wrote:



 a linear solution.

 - initialize an array of 26 (count for each character) with zeros.
 - scan pattern array and toggle equivalent alphabet's occurance field
 - scan subject string and skip occured alphabets

 sample program:


 alphabets_occurance[26]={0,0,0,...}

 void fun(char *subject,char *pattern)
 {

 //toggle dirty alphabets occured in pattern string
for(int i =0;subject[i] !='\0';i++)
{
  alphabets_occurance[subject[i] - 'a'] = 1;
}

//have two indexs to traverse the subject array and skip dirty
 alphabets
int curr_count=0,forward_count=0;
for(int i =0;pattern[i]!='\0';i++)
{
  if(alphabets_occurance[pattern[forward_count] - 'a'] !=1)
  {
 //not a dirty alphabet - include in output
 pattern[curr_count]=pattern[forward_count];
 curr_count++;
  }
  forward_count++;
}
   //terminate output string
   pattern[curr_count]='\0';
 }


 costs time at  o(strlen(pattern)+strlen(subject)) and mem 26 bytes..



 On 8/12/07, Peeyush Bishnoi [EMAIL PROTECTED] wrote:
 
  One solution to this problem is that :
 
  char s[]=abracadbra;
  char p[]=bca;
  char temp[];
 
  1. First Remove element b of array p from array s .
Compare b of array p with with characters of array s .
if b is not matched with characters of array s
   insert those characters of s into new temp array .
   continue this till s reaches '\0';
 now again reassign the reduced characters of temp array back into
  array s;
 
  continuously repeat the step 1 for another characters in p till p become
  or reaches '\0' ;
 
  finally you have an array which doesn't have characters which are there
  in p array;
 
 
  I think it only need an extra temporary array , but at each interation
  array size is getting reduced  as well no. of time to compare elements is
  also get reduced .
 
  If any one have questions please ask;
 
  Thank you ,
 
  ---
  Regards
  Peeyush Bishnoi
 
  On 8/7/07, Arulanandan P  [EMAIL PROTECTED] wrote:
  
   You have to write a function whose prototype is given bellow. this
   function will accept two char * named subject and pattern. for example
   subject=abracadbra
   and pattern=bca.now it should check occurrences of all chars of
   string pattern in subject . If any match occurs then it will remove that
   char from subject . so finally , as in our example
   at end subject =rdr
  
   void fun(char *subject,char *pattern)
   {
   // write your code here
   }
  
  
  
 
 
  --
  
  Peeyush Bishnoi
 
 
 

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Re: Height of a binary tree

2007-04-18 Thread pramod negi
I think this always return height 1. isn't it

On 4/17/07, BiGYaN [EMAIL PROTECTED] wrote:


 We will be calling the function like :
 height = getheight(root);

 and here's the function defination :
 int getheight ( node *p )
 {
if ( p==NULL )
return 0;
else
rh = getheight ( p-right );
lh = getheight ( p-left );
return ( (lhrh ? lh : rh)+1 );
 }


 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Re: the sum of two unsigned integers

2007-02-06 Thread pramod negi



 i think


 to check whethere the result is overflowed or not

check if ((A+B) -A is not equal to  B)
   printf(Overflow);


correct in if i m 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups-beta.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Re: spiral matrix..

2007-02-06 Thread pramod negi
The way u print a matrix in spiral order, same logic u can use to form the
matrix from given input PROVIDED the order of matrix is given ...
and this can be done in O(m x n) complexity...

--Negi

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups-beta.google.com/group/algogeeks
-~--~~~~--~~--~--~---