this will not solve ..think of node->r->r->l->l
Best Regards
Ashish Goel
"Think positive and find fuel in failure"
+919985813081
+919966006652
On Mon, Feb 14, 2011 at 7:50 PM, SEHAJ SINGH KALRA wrote:
> HAD MISSED OUT SOPME THINGS IN PREVIOUS REPLY.
> SORRY GUYS
> hereby i rectify the
since the question does not talk about extra space, make a BST but that will
be nlgn..
or use counting sort for O(n)
Best Regards
Ashish Goel
"Think positive and find fuel in failure"
+919985813081
+919966006652
On Sun, Jan 16, 2011 at 8:51 AM, nphard nphard wrote:
> Given an array of intege
trie tree will be better to implement
On Thu, Feb 17, 2011 at 11:07 AM, Jammy wrote:
> Greedy, always choose the remaining one that is the lexicographically
> smallest since choose any other way will yield a lexicographically
> greater one.
>
>
> void concante(char **strings, int n){
> qsort
take an array of 10 ,travese the whole rcord and apply min heap on these 10
elements.
as like first 10 no will be there and we apply minheap so we will get
minimun num in these 10 number..If next numbe is greater then minimun no in
array ..we will replace it and apply minheap ...
On Thu, Feb 17, 2
Question is to find the number of coins received on Nth day and not the
total number of coins received after N iterations.
On Wed, Feb 16, 2011 at 11:48 PM, Praveen wrote:
> Hi All
>
>total number of coins = 1+(2+2)+(3+3+3)+(4+4+4+4)+(N+N+.N
> times)
>
Divide records into parts that could fit into main memory. Do rank
find algorithm for certain range if necessary.
On Feb 16, 7:26 pm, bittu wrote:
> given a very large file (millions of record), find the 10 largest
> numbers from it.in minimum time complexity
> Don't think about hashing . Again I
Node *flatten(Node *node) {
if (!node)
return NULL;
Node *head = node;
Node *next = node->next;
node->next = NULL;
if (node->down)
node->next = flatten(node->down);
while (node->next != NULL)
node = node->next;
node->next = flatten(next);
return head;
}
On Wed, Feb 16, 2011 at 8:38 PM, bittu wr
Greedy, always choose the remaining one that is the lexicographically
smallest since choose any other way will yield a lexicographically
greater one.
void concante(char **strings, int n){
qsort(strings,n,sizeof(char *),compareStr);
}
int compareStr(const void *a, const void *b){
return
@Bittu: It is interesting that you might want to sort complex numbers,
since they don't form an ordered field. See, e.g.,
http://en.wikipedia.org/wiki/Ordered_field for an explanation why.
Dave
On Feb 16, 5:57 am, bittu wrote:
> write header file for sorting general element. it can sort any type
Hi All
total number of coins = 1+(2+2)+(3+3+3)+(4+4+4+4)+(N+N+.N
times)
= 1+(2*2)+(3*3)+4*4+...+(N*N)
= (N*(N+1)*(2N+1))/6
Please do correct me if i am wrong
Regards
Praveen
On Thu, Feb 17, 2011 at 6:26
Try this code.
#include
#include
using namespace std;
int main()
{
string sArray[5] ={"aab","abc","bba","acc","bcc"};
int n = 5;
for(int i = 0;i < n; i++)
{
for( int j = 0; j < n - 1 ; j++)
{
if(sArray[j] > s
hope it may work
typedef void (*Swapfunc)(void *element_1, void *element_2);
typedef int (*Cmpfunc)(void *element_1, void *element_2);
void GenericSort(void *array, uint32_t nbElems, Swapfunc swapFunc,
Cmpfunc cmpFunc);
Thanks & Regards
Shashank Mani >>"The best way to escape from a problem
Given a linked list structure where every node represents a linked
list and contains two pointers of its type:
(i) pointer to next node in the main list.
(ii) pointer to a linked list where this node is head.
Write a C function to flatten the list into a single linked list.
Eg.
If the given link
WAP or Algo That will check whether the memory allotted to the program
at the initial and the memory returned to the system is same or not.
Thanks & Regards
Shashank Mani
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group
I did it.
#include
#include
using namespace std;
int main(){
int n,ac,k,sum;
while(cin>>n && n){
ac=0;
k=ceil((sqrt(1+8*n)-1)/2)-1;
ac+=k*(k+1)*(2*k+1)/6;
sum=(k+1)*(k+2)/2;
ac+=(k+1)*((k+1)-(sum-n));
cout<
> Let f(n) = n(n+1)/2
> We have
Given a group of strings, find a string by concatenating all the
strings in any order which produces the lexicographically smallest
string.
For e.g strings are acc bcc abb
So the string formed should be abbaccbcc
Thanks
Shashank
--
You received this message because you are subscribed to the Goog
given a very large file (millions of record), find the 10 largest
numbers from it.in minimum time complexity
Don't think about hashing . Again Its Flat File Not the Database
Thanks & Regards
Shashank Mani
--
You received this message because you are subscribed to the Google Groups
"Algorithm G
Let f(n) = n(n+1)/2
We have to find n1 and n2 such that f(n1) < N <= f(n2) and n2 = n1 + 1.
Solution is n2.
Can be done in O(1) as follows:
Solve N = n(n+1)/2 for unknown n.
Requires us to solve quadratic equation: n^2 + n - 2N = 0
Find positive root of the equation which could be a real number.
It seems to be a very easy problem, but I'm not finding an *equation *that
solves it... could someone help me with the steps?
Brief:
A king pays 1 gold coin to a knight on the first day. 2 gold coins for the
next 2 days, 3 gold coins for the next 3 days, and so on...
Given a day N, how much gold c
On Feb 16, 12:53 pm, bittu wrote:
> Two robots are placed at different points on a straight line of
> infinite length. When they are first placed down, they each spray out
> some oil to mark their starting points.
>
> You must program each robot to ensure that the robots will eventually
> crash
one idea is that quad trees are used in 2d collision detection (and
OctTrees in 3d collision detection). I haven't ever written a code on
it but the basic premise is that every node represents a point and say
has it's x and y co-ordinates and 4 children, which actually represent
4 quadrants.
So if
Nice solution. Similarly you could #define:
void change()
{
#define change() i=10
}
On Feb 16, 12:55 pm, ankit sablok wrote:
> nice solution
>
> On Feb 15, 11:22 pm, jagannath prasad das wrote:
>
>
>
>
>
>
>
> > void change()
> > {
> > #define i i=10,n}
>
> > this will do..
>
> > On Tue, F
@all well i appreciate your suggestion but all of you replied one
word answer actually i forget to say "Best Data Structure & why"
well hashing,trie will definitely solve this
@ankit i wants to see your trie implementation for this problem , as i
had not done lot stuff with trie (i read it theo
Two robots are placed at different points on a straight line of
infinite length. When they are first placed down, they each spray out
some oil to mark their starting points.
You must program each robot to ensure that the robots will eventually
crash into each other. A program can consist of the f
case 1.
|-|--|
| 0 | remaining 7 bit|
|-|--|
MSB
When Character is represented by 1 Byte
case 2.
||-||-|
| 1 | last 7 bit | dont care
nice solution
On Feb 15, 11:22 pm, jagannath prasad das wrote:
> void change()
> {
> #define i i=10,n}
>
> this will do..
>
> On Tue, Feb 15, 2011 at 11:33 PM, Rel Guzman Apaza wrote:
>
>
>
>
>
>
>
> > Nothing... 10 in base 5 = 5 in base 10.
>
> > void change(){
> > printf(""); //...?
AX is the low order accumulator register used in the microprocessor
generally the value returned is from the accumulator if u modify that
value it will return the value u set it to
as the Register is Divided into 2 parts AH - higher order and AX -
lower order the value 10 is stored in AX and is ret
trie construction would do for this
On Wed, Feb 16, 2011 at 10:15 PM, yv paramesh wrote:
> build a tree
>
> On Wed, Feb 16, 2011 at 10:10 PM, vaibhav agrawal
> wrote:
> > Hash, SortedSet
> >
> > On Wed, Feb 16, 2011 at 9:58 PM, bittu
> wrote:
> >>
> >> Given a set of words one after another, g
build a tree
On Wed, Feb 16, 2011 at 10:10 PM, vaibhav agrawal wrote:
> Hash, SortedSet
>
> On Wed, Feb 16, 2011 at 9:58 PM, bittu wrote:
>>
>> Given a set of words one after another, give a data structure so that
>> you,will know whether a word has appeared already or not.
>>
>> Thanks
>> Shash
Hash, SortedSet
On Wed, Feb 16, 2011 at 9:58 PM, bittu wrote:
> Given a set of words one after another, give a data structure so that
> you,will know whether a word has appeared already or not.
>
> Thanks
> Shashank
>
> --
> You received this message because you are subscribed to the Google Grou
Given a set of words one after another, give a data structure so that
you,will know whether a word has appeared already or not.
Thanks
Shashank
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@go
since it is guaranteed that l points to the start of the character.
Thus I would refer to 'X‘ as the byte l points to. Each number in the
following represents the MSB of the corresponding byte. E.g. 101X -->
the byte preceding X has MSB 1 and the byte preceding that has MSB 0
the byte preceding tha
he first few f(i):
f(1)=0
f(2)=max(f(1)+f(1-1+1)+1) = 1
f(3)=max{f(1)+f(2)+1, f(2)+f(1)+1} = 2
f(4)=max{f(1)+f(3)+1, f(2)+f(2)+1, f(3)+f(1)+1} =3
f(5)=max{f(1)+f(4)+1, f(2)+f(3)+1, ,f(4)+f(1)+1} = 4
f(6)=max{.} =5
what I can see here is in each f(i), all comma separated expressions
evalua
f(n)=n-1.
On Wed, Feb 16, 2011 at 7:39 PM, Akshata Sharma
wrote:
> please help..
>
> if f(n+1) = max{ f(k) + f(n-k+1) + 1} for 1 <= k <= n; f(1) = 0.
> Find f(n+1) in terms of n.
> Eg: f(4) = ? n = 3; 1<= k <= 3; f(4) = max{f(1) + f(3) + 1, f(2) +
> f(2)+1, f(3) + f(1) +1}
>
> --
> You received
template
void sort(Iterator first, Iterator last, Compare cmp);
On Feb 16, 5:57 am, bittu wrote:
> write header file for sorting general element. it can sort any type of
> object(int,float,complex number, objects)
>
> Thanks
> Shashank
--
You received this message because you are subscribed to
please help..
if f(n+1) = max{ f(k) + f(n-k+1) + 1} for 1 <= k <= n; f(1) = 0.
Find f(n+1) in terms of n.
Eg: f(4) = ? n = 3; 1<= k <= 3; f(4) = max{f(1) + f(3) + 1, f(2) +
f(2)+1, f(3) + f(1) +1}
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" gr
many irregular shape objects are moving in random direction. provide
data structure and algo to detect collision. Remember that objects are
in million.
Thanks
Shashank
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, se
write header file for sorting general element. it can sort any type of
object(int,float,complex number, objects)
Thanks
Shashank
--
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.
one system API available setOStimer(time n, function ptr, function
arg) it sets time for n sec. after expiration of timer it calls
function. if another timer set with setOStimer, it will erase
previously sets timer.
Ex. at t = 0, setOStimer(5,fn,arg) at t = 4, setOStimer(10,fn1,arg1)
now first time
a one line solution is needed...
--
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
and also
void change()
{
// Code here
int x = 1;
int*p= &x;
while(*p != 5) p++;
*p = 10;
}
On Wed, Feb 16, 2011 at 8:02 AM, Balaji S wrote:
>
> The solution is..
>
>_AX = 10;
>
>
> can anyone explain??
>
> --
> You received this message because you are subscribed to the Google Groups
>
41 matches
Mail list logo