Hi ,
I think we can do a very generic solution by
dividing the target in three cases
1) Target is smaller than all the 6 integer
2) Target is in between the 6 integers
3) Target is greater than all 6 integers
solving case 1) search if any given integer is multiple of the target else
try to get t
I guess we are allowed to use the operation multiple times.
I had thought of the solution, could you please look below and tell me
whether I'm missing any case or not.
I know the complexity of the solution is very bad(exponential).
But if you have some other cool algorithm I would be happy to hear.
are we allowed to use operation only once or multilpe times?
On Fri, Mar 22, 2013 at 6:27 AM, prankur gupta wrote:
> 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 intege
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 Brook
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 algogeeks@googlegroups.c
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
algogeeks+unsubsc
First thing on my Mind External Sorting.
On Wed, May 23, 2012 at 7:21 PM, Decipher 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 (file1, file2)
> file1 h
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
internal_nodes=TotalNodes(root) - No_of_leaf_nodes(root);
On Wed, May 9, 2012 at 1:19 PM, Amit Jain 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 Complexity: O
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 wrote:
> you are n
you are not checking whether the current node is an internal node or not !!
On Thu, May 3, 2012 at 12:47 AM, Rose wrote:
> Is this algorithm right or how shall I write it?
>
> *
> *
>
> *
> *
>
> *Construct an algorithm **Intern(**x**)**, which returns the number of
> internal nodes in the tree.
Is this algorithm right or how shall I write it?
*
*
*
*
*Construct an algorithm **Intern(**x**)**, which returns the number of
internal nodes in the tree. *
* *
Algorithm Intern(x)
1: if (x = nil) then
2: return 0
3: else
4: return 1 + Intern(left[x]) + Intern(right[x])
5: en
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= fork()
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 t
Hi Guys,
I created this page to place some materials on algorithms. Suggestions are
welcome.
https://sites.google.com/site/quixadamaratona/
Ps: The page is in Portuguese.
Best wishes,
*
*
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
You are given two end points ( consider them as two end stations
at some distance ) there are 100 stations between these two . Now you
need to build a train track between these two end points which
includes only 10 stations and not more than that . Now the objective
is to find such 10 stations suc
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
can be done in O(n) with hashing
On Wed, Aug 31, 2011 at 11:09 AM, Ankit Minglani
wrote:
> one method can be :
>
> Let T = the sum
>
> for(i=0;i {
>temp=T- x[i];
>// perform a binary search on array[ i+1. n-1] to find temp it if
> does then just output.
> }
>
>
>
>
>
>
>
>
>
>
>
>
> O
one method can be :
Let T = the sum
for(i=0;i wrote:
> Its brute force method.O(n^2) algo...
> for(int i=0;i for(int j=i+1;j {
> if(x==A[i]+A[j])
> { print A[i],A[j]; break;}
>
> }
>
> On Wed, Aug 31, 2011 at 1:15 AM, Reynald wrote:
>
>> For example, in array, say,
>> <
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;i for(int j=i+1;j {
>
Its brute force method.O(n^2) algo...
for(int i=0;i wrote:
> 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 alg
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
algoge
@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 wrote:
> Here is a modified function that finds the element that crosses a
> particular percentage in an array. Please note tha
Here is a modified function that finds the element that crosses a particular
percentage in an array. Please note that the code returns a false value if
there is no number that appears more frequently than the input percentage.
Loop through the array in O(n) and ensure that num indeed is an acceptab
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)
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 algogeeks@goog
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 algogeeks@googlegroups.co
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
algogeeks+unsubscr...@goo
Can you suggest a sample program which has complexity O(log log n)?
Regards
Ajai Sathyan
--
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 e
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 si
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
wrote:
> @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
@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
wrote:
> Can you bit descriptive..
>
>
> On Sat, Jun 11, 2011 at 7:27 PM, rahul rai wrote:
>
>> Count the number of spaces i
Can you bit descriptive..
On Sat, Jun 11, 2011 at 7:27 PM, rahul rai 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 wrote:
> > I wonder if th
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 wrote:
> Hi,
> Can anyone have algorithm or program for convert word into number
>
> Input. Three hundred twenty three : o
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 wrote:
> I wonder if there is any practical use of this algorithm for real life
> implementation . . Please let m
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 po
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 wrote:
> Hi all,
>
> I am working on dynamic resource allocation problem. I have set of
> Consumer and resource. Consumers are with priority (
how much resource each customer needs...??
On Wed, May 4, 2011 at 6:13 PM, LiveShell 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 slice to each con
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
--
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
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 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 poss
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 wrote:
> Is there any specific nee
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 wrote:
> Given n point on the plane
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" g
;>>
>>> On Fri, Oct 1, 2010 at 6:00 AM, adit.sh...@gmail.com <
>>> adit.sh...@gmail.com> wrote:
>>>
>>>> The problem here is more about finding the most optimal solution and not
>>>> just solution.
>>>> Rgds
>>>> Ad
t;>
>>> 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.
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] Algo
gds
> 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
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 be
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 thi
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 wrote:
> A possible solution i can think is create a directed graph where each
> vertex is a envelope and edges are from a bigger envelope
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 mess
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 dimension
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 wrote:
> Most efficient algorithm to find all subsets of size K??
>
>
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
algogeeks+unsubscr...@goo
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
we can find the sum of all elements i.e, n(n+1)/2.
and then compute the sum of all squares of elements..i.e (n(n+1)(2n+1))/6
now u have two equations..u can now compute both the missing element and the
duplicate..
--
You received this message because you are subscribed to the Google Groups
"Algo
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 ... wrote:
> What if the number are not consecutive?
>
> My approach-
> Put
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 wrote:
> Solution :
>
> 1. Find Xor of numbers from 1 to n-1.
>
> 2. Find Xor of the numbers present in the array.
>
> 3. Xor the results from st
Solution :
1. Find Xor of numbers from 1 to n-1.
2. Find Xor of the numbers present in the array.
3. Xor the results from step 1 and 2 you will get the repeated number.
On Wed, Jul 28, 2010 at 8:46 PM, akshay wrote:
> An array of unsorted numbers n is given with one no.repeated once ie
> n-1
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
@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
*
*
*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 l
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 af
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 als
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
draw a line or equation of a line?
On Mon, Jul 12, 2010 at 4:38 PM, Anand 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 post to this
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
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 "gif
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
"Al
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 algoge...@googlegroups
void PrintFamilyTree(const short& generation)
{
printf("Name : %s Generation = %d\n", m_Name.c_str(),generation);
vector::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 <
iitm.adi
Hi,
On Tue, Nov 24, 2009 at 6:38 PM, Ankur 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 Generation:1
> Name: Gr
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 Generation:1
Name: Greg Generation:2
Name: Carol: Generation: 2
Name: Peter Generation: 3
Hi All,
Can anyone provide me a good program/algorithm to find all anagrams for a
given word.
Input string should be of variable length (max 26 char). Just printing is
not enough,
we need to store the output to a file or static memory somewhere.
Thanks in advance.
--
Dinesh Bansal
The Law of Wi
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. Let'
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 in
does anyone has jon kleinberg Algorithm design ebook.
Please mail as attachment.
Raj
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegr
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:
h
:36 AM
Subject: [algogeeks] algorithm brute-forcing
To: Algorithm Geeks
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 lik
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, bu
Hi,
I am looking for an efficient algorithm to search for k-median across
disjointed vectors.
For example, I have 10 different size arrays of floats (size varies
from 20k to 100k elements) from which I would like to get 1000th
element of the combined set (total set is 500k elements).
Current
Hi,
I would like to know which is the best algorithm for sorting 7
elements. I have an array which is having 7 columns and many rows. I
want to sort all the columns individualy. So i want to know which is
the algorithm that i have to use for it.
Thanks and regards
Amal P.
--~--~-~--
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 r
I'm new to the formal study of analyzing algorithms.
Questions for any reader with even a modicum of experience - thanks in
advance for any feedback!
1) What tools and techniques do you utilize when analyzing algorithms?
Is your preferred way to draw box-and-pointer diagrams out on paper,
for in
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 and
88 matches
Mail list logo