Re: [algogeeks] Re: perfect square condition checking....

2013-02-07 Thread Prem Krishna Chettri
Yea Dave .. I was actually looking for your response.. Coz it generally have some mathematical background. So, Could U provide us some least Complexity Algo for this same old general and basic problem. On Thu, Feb 7, 2013 at 11:08 AM, Dave wrote: > @Gaurav: Does it work for n = 25 or for n = 8?

Re: [algogeeks] size of array

2013-02-03 Thread Prem Krishna Chettri
M, "Piyush" wrote: > >> it will always work if array is statically allocated >> Not if dynamically allocated, say using malloc etc. >> >> On 30-Jan-13 1:55 PM, Prem Krishna Chettri wrote: >> >> @Piyush .. Never works.. >> >>@All th

Re: [algogeeks] size of array

2013-01-30 Thread Prem Krishna Chettri
@Piyush .. Never works.. @All there is no way to do the given requirement in pure C. On Wed, Jan 30, 2013 at 1:45 PM, Piyush wrote: > sizeof(array)/sizeof(array[0]) > > > On 28-Jan-13 3:44 PM, Anil Sharma wrote: > > How to calculate the size/lenght of an int array which is passed as an > O

Re: [algogeeks] Pointers Usage

2013-01-02 Thread Prem Krishna Chettri
of accessing > different blocks of memory. Apart from that it also results in more space > consumption. > > On Wed, Jan 2, 2013 at 11:23 AM, Prem Krishna Chettri > wrote: > >> Boss.. thats kinda bit basic to ask anyways.. lemme give bit of details. >> >&g

Re: [algogeeks] Pointers Usage

2013-01-01 Thread Prem Krishna Chettri
Boss.. thats kinda bit basic to ask anyways.. lemme give bit of details. Languages with pointer have WAY more flexibility to write a code upto any segment (I mean lower layer of programming like Device Driver) as they are directly talking to memory, where as if we don't have pointer we need to tak

Re: [algogeeks] Linked List question

2012-12-27 Thread Prem Krishna Chettri
< naveenshuklasweetdrea...@gmail.com> wrote: > But suppose a random number generate a value 5 and your linked list has > only four elements. In that case what would be the answer ??? > > On Thu, Dec 27, 2012 at 4:03 PM, Prem Krishna Chettri > wrote: > >> Well my algo will

Re: [algogeeks] Linked List question

2012-12-27 Thread Prem Krishna Chettri
Well my algo will be Something like this 1> Get a Random number. Perhaps You can have the function like Randon(List *head, int Randomnumber) 2> Use the function argument Randomnumber to loop the list. i.e. for(int count=0;count<=Randomnumber;count++ ){ head

Re: [algogeeks] Regex tester

2012-12-23 Thread Prem Krishna Chettri
Well I can tell you Something about design pattern to solve this case.. What I mean is by using The State Machine Design Pattern, Anyone can solve this. but Ofcourse it is complicated. On Sun, Dec 23, 2012 at 11:01 PM, shady wrote: > that's the point, Have to implement it from scratch

Re: [algogeeks] Re: Implement Malloc and Free

2012-12-19 Thread Prem Krishna Chettri
I remember myself providing lot of codes and algo for this age old question.. Why don't U guys check it out first b4 posting.. Regards. On Wed, Dec 19, 2012 at 10:54 PM, Don wrote: > Start with a large array of bytes to use as a buffer. Keep a list of > pointers to blocks of available memory.

Re: [algogeeks] Cutting a pizza

2012-12-06 Thread Prem Krishna Chettri
Problem on Greedy Algorithm.. Pretty Famous Question On Thu, Dec 6, 2012 at 8:58 PM, bharat b wrote: > It is like finding a line which connects most number of points. > > http://karmaandcoding.blogspot.in/2012/02/find-line-that-intersects-max-number-of.html > : > not a good solution .. O(n^2) >

Re: [algogeeks] this pointer help c++

2012-10-09 Thread Prem Krishna Chettri
Well Lemme try few more hand here.. Basics First Guys :- this :- is a hidden pointer to a class (Agree ?). So whats so special about it.. Answer is its compaction when the object of the class is being created. Why? Here it goes. As object memory allocation (I hope everyone knows) h

Re: [algogeeks] 5 tyres 10000 Kilometers..

2012-08-28 Thread Prem Krishna Chettri
se of the 5 new tyres, nt considering the old ones, > even in that case, the above wud be true. > > On Tue, Aug 28, 2012 at 9:39 PM, Prem Krishna Chettri > wrote: > >> Guys Something good to share here.. >> >> Query :- Tomorrow I am Planning to take my car for

[algogeeks] 5 tyres 10000 Kilometers..

2012-08-28 Thread Prem Krishna Chettri
Guys Something good to share here.. Query :- Tomorrow I am Planning to take my car for a ride of 1 ( Ten Thousands ) Km. As the journey will be rough so I am planning to pack 5 new tyres.. Now being very conservative, I want to use each of them such that they all wear equally.. Now the ques

Re: [algogeeks] what is priority inversion ?

2012-08-08 Thread Prem Krishna Chettri
Read Mar's PathFinder Case Failure It would illustrate it .. Infact the case was observed first on PathFinder Mission itself. On Wed, Aug 8, 2012 at 4:41 AM, Hraday Sharma wrote: > i just read about priority inversion , how does it take place ? > i read it in Galvin , it wasnt clear there

Re: [algogeeks] amazon online test question

2012-08-05 Thread Prem Krishna Chettri
Wow.. You got this question... Lucky Fellow so easy.. I remember SISO asking such question long back.. its way below Amazon Standard... Basically they want to make Sure U understand the question.. Implementation is jst a copy of the content of the current SLL Node and rewiring the rest. On Sun, A

Re: [algogeeks] Amazon CodeSprint

2012-08-04 Thread Prem Krishna Chettri
Well, I donoo the TO cost Impact on this question. If we need to get the solution within the given interview time , we can go for the permutation approach.. i.e permute all the operators and calculate. But the T(O) and S(O) is seriously jeopardize. Anyone got better ones?? On Sat, Aug 4, 2012 at

Re: [algogeeks] Java Design Question..

2012-08-02 Thread Prem Krishna Chettri
One Line Answer.. Check Factory Design Pattern. On Thu, Aug 2, 2012 at 10:13 PM, teja bala wrote: > I had a java class(acts as a database class) which got a method which > returns the respective object of the class based on given data(instance > variable) .. eg: given customer id and 3 classe

Re: [algogeeks] Re: Facebook Interview Question

2012-07-30 Thread Prem Krishna Chettri
Well as far as I Knw this is the typical question which Amazon was know to ask frequently ... the reason behind this is simple to see how is the peoples approach. However the right answer of this question is yet to found ... its under research... On Mon, Jul 30, 2012 at 6:46 PM, Lucifer wrote:

Re: [algogeeks] malloc()

2012-07-26 Thread Prem Krishna Chettri
This question has been answered by Me.. Long back.. Check the thread.. On Thu, Jul 26, 2012 at 8:47 PM, jatin wrote: > Implementation/Definition of malloc(),realloc() in . any idea on > how is it working? thanks. > > -- > You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Re: output

2012-07-25 Thread Prem Krishna Chettri
Well Guys, M here just to show wats hpning.. Have your own views.. 1> Everything is right till While loop.. I mean p1 pointing to the heap of the address of the String "Name" , P1 getting 20 bytes of memory chunk and so on.. So here we go now. As this Stupid looking while is culprit he

Re: [algogeeks] Re: trie display

2012-06-28 Thread Prem Krishna Chettri
Haha.. I got the query.. U wanna check this Google Suggestion implemention.. :) Well, the code seems fairly true.. use recursive approach.. (thats how G generally uses ) Here it is.. Search (struct trie *node) { for(i=0;i<26;i++) { if(!node->

Re: [algogeeks] trie display

2012-06-28 Thread Prem Krishna Chettri
Well it Seems like problem is the DS here. if U have the DS of trie as struct trie { char letter;// Not being general boolean islast; int startindex; struct trie *next; }; I am sure you w

Re: [algogeeks] Precedence or Associativity

2012-06-17 Thread Prem Krishna Chettri
Hello Dear.. This Age Old question is Still Haunting Ppls.. In fact this ain't a question at all.. this Should be known while we start writing first of the C/C++ programming.. Well.. Just to make some ppls Life easier here it goes AGAIN.. ++i=++0=1 so it will be one.. Now as OR means. either o

Re: [algogeeks] Re: Can anyone explain this strange behavior ?

2012-06-11 Thread Prem Krishna Chettri
Easy Buddy.. this is primary thing.. Surprise to know that ppls still don't knw abt this.. for OR:- if left expr evaluate non zero it won't compute right side. For And:- if left expr evalute zero , it won't compute right side Prem On Tue, Jun 12, 2012 at 11:10 AM, sengar.mahi wrote: > No

Re: [algogeeks] What would be the output for the following code fragment?

2012-06-07 Thread Prem Krishna Chettri
Hahaha.. Xcellent question Dude.. People Who Know can easily explain.. So for who don't here it is.. It has nothing to do with Endianess Mr.Yogesh.. Actually the bit patter happens to be reside such that ob.ch[0] fills with all ones .. Now as we knw the sign bit concept , here compilers goes mad

Re: [algogeeks] Re: What would be the output for the following code fragment?

2012-06-07 Thread Prem Krishna Chettri
Well Thanks Rajni but I don't see any BETTER EXPLANATION of endianess here , as you are completely relying on library function like htonl() to provide data manipulation for you. The use case mentioned is absolutely valid and very promising although. Yeah both guys are on the spot .. :) Br, Prem

Re: [algogeeks] Re: What would be the output for the following code fragment?

2012-06-07 Thread Prem Krishna Chettri
Try decode how the final value of 556 or 228 end up there.. it alwayz compiles to those values .. try finding how compiler end up to these values.. On Thu, Jun 7, 2012 at 12:53 PM, Abhishek Sharma wrote: > @prem, i don't get it.could you please elaborate the interesting part of > this solution ?

Re: [algogeeks] Re: What would be the output for the following code fragment?

2012-06-06 Thread Prem Krishna Chettri
Does anybody know's Why the Value is like this So... Seems simple but when I decoded it.. its very interesting... U all should look into this simple question which can reveal some internal manipulation. Good One !!! BR, Prem On Thu, Jun 7, 2012 at 1:13 AM, Garima Mishra wrote: > 556 if the mac

Re: [algogeeks] want to create a table of words having 2 columns seperate for name and surname

2012-06-05 Thread Prem Krishna Chettri
More than a programming, I believe this is a logical question. Some of the assumption you can take into consideration is how many names a particular person can possibly have. say, John F Kennedy, So, your array now can't hold 3 names in two dimension, so what you wanna do, increase an array of one

Re: [algogeeks] importance of heaps

2012-06-05 Thread Prem Krishna Chettri
Each DS has its own importance. So before you approach a problem , it is better to understand the advantage of each DS. Infact, the Fibonacci heap is having an big advantage of O(1) time searching element, which is extremely significant as even the DS like Trie can't afford to do so.. All in all, i

Re: [algogeeks] classic problem to tree to circular doubly linked list

2012-05-24 Thread Prem Krishna Chettri
As the code is already shared in the given link. I just wanna try explain how it is .. Struct Node { Data d; Struct Node *right; Struct Node *left; }; Thats the basic structure of the Link List. Now say U hav

Re: [algogeeks] Algorithm Question

2012-05-23 Thread Prem Krishna Chettri
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

Re: [algogeeks] Amazon Q

2012-05-23 Thread Prem Krishna Chettri
This is an Age Old Amazon Question .. int main(void) { int card[52]; int n; srand(time(0)); for(int i=0;i<52;i++) card[i]=i; while(cin>>n) { for(int i=0;i<(52-i);i++) { int r=i+(rand()%(52-i)); int temp=card[i]; card

Re: [algogeeks] Google Q: longest word made of subwords within the list

2012-05-22 Thread Prem Krishna Chettri
t if input is something > like this :- > > best > bestest > test > testbest > testbesttest > > btw TRIE containing only distinct word i.e words not made up of sub words > would be enough to solve the problem > > On Tue, May 22, 2012 at 11:40 PM, Prem Krishna Chettr

Re: [algogeeks] Google Q: longest word made of subwords within the list

2012-05-22 Thread Prem Krishna Chettri
Yea this is a Straight Cut Trie Question No Doubt.. Perhaps DWAG may be taken into consideration.. T(O)=O(n) can be done easily.. ( By tracking Second and First Longest word found soFar and updating otherwise accordingly) Can someone do it better? On Tue, May 22, 2012 at 6:15 PM, Ashish Goel w

Re: [algogeeks] Google Q : all anagrams next to each other

2012-05-22 Thread Prem Krishna Chettri
What I Could possibly think of is For each string S1 that is an anagram of some string S, use Map and Store the Key Value as (S1,S). Now there is a trick here abt how to reduce Time Complexity here... Now its easy to put all string which has correspondence S next to each other. This is Simple o

Re: [algogeeks] Partition the array with equal average

2012-05-18 Thread Prem Krishna Chettri
Are U asking the Code Again ?? :) On Fri, May 18, 2012 at 2:19 PM, saurabh singh wrote: > > Saurabh Singh > B.Tech (Computer Science) > MNNIT > blog:geekinessthecoolway.blogspot.com > > > > On Thu, May 17, 2012 at 11:40 PM, Prem Krishna Chettri > wrote: > >&

Re: [algogeeks] Partition the array with equal average

2012-05-17 Thread Prem Krishna Chettri
I guess this is Subset minimization problem's Modification.. Algo.. 1> Get all the Subset of the particular array. Best Algo O(n2). 2> Now try to find the subsets having similar average. Again best algo known is O(n2). Anyone have better options?? BR, Prem On Fri, May 18, 2012 at 12:05 PM, p

Re: [algogeeks] Re: storing URL's

2012-05-17 Thread Prem Krishna Chettri
For the cases where Storing the Value is the only Concern and (Not the Retrieval efficiency), I would Suggest Something called DFA Subset minimization.. Google for it ... and after the final subset as said U can use something called DAWG for the most Most Optimal solution.. On Thu, May 17, 2012 at

Re: [algogeeks] Re: Find Power(N,N),

2012-05-16 Thread Prem Krishna Chettri
Yes U are Correct.. in Such cases the Compiler itself has overcome ( or tried to overcome) the architecture limitations to some extends but what will happen if U need say 128 or 256 or more values?? Again U hv your compiler restricted limitation right? So that what I am talking about is.. Wri

Re: [algogeeks] Re: finding anagrams in a list of words

2012-05-16 Thread Prem Krishna Chettri
Well this is an Age old question yet there seems to have a lots of room for further modification.. 1> Comparison of String Individually. Effective yet O(n2) 2> Why dont we let some function do the job say if( Sort(String 1)==Sort(String 2)) Anagra

Re: [algogeeks] Re: Algo for Search in a 2D Matrix

2012-05-16 Thread Prem Krishna Chettri
Well I hv got Something running in my mind buy ofcse need some cornor case tuning. If we take sqrt() of the number (say K) than we can avoid looking into sqrt(k)-1 and sqrt(k)+1 rows and column entirely, which literally means that the final solution is possible in constant time (the time indepe

Re: [algogeeks] Re: Function Name Mismatch

2012-02-07 Thread Prem Krishna Chettri
This is a simple implementation to Factory Design Pattern. What you have to do is make an arbitrary class (Your Adapter) and always call this. However, the implementation of this class should be smart enough to route your call accordingly. As suggested by DON , its the c++ implementation of Factor

Re: [algogeeks] how many times you can write that word using subsets of the string

2011-12-28 Thread Prem Krishna Chettri
Well. this seems interesting question. 1> You have to break the string to the lowest possible subset. I know O(log n) algo for this. 2> Number of possibilities of creating a second sentence from this subset. This is subset formation and I guess will take O(nlogn) atleast for n possible elements.

Re: [algogeeks] Detect a loop with just head ptr given

2011-12-08 Thread Prem Krishna Chettri
;> >>>> On 12/8/11, Deepak Nettem wrote: >>>> > If you allow storing an extra bit with every node (to mark whether a >>>> node >>>> > has been visited), you can do it with just one pointer. But that's >>>> less >>>>

Re: [algogeeks] Detect a loop with just head ptr given

2011-12-08 Thread Prem Krishna Chettri
Ofcourse we can.. U knw the head address now U start visit the list what is the big deal?? Jst u gotto create two pointer say fast and slow with two diff speed of action.. On Thu, Dec 8, 2011 at 6:27 PM, Ankur Garg wrote: > Can we detect if a loop is present in Linked List if only head ptr i

Re: [algogeeks] virtual destructor problem

2011-12-07 Thread Prem Krishna Chettri
The Output would be only the base class object destructor would be called so output :- derivedClass2 Des called Now why .. It is no more than just a base parent concept here, so base pointer capable if holding its derived object address get's derived object as new derivedClass2() creates only

Re: [algogeeks] Soritng

2011-11-22 Thread Prem Krishna Chettri
This is a Great Question .. Answering My Opinion as Follows :- 1> Its QuickSort :- Coz we compare on the basis of pivotal element so , we are reducing half (or More ) of the total comparison by picking the the pivot as a bench mark. All rest of the sorting do the full element comparison. 2> It

Re: [algogeeks] Query: Function returning void pointer

2011-11-21 Thread Prem Krishna Chettri
Ofcrse yes... hvnt you use Malloc ?? On Tue, Nov 22, 2011 at 1:23 PM, Aniket wrote: > Can a function return a void pointer ? > > -- > 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

Re: [algogeeks] Searching In a large file

2011-10-27 Thread Prem Krishna Chettri
Clearly this is an external sorting question.. Merge sort Can Be Used.. On 10/27/11, shiva@Algo wrote: > Given a file containing roughly 300 million social security > numbers(9-digit numbers), find a 9-digit number that is not in the file. > You have unlimited drive space but only 2megabytes of

Re: [algogeeks] Re: Hash Table

2011-10-27 Thread Prem Krishna Chettri
ja wrote: > >> @Prem : >> So is the time complexity is O(1) or O(log n) or O(n)??? >> >> >> On 27 October 2011 07:28, Prem Krishna Chettri wrote: >> >>> Well, if we talk abt space complexity in Hash.. M srry we require O(n) >>> for Hash Datastructu

Re: [algogeeks] Re: Hash Table

2011-10-27 Thread Prem Krishna Chettri
Well, if we talk abt space complexity in Hash.. M srry we require O(n) for Hash Datastructure... As each Bucket can contain at most one data value of Key Value pair,thats where key is gonna hash your value.. However, when we talk abt time complexity, its alwayz, the Hash Function dependable questi

Re: [algogeeks] Re: Hash Table

2011-10-27 Thread Prem Krishna Chettri
If N Element is already hashed and when you insert next element , Does hashing will take log N time to find the next available position? Actually the next insertion typically does not have any co-relation to pre-existing table content (Until your Hash function is badly designed to hash always on th

Re: [algogeeks] Find all possible combination of integers for a given sum

2011-10-25 Thread Prem Krishna Chettri
Its a subset Manipulation Problem.. Very simple logic.. Can Use Recursion for even more simplicity.. Call Recursion one with that element and once wdout.. On 10/25/11, Meng Yan wrote: > Hi, my question is > > given sum=N and combination constraint=M (the number of elements), how to > find all pos

Re: [algogeeks] Re: Adobe final interview question : small change

2011-09-23 Thread Prem Krishna Chettri
This is Simple query related to Factory Design Pattern... Have a look at the Auto Registration of Factory Design pattern.. :) Prem On Fri, Sep 23, 2011 at 3:02 PM, algo geek wrote: > You have a library provided by the vendor. All you have is header files and > library files. > Library contain

Re: [algogeeks] plzzzzzzzz heeeppppp!!!!!!!!!!1

2011-09-14 Thread Prem Krishna Chettri
Its an open ended question for the New Guys.. So.. here its some analysis.. If its project is R&D with high profile org like Amazon.. Google.. SDET is Developer in Test (Framework Developer for TESTING) but QA is a Complete Tester (Mostly No Code Work).. So SDET will develop in basically in So

Re: [algogeeks] Re: Stack problem

2011-09-06 Thread Prem Krishna Chettri
(num); >else{stk1.push(num);stk2.push(num)} > } > } > > int pop(){ > int num=stk1.pop(); > if(num==stk2.top())stk2.pop(); > return num; > } > > On Tue, Sep 6, 2011 at 6:12 PM, Prem Krishna Chettri > wrote: > >> Guys What the Iss

Re: [algogeeks] Re: Stack problem

2011-09-06 Thread Prem Krishna Chettri
Guys What the Issue Here?? I think its straight forward. If I hv two Stack First :- Keep pushing and Popping the incoming values Second :- Keeping track of the so far min element in the First Stack. Now maintaining second stack is bit tricky. PUSH :- If the element is first

Re: [algogeeks] Re: probability ques

2011-08-29 Thread Prem Krishna Chettri
Hi Guys, Comment required from NIT Warangal ppls. Who is this guy?? Who claims this ... http://timesofindia.indiatimes.com/tech/careers/job-trends/Facebook-hires-NIT-Warangal-student-for-Rs-45-lakh/articleshow/9793300.cms -- You received this message because you are subscribed to the Google

Re: [algogeeks] chanege in immutable string

2011-08-25 Thread Prem Krishna Chettri
Its true that in Java String are immutable. Even in the code given its immutable.. Its actually the code executed like this.. String s="java"; // S holds to java. s+="c c++"; // Here S = S + "c c++" "Java" + "c c++" which is now assigned to the new variable which here is s it

Re: [algogeeks] Re: amazon q

2011-08-23 Thread Prem Krishna Chettri
Its Both of the BST and Heap... Prem On Tue, Aug 23, 2011 at 5:01 PM, sagar pareek wrote: > I m surprised that ur whole explanation is for me :-o > Check ur previous post and then last post... > i think u r confused > > > On Tue, Aug 23, 2011 at 3:10 PM, WgpShashank > wrote: > >> @sagar, >> >>

Re: [algogeeks] Re: question on fork()

2011-08-23 Thread Prem Krishna Chettri
I Can See 10 Green and 10 Red Process.. Can Someone Compile to verify this... Prem On Tue, Aug 23, 2011 at 1:24 AM, gmagog...@gmail.com wrote: > Infinite times > Yanan Cao > > > > On Mon, Aug 22, 2011 at 2:43 PM, Don wrote: > >> // DO NOT RUN THIS! By inspection, how many times will it print "H

Re: [algogeeks] Puzzle

2011-08-18 Thread Prem Krishna Chettri
Only N is Married.. as if L is not married that n Must be married .. Again for M to marry N must not Marry. but as N is Married.. so.. M cannot marry... On Fri, Aug 19, 2011 at 9:24 AM, Dheeraj Sharma wrote: > M and N are married > > > On Fri, Aug 19, 2011 at 5:19 AM, Abhishek Sharma > wrote:

Re: [algogeeks] Re: Memory Leak

2011-08-17 Thread Prem Krishna Chettri
Well to answer U SAMM.. M not a fresher so in my interview they wont ask me this Rather they ask me Design Valgrind.. :D So... I told U guys tool name Implementation is Something U can think of.. My Recommendation is Use of Stack.. Prem On Tue, Aug 16, 2011 at 8:35 PM, SAMMM wrote: > If u wer

Re: [algogeeks] Memory Leak

2011-08-16 Thread Prem Krishna Chettri
Use valgrind.. On Mon, Aug 15, 2011 at 10:39 AM, Ankur Khurana wrote: > @rajeev +1 . great software . > > > On Mon, Aug 15, 2011 at 9:33 AM, rajeev bharshetty > wrote: > >> Valgrind is an effective open source tool to detect memory leaks and many >> more bugs in the program. >> >> http://valgri

Re: [algogeeks] an array question

2011-08-12 Thread Prem Krishna Chettri
Amazing , Kindly Follow me up :- 1> Given Array of Random Value ... say int a[]= {20,365,299,50,67,21}; Apply Any Sorting Algo on it... which Results into somewhat like a={365,299,67,50,21,20,.. blah..}... 2> Well No U hv to put those values to a string variable.

Re: [algogeeks] an array question

2011-08-12 Thread Prem Krishna Chettri
1> Sort the Array 2> Put it to the String Accordingly.. Prem On Fri, Aug 12, 2011 at 6:04 PM, Yasir Imteyaz wrote: > An array of integers is given and you have to find the largest possible > integer by concatenating all elements: > > example: > array: 87 36 52 > answer: 875236 > > array: 8

Re: [algogeeks] Re: amazon help

2011-08-12 Thread Prem Krishna Chettri
@ Shashank :-> Amazing one.. thx for Share.. :) Prem On Fri, Aug 12, 2011 at 4:15 PM, WgpShashank wrote: > @Akshmkj , A Blog For Geeks , Fresher Might Stuck !!! > > http://shashank7s.blogspot.com -" Cracking The Code " You Might Enjoy > > > > Regards > Shashank Mani > Computer Science >

Re: [algogeeks] Pointer Question

2011-08-12 Thread Prem Krishna Chettri
Ideally Speaking all of the option here seems not matching as this is the function pointer not an ordinary pointer. So the closest match is b but actually its not pointing to any 2 D or 3 D array or somewhat but rather it points to the block of memory starts from the dynamic address of row and onw

Re: [algogeeks] how o/p is coming

2011-08-11 Thread Prem Krishna Chettri
Yep, Ideally, if() statement evaluates the last push stack value from the stack and apparently here the last value evaluates to be 0 resulting the failure of the if condition. Please verify the compilation. :) Prem On Thu, Aug 11, 2011 at 4:21 PM, hary rathor wrote: > print nothing , your o

Re: [algogeeks] suggest simple code for

2011-08-08 Thread Prem Krishna Chettri
int Height (struct Tree *Node ) { if(Node==NULL) } On Mon, Aug 8, 2011 at 6:33 PM, jagrati verma wrote: > finding the depth or height of a tree. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send e

Re: [algogeeks] realloc and malloc

2011-08-08 Thread Prem Krishna Chettri
If U Knw the inner DS of MM.. I can help U ... MALLOC :-> Jst retrun the add of the pointer from where U shoud start the Allocation to the point upto where U want. Say :- > Memeory is a chuck of space which can be represented by my global array like char Heap[1000]; Considering 1000 is

Re: [algogeeks] Re: amazon question

2011-08-08 Thread Prem Krishna Chettri
When Process executed fork(). It create the Same Structure as the main process.The only difference is the return value of the child fork process is 0 and that of parent is the PID of its Child process. Now you can draw the pictorial representation of the fork processes during the execution and its

Re: [algogeeks] plz help with this

2011-08-02 Thread Prem Krishna Chettri
Well This is Certainly lacks logic behind the Coder. Please remember EVERY RECURSIVE PROGRAM Need Break for certain condition. here mid keep updating without knowing when to finish the recursion so the code never goes below line seven.. I appreciate this way of Creating LOOP although its a good

Re: [algogeeks] ITS NOT FAKE... Plz read and forward it.( From Micosoft Bill Gates)

2011-08-01 Thread Prem Krishna Chettri
This is Really Junk. Guys Dont Send Spam Thx On Mon, Aug 1, 2011 at 11:00 PM, Vamsi Achyuth wrote: > - Forwarded Message > *From:* Dileep Kumar Gangunta > *To:* mdbedu_dil...@yahoo.co.in > *Sent:* Mon, 1 August, 2011 11:37:59 AM > *Subject:* Fw: Plz read and forward it.( Fr

Re: [algogeeks] DS representation.

2011-07-29 Thread Prem Krishna Chettri
For all Folks.. DS question answer cannot be simple yes no. it is always the tradeoff of Space and time Complexity. On Fri, Jul 29, 2011 at 3:26 PM, rajeev bharshetty wrote: > You can use a Hash map which maps the coefficients of the > equation and their exponents. > Is this feasible ?? > > >

Re: [algogeeks] DS representation.

2011-07-29 Thread Prem Krishna Chettri
SLL... Bit Field (best optimisation)... On Fri, Jul 29, 2011 at 3:06 PM, Puneet Gautam wrote: > Hi, > > pls tell me which data structure has following representation:: > > A+Bx+Cx(^2)+Dx(^3)+...+Nx(^n-1).?? > > reply asap...!! > > -- > You received this message because you are subscri

Re: [algogeeks] swapping 2 variables without using temporary variables

2011-07-29 Thread Prem Krishna Chettri
On Fri, Jul 29, 2011 at 12:26 PM, Prem Krishna Chettri > wrote: > >> Replying to all the Above Code. >> >> 1> XOR operation to swap variable are not a solution as it fails for >> swapping of same value results 0. >> >> 2> the Short and Sweet looking

Re: [algogeeks] Logical operator question

2011-07-29 Thread Prem Krishna Chettri
little bit confusing..Vijay > > > On Fri, Jul 29, 2011 at 12:39 PM, Prem Krishna Chettri > wrote: > >> 1 >> >> and >> >> -3 -3 -4.. >> >> >> Verify the Compilation.. >> >> Regards >> Prem >> >&g

Re: [algogeeks] Logical operator question

2011-07-29 Thread Prem Krishna Chettri
1 and -3 -3 -4.. Verify the Compilation.. Regards Prem On Fri, Jul 29, 2011 at 12:35 PM, Vijay Khandar wrote: > Thanks, but also one small doubt > If x=y=z=-4 then plz tell me o/p of > pf(++x&&++y||++z) and pf(x,y,z) these two statements. > > > On Fri, Jul 29, 2011 at 10:52

Re: [algogeeks] swapping 2 variables without using temporary variables

2011-07-28 Thread Prem Krishna Chettri
Replying to all the Above Code. 1> XOR operation to swap variable are not a solution as it fails for swapping of same value results 0. 2> the Short and Sweet looking various modification of code fails to swap data when U swap data between two different data type. So I suggest you all guys to us

Re: [algogeeks] Logical operator question

2011-07-28 Thread Prem Krishna Chettri
Thx Kavi.. :) On Thu, Jul 28, 2011 at 2:59 PM, kavitha nk wrote: > @prem::ya its rite.. > > > //BE COOL// kavi > > -- > 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 u

Re: [algogeeks] C output

2011-07-28 Thread Prem Krishna Chettri
Well, this is quiet obvious even the least follower of C struct can answer it but the good part is why does compiler is design to do so.. Hope ppls do follow me in this activation rec.. yy *q struct yy (defined in somewhere) x.. Guys above notation is in stack so srry again for no Whiteboard

Re: [algogeeks] Small Doubt

2011-07-28 Thread Prem Krishna Chettri
PM, MANNU wrote: > @Prem: Each program is provided with a pool of address, which consist > of heap, stack etc. > My question is that if I write an address 0xff which is > not provided to that program then > what will be the output? > > On 7/28/11,

Re: [algogeeks] Logical operator question

2011-07-27 Thread Prem Krishna Chettri
Can SomeOne verify the Compilation as .. 1 211 1 221 1 222 0 0-10 0 00-1 0 0-1-1 Thx.. On Thu, Jul 28, 2011 at 11:47 AM, sagar pareek wrote: > +1 @ankur :) > > > On Wed, Jul 27, 2011 at 11:23 PM, Ankur Khurana > wrote: > >> one request : dont use trubo C >> >> >> On Wed, Jul 27, 2011 at 10:23

Re: [algogeeks] Small Doubt

2011-07-27 Thread Prem Krishna Chettri
First of all this is a good Question as this is use regularly in Device Driver kind of Development Mode and hence there is no question of Not Possible. So how to Do it is Question. which is as follows :- Point your pointer to mem add that U want and Now this Mem Add is HEX guys (Not 4 or 5 or any

Re: [algogeeks] The Google Resume

2011-07-27 Thread Prem Krishna Chettri
Anyone got this book?? pdf.. or URL link is highly appreciated. Thx.. On Tue, Jul 26, 2011 at 8:37 PM, Ankur Garg wrote: > +1 > Me too looking out for the same :( > > > On Tue, Jul 26, 2011 at 7:10 PM, Saravanan T wrote: > >> +1 >> >> Pls send to my email id as well.. >> >> >> On Tue, Jul 26, 2

Re: [algogeeks] Re: size of self referential structure

2011-07-26 Thread Prem Krishna Chettri
Its Cos that is pointer and all pointers is 4 bytes address.. On Tue, Jul 26, 2011 at 7:11 PM, Puneet Gautam wrote: > @everyone: > I have this mind strangling doubt..!!! > > Why is "char *s[5]" of 20 bytes...? > > yes the output is 28... > > On 7/26/11, Don wrote: > > A reasonable guess would be

Re: [algogeeks] Re: doubt in evaluating in expression

2011-07-25 Thread Prem Krishna Chettri
Well Guys, Jst to through some light on last Query.i.e y=++x + (++x + ++x) ; if you check the current activation record there is space allocated for only one variable that goes on changing till you dont violate the pint Rule. So you both are correct.. it will print 18 and yeah the value is com

Re: [algogeeks] Printf evaluation

2011-07-22 Thread Prem Krishna Chettri
Values will be Pushed to the Stack from left to right and Evaluated to be finally printed from the Stack. On Fri, Jul 22, 2011 at 4:01 PM, rShetty wrote: > #include > > int main() > { > > int i=1; > printf("%d%d%d%d",++i,++i,++i,i++); > > return 0; > > } > > Explain how it will be evaluated ?

[algogeeks]

2011-07-21 Thread Prem Krishna Chettri
If u check the real call Stack .. rather Activation record you will understand the details .. but as of now I can see that a *a is one value in stack and a *b is another .. So when U call any value with b object its b value.. so a wont be effected... but yeah its depends on Memory Model as well as