If virtualization is concerned, then answer would be choice d. Since its
not necessary to load complete process in memory.
On Sat, Dec 8, 2012 at 12:45 AM, sahil gupta sahilgupta...@gmail.comwrote:
It's b.
Windows follow this Operation.
On Fri, Dec 7, 2012 at 4:21 AM, manish
this. because we are maintaining only one visited
matrix.
On Wed, Oct 17, 2012 at 7:54 AM, Navin Kumar algorithm.i...@gmail.comwrote:
@Rahul: Loop won't occur because when you are visiting any matrix element
then you are marking 1 in visited matrix. So second time it will be seen
@Rahul: Loop won't occur because when you are visiting any matrix element
then you are marking 1 in visited matrix. So second time it will be seen as
a already visited element and it will choose another element (or path if
exist) or will blocked.
On Tue, Oct 16, 2012 at 9:31 AM, Rahul Kumar Patle
=sizeof(arr)-1;
do
{
if(elem==arr[n])
print found;
n--;
}while(n);
On Mon, Oct 1, 2012 at 9:33 AM, Navin Kumar algorithm.i...@gmail.comwrote:
@atul: keep one more checking outside loop for element at 0 th index.
Because when n = 0 the your loop come out from the loop
@atul: keep one more checking outside loop for element at 0 th index.
Because when n = 0 the your loop come out from the loop without comparing
it.
On Mon, Oct 1, 2012 at 8:55 AM, atul anand atul.87fri...@gmail.com wrote:
n=sizeof(arr);
n--;
while(n)
{
if(elem=arr[n])
On Sun, Sep 23, 2012 at 5:08 PM, Navin Kumar algorithm.i...@gmail.comwrote:
Build a common suffix tree for the given string and for its reverse. Then
take out the string ending at maximum depth at a common node. Time
complexity would be linear.
On Sat, Sep 22, 2012 at 5:33 PM, Aditya Raman
-5, Navin Kumar wrote:
@all: Please explain question number 8. I am not getting the question
exactly what it says ?
On Fri, Sep 21, 2012 at 9:30 AM, Dave dave_an...@juno.com wrote:
@Bharat: Simulate long division, dividing a number ...1 by the
number. You can do this one digit at a time
@all: Please explain question number 8. I am not getting the question
exactly what it says ?
On Fri, Sep 21, 2012 at 9:30 AM, Dave dave_and_da...@juno.com wrote:
@Bharat: Simulate long division, dividing a number ...1 by the number.
You can do this one digit at a time, printing the
Which data structure is used to maintain browser history?
--
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/-/MCj-0bFwvV0J.
To post to this group, send email to
and add it
to hastable.
clear all previous monday to sunday queues.
and start creating queue for new week.
On Tue, Sep 18, 2012 at 1:20 PM, Navin Kumar algorithm.i...@gmail.comwrote:
Which data structure is used to maintain browser history?
--
You received this message because you
it dynamically changing leads lot of
other questions before going give algo .
On Sat, Sep 8, 2012 at 7:43 PM, Navin Kumar algorithm.i...@gmail.comwrote:
Given a file which has billions of words and file can be loaded in
memory. Now find 10 most frequent words in file. What if file is
dynamically
...@gmail.com wrote:
hashmap for word to count mapping and a heap will have count and
corresponding words (will get updated at run time)
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
On Tue, Sep 11, 2012 at 2:07 PM, Navin Kumar algorithm.i
@tendua: answer would be 6C3. Read about combination definition.
On Thu, Sep 6, 2012 at 5:05 PM, atul anand atul.87fri...@gmail.com wrote:
question says *3 alphabets with no data repeated* ...you no need of doing
3! permutation.
eg 123 and 321 are same
On Thu, Sep 6, 2012 at 4:35 PM,
@tendua: Answer will be 6C3 x 3! .
For example: If 5 letters are given then you can get only 10 combination of
different letter = 5C3
ABC
ABD
ABE
BCD
BCE
CDE
ACD
ACE
ADE
BDE
now each of these can be arranged in 3! ways. So final answer will be : 120
On Fri, Sep 7, 2012 at 1:11 AM, tendua
@all: Now the problem is for getting O(n) time and O(1) space we have to
run two inorder traversal simultaneously. How can we do it??
On Mon, Sep 3, 2012 at 9:31 PM, Karthikeyan V.B kartmu...@gmail.com wrote:
@navin and @atul:
inorder traversal without recursion and stack can be done using
to sorted DLL..
now it is a double linked list , so we can find 2 number in O(n) time
by keeping 2 pointers(one at start and one at end) from sorted DLL.
now convert DLL to BST.
On Mon, Sep 3, 2012 at 1:32 AM, Navin Kumar algorit...@gmail.comwrote:
MICROSOFT:Given a BST and a number. Find two node
Given an unsorted integer array. Find the contiguous sub sequences whose
sum is 0.
--
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/-/pFvfWQjVrnkJ.
To post to
as the difference
between the sum of 2 prefixes.
3. for each entry search for the corresponding difference such the index
found is greater than original index.
Works for any sum, not just 0. Takes O(n log n)
On 2 September 2012 14:22, Navin Kumar algorithm.i...@gmail.com wrote:
Given an unsorted
@pradip: Finding same element in temp array is little bit tricky. For
displaying item from i+1 to j , you have to make sure that there is equal
element at i and j index in temp array. How will you ensure it in O(n) time?
On Sun, Sep 2, 2012 at 3:16 PM, Pradeep Mishra
void correctBST(struct node *root)
{
int flag =0;
static struct node *temp1, *temp2, *temp3, *prev;
static int found;
if(found) return;
if(root) {
correctBST(root-left);
if(!temp1 prev root-data prev-data) {
temp1 = prev;
temp2 = root;
that only works in
linear time if the input is entirely positive integers?
Maybe I'm being stupid but wont checking that array be quadratic?
On 2 September 2012 20:02, Navin Kumar algorithm.i...@gmail.com
wrote:
@pradip: Finding same element in temp array is little bit tricky. For
displaying
or notwhich will be O(n).
On 9/2/12, Navin Kumar algorithm.i...@gmail.com wrote:
@atul : suppose if all element of input array is zero then i think
hashing
will also produce n^2 output. so worst case time complexity would be
O(n^2).
On Sun, Sep 2, 2012 at 9:18 PM, Carl Barton
odysseus.ulys
--
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/-/aLuPUOKxmaoJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this
no reason why a trie or a tree node couldn't be used to
'represent'
more than one word. Although you'd take a penalty in the complexity for
searching etc.
On 31 August 2012 15:33, Navin Kumar algorithm.i...@gmail.com wrote:
Can we store multiple words in single TRIE node by using linked list
Can we store multiple words in single TRIE node by using linked list or
some other data structure. Based on the some property a node in TRIE will
hold all the word with same property.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view
@sangeeta: n-1 comparison required to choose winner. By tournament approach
winner has played match with logn team and winner must have beaten second
largest element. So among logn number we can select maximum in logn - 1
comparison.
So total comparison required is: n + logn -2
On Thu, Aug 30,
Q1 Solution: . we can use doubly linked list with hash to implement all the
operation in O(1).
By keeping track of head and tail pointer we can do enqueue and dequeue in
O(1) time.
In hash we will keep track of each element present in linked list(queue).
With node value as a hash key and address
Reversing a linked list if loop exists:
1. Find the node from which loop start by any loop finding algorithm in
linked list and keep the position of that node.
2. Unroll the loop i.e. set the last node's(last unrepeating node) next
pointer to NULL.
3. Reverse this singly linked list.
4. Change
Few more Test cases :
Check for 10 node.
Check for 1 million node
Check for even number of nodes
Check for odd number of nodes...
etc etc...
On Fri, Aug 24, 2012 at 6:25 PM, Navin Kumar algorithm.i...@gmail.comwrote:
Reversing a linked list if loop exists:
1. Find the node from which loop
Anagram problem solution using TRIE..
For each word in dictionary we will put it in TRIE as..
1. First sort the word
2. Search in trie using sorted word. If search found then we will add the
original word in that TRIE node.
3. If node node not found then using simple TRIE insertion insert
x ^= 15;
(^ = bit wise xor)
On Wed, Aug 22, 2012 at 4:16 PM, Abhi abhi120@gmail.com wrote:
Write a one line code to invert the last four bits of an integer ?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on
@Ashish: According to your algo making multimap itself takes O(mn) time
complexity (preprocessing). After then getting anagram of a string takes
O(n) time. Am i right?
On Thu, Aug 23, 2012 at 6:51 AM, Ashish Goel ashg...@gmail.com wrote:
O(n)
convert each string into format a1b2and then
with probability 1/i.
When EOF is reached, every word in the file will have probability 1/n of
being the saved word. Print it.
Dave
On Saturday, August 18, 2012 1:28:56 AM UTC-5, Navin Kumar wrote:
Print a *Random word* from a file. Input is path to a file,
constraints- No extra memory like
Print a *Random word* from a file. Input is path to a file,
constraints- No extra memory like hashing etc. All the words in the file
should have equal probability.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on
We have to consider cases when an element is zero.
On Thu, Aug 16, 2012 at 7:07 PM, shady sinv...@gmail.com wrote:
well we can do with just one array. Overwrite the answer directly on
left[] array.
On Thu, Aug 16, 2012 at 6:47 PM, mohit mohitsingh1...@gmail.com wrote:
here are the steps
We can solve using Dynamic programming..
Take n*2 matrix for storing sum. Let A be original matrix and matrix M hold
sum. Let M[i, j] contains max sum upto i th row and j th column.
recursion will be as follows:
M[i, j] = max(M[i - 1, j], M[i, j-1]) + A[i, j]
By above formula fill whole M
the question again and join us for solving the main problem
On Sun, Aug 12, 2012 at 4:19 PM, Navin Kumar algorithm.i...@gmail.comwrote:
We can solve using Dynamic programming..
Take n*2 matrix for storing sum. Let A be original matrix and matrix M
hold sum. Let M[i, j] contains max sum upto i th row
I think best data structure would be Optimal BST
On Fri, Aug 10, 2012 at 11:47 PM, Kumar Vishal kumar...@gmail.com wrote:
Huffman tree ???
On Fri, Aug 10, 2012 at 11:38 PM, Varma Selvaraj varm...@gmail.comwrote:
A data cache needs to be implemented for the top 100 data items selected
@vaibhav : yes it will be a balanced BST.
On Wed, Aug 8, 2012 at 11:29 AM, vaibhav shukla vaibhav200...@gmail.comwrote:
@Navin
By your algo of starting with the middle node,I guess a balanced BST would
be created. Is it ?
On Wed, Aug 8, 2012 at 1:24 AM, Navin Kumar algorithm.i
1. Convert your Binary tree into doubly linked list.
2. Sort the linked list using merge sort
3. Build BST using doubly linked list by each time selecting middle node
and recursively calling left part of linked list and right part of linked
list.
On Tue, Aug 7, 2012 at 10:23 PM, vaibhav shukla
This is a linear time constant space algorithm.
Assume the stocks prices are given in an array where index represents the
day no . For ex a[365] represents stock price on 365th day of year.
Find the min and max element in the array.
If the min comes before max, then return the dates- min to
++]=arr[i];
a[l++]=arr[j++];
a[l++]=arr[k++];
}
for(int i=0;in;i++)
arr[i]=a[i];
free(a);
}
cud be dun be dun recursively also to minimize d space complexity...
On Sat, Aug 4, 2012 at 8:20 AM, Navin Kumar algorithm.i...@gmail.comwrote:
In given array of elements like
[a1,a2,a3,..an,b1
Given the array of digits, you have to calculate the least positive
integer value of the expression that could *NOT *have been received by you.
The binary operators possible are *, +, -, / and brackets possible are (
and ). Note that / is an integer division i.e. 9/5 = 1.
For ex- 6 6 4 4 the
In given array of elements like [a1,a2,a3,..an,b1,b2,b3,..bn,c1,c2,c3,...cn]
.Write an efficient program to merge them like
[a1,b1,c1,a2,b2,c2,...an,bn,cn].
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web
@sahil: Please elaborate your question. I didn't understand your question.
what is straight doubly linked list?? How many pointers each node have??
On Thu, Aug 2, 2012 at 4:26 PM, Amit Basak abas...@gmail.com wrote:
Does each node in the list have three pointers?
What do you mean by straight
can get
using the DLL/array given ..?
On Tue, Jul 31, 2012 at 10:57 PM, manish untwal
manishuntw...@gmail.comwrote:
hey friends,
just wanted to ask like what they ask in quants and DI
On Tue, Jul 31, 2012 at 10:45 PM, Navin Kumar
algorithm.i...@gmail.comwrote:
@Daksh: total number
You are blindfolded and 20 coins are placed on the table in front of you.
Out of them 10 coins have heads facing up and other tails. You are allowed
to flip and move the coins. You should divide those coins into two sets
such that one set contains 10 heads and other tails. You are allowed to
@Daksh: total number of BST possible with n nodes will be : catalan number
we can build balanced BST by each time selecting middle element as a root
node and its left pointer will point to left linked list and right pointer
will point to right linked list. Do it recursively for left list and
think we are blindfolded..
how can we know afetr dividing 10 coins that 7 r heads.. or 'x' are heads
and we need to flip it over.. ?
On Tuesday, 31 July 2012 12:33:09 UTC+5:30, Navin Kumar wrote:
You are blindfolded and 20 coins are placed on the table in front of you.
Out of them 10 coins
Given array of integers (0 or +ve or -ve value) find two elements having
minimum difference in their absolute values.
e.g. Input {10 , -2, 4, 9,-20,17,-8,14,12)
output {9,-8}
I have solved it in O(nlogn). can it be solved in O(n).
--
You received this message because you are subscribed to the
#include stdio.h
#include stdlib.h
#include ctype.h
char *decrypt(char *s)
{
int n;
char *digit = (char *)malloc(sizeof(char) * 5);
char *p1 = (char *)malloc(sizeof(char) * 1024);
char *p = p1;
char *digit2;
char prev;
prev = *s;
*p++ = *s++;
while(s != '\0') {
logic is very simple ...just trace the program you will understand.
On Wed, Jul 25, 2012 at 7:28 PM, Navin Kumar algorithm.i...@gmail.comwrote:
#include stdio.h
#include stdlib.h
#include ctype.h
char *decrypt(char *s)
{
int n;
char *digit = (char *)malloc(sizeof(char) * 5);
char
Given a Circuit (with resistors), we need to calculate the total
resistance. Input will be like AB-5ohm, BC-6ohm, BC-10ohm, BC-20 ohm, CD-5
ohm. BC has been repeated twice implying they are in parallel. Write a
program by implementing efficient data structure for storing and
calculating the
18, 2012 at 2:07 AM, Navin Kumar algorithm.i...@gmail.com
wrote:
Assuming a preexisting list of 100 words, how would you efficiently
see if a word received from input is an anagram of any of the 100 words?
--
You received this message because you are subscribed to the Google
Groups Algorithm
, July 14, 2012 2:55:48 PM UTC-5, Navin Kumar wrote:
A set of integer values are being received (1 per day). Store these
values and at any given time, retrieve the min and max value over the last
k days. What data structures would you use for storing and retrieving ?
--
You received this message
Assuming a preexisting list of 100 words, how would you efficiently see if
a word received from input is an anagram of any of the 100 words?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
wrote:
Min or max heap accordingly. This will do the job in O(log n) time.
On Sun, Jul 15, 2012 at 1:25 AM, Navin Kumar algorithm.i...@gmail.comwrote:
A set of integer values are being received (1 per day). Store these
values and at any given time, retrieve the min and max value over the last
A set of integer values are being received (1 per day). Store these values
and at any given time, retrieve the min and max value over the last k days.
What data structures would you use for storing and retrieving ?
--
You received this message because you are subscribed to the Google Groups
Given Preorder and postorder traversals of a tree. Device an algorithm to
constuct a fully binary tree from these traversals.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
--
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/-/lZRdyZn85fcJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this
need not check further down or recursively. {why? reason it.. its
simple}
On Wednesday, 27 June 2012 18:35:12 UTC-4, Navin Kumar wrote:
Design an algorithm that, given a list of n elements in an array, finds
all the elements that appear more than n/3 times in the list. The algorithm
should
or recursively. {why? reason it.. its
simple}
On Wednesday, 27 June 2012 18:35:12 UTC-4, Navin Kumar wrote:
Design an algorithm that, given a list of n elements in an array, finds
all the elements that appear more than n/3 times in the list. The algorithm
should run in linear time
( n =0 ).
You
Minimum no. weighings:
Divide 8 coins in group of 3, 3 and 2.
For minimum weighsing group1 's total weight is x units(say) --FIrst
weighing
Groups 2nd total weights is y units Second weighing.
Lastly one more weighing among a unit and b unit coins.---3 rd weighing
So minimum 3
. Depending upon outcome we will
categorize them a and b.
So 3 weighing is required.
On Tue, Jul 10, 2012 at 7:05 PM, payal gupta gpt.pa...@gmail.com wrote:
@navin...Sorry didnt get you how come u were able to segregate all the
coins by the proposed method??
On 7/10/12, Navin Kumar
Given two strings .Print all the interleavings of the two strings.
Interleaving means that the if B comes after A .It should also come after A
in the interleaved string.
ex-
AB and CD
ABCD
ACBD
ACDB
CABD
CADB
CDAB
--
You received this message because you are subscribed to the Google Groups
@payal:
In this case too i think minimum number of weighing required is 3.
Slightly change in my previous solution. x1+x2+x3 = 3x and y1+y2+y3 = 3y.
On Wed, Jul 11, 2012 at 8:00 AM, payal gupta gpt.pa...@gmail.com wrote:
@ Dave sir
the balance considered here is simple balance scale
Let A[n] be an array of n distinct number. If ij and A[i] A[j] then the
pair (i , j) is called inversion of A.
Give an algorithm that determines the total number of inversions in
O(nlogn) time.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks
Thanx Deepika :)
On Sun, Jul 8, 2012 at 11:48 AM, deepikaanand swinyanand...@gmail.comwrote:
http://www.geeksforgeeks.org/archives/3968
On Jul 8, 11:01 am, Navin Kumar algorithm.i...@gmail.com wrote:
Let A[n] be an array of n distinct number. If ij and A[i] A[j] then
the
pair (i , j
@Vindhya: BST can be reconstructed only by preorder traversal. In case of
binary tree we need two traversal inorder and pre/post order
On Wed, Jul 4, 2012 at 1:07 PM, vindhya chhabra vindhyachha...@gmail.comwrote:
u need inoder traversal as well
On Wed, Jul 4, 2012 at 11:22 AM, Navin Kumar
we can serialize the binary tree using preorder traversal and marking NULL
pointer as '#'.
source:
http://www.leetcode.com/2010/09/serializationdeserialization-of-binary.html
On Wed, Jul 4, 2012 at 4:21 PM, Ashish Goel ashg...@gmail.com wrote:
my understanding is to either write the level
Suppose a file.txt contains : 50 40 30 # # 5 # 10 # #
i want to fetch only integers. How should i fetch it. I tried with fgetc
and fscanf but it was too complicated.
My approach: fetched one word at a time and put it into separate string and
then i converted that string to integer(if each
--
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/-/xmZH9KY72_IJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this
Design an algorithm that, given a list of n elements in an array, finds all
the elements that appear more than n/3 times in the list. The algorithm
should run in linear time
( n =0 ).
You are expected to use comparisons and achieve linear time. No
hashing/excessive space/ and don't use
whether it is in character array or integer array??
On Tue, Jun 26, 2012 at 3:40 PM, Ashish Goel ashg...@gmail.com wrote:
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
--
You received this message because you are subscribed to the Google
please provide some good data structure to solve this problem:
http://www.careercup.com/question?id=14062676
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
--
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/-/xM3mGdcfvi4J.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this
Is this similar to finding the diameter of a tree(longest disteance between
two leaves) ?? If yes than visit this link
http://www.cs.duke.edu/courses/spring00/cps100/assign/trees/diameter.html
On Sat, Jun 23, 2012 at 2:44 PM, Avinash jain.av...@gmail.com wrote:
Some how I found that we need to
Is longest path between two node in a tree is equal two logest path between
two leaves??
On Sat, Jun 23, 2012 at 5:35 PM, Navin Kumar algorithm.i...@gmail.comwrote:
Is this similar to finding the diameter of a tree(longest disteance
between two leaves) ?? If yes than visit this link
http
Extract words from file and make a BST. Then do inorder traversal and print
them.
On Fri, Jun 22, 2012 at 3:52 PM, Sourabh Singh singhsourab...@gmail.comwrote:
u can use stl::map(string,vectorstring)
idea is same bucket sort :-)
On Fri, Jun 22, 2012 at 3:02 AM, Eshwar eshwaronl...@gmail.com
How to reverse a Queue .
Constraints: Time complexity O(n). space complexity: O(1)
--
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/-/kepls-8qRwgJ.
To post to
, Jun 20, 2012 at 6:39 PM, saurabh singh saurabh.n...@gmail.comwrote:
count the size of queue : O(n)
loop for n and do remove and add in queue : O(n)
Total : O(n)
On Wed, Jun 20, 2012 at 6:34 PM, Navin Kumar algorithm.i...@gmail.comwrote:
How to reverse a Queue .
Constraints: Time
, 2012 at 6:46 PM, Navin Kumar algorithm.i...@gmail.comwrote:
@Saurabh: queue will be remain unchanged according to your algorithm.
Because if you will delete an element from front and add at rear no change
will be there. After n iteration front will be pointing to same element and
rear will also
, Jun 20, 2012 at 6:46 PM, Navin Kumar algorithm.i...@gmail.comwrote:
@Saurabh: queue will be remain unchanged according to your algorithm.
Because if you will delete an element from front and add at rear no change
will be there. After n iteration front will be pointing to same element and
rear
return nQ
end
return q
end
On Wednesday, June 20, 2012 6:57:23 PM UTC+5:30, Navin Kumar wrote:
Use only standard operation of Queue like: EnQueue, DeQueue, IsEmptyQueue
etc
On Wed, Jun 20, 2012 at 6:50 PM, amrit harry dabbcomput...@gmail.comwrote:
can we create other methods or we
@saurabh : i want solution with space complexity of O(1) . your solution is
right but it takes O(n) space.
On Wed, Jun 20, 2012 at 8:28 PM, saurabh singh saurabh.n...@gmail.comwrote:
Why will my proposed solution not work for you ???
On Wed, Jun 20, 2012 at 8:19 PM, Navin Kumar algorithm.i
saurabh.n...@gmail.comwrote:
How ??
I am asking to manipulate the same queue.
Dequeue n-1 elements and enqueue them in order to you take out to the same
queue..Where is extra space involved ?
On Wed, Jun 20, 2012 at 8:36 PM, Navin Kumar algorithm.i...@gmail.comwrote:
@saurabh : i want solution
@Rishabh: i know using stack or recursion it can be done easily with O(n)
space. I want to know whether there exist more space efficient algo for
this problem or not?
On Wed, Jun 20, 2012 at 9:20 PM, Rishabh Agarwal rishabh...@gmail.comwrote:
@Navin: as you say you have to take stack or some
@Umer:
rand(5) + (rand(5)%2): = it will never give 6 because for rand(7) range
will be 0-6.
So better try this: rand(5) + (rand(5)%3).
On Tue, Jun 19, 2012 at 2:45 PM, Umer Farooq the.um...@gmail.com wrote:
rand(5) + (rand(5)%2);
On Tue, Jun 19, 2012 at 12:30 PM, Sourabh Singh
void Reverse(struct Stack *S) {
int data;
if(IsEmptyStack(S)) return;
data=pop(s);
ReverseStack(S);
InsertAtBottom(S, data);
}
void InsertAtBottom(struct stack *S, int data)
{
int temp;
if(!IsEmptyStack(S)){
push(S,data);
return;
}
temp=pop(S);
@all:
In my code isntead of (!IsEmptyStack) use IsEmptyStack
Logic :
First pop the all element and then start putting element at bottom in
reverse order i.e. the element which is fetched last is put at the bottom
and so on.
ex: let our stack is: 1 2 3 4 (1 is at bottom).
function Call is will
I corrected in function InsertAtBottom :In my code isntead of
(!IsEmptyStack) use IsEmptyStack
On Fri, Jun 15, 2012 at 10:49 AM, Navin Kumar algorithm.i...@gmail.comwrote:
@all:
In my code isntead of (!IsEmptyStack) use IsEmptyStack
Logic :
First pop the all element and then start putting
@Ashot: You can traverse array one time. In your case you are traversing
twice. First for counting occurrence of R , G and B then again traversing
for assigning values. But constraints is that you have to traverse only
once.
On Sun, Jun 10, 2012 at 5:13 PM, Akshat Sapra sapraaks...@gmail.com
Write an efficient program that prints the distinct words in its input
sorted into decreasing order of frequency of occurrence. Precede each word
by its count.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the
Given a character array as input. Array contains only three types of
characters 'R', 'G' and 'B'. Sort the array such that all 'R's comes before
'G's and all 'G's comes before 'B's.
Constraint :- No extra space allowed(except O(1) space like variables) and
minimize the time complexity.
You
but was
getting 8 32 96...and dats the correction required which i made
On Fri, Jun 8, 2012 at 8:08 AM, Navin Kumar algorithm.i...@gmail.comwrote:
@Mahendra: for ur above code with t=(a2)+a o/p will be 5,10, 15 as i
explained above. without bracket answer will be 8 , 32 and 96 because +
precedence
one left shift is equivalent to multiplying with 2.Two left is equivalent
to multiplying with 2^2. and so on. so i left shift means multiplying with
2^i.
In your program you did left shift with 2.so it is equivalent to
multiplying with 4. so when input is 1 function will return 4*1+1=5. when
@Mahendra: for ur above code with t=(a2)+a o/p will be 5,10, 15 as i
explained above. without bracket answer will be 8 , 32 and 96 because +
precedence is higher than .
On Fri, Jun 8, 2012 at 7:31 AM, Mahendra Sengar sengar.m...@gmail.comwrote:
Cracked it...i guess precedence of + is more than
#include stdio.h
#include stdlib.h
#include sys/types.h
#include dirent.h
#include unistd.h
#include ctype.h
#include string.h
void dirfun(char *);
int main()
{
char *home=/home/navin/temp/;
dirfun(home);
return 0;
}
void dirfun(char *path)
{
struct dirent
you can set your directory path in this line
char *home=/home/navin/temp/;
On Sun, Jun 3, 2012 at 11:26 AM, Navin Kumar algorithm.i...@gmail.comwrote:
#include stdio.h
#include stdlib.h
#include sys/types.h
#include dirent.h
#include unistd.h
#include ctype.h
#include string.h
void
I think the easiest method to do this problem is this:
http://k2code.blogspot.in/2011/09/deleting-node-in-singly-linked-list-if.html
On Thu, May 31, 2012 at 5:58 PM, Ashish Goel ashg...@gmail.com wrote:
that is what i have done by using recursion=stack.
my code has problem, after
1 - 100 of 105 matches
Mail list logo