Let A[n] be an array of n distinct number. If ij and A[i] A[j] then the
pair (i , j) is called inversion of A.
Give an algorithm that determines the total number of inversions in
O(nlogn) time.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks
http://www.geeksforgeeks.org/archives/3968
On Jul 8, 11:01 am, Navin Kumar algorithm.i...@gmail.com wrote:
Let A[n] be an array of n distinct number. If ij and A[i] A[j] then the
pair (i , j) is called inversion of A.
Give an algorithm that determines the total number of inversions in
Thanx Deepika :)
On Sun, Jul 8, 2012 at 11:48 AM, deepikaanand swinyanand...@gmail.comwrote:
http://www.geeksforgeeks.org/archives/3968
On Jul 8, 11:01 am, Navin Kumar algorithm.i...@gmail.com wrote:
Let A[n] be an array of n distinct number. If ij and A[i] A[j] then
the
pair (i , j)
You can use either Merge sort or BIT(refer TopCoder tutorial).
--
Prakhar Jain
IIIT Allahabad
B.Tech IT 3rd Year
Mob no: +91 9454992196
E-mail: rit2009...@iiita.ac.in
jprakha...@gmail.com
On Sun, Jul 8, 2012 at 11:31 AM, Navin Kumar algorithm.i...@gmail.comwrote:
Let A[n] be an
Try like merge sort.
http://www.geeksforgeeks.org/archives/3968
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
+1 Akshat
On 7/7/12, Akshat Sapra sapraaks...@gmail.com wrote:
There is no need to use any other data structure or sort the array one can
directly construct the BST from a given array by taking one element at a
time from the beginning and inserting into a BST.
--
Akshat Sapra
Under
Alice is a teacher of kindergarten. She wants to give some candies to
the children in her class. All the children sit in a line and each
of them has a rating score according to his or her usual
performance. Alice wants to give at least 1 candy for each children.
Because children are somehow
@ashgoel - Could you please explain what exactly are you doing here ?
On Wednesday, 4 July 2012 16:16:38 UTC+5:30, ashgoel wrote:
Q4
vectorString prefix;
prefix[0]=NULL;
prefixCount =1;
for (int i=0;in;i++)
for (int j=0;jn;j++)
for (int k=0; kprefixCount;k++)
{
if
int i=5;
i=++i/i++;
print i;
i=1
how?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
Firstly, this is ambiguous and expressions with multiple
increment/decrement operators will get executed according to the compiler.
Even if you consider the normal way, as we(humans) percieve it, it will be
evaluated as
(++i)/(i++), which is 6/5, which is 1.
Simple!
On Sun, Jul 8, 2012 at
Sorry, its 6/6 and not 6/5,
regds.
On Sun, Jul 8, 2012 at 10:39 PM, adarsh kumar algog...@gmail.com wrote:
Firstly, this is ambiguous and expressions with multiple
increment/decrement operators will get executed according to the compiler.
Even if you consider the normal way, as we(humans)
agree with adarsh
On Sun, Jul 8, 2012 at 10:39 PM, adarsh kumar algog...@gmail.com wrote:
Sorry, its 6/6 and not 6/5,
regds.
On Sun, Jul 8, 2012 at 10:39 PM, adarsh kumar algog...@gmail.com wrote:
Firstly, this is ambiguous and expressions with multiple
increment/decrement operators
but i am confused in this problem...
int a=10;
int b;
b=--a--;
printf(%d %d,a,b);..what will output?
On Sun, Jul 8, 2012 at 11:39 PM, md shaukat ali ali.mdshau...@gmail.comwrote:
agree with adarsh
On Sun, Jul 8, 2012 at 10:39 PM, adarsh kumar algog...@gmail.com wrote:
Sorry, its 6/6 and
I think it should output:
9 9
On Sun, Jul 8, 2012 at 11:42 PM, md shaukat ali ali.mdshau...@gmail.comwrote:
but i am confused in this problem...
int a=10;
int b;
b=--a--;
printf(%d %d,a,b);..what will output?
On Sun, Jul 8, 2012 at 11:39 PM, md shaukat ali
ali.mdshau...@gmail.comwrote:
.i think there will be an error in this -l value required, as post
increment has more precedence than pre increment
On Sun, Jul 8, 2012 at 11:44 PM, ashish jain ashishjainco...@gmail.comwrote:
I think it should output:
9 9
On Sun, Jul 8, 2012 at 11:42 PM, md shaukat ali
int a=10;
int b;
b=--a--;
printf(%d %d,a,b);. l value error in this ques..
On Sun, Jul 8, 2012 at 11:48 PM, vindhya chhabra
vindhyachha...@gmail.comwrote:
.i think there will be an error in this -l value required, as post
increment has more precedence than pre increment
On Sun, Jul 8, 2012
b=--a--; this will result into compiler error because 1st the post
decrement will occur and value will be saved in a temp variable . but
you cannot apply pre decrement on temp variable.
On 7/8/12, vindhya chhabra vindhyachha...@gmail.com wrote:
int a=10;
int b;
b=--a--;
printf(%d %d,a,b);. l
then atul what would be the output of this prob...
int a=10;
int b=a++*a--;
prinf (%d,b);
On Sun, Jul 8, 2012 at 11:52 PM, atul anand atul.87fri...@gmail.com wrote:
b=--a--; this will result into compiler error because 1st the post
decrement will occur and value will be saved in a temp variable
it violates sequence pt. rule..so output is compiler dependent , but
as there is Lvalue error it would compile fine.
but in prev case pre decrement expects Lvalue but has r-value instead
bcoz of the post increment.
On 7/9/12, md shaukat ali ali.mdshau...@gmail.com wrote:
then atul what would
The next solve the problem of eight Queeen... but i don't undestand
it!!! can you explain me?
(defun n-queens (n m)
(
if (= n 1)
(loop for x from 1 to m collect (list x))
(loop for sol in (n-queens (1- n) m) nconc
(loop for col from 1 to m when
(loop for row
the o/p will be 2 not 1 because of the post-increment operator.
On Sun, Jul 8, 2012 at 10:23 PM, rahul sharma rahul23111...@gmail.comwrote:
int i=5;
i=++i/i++;
print i;
i=1
how?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To
Requires review and comments:
My solution:
find the continuous increasing sequences from the input followed by
continues decreasing array.
let there are k such array (continuous increase followed by continuous
decrease)
Now we have the trivial components. find sum for each such array.. and sum
22 matches
Mail list logo