Re: [algogeeks] MS written Reasoning question

2013-05-03 Thread rahul sharma
@ashish...4 all selected...remaining 2 to be selected..1 m,ba 1 betch makes one 2 mba and 1 mca...but as it is not only option coz we can put 2 mcas at 2 remaing pos so this is not true...3 are ignored 4th must be true.. On Mon, Apr 29, 2013 at 7:37 AM, ashish gupta wrote: > Ans is 1 M.

Re: [algogeeks] MS written Reasoning question

2013-05-01 Thread ashish gupta
Ans is 1 M.A + 2 B.Tech + 2 MBA + 1 MCA. Explanation: (1) Exactly one must be an MA. (2) Given: "2 b.tech are seleceted" and the statement "if at least one btech is selected then exactly 2 MBA are selected (vice versa condition)" So exactly 2 MBA will be selected. (3) Remaining 1 would be MCA.

Re: [algogeeks] MS written Reasoning question

2013-05-01 Thread Padarn Wilson
b and d cannot be true at the same time. d) -> 2 MBA -> 2 BTECH -> 2 left to allocate. But b) allocates 3 more. On Sat, Apr 27, 2013 at 4:02 AM, rahul sharma wrote: > 10 candidates appear for an interview and 6 selected. > 2-M.A > 2-MCA > 4-BTECH > 2-MBA. > If at least one MBA is selected then

Re: [algogeeks] MS written Reasoning question

2013-05-01 Thread Padarn Wilson
(oh sorry forgot to mention - d must be true because of the statement 'if at least one MBA is selected then exactly 2 BTECH are selected and vice versa') On Mon, Apr 29, 2013 at 6:22 AM, Padarn Wilson wrote: > b and d cannot be true at the same time. > > d) -> 2 MBA -> 2 BTECH -> 2 left to allo

[algogeeks] MS written Reasoning question

2013-04-28 Thread rahul sharma
10 candidates appear for an interview and 6 selected. 2-M.A 2-MCA 4-BTECH 2-MBA. If at least one MBA is selected then exactly 2 btech are selected and vice versa. Of six candidates,exactly one must be an MA cndidate question:- which of the following statementsis definitely true:,if 2 btech are sel

Re: [algogeeks] MS interview question

2013-04-26 Thread achala sharma
1. Make a trie of all dictionary words. 2.then run a loop for all characters of string 3.suppose start from I ,as I is a word in dictionary,"word found" then increment counter 4.Now counter comes to X,no word found 5.Now it comes to A,two word could start from A(A and AM) now run this loop till end

[algogeeks] MS interview question

2013-04-14 Thread rahul sharma
Suppose you are given a string IAMABOY and a dictionary then divide it into I AM A BOY if it is possible to break form as many dictionary words from a string giveM able to solve it..but how if we are given a string like IXAFGMJAHBDSOXDY. how can we form I AM A BOY..will be done in Opower(2,n)

Re: [algogeeks] MS Question:WAP to print last n lines of a log file

2013-03-12 Thread Sairam Ravu
lines = 0; string last_n_lines[n]; //read each line into a circular buffer while(getline(file,last_n_lines[lines%n])) { lines++; } // if number of lines < n // then print all of them if(lines<=n) { start = 0; count = lines; } else { start = lines%n; count = lines; } //Now print all o

Re: [algogeeks] MS Question:WAP to print last n lines of a log file

2013-03-12 Thread sourabh jain
Read line by line . use doublylinkedlist(Queue)/ Circular Buffer of size N. when EOF is achieved print the lines. On Mon, Mar 4, 2013 at 9:10 AM, Ashish Goel wrote: > Q1. Given a log file, pirnt last n lines. Note that the Log file is being > written into. > Q2. Implement Circular Buffer. > > >

Re: [algogeeks] MS Question:WAP to print last n lines of a log file

2013-03-04 Thread Karthikeyan V.B
int main() { int n=10; cout<<"Enter the value of n:"; cin>>n; int i=0; ifstream file("C:\\Users\\kvb\\Desktop\\sample.txt"); string line; string buffer[n]; if(file.is_open()) { while(file.good()) { getline(file,line); buf

Re: [algogeeks] MS Question:WAP to print last n lines of a log file

2013-03-04 Thread Anurag Sharma
Both questions look related to me. If the log file is being updated as well simultaneously, you should be able to use Circular queue/buffer for that. On Mon, Mar 4, 2013 at 9:10 AM, Ashish Goel wrote: > Q1. Given a log file, pirnt last n lines. Note that the Log file is being > written into. > Q

[algogeeks] MS Question:WAP to print last n lines of a log file

2013-03-03 Thread Ashish Goel
Q1. Given a log file, pirnt last n lines. Note that the Log file is being written into. Q2. Implement Circular Buffer. Best Regards Ashish Goel "Think positive and find fuel in failure" -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To uns

Re: [algogeeks] MS Question

2013-01-22 Thread Amitesh Singh
you can't implement in O(log n). It can be done in O(log n) in case of Ranked BS Tree. -- Amitesh On Sun, Jan 20, 2013 at 6:23 PM, Praveen wrote: > If for all the nodes in BST we also store the size of subtree, then it is > possible to find nth smallest element in O(logN). > > On Sun, Jan 2

Re: [algogeeks] MS Question

2013-01-20 Thread Praveen
If for all the nodes in BST we also store the size of subtree, then it is possible to find nth smallest element in O(logN). On Sun, Jan 20, 2013 at 4:57 PM, Guneesh Paul Singh wrote: > not possible unless u use augmented bst..which itself takes o(n) to built > > -- > > > -- Praveen Sonare +91

Re: [algogeeks] MS Question

2013-01-20 Thread Mohanabalan D B
http://stackoverflow.com/questions/2329171/find-kth-smallest-element-in-a-binary-search-tree-in-optimum-way On Sun, Jan 20, 2013 at 4:57 PM, Guneesh Paul Singh wrote: > not possible unless u use augmented bst..which itself takes o(n) to built > > -- > > > --

Re: [algogeeks] MS Question

2013-01-20 Thread Guneesh Paul Singh
not possible unless u use augmented bst..which itself takes o(n) to built --

[algogeeks] MS Question

2013-01-19 Thread Umer Farooq
Given a BST, how would you return the nth smallest element. The code had to cover all the edge cases and was expected to write a logn solution. -- Umer --

Re: [algogeeks] MS interview

2012-08-24 Thread Navin Kumar
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 sorte

Re: [algogeeks] MS QUESTION

2012-08-24 Thread Navin Kumar
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 wrote: > Reversing a linked list if loop exists: > > 1. Find the node from which loop start by any loop findi

Re: [algogeeks] MS QUESTION

2012-08-24 Thread Navin Kumar
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

[algogeeks] MS QUESTION

2012-08-24 Thread sulekha metta
Hi all, This was asked in microsoft, question is write a program to reverse a linked list.and write it's test cases. i got very few test cases 1) check if the node is null 2) check if there is only one node 3) check if there is any loop in the linked list. can any one tell how to reverse

[algogeeks] MS interview

2012-08-24 Thread GAURAV CHAWLA
Ques Given a large text... in the text.. there are > , < etc representing > and <.(there can be others like &eq; etc) the task is to replace such (>) with the '>' symbol... and (<) with '<' given the table which have corresponding matches... and table is fin

Re: [algogeeks] MS interview

2012-08-22 Thread Navin Kumar
@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 wrote: > O(n) > convert each string into format a1b2and then insert into multim

Re: [algogeeks] MS interview

2012-08-22 Thread Ashish Goel
O(n) convert each string into format a1b2and then insert into multimap wityh this a1b2...as key and original word as value. All words with same key are anagrams Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Wed, Aug 22, 2012 at 11:39 PM, GAU

[algogeeks] MS interview

2012-08-22 Thread GAURAV CHAWLA
Ques.. Given a m-word dictionary ... and a n-sized word... .. now suggest DS for dictionary such that you can find out all the anagrams of the given word present in dictionary... -- Regards, G C -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" gr

Re: [algogeeks] MS Design Ques

2012-07-07 Thread Anshu Mishra
Best will be storing BIG_INT in array of integers. int [] val; //store actual number int size; // required length of val array. take the string as input for constructors and convert it into 2's complement form, maintaining little endian order or big endian order. Perform other operation keeping o

Re: [algogeeks] MS Design Ques

2012-07-07 Thread sravanreddy001
i was thinking of character array. which is same as string. Any thoughts on better alternatives? On Friday, 6 July 2012 13:34:01 UTC-4, anshu wrote: > > yes, We can have much better data structure for storing big integer > instead of string just for simplicity I have taken string. > > On Fri, Jul

Re: [algogeeks] MS Design Ques

2012-07-06 Thread Anshu Mishra
yes, We can have much better data structure for storing big integer instead of string just for simplicity I have taken string. On Fri, Jul 6, 2012 at 11:11 AM, Mithun Kumar wrote: > @anshuman... > > Are you converting numbers to string because data types ranges > and precision differs? or is the

Re: [algogeeks] MS Design Ques

2012-07-06 Thread Mithun Kumar
@anshuman... Are you converting numbers to string because data types ranges and precision differs? or is there any other reason? -mithun On Fri, Jul 6, 2012 at 12:58 AM, payal gupta wrote: > thnx...4 d rply.. > > Regards, > PAYAL GUPTA, > NIT-B. > > > On Fri, Jul 6, 2012 at 12:43 AM, Anshu Mis

Re: [algogeeks] MS Design Ques

2012-07-05 Thread payal gupta
thnx...4 d rply.. Regards, PAYAL GUPTA, NIT-B. On Fri, Jul 6, 2012 at 12:43 AM, Anshu Mishra wrote: > First define all the basic operation you can apply on two numbers. > > Binary operation : +, -, *, /, %, optional(&(and), |(or), ^(xor)) > Unary operation : !, ~, - > Comparison : <, > ==, != >

Re: [algogeeks] MS Design Ques

2012-07-05 Thread Anshu Mishra
First define all the basic operation you can apply on two numbers. Binary operation : +, -, *, /, %, optional(&(and), |(or), ^(xor)) Unary operation : !, ~, - Comparison : <, > ==, != Define all these operation. Most simplest one can be, class BIG_INT { private string val; //Define constru

Re: [algogeeks] MS Design Ques

2012-07-03 Thread Mithun Kumar
can you elaborate question...what is BIG_INT? On Sun, Jul 1, 2012 at 8:13 PM, payal gupta wrote: > design a BIG_INT library... > > Regards, > PAYAL GUPTA, > NIT-B. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To view this discu

Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order

2012-07-02 Thread atul anand
@amol : algo seems to work but will fail if size of arr increases. int arr[]={21,2,7,9,20,15,3,5,0,17,11,12,13,14,1,8,10,4,19,6,18,16}; it will fail for above case. if we u run outer loop one more time then it will work fine. So there should be some relation b/w number of elements and minimum numbe

Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order

2012-07-02 Thread atul anand
opssyeah dat was the bug... now got it :) On Mon, Jul 2, 2012 at 4:08 PM, Amol Sharma wrote: > @atul: > the logic for the O(n) counting is same as for the count sort. > > you haven't write the swap function correctly, > > here is correct code for swap function -- > > >

Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order

2012-07-02 Thread atul anand
yes it is same and it not working . Apart for this you had provided code for sorting O(n) time and not the idea/algo. please explain the algorithm , how you are sorting it within O(n) time and O(1) space complexity. On Mon, Jul 2, 2012 at 3:18 PM, Amol Sharma wrote: > i don't see any change in t

Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order

2012-07-02 Thread Amol Sharma
i don't see any change in the code you posted...other than expanding swap function i believe in discussing the idea/algonot the code.. -- Amol Sharma Final Year Student Computer Science and Engineering MNNIT Allahabad

Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order

2012-07-02 Thread atul anand
@amol : #include int main() { int arr[]={5,0,1,2,6,7,8,3,4,9}; int i,j,n,temp; n=sizeof(arr)/sizeof(arr[0]); for(j=0;j<=1;j++) { for(i=0;ihttp://groups.google.com/group/algogeeks?hl=en.

Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order

2012-07-02 Thread Amol Sharma
zeof(a)/sizeof(int)); >>>>> >>>>> copy(a,a+sizeof(a)/sizeof(int),ostream_iterator(cout,","));cout<>>>> >>>>> } >>>>> >>>>> >>>>> Regards >>>>> >>>>> On F

Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order

2012-07-01 Thread Hassan Monfared
On Fri, Jun 29, 2012 at 7:52 PM, utsav sharma >>> > wrote: >>>> >>>>> @bhaskar:- please explain stable sorting algorithm you would use(as >>>>> mainly all of them require extra space) >>>>> @sourabh:- that previous post discussion does't lead to

Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order

2012-07-01 Thread atul anand
>>>> On Fri, Jun 29, 2012 at 8:39 PM, Bhaskar Kushwaha < >>>> bhaskar.kushwaha2...@gmail.com> wrote: >>>> >>>>> @saurabh please provide the link to the post you are mentioning >>>>> >>>>> On Fri, Jun 29, 2012 at

Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order

2012-07-01 Thread Amol Sharma
>> for(int i=1;i>> >>>> if(pdata[i-1]>0 && pdata[i]<0) >>> >>>> { >>> >>>> swap(pdata[i-1], pdata[i]); >>> >>>> changed=true; >>> >>>> } >>> >>>> }while(changed)

Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order

2012-07-01 Thread shiva@Algo
;>> } >> >>>> }while(changed); >> >>>> } >> >>>> >> >>>> void test_inplace_pos_neg() >> >>>> { >> >>>> int a[]={-1,-5,10,11,15,-500,200,-10}; >> >>>> >> >>>

Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order

2012-07-01 Thread shiva@Algo
; > >>>> > >>>> > copy(a,a+sizeof(a)/sizeof(int),ostream_iterator(cout,","));cout< >>>> > >>>> } > >>>> > >>>> > >>>> Regards > >>>> > >>>> On Fri, Jun 29,

Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order

2012-07-01 Thread Bhaskar Kushwaha
utsav sharma >>>> wrote: >>>> >>>>> @bhaskar:- please explain stable sorting algorithm you would use(as >>>>> mainly all of them require extra space) >>>>> @sourabh:- that previous post discussion does't lead to any correct >>&

Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order

2012-07-01 Thread Darpan Baweja
>>>> >>>> On Fri, Jun 29, 2012 at 8:39 PM, Bhaskar Kushwaha < >>>> bhaskar.kushwaha2...@gmail.com> wrote: >>>> >>>>> @saurabh please provide the link to the post you are mentioning >>>>> >>>>> On F

Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order

2012-07-01 Thread Amol Sharma
gt;>>>> If the order is important then I think we can use any stable sorting >>>>> algorithm with the following comparison function >>>>> >>>>> int compare (int a ,int b) >>>>> { >>>>> if((a>0&&b>0)

[algogeeks] MS Design Ques

2012-07-01 Thread payal gupta
design a BIG_INT library... Regards, PAYAL GUPTA, NIT-B. -- 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/-/EHIiPPFJ4t0J. To post to this group, send email to

Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order

2012-06-29 Thread Bhaskar Kushwaha
t;>>> if((a>0&&b>0)||(a<0&&b<0)) return 0; >>>> else return a>>> } >>>> On Fri, Jun 29, 2012 at 3:37 PM, raghavan M < >>>> peacelover1987...@yahoo.co.in> wrote: >>>> >>>>> This is a v

Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order

2012-06-29 Thread Hassan Monfared
&&b>0)||(a<0&&b<0)) return 0; >>> else return a>> } >>> On Fri, Jun 29, 2012 at 3:37 PM, raghavan M < >>> peacelover1987...@yahoo.co.in> wrote: >>> >>>> This is a variant of that one >>>> >>&g

Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order

2012-06-29 Thread utsav sharma
gt; This is a variant of that one >>> >>> ------ >>> *From:* saurabh singh >>> *To:* algogeeks@googlegroups.com >>> *Sent:* Friday, 29 June 2012 3:05 PM >>> >>> *Subject:* Re: [algogeeks] MS Que

Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order

2012-06-29 Thread Bhaskar Kushwaha
m:* saurabh singh >> *To:* algogeeks@googlegroups.com >> *Sent:* Friday, 29 June 2012 3:05 PM >> >> *Subject:* Re: [algogeeks] MS Question: Segregrate positive and negative >> nos in array without changing order >> >> duplicate of a previous post.Kindly refe

Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order

2012-06-29 Thread Bhaskar Kushwaha
--- > *From:* saurabh singh > *To:* algogeeks@googlegroups.com > *Sent:* Friday, 29 June 2012 3:05 PM > > *Subject:* Re: [algogeeks] MS Question: Segregrate positive and negative > nos in array without changing order > > duplicate of a previous post.Kindly r

Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order

2012-06-29 Thread raghavan M
This is a variant of that one From: saurabh singh To: algogeeks@googlegroups.com Sent: Friday, 29 June 2012 3:05 PM Subject: Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order duplicate of a previous

Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order

2012-06-29 Thread raghavan M
algogeeks@googlegroups.com Sent: Friday, 29 June 2012 3:06 PM Subject: Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order one can modify dutch national flag algo for two colors(2 types positive n negative) -- You received this message because you are subscrib

Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order

2012-06-29 Thread adarsh kumar
Quick sort partition routine variation. On Fri, Jun 29, 2012 at 3:06 PM, Ravi Ranjan wrote: > one can modify dutch national flag algo for two colors(2 types positive n > negative) > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To p

Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order

2012-06-29 Thread Ravi Ranjan
one can modify dutch national flag algo for two colors(2 types positive n negative) -- 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

Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order

2012-06-29 Thread saurabh singh
duplicate of a previous post.Kindly refer to that post. Saurabh Singh B.Tech (Computer Science) MNNIT blog:geekinessthecoolway.blogspot.com On Fri, Jun 29, 2012 at 10:41 AM, raghavan M wrote: > Hi > Question as in subject > > *No extra space (can use one extra space)-O(1) max > *No order change

[algogeeks] MS Question: Segregrate positive and negative nos in array without changing order

2012-06-29 Thread raghavan M
Hi Question as in subject *No extra spaceĀ (can use one extra space)-O(1) max *No order change allowed example: input : 1,-5,2,10,-100,-2 output: -5,-10,-100,1,2 input : -1,-5,10,11,15,-500,200,-10 output : -1,-5,-10,-500,-10,10,11,15 Thanks Raghavn -- You received this message because you a

Re: [algogeeks] MS Question :implement read write lock class

2012-06-29 Thread Mithun Kumar
This link should help http://stackoverflow.com/questions/5667793/how-does-a-read-write-mutex-lock-work?rq=1 -mithun On Fri, Jun 29, 2012 at 7:30 AM, bharat b wrote: > class lock > { > enum{"read", "write","free"}status; > }; > By default, make status value as "free". > Based on the request,

Re: [algogeeks] MS Question :implement read write lock class

2012-06-28 Thread bharat b
class lock { enum{"read", "write","free"}status; }; By default, make status value as "free". Based on the request, status value will be changed... Based on the value of the status, we should decide whether another read/write lock can be given. Any suggestions ? On Thu, Jun 28, 2012 at 4:46 PM, As

[algogeeks] MS Question :implement read write lock class

2012-06-28 Thread Ashish Goel
Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 -- 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, se

Re: [algogeeks] MS Question: Add two large numbers where the numbers are stored in an array format

2012-06-27 Thread Lomash Goyal
we can create linked list for the number where each node will store some k digits (say 5) in the reverse order.then we just perform a normal addition of the data of the nodes with the help of carry. note that if the numbers are not positive then we need to maintain a sign bit node also.if any of th

Re: [algogeeks] MS Question: Add two large numbers where the numbers are stored in an array format

2012-06-26 Thread Ashish Goel
the base is not given, so 10 can't be assumed Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Tue, Jun 26, 2012 at 4:38 PM, amrit harry wrote: > make size of both array by adding '0' in front of smaller array > then > int carry=0; > for(i=array.

Re: [algogeeks] MS Question: Add two large numbers where the numbers are stored in an array format

2012-06-26 Thread Kumar Vishal
I mean 123 is store as 1,2,3 or 3,2,1 On Tue, Jun 26, 2012 at 6:01 PM, Kumar Vishal wrote: > MSB is at end or at the last of the array .. ?? > > On Tue, Jun 26, 2012 at 5:43 PM, saurabh singh wrote: > >> ^ Does it make any difference? >> Saurabh Singh >> B.Tech (Computer Science) >> MN

Re: [algogeeks] MS Question: Add two large numbers where the numbers are stored in an array format

2012-06-26 Thread Kumar Vishal
MSB is at end or at the last of the array .. ?? On Tue, Jun 26, 2012 at 5:43 PM, saurabh singh wrote: > ^ Does it make any difference? > Saurabh Singh > B.Tech (Computer Science) > MNNIT > blog:geekinessthecoolway.blogspot.com > > > > On Tue, Jun 26, 2012 at 5:32 PM, Navin Kumar wrote: > >>

Re: [algogeeks] MS Question: Add two large numbers where the numbers are stored in an array format

2012-06-26 Thread amrit harry
make size of both array by adding '0' in front of smaller array then int carry=0; for(i=array.size();i>=0;i--) { sum[i]=carry+arrayA[i]+arrayB[i]; carry=sum[i]/10; sum[i]=sum[i]%10; } then reverse and print sum On Tue, Jun 26, 2012 at 3:40 PM, Ashish Goel wrote: > > Best Regards > Ashish Goel > "

Re: [algogeeks] MS Question: Add two large numbers where the numbers are stored in an array format

2012-06-26 Thread saurabh singh
^ Does it make any difference? Saurabh Singh B.Tech (Computer Science) MNNIT blog:geekinessthecoolway.blogspot.com On Tue, Jun 26, 2012 at 5:32 PM, Navin Kumar wrote: > whether it is in character array or integer array?? > > > On Tue, Jun 26, 2012 at 3:40 PM, Ashish Goel wrote: > >> >> Best Re

Re: [algogeeks] MS Question: Add two large numbers where the numbers are stored in an array format

2012-06-26 Thread Navin Kumar
whether it is in character array or integer array?? On Tue, Jun 26, 2012 at 3:40 PM, Ashish Goel 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 Groups >

[algogeeks] MS Question: Add two large numbers where the numbers are stored in an array format

2012-06-26 Thread Ashish Goel
Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 -- 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, se

Re: [algogeeks] MS Question: Reverse stack using push, pop without any auxiliary data structure

2012-06-17 Thread algogeek
This solution works perfectly :) On Friday, June 15, 2012 10:59:22 AM UTC+5:30, Navin Kumar wrote: > > I corrected in function InsertAtBottom :"In my code isntead of > (!IsEmptyStack) use IsEmptyStack" > > On Fri, Jun 15, 2012 at 10:49 AM, Navin Kumar wrote: > >> @all: >> >> In my code isntea

Re: [algogeeks] MS Question: Reverse stack using push, pop without any auxiliary data structure

2012-06-14 Thread Navin Kumar
I corrected in function InsertAtBottom :"In my code isntead of (!IsEmptyStack) use IsEmptyStack" On Fri, Jun 15, 2012 at 10:49 AM, Navin Kumar wrote: > @all: > > In my code isntead of (!IsEmptyStack) use IsEmptyStack > > Logic : > > First pop the all element and then start putting element at bott

Re: [algogeeks] MS Question: Reverse stack using push, pop without any auxiliary data structure

2012-06-14 Thread Navin Kumar
@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

Re: [algogeeks] MS Question: Reverse stack using push, pop without any auxiliary data structure

2012-06-14 Thread Nishant Pandey
i think i already explained the logic initially :) On Thu, Jun 14, 2012 at 9:30 PM, Hassan Monfared wrote: > how can you pop from empty stack ? > " temp=pop(S); " > > Regards, > Hassan > > On Thu, Jun 14, 2012 at 8:25 PM, Ashish Goel wrote: > >> Navin: copy pastes not encouraged till the logic

Re: [algogeeks] MS Question: Reverse stack using push, pop without any auxiliary data structure

2012-06-14 Thread Karthikeyan V.B
Hi all, Generate combinations (taken k out of n) of a given string Eg: Input : abcd Output: abc acd abd bcd -- 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

Re: [algogeeks] MS Question: Reverse stack using push, pop without any auxiliary data structure

2012-06-14 Thread Nishant Pandey
the steps would be like this : if i say stack is like this 1,2,3,4 then 1) pop each and every item from the stack till stack is empty the nodes will be ther in function call stack stil not pushed 2) now now take elements from function call stack like 4 and push it 3) when 3 comes next time first

Re: [algogeeks] MS Question: Reverse stack using push, pop without any auxiliary data structure

2012-06-14 Thread Nishant Pandey
stack means inbuild stack we cant use any DS from our program explicitly. On Thu, Jun 14, 2012 at 2:44 PM, rahul patil wrote: > to store items in stack you will need some DS. Do they mean you cant use > any auxillary DS than stack ? > > > On Thu, Jun 14, 2012 at 2:24 PM, Ashish Goel wrote: > >>

Re: [algogeeks] MS Question: Reverse stack using push, pop without any auxiliary data structure

2012-06-14 Thread Lomash Goyal
void pushreverse(int data) { int temp; if(top==0) { push(data); return; } else temp=pop(); pushreverse(data); push(temp); } int reversestack() { //static int arr[50]; int top2=0; int i; if(top==0) { return top2; } top2=pop(); reversestack(); pushreverse(top2); } On Thu, Jun 14, 2012 at 2:44 P

Re: [algogeeks] MS Question: Reverse stack using push, pop without any auxiliary data structure

2012-06-14 Thread Hassan Monfared
how can you pop from empty stack ? " temp=pop(S); " Regards, Hassan On Thu, Jun 14, 2012 at 8:25 PM, Ashish Goel wrote: > Navin: copy pastes not encouraged till the logic is also clarified ;) > > Best Regards > Ashish Goel > "Think positive and find fuel in failure" > +919985813081 > +919966006

Re: [algogeeks] MS Question: Reverse stack using push, pop without any auxiliary data structure

2012-06-14 Thread Ashish Goel
Navin: copy pastes not encouraged till the logic is also clarified ;) Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Thu, Jun 14, 2012 at 7:25 PM, Sourabh Singh wrote: > @ Navin Kumar > > Nice . Solution. > But > your function also make a stac

Re: [algogeeks] MS Question: Reverse stack using push, pop without any auxiliary data structure

2012-06-14 Thread Sourabh Singh
@ Navin Kumar Nice . Solution. But your function also make a stack only. so you are using a stack[internal] here. but may be this one is allowed:-) On Thu, Jun 14, 2012 at 5:23 AM, Navin Kumar wrote: > void Reverse(struct Stack *S) { > int data; > if(IsEmptyStack(S)) return; > d

Re: [algogeeks] MS Question: Reverse stack using push, pop without any auxiliary data structure

2012-06-14 Thread Navin Kumar
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); Ins

Re: [algogeeks] MS Question: Reverse stack using push, pop without any auxiliary data structure

2012-06-14 Thread rahul patil
to store items in stack you will need some DS. Do they mean you cant use any auxillary DS than stack ? On Thu, Jun 14, 2012 at 2:24 PM, Ashish Goel wrote: > > Best Regards > Ashish Goel > "Think positive and find fuel in failure" > +919985813081 > +919966006652 > > -- > You received this messag

[algogeeks] MS Question: Reverse stack using push, pop without any auxiliary data structure

2012-06-14 Thread Ashish Goel
Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 -- 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, se

Re: [algogeeks] MS Q: how to test a driverless car?

2012-06-11 Thread Akshat Sapra
There are certain things that one need to test while assessing a driverless car :- 1> *Gear* - Gears should be changed according to different speed lower limits. For example - 1 st gear upto speed 10 km/hr. 2nd gear upto speed 30 km/hr 3rd ge

Re: [algogeeks] MS Question : find word in 2D array

2012-06-09 Thread Bhaskar Kushwaha
@utsav u haven't initialized match anywhere so ur algo fails On Thu, Jun 7, 2012 at 2:50 AM, utsav sharma wrote: > i think it can be solved using DP > word="bcdf" take hash of word h[b]=1 h[c]=2 h[d]=3 h[f]=4 > given 2d matrix m[][]= > {b c b e f g h > b c d f p o u > d f d f g k p } > > ta

Re: [algogeeks] MS Q: how to test a driverless car?

2012-06-08 Thread Ashish Goel
Things like sensor data coming from CAN/MoST from the car is collected and analysed in real time to avoid collisions, off-lane movement, distance maintenance, auto parking(including parallel), slippage on road/snow, GPS integration for perfect location and location specific data (like traffic,schoo

Re: [algogeeks] MS Q: how to test a driverless car?

2012-06-07 Thread Umer Farooq
What are the specs of the car. Can you please give the answer to the following clarifying questions: - How much distance is it suppose to travel without the driver? - Is it suppose to run on smooth roads only or can it also run on roads with jumps on it? On what type of road is the car most suitab

Re: [algogeeks] MS Question : find word in 2D array

2012-06-06 Thread utsav sharma
i think it can be solved using DP word="bcdf" take hash of word h[b]=1 h[c]=2 h[d]=3 h[f]=4 given 2d matrix m[][]= {b c b e f g h b c d f p o u d f d f g k p } take another matrix match[][] if( h[ m[i][j] ] > 0 ) //if this char is in word then {a=h[ m[i][j] ]; if (match[i-1][j] ==a-

Re: [algogeeks] MS Question : find word in 2D array

2012-06-06 Thread atul anand
i did this question long time back well simple brute force check can be doneyou can keep one flag matrix of same size to avoid necessary recursion. On 6/6/12, Ashish Goel wrote: > WAP to find a word in a 2D array. The word can be formed on > row/col/diagnal/reverse diagnal > > Best Regar

[algogeeks] MS Q: how to test a driverless car?

2012-06-06 Thread Ashish Goel
Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 -- 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, se

[algogeeks] MS Question : find word in 2D array

2012-06-06 Thread Ashish Goel
WAP to find a word in a 2D array. The word can be formed on row/col/diagnal/reverse diagnal Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To pos

Re: [algogeeks] MS Question: Delete a node in single linked list if it is less than any of the successor nodes

2012-06-04 Thread atul anand
whats problem with the approch provided by navin http://k2code.blogspot.in/2011/09/deleting-node-in-singly-linked-list-if.html it seems much simpler ...is there any test case for which it wont work ?? On Mon, Jun 4, 2012 at 3:25 PM, Amol Sharma wrote: > here is the question ans solution with p

Re: [algogeeks] MS Question: Delete a node in single linked list if it is less than any of the successor nodes

2012-06-04 Thread Amol Sharma
here is the question ans solution with proper explanation http://www.geeksforgeeks.org/archives/11604 -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad

Re: [algogeeks] MS: searching problem......help me out...

2012-06-03 Thread Abhishek Goswami
Hi Rahul, In the below url,They have mentioned the parallel searching. it means divide array than search element from two point. i.e number of element is {48,23,10,32,5} search 32. divide array [0-2] and [3-4] range... traverse the array from p[0] and p [3]... till half of the loop. I hope w

Re: [algogeeks] MS: searching problem......help me out...

2012-06-03 Thread abhinav gupta
@ Abhishek : Link that you have provided is for kth min element in the unsorted array, but here i dont know the given value is of at what min position. On Sun, Jun 3, 2012 at 9:06 AM, abhinav gupta wrote: > @Rahul: but for heapify, i need to build heap tree first from the list. > which will cos

Re: [algogeeks] MS: searching problem......help me out...

2012-06-03 Thread abhinav gupta
@Rahul: but for heapify, i need to build heap tree first from the list. which will cost linear traversal of the elements, that will cost O(n). but i need to search it in O(log n) or polylogrithmic complexity of (log n) i.e. (log^2 n). On Sun, Jun 3, 2012 at 8:55 AM, Rahul Kumar Patle wrote: > @a

Re: [algogeeks] MS: searching problem......help me out...

2012-06-03 Thread Rahul Kumar Patle
@abhinav: if you want to search just 15 in log(n) time then you can use the concept of heap tree.. apply one round of heapification (not for all elements but just one time it will be complete in log(n) times), and you will need to swap elements but when you got element 15 you can stop.. although sp

Re: [algogeeks] MS: searching problem......help me out...

2012-06-03 Thread Abhishek Goswami
Hi, I have found two url which contain answer of your question some extent. 42bits.wordpress.com/2010/04/17/find-kth-minimum-in-a-unsorted-array/ http://www.medwelljournals.com/fulltext/?doi=rjasci.2011.70.75 On Sun, Jun 3, 2012 at 8:31 PM, abhinav gupta wrote: > > We have given a list

[algogeeks] MS: searching problem......help me out...

2012-06-03 Thread abhinav gupta
We have given a list 14 6 7 15 8 9 we have to find 15 in (log n ) times. -- *Thanks and Regards,* Abhinav Kumar Gupta **abhinav@gmail.com -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email t

RE: [algogeeks] MS Question: WAP to find files in a

2012-06-02 Thread Ashish Goel
directory/subdirectories MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The question is to implement without use of any library Sent from my Windows Phone From: atul anand Sent: 03-06-2012 11:19 To: algogeeks@googlegroups.com Subject: Re:

  1   2   3   4   5   >