are we allowed to use operation only once or multilpe times?
On Fri, Mar 22, 2013 at 6:27 AM, prankur gupta duke.lnm...@gmail.comwrote:
Hi All,
Could you help me this question.
This was asked at Yelp Interview.
Given 6 integers and 1 target value, write a function to get the target
value
Hi All,
Could you help me this question.
This was asked at Yelp Interview.
Given 6 integers and 1 target value, write a function to get the target
value using 6 integers with any on these operations +,*,-,/
Thanks
--
PRANKUR GUPTA
Masters Student (CSE)
State University of New York
Stony
min heap wid N elements containing first line from each file will do...
remove the top most n insert next one from dat file only
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
Given N files on disk of sizes 16 GB, containing integers in sorted
order, one integer per line. Create a single file with all the integers in
sorted order.
Usage : sortEM (file1, file2)
file1 has list of input files, one name per line
file2 is the name of file into which the output has to be
First thing on my Mind External Sorting.
On Wed, May 23, 2012 at 7:21 PM, Decipher ankurseth...@gmail.com wrote:
Given N files on disk of sizes 16 GB, containing integers in sorted
order, one integer per line. Create a single file with all the integers in
sorted order.
Usage : sortEM
Hi,
k-way merge procedure of external sorting should be applied
--
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
Here is my version
Algorithm count(x)
1: if (x==nil || (left[x]== nil and right[x]==nil))
2: return 0
3: return count(left[x]) + count(right[x]) +1
Time Complexity: O(n) where is n is total number of node in tree.
Thanks
On Wed, May 9, 2012 at 11:17 AM, Akshay Rastogi akr...@gmail.com
internal_nodes=TotalNodes(root) - No_of_leaf_nodes(root);
On Wed, May 9, 2012 at 1:19 PM, Amit Jain aj201...@gmail.com wrote:
Here is my version
Algorithm count(x)
1: if (x==nil || (left[x]== nil and right[x]==nil))
2: return 0
3: return count(left[x]) + count(right[x]) +1
Time
you are not checking whether the current node is an internal node or not !!
On Thu, May 3, 2012 at 12:47 AM, Rose itro...@gmail.com wrote:
Is this algorithm right or how shall I write it?
*
*
*
*
*Construct an algorithm **Intern(**x**)**, which returns the number of
internal nodes in
28 questions 120 min +1/-0.25
3 programming qs
1.to add two numbers stored in link list
2.to test is the given tree is a sumtree or not
3.to store numbers from a tree to a file and then retrieve those
values and buld the tree
Objective type qs
1. rec= fork();
rec= fork();
rec= fork();
rec=
I was asked this question sometime during an interview.
WE have an array of known length. The elements in array can be repetitive.
now sort the array based on frequency of occurrence of each element in
array.
Eg: a= {4.3.2.5.4.6.2.6}
after sorting a={4,4,2,2,6,6,3,5}
4,2,6 all occurs twice, in
With hashing..
make a hash table of elements from 0 to sum/2
if an element k is in sum/2 to sum then check if sum-k is in the hashtable.
take care of the case when sum is even and sum/2 occurs only once.
TC: O(n) Space complexity: O(sum)
Method2: Sort the elements.
Now maintain to pointers one at
For example, in array, say,
8, 9, 2, 4, 6, 2, 3
Input 5, output 2 and 3.
--
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
Its brute force method.O(n^2) algo...
for(int i=0;in;i++)
for(int j=i+1;jn;j++)
{
if(x==A[i]+A[j])
{ print A[i],A[j]; break;}
}
On Wed, Aug 31, 2011 at 1:15 AM, Reynald reynaldsus...@gmail.com wrote:
For example, in array, say,
8, 9, 2, 4, 6, 2, 3
Input 5, output 2
Discussed so many times on the group
search in the group archive..No point repeating things again and again
On Wed, Aug 31, 2011 at 11:04 AM, bharatkumar bagana
bagana.bharatku...@gmail.com wrote:
Its brute force method.O(n^2) algo...
for(int i=0;in;i++)
for(int j=i+1;jn;j++)
one method can be :
Let T = the sum
for(i=0;in;i++)
{
temp=T- x[i];
// perform a binary search on array[ i+1. n-1] to find temp it if
does then just output.
}
On Wed, Aug 31, 2011 at 11:04 AM, bharatkumar bagana
bagana.bharatku...@gmail.com wrote:
Its brute force
@Pramod Nice work. Although I think Carrot = 100 - percentage and Stick =
percentage will work instead of the current values.
On Tue, Aug 16, 2011 at 1:13 AM, PramodP p.pramod.n...@gmail.com wrote:
Here is a modified function that finds the element that crosses a
particular percentage in an
Design an algorithm to find all elements that appear more than n/2
times in the list. Then do it for elements that appear more than n/4
times.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
For n/2 I came across a nice algo sometime back.
here is how to do it (I am providing algo):
int A[n], i, num, freq=0;
set num = A[0] and freq= 1; // assume first number to be the n/2 times
occurring element.
from i=1 to n-1
{
if (A[i] == num)
freq++;
else
freq--;
freq = (freq 0)?
Can u suggest a program with complexity O( log 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
Searching a node in a tree of string or integer arrays and then using binary
search withinn that node to retrive a particular value
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
I used a map and implemented the code. The algo to achieve this can be done
in under 10 lines, the overall program is 50 lines.
You can have a look at the code here:
https://github.com/swagatata/ds_and_algos/blob/master/cpp/trivia/currency_conversion.cpp
The basic idea is to use an approach
Hi,
Can anyone have algorithm or program for convert word into number
Input. Three hundred twenty three : output 323
InputTwenty : output -20
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To
I wonder if there is any practical use of this algorithm for real life
implementation . . Please let me know where you caught this problem
On 6/11/11, Abhishek Goswami zeal.gosw...@gmail.com wrote:
Hi,
Can anyone have algorithm or program for convert word into number
Input. Three hundred
Count the number of spaces in the sentence. If the last word is
{one/two .} the just do the calling on the speciab part of code
printing the rest of sentence
On 6/11/11, rahul rai raikra...@gmail.com wrote:
I wonder if there is any practical use of this algorithm for real life
Can you bit descriptive..
On Sat, Jun 11, 2011 at 7:27 PM, rahul rai raikra...@gmail.com wrote:
Count the number of spaces in the sentence. If the last word is
{one/two .} the just do the calling on the speciab part of code
printing the rest of sentence
On 6/11/11, rahul rai
@I got one of my interview . I tried to solve this issue but could not
it...I did googling but could not help me much...
On Sun, Jun 12, 2011 at 12:26 AM, Abhishek Goswami
zeal.gosw...@gmail.comwrote:
Can you bit descriptive..
On Sat, Jun 11, 2011 at 7:27 PM, rahul rai raikra...@gmail.com
may be a map can help that maps string to their integer values ans then
using some set of rule to convert to a number
On Sun, Jun 12, 2011 at 12:28 AM, Abhishek Goswami
zeal.gosw...@gmail.comwrote:
@I got one of my interview . I tried to solve this issue but could not
it...I did googling but
You can assign weight to all the consumers based on priority and then divide
all the resource based on weight.
On Wed, May 4, 2011 at 6:13 PM, LiveShell livesh...@gmail.com wrote:
Hi all,
I am working on dynamic resource allocation problem. I have set of
Consumer and resource. Consumers are
Hi all,
I am working on dynamic resource allocation problem. I have set of
Consumer and resource. Consumers are with priority (High, Medium,
Low). Now I want to assign resource slice to each consumer based on
priority and no of consumers.
ie
Priority| No of Consumers
how much resource each customer needs...??
On Wed, May 4, 2011 at 6:13 PM, LiveShell livesh...@gmail.com wrote:
Hi all,
I am working on dynamic resource allocation problem. I have set of
Consumer and resource. Consumers are with priority (High, Medium,
Low). Now I want to assign resource
Hey,
Monthly challenge of http://algorithmguru.com has started.participate to
excel your skills in algorithms and win prizes worth $50.
--
Regards
Ravi Maggon
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send
Given n point on the plane, find out whether any 3point on the same line.
How to use recursion to solve the problem? Could you help me find the
algorithm and give the time complexity?
Bests,
Claire
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks
Is there any specific need to use recursion?
One alternate is to find slope and constant (m and c) for every pair of
points and same value of m c will specify the points on the same line.
Time complexity is O(n*n).
On Sat, Oct 23, 2010 at 4:31 PM, Meng Yan mengyan.fu...@gmail.com wrote:
there are (n*(n-1))/2pairs of points. I think if we use your method, the
time complexity should be O(n^4).
Is it possible to put all points into k different domain and using
T(n)=T(n/k)+f(n) to solve this problem?
On Sat, Oct 23, 2010 at 7:51 PM, preetika tyagi preetikaty...@gmail.comwrote:
Is
You have to scan every pair of points only once to get the value of 'm' and
'a', so the time complexity would be O(n^2).
On Sat, Oct 23, 2010 at 6:22 PM, Meng Yan mengyan.fu...@gmail.com wrote:
there are (n*(n-1))/2pairs of points. I think if we use your method, the
time complexity should be
Dontula
Sent: 29/09/2010, 09:25
To: algogeeks@googlegroups.com
Subject: Re: [algogeeks] Algorithm to determine the largest number of
envelopes that can be nested inside one another.
I think we can do like this,
1. Sort all the xi's in ascending order - nlog(n)
2. Then find the longest
: Sathaiah Dontula
Sent: 29/09/2010, 09:25
To: algogeeks@googlegroups.com
Subject: Re: [algogeeks] Algorithm to determine the largest number of
envelopes that can be nested inside one another.
I think we can do like this,
1. Sort all the xi's in ascending order - nlog(n)
2. Then find
about finding the most optimal solution and not
just solution.
Rgds
Adi
-Original Message-
From: Sathaiah Dontula
Sent: 29/09/2010, 09:25
To: algogeeks@googlegroups.com
Subject: Re: [algogeeks] Algorithm to determine the largest number of
envelopes that can be nested inside one
.
Rgds
Adi
-Original Message-
From: Sathaiah Dontula
Sent: 29/09/2010, 09:25
To: algogeeks@googlegroups.com
Subject: Re: [algogeeks] Algorithm to determine the largest number of
envelopes that can be nested inside one another.
I think we can do like this,
1. Sort all the xi's
The problem here is more about finding the most optimal solution and not just
solution.
Rgds
Adi
-Original Message-
From: Sathaiah Dontula
Sent: 29/09/2010, 09:25
To: algogeeks@googlegroups.com
Subject: Re: [algogeeks] Algorithm to determine the largest number of envelopes
that can
I think we can do like this,
1. Sort all the xi's in ascending order - nlog(n)
2. Then find the longest increasing sequence of yi's - nlog(n)
3. complexity will be nlog(n).
Thanks,
Sathaiah Dontula
On Tue, Sep 28, 2010 at 11:37 PM, Prashant Kulkarni
prashant.r.k...@gmail.com wrote:
i think
You are given an unlimited number of each of n different types of
envelopes. The dimensions of envelope type i are xi × yi.(i is in sub
script) In nesting envelopes inside one another, you can place
envelope A inside envelope B if and only if the dimensions A are
strictly smaller than the
A possible solution i can think is create a directed graph where each
vertex is a envelope and edges are from a bigger envelope to smaller
envelope ( one which can fit in bigger envelope ) . Now the problem is
reduce to finding longest path in the graph .
Regards
Rahul
--
You received this
i think it is similar to finding max in a list O(n) or sorting algorithm
O(n log n)
-- Prashant Kulkarni
On Tue, Sep 28, 2010 at 11:33 PM, Rahul Singal rahulsinga...@gmail.comwrote:
A possible solution i can think is create a directed graph where each
vertex is a envelope and edges are
Generate all binary strings of length k. For eg: S={1,2,3,4,5} generate all
binary strings of length 5. 0 represents that particular number is absent
and 1 for the presence of the number.
On Fri, Aug 13, 2010 at 11:35 PM, asdf gyanendra1...@gmail.com wrote:
Most efficient algorithm to find all
Most efficient algorithm to find all subsets of size K??
--
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
given a rand5 function which generates numbers from 1 to 5 with equal
probability.. give an algorithm which uses rand5 function and generates
numbers from 1 to 7 with equal probability
--
With Regards,
Jalaj Jaiswal
+919026283397
B.TECH IT
IIIT ALLAHABAD
--
You received this message because you
Good approach Shiv.I think thats the best way to do so.The question does not
strictly say we have consecutive n-1 distinct numbers.So,its not worth
considering that particular case.
On Thu, Jul 29, 2010 at 12:08 AM, Shiv ... shivsinha2...@gmail.com wrote:
What if the number are not consecutive?
An array of unsorted numbers n is given with one no.repeated once ie
n-1 distinct nos to find duplicate no. in o(n) complexity
--
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
What if the number are not consecutive?
My approach-
Put the numbers in a hash till a collision occurs.
On Wed, Jul 28, 2010 at 9:21 PM, Apoorve Mohan apoorvemo...@gmail.comwrote:
Solution :
1. Find Xor of numbers from 1 to n-1.
2. Find Xor of the numbers present in the array.
3. Xor the
Add Each number from the stream to a Doubly linked list in sorted fashion
i = 1;
j = 1;
while( stream not empty)
{
if( i == 1 j == 1)
{
Median = Cur ; /*Create New list with ist Number*/
}
Add_Node_In_Sorted_Order(Cur);
If( If new node is added
*
*
*Using partition Logic of Quick Sort:
*
*Algoritm:*
1. pivot = 1st element.
2. Find the position of pivot in the array using partition logic of Quick
sort
3. If Rank lies on the right side of the position then call this function
with the right array
4. If rank lies on the
@Anand...for better efficiency..we can find the pivot as a random
integer..for better worst case complexity..
--
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
You are given a stream of numbers which can be positive or negative. You are
required to provide an operation FIND MEDIAN..which when invoked should be
able return the median of the numbers in stream (in sorted order) in O(1)
time.
Eg: 0 1 2 3 4
Right FIND MEDIAN returns 2 as median
Now input is
What are the best books/sites available to get a great hands-on on
algorithms?
I am basically looking for books/sites that explain well to a non-
computer-science student.
Maths/Algebra should be there but in an easy to understand manner and
should cover a really wide range.
A fat book should
2 coordinate points p(x,y)and q(x,y) are given and write an algorithm to
draw aline
--
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
draw a line or equation of a line?
On Mon, Jul 12, 2010 at 4:38 PM, Anand anandut2...@gmail.com wrote:
2 coordinate points p(x,y)and q(x,y) are given and write an algorithm to
draw aline
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To
Algorithm to draw a line. While searching on net, I got few pointers.
http://www.cs.unc.edu/~mcmillan/comp136/Lecture6/Lines.html
On Mon, Jul 12, 2010 at 4:53 PM, ashish agarwal
ashish.cooldude...@gmail.com wrote:
draw a line or equation of a line?
On Mon, Jul 12, 2010 at 4:38 PM, Anand
You are given a set of phrases (let us call them keywords), each of
1-4 words. Group the keywords into clusters (groups of keywords) by
picking keywords which are similar to each other.
There are multiple ways to cluster(group) them
1) using single keyword as the cluster name. Eg cluster name
Jig saw puzzle, What are the data structures? Assume you have some
method which can tell you if two pieces fit together. How would you
solve the puzzle, minimizing the number of times you have to call that
function?
--
You received this message because you are subscribed to the Google Groups
given 2N points in a plane. Pair up to obtain N distinct pairs such
that total sum of paired distances is minimum.
N can be atmost 50.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
Hi,
On Tue, Nov 24, 2009 at 6:38 PM, Ankur ankuraror...@gmail.com wrote:
What would be the best algorithm for the undermentioned problem.
Implement method PrintFamilyTree() that prints out the Name and
Generation of the tree
Output should resemble
Name: Jan Generation:0
Name: Mike
void PrintFamilyTree(const short generation)
{
printf(Name : %s Generation = %d\n, m_Name.c_str(),generation);
vectorHuman*::iterator it;
for (it = this.begin(); it this.end() ;it++)
{
it-PrintFamilyTree(generation+1);
}
}
On Tue, Nov 24, 2009 at 9:20 PM, Aditya Shankar
Hi,
I'm a hobbyist programmer and need an algorithm for finding a best fit
for laying out a grid of graphics objects (square pictures with
captions) in a given rectangle or in a given range between X1 and X2.
User defined input:
imageCount
imageMinSide, imageMaxSide
gutterMin, gutterMax
X1 X2
There are plenty of games on net, where You have fixed (randomly
generated) letters (let's say fifteen of them) and You have to make up
as many valid words You can.
There are some constraints, like word must bet nominative noun, but it
doesn't really matters, You count on external word-list.
Hello,
I am writting to ask if you know the difference between algorithm
composition, algorithm combination and algorithm aggregation.
For example, a weighted sum of algorithms I think that it is a
combination.
But I can imagine examples of composition or aggregation.
Thank you very much
Hi.
What we have: we have a black box with some unknown crypto algorithm
inside.
We can test it as many times as we want, placing input data and key at
input and see output.
We know that black box is just one something like LFSR implementation
(Linear feedback shift register), modified somehow,
Subject: [algogeeks] algorithm brute-forcing
To: Algorithm Geeks algogeeks@googlegroups.com
Hi.
What we have: we have a black box with some unknown crypto algorithm
inside.
We can test it as many times as we want, placing input data and key at
input and see output.
We know that black box is just one
On 8 апр, 03:03, Pradeep Muthukrishnan
[EMAIL PROTECTED] wrote:
I dont completely get the question...Is the set of possible inputs bounded?
If yes, then why cant we generate all possible inputs and feed it to the
black box? hope u can clarify it more?
I'm sorry, more on that is there:
hi,
I am new to this group, I am looking for an algorithm
for allocating time-slots in a scheduling table.
Scheduling table has a depth of n ( max value 2048 )
time slots and it can be used to schedule m ( max
value 512 ) queues.
A queue can have at most 12 time slots in the calendar
table. Main
Hey all,
I want to get the numbers from 0-16384 whose equivalent binary number
has at the most 4 1s in it.
I can do this by setting up a counter and doing an AND operation of a
number with all numbers which are power of 2 between 0-16384. I update
the couter for each successful AND operation
72 matches
Mail list logo