One possible solution would be to create an array of pointers to the list..
array index indicates how many times the element occurs and the list gives
the elements.
On Sun, Oct 3, 2010 at 11:22 AM, sharad kumar aryansmit3...@gmail.comwrote:
it will take same amount of memory nakey value is
In hash map insertion and seach take O(logn) time but less space.
So according to sharad insert all elements in hash map which will take
O(nlogn) time and 0(n) space.
But if you are sure about the range of numbers which would appear in the
list, you can use counting mechanism. Like if you know
@kusuma main concern is how will you create the list which are coming once.
you have to check the current value with all values you pushed into the list
and if match occures you have to delete the element from existing list and
insert in next list having index greater by one. and if duplication
Sorting : O(nlogn) time
So hash map solution will also same time. I guess one can customize it
according to the requirements and constraints.
On Sun, Oct 3, 2010 at 11:50 AM, kusuma sanjeev kushina...@gmail.comwrote:
array elements: 1 2 9 8 7 5 2 3 1 1 4 2 6 2 3
sort: 1 1 1 2 2 2 2 3 3 4 5 6
thanx, to correct me.
yes..radix sort takes O(d(n+k)) time.
On Oct 3, 4:17 am, Gene gene.ress...@gmail.com wrote:
Radix sort _is_ dependent on the length of keys. If the radix is R,
then the sort must make ceiling(log_R(k)) passes over the data.
Increasing the R to decrease the number of
@anand: the greedy appoach will not work in this test case:
{2,10,25,
1,20,10,
100, 5, 100}
i think use DP. create an 'max matrix of same order.
max[i,j]= maximum( max[i-1][j] + a[i][j], max[i][j-1]+a[i][j] );
max[n-1][n-1] will be the answer.
Tell me if i m wrong.
On Oct 2, 10:29 pm, Anand
Will u plz elaborate ur solution.
give the algo to how to find all binary trees.
On Oct 2, 9:51 pm, Harshal ..Bet oN iT!! hc4...@gmail.com wrote:
2) We need to find the all complete binary trees using 3 of the (+,*,/,-)
at a time as internal nodes and n1,n2,n3,n4 as leaves, and then inorder
they will be integers in q2...
On 10/2/10, swayambhoo jain swayambhoo.j...@gmail.com wrote:
Are the four numbers in question #2 integers or they can be anything?
On Sat, Oct 2, 2010 at 10:03 AM, swayambhoo jain
swayambhoo.j...@gmail.comwrote:
What about the case when we have repeated
Check this out:
http://www.linuxask.com/questions/clear-screen-in-mysql-client
On Sep 14, 2:27 pm, Ayush Mittal ayushmittal2...@gmail.com wrote:
what is the command to clear screen in mysql..?
--
You received this message because you are subscribed to the Google Groups
Use counting Sorting Algorithm...i am givin the code below ..it sort
the array in O(n) but uses xtra memory space (n+k)...we have to pay
eother memory or time
#include stdlib.h
#includestdio.h
#includeconio.h
int main()
{
int array[]={4,2,2,2,4,5,9,5,10};
int size=10;
int
If-a-person-dials-a-sequence-of-numbers-on-the-telephone-what-
possible-
words-strings-can-be-formed-from-the-letters
finally i have found the anwer i though about it that it sould be
(3*k1)! for 1=k1=6 and
(4*k2)! for 2 keys dat is nothing but the all the permutation of
character on the
If we are pressing n numbers, the it should be (26)^N.
As each time we press the number it is going to be any character.
--
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
@harshal :
range of integers are given from 1 to n^3-1,,there are total n integers
only.
also:-Treat the numbers as 2-digit numbers in radix n. Each digit ranges
from 0 to n^3 -1.
Sort these 2-digit numbers with radix sort.
There are 2 calls to counting sort, each taking (n + n) = (n) time, so
Doesn't this use O(n^3) space and the time complexity will also be
O(n^3) (passing through n^3 different possible values).
Use Radix Sort with radix/base equal to n, meaning that instead of
using the digits of numbers in base 10, find the digits in base n.
On Oct 3, 1:30 pm, bittu
*
lets have another approach,tell me if it works
Notice that the number of digits used to represent an n^3 different numbers
in a k-ary number system is d= log(n^3) base k.
Thus considering then 3 numbers as radix n numbers gives us that:
d=log (n^3)base n= 3logn(n)= 3
Radix sort will then
@Mridul
Thats correct. You can however optimize on space complexity. At any point of
time you need only current max row and previous max row, so you can manage
with only 2 rows (in fact just 1 if you optimize furthure).
On Sun, Oct 3, 2010 at 1:02 PM, Mridul Malpani
Thanks guys, i got it..
--
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,
yeah Mirdul.
you are correct.
http://codepad.org/qYuXmPyB
http://codepad.org/qYuXmPyB
On Sun, Oct 3, 2010 at 7:08 AM, ravindra patel ravindra.it...@gmail.comwrote:
@Mridul
Thats correct. You can however optimize on space complexity. At any point
of time you need only current max row and
for the first one it is permutation with repetition
because the order matters
n = no of digits
When you have *n* things to choose from ... you have *n* choices each time!
So when choosing *r* of them, the permutations are:
*n × n × ... (r times) = nr*
correct me if am wrong
--
You received
here r is numbers we choose usually we have 10 numbers(in case of cell
phone) we have 10[0.9] digits so 10^10 numbers are there...correct
me if am wrong
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email
for question 2. it seems awful but;
Since there are no paranthesis and /,* preceeds +,- if there
is an * or / , the leftmost one should be performed before the others.
First check the case if no *,/ occurs by checking all the sums
n1,n2,n3,n4; -n1,n2,n3,n4 (there are 2^4, either negative
I don't understand what you mean when you say minimum among all the
nodes in the graph.
In any case, your definition of centre of tree looks similar to the
closeness centrality measure -
http://www.faculty.ucr.edu/~hanneman/nettext/C10_Centrality.html#Closeness
I doubt you can do it in O(N)...
For the third problem, involving the maze: There must be N moves down
and M moves to the right. Thus, there is a total of M+N moves, and the
number of these is the binomial coefficient (M+N) choose M, which of
course equals the binomial coefficient (M+N) choose N. This
contradicts the answer
23 matches
Mail list logo