It is simple.
Initialize BIT[MAXN+1] to zero.
1.Iterate from Right to left
2.For each element array[i] Check how many elements are smaller than
array[i].
This can be done by just a simple query(array[i]-1);
3. Update the array[i]th index in BIT by 1.
// Simple code snippet.
long an
how to count the no. of inversion pairs in array using Binary Indexed
Tree... plz help..
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send ema
CSI : Computer Science Integrated (5yr)
CSE is 4 year
On Sat, Oct 15, 2011 at 1:59 PM, hary rathor wrote:
> sunny : are you in 5th year . i have heard that b-tech is 4 year degree?.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
>
sunny : are you in 5th year . i have heard that b-tech is 4 year degree?.
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogee
Given a n vertex polygon, find in how many ways k non intersecting diagonals
can be drawn ?
or
in How many ways it can be divided into k+1 regions such that no 2 diagonals
intersect ?
Limits:1 <= k <= N <= 10^9
--
Sunny Aggrawal
B.Tech. V year,CSI
Indian Institute Of Technology,Roorkee
--
How about using vertices and edges format in graphs?
- Traverse through each vertex in vertices list, and add all the edges to
the edge list if they are not already present in the edge list.
- Keep a counter to detect addition of new edges.
On 18 August 2011 01:31, Luciano Junior wrote:
> How ma
How many different ways are there to count how many streets have in a city,
based on the city map?
What algorithms can be used for response this question ?
--
Luciano Soares Pinheiro Jr.
Analista desenvolvedor Sr.
--
You received this message because you
yeah, it can be modified as N queen problem but basically I was looking for
this as job assignment problem.
--
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/-
is THIS like N queen problem ???
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more
i have an idea of changing each row to decimal equilant
so we have an array of size n
each array element has logn bits, resetting each all bits except one
everytime and checking for AND of all n array
it should take maximum of O(logn)^n. improvements or ideas are welcome
surender
On Sat, Jul 16,
I agree with skript: Number of ways of doing this is n!
One in the first row can be placed in n ways.
After one in first row has been placed,
we can place One in second row in n-1 ways and so on.
So total num of ways is n*(n-1)*...*1 = n!
One possible solution to this problem can be coded as foll
O(n!)
On Fri, Jul 15, 2011 at 12:17 PM, Sarvesh wrote:
> it is simple n*n ways.
>
>
> On Thu, Jul 14, 2011 at 11:36 PM, tendua <6fae1ce6347...@gmail.com> wrote:
>
>> We are given n by n boolean matrix ( n <= 20). Output of matrix should
>> be such that every row and every column should have only
it is simple n*n ways.
On Thu, Jul 14, 2011 at 11:36 PM, tendua <6fae1ce6347...@gmail.com> wrote:
> We are given n by n boolean matrix ( n <= 20). Output of matrix should
> be such that every row and every column should have only one true
> value ( true=1, false=0). Input matrix can have any num
It can be done in O(2^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,
if we have to find out no of possible outputs ...then we can do this
for(i=1;i<=n;i++)
{
ans=ans * no of 1s in ith row
return(ans);
}
On Thu, Jul 14, 2011 at 11:46 PM, SkRiPt KiDdIe wrote:
>
>
> Will a Back-tracking solution suffice..??
>
> --
> You received this message because you are s
Will a Back-tracking solution suffice..??
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
We are given n by n boolean matrix ( n <= 20). Output of matrix should
be such that every row and every column should have only one true
value ( true=1, false=0). Input matrix can have any number of 1's and
there will be no row or column having all zero values. Example: let
n=4
Input Matrix:
1 0 1
My code using dp takes leeser amount of time than a few submitted
solutions still submission says TLE ..
Kindly help!!
#include
#include
#include
#include
using namespace std;
int A[1001][1001];
bool if_palindrome( string s, int i, int j )
{
if( s[i] == s[j] ){
Number of Ways of arranging N 0's, N 1's and N 2's such that number of
0's are always greater than equal to number of 1's till any place but
not more than by K and similarly number of 1's are always greater than
equal to number of 2's till any place but not more than by K?
--
You received this me
Here's my try:
The following function returns the rectangle number given the dimensions of
the rectangle.
int FindRectangleNumber(int row, int colm)
{
if (row == colm)
return row;
if (row == 1)
return colm;
if (row%2 == 0 && colm%2 == 0)
return 2*FindRectangleNumber(row/2, colm/2);
if (
Can anyone help in finding number of rectangles having a given
recatngle number. A rectangle number is defined as the number of unit
sided square formed inside the given rectangle having a common point
with a diagonal of rectangle. The sides of rectangle have integer
length. E.g. number of rectangl
Hello!
I'd like to present my solution to the problem introduced in the
topic. First thing first, the detailed definition is in place :
Given the set of integers S = {e_1,e_2 , ... e_n } find (count) all
subsets S_n of S so, that sum(S_n) = N, for a given integer N.
After thinking a bit about t
Can we change counting sort to sort inplace only using O(k) space where
the numbers range from 1...k?
The problem precisely is to design a sorting algorithm to sort 'n'
records whose keys range from 1...k in O(n) time using only an
auxiliary array of size k. The algorithm should sort be stable and
I have a data structure and also i have 3 basic operation, find_min,
delete_min and insert .
A sequence of m operation could look like this:
insert,insert,insert,delete,find_minetc..
Any M operations of these, should have O(M+k) complexity( O(m+k) -worst
case).
My ideea is to have a sorted arr
24 matches
Mail list logo