You are on page 1of 10

Gmail - Fwd: [softwarriors_cse] Fwd: my set question bank--with datastructure q/a

Page 1 of 10

Aravind Narayanan <>

Fwd: [softwarriors_cse] Fwd: my set question bank--with datastructure q/a
Fri, Aug 4, 2006 at 10:24 PM To:,, akshay chander <> Arunkumar Senthilnathan <>

__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around ---------- Forwarded message ---------From: sangeetha tv <> To: Date: Thu, 22 Jun 2006 19:35:23 -0700 (PDT) Subject: [softwarriors_cse] Fwd: my set question bank--with datastructure q/a our senior sent ths Note: forwarded message attached.

Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail Beta. __._,_.___ Messages in this topic (1) Reply (via web post) | Start a new topic Messages | Files | Photos | Links | Database | Polls | Members | Calendar You are receiving Individual Emails Change Delivery Settings Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe We Made Changes Your Yahoo! Groups email is all new. Learn More Share Feedback Recent Activity 1 New Files Visit Your Group SPONSORED LINKS Colleges and universities School education College and university in tennessee College and university search 8/6/2006

Gmail - Fwd: [softwarriors_cse] Fwd: my set question bank--with datastructure q/a

Page 2 of 10


__,_._,___ ---------- Forwarded message ---------From: vijay balaji <> To: Date: Thu, 22 Jun 2006 03:20:00 +0100 (BST) Subject: my set question bank--with datastructure q/a

Yahoo! India Answers: Share what you know. Learn something new Click here

M.SELVAM TRILOGY: written questions r easy than ever before.. n a question involving POSTFIX translation n matching the word was nice...get the full question 4m anyothers. #ask the questions clearly..make assumptions n tell him those n sols using that assumption n also the downside of this soln.(only if u cud not get the ans quickly)... #start 4m the trivial solutions n keep on improving it until u or he is satisfied. #most tree questions can b solved using recursion.. #for search n some others use hashing... #tell the solutions as u think commentary #be clear while coding n b legible in coding*(really very important)...test the malloc's null etc.. I LEVEL: 1. given a tree. add an extra component to its node specifying the no. of nodes in each subtree. also modify 2 find the difference between the no of nodes in left subtree n right subtree. 2. given 2 sorted arrays. give the easiest way of printing all in sorted order except the commons in these two arrays. then he asked to modify the logic to print only the commons ie intersection of these 2. 3.the node structure is :{string, no. of nos, list of nos. ptr to next.node in list } how will u store it in persistent media n retreive back correctly.. he kept on modifying this to include another list of same structure with its head ptr being included in the above structure.. also he played with strings- be clear with zero length string n null string- i was baffled n perplexed it. 4. how will u confirm that a given sudoku has been solved correctly. know its order too. 5.n 2-3 very easy questions in c,c++ hints: 1.recursion-modify finding the depth of the tree. 2.use the merge sort techniq wid some optimisations 2 make it fast. 3.use the length of the string, length of the list of nos., newline.. to make thgs easy. 4.normal traversals with a flag of 'n'bit it 4 each row n each col n each 3n^2 traversals..--0 (n^2).optimise it werever possib ----------------------------------------- 8/6/2006

Gmail - Fwd: [softwarriors_cse] Fwd: my set question bank--with datastructure q/a

Page 3 of 10

II Level: 1.given a tree with only one node having 2 parents at different levels.. write a code 2 identify it n print the necklace pattern resulting bcos of this 2parent node..he allowed 2 use a flag in the node struct n later askd soln without using xtra space. 2.write non-recursive inorder-traversal, with tail-recursion inorder traversal. 3.give n^2,nlgn,n solutions to find a pair a,b such that a+b=x(given) in a sorted array.. he asked if i knew this question already..n i lied.. 4.identify the common ancestor of given 2 nodes.he complicated it by allowing no extra space.. hints: inorder traversal n mark the flag as u proceed if its not markd else thats the node to b found n print it.. without the flag: use the breadth first traversal n on enqueing chk if this node(adrs n not no. since tree is not of distinct elems) is already present n if so thats the culprit node n print the necklace pattern.. i didnt code it well..n tats made a difference 2.easy 3.0(n)- come 4m both ends..i,j if a[i]+a[j]==x print if a[i]+a[j] < x i++ if a[i]+a[j] > x j-- until i<=j space : use a variable n in recursion increment in differently for left n right subtrees wiht the probing nodes n if the value is sum of both lft n rgt- common ancestor. int ancestor(int i,int j,tree *node) { int r=0; if(node==0) return r; if(i==node->data) r=1; if(j==node->data) r=2; r+=ancestor(i,j,node->left); r+=ancestor(i,j,node->right); if(r==3) printf("common ancestor %d",node->data); return r; } --------------------------------------III level: 1.given 2 unsorted arrays how will u find the common nos n uncommon nos efficiently... he ruled out sorting saying the posns r 2 b preserved n arrays are of larger size... i shd hav used hashing but i gave a diff soln n didnt code it well. he terminated the iview !!!!ALL THE BEST!!!! ************************************************* AMAZON: all r quite easy written: 8/6/2006

Gmail - Fwd: [softwarriors_cse] Fwd: my set question bank--with datastructure q/a

Page 4 of 10

given a tree - find the longest path(4m lft bottom to root of subtree to its right bottom) of the the one with the large depth in left subtree n right subtree.. I LEVEL: reg project, c-c++ basics, how had i implemented c++ concepts in my project, 4-5 dbms questions n i didnt answer even 1 correctly.... 2 probability questions.. a familiar puzzle. interesting data structure i've used... inorder traversal.... merging 2 sorted arrays.. ============================================== II LEVEL: askd my favourite subj n many basic easy questions 4m CA... code 2 find if a gn no. is power of 2, find the no. of bits set in a byte. a probability question. how will u store a tree in a persistent media such that its retreivable as such.. ans:storing inorder n preorder is ruled out.. he askd the code to construct a tree 4m these 2 n then ruled out this since same no. is stored twice in both arrays.... so i gave a file storing the pictorial rep of tree as such with sum modifications 2 save storage 4 the leaf nodes n a mt node @ a level n while coding it, i forgot n left some cases in my logic n its crucial... so pls b clear while coding n b legible wid flow n they will simulte test cases wid urs... askd me 2 design a car n the classes i shd use 4 the object-car. he gave me a simple set of attribs of car n saw how i'm accomodating scalability, sw reuse in these..n i didnt do well..n was advised not to forcibly include all the OOPS concepts 4 the trivial thgs..!! --------------------------------------------III level: ambitions,family details, plans,placements.. reg prjs, questions 4m that.. basic c,c++ quests.. askd the design 4 a editor like vi or 4 any language.. i included many of the features of VC++ editor n normal features u think of... later i was advised after rejection tat i need 2 be concentrating more on coding n legible in coding n not 2 confuse design n implementation... b careful..they look 4 minute intricate thgs n so b careful thruout..they xpect a decent knowledge in probability too. !!!!ALL THE BEST!!!! ************************************************* YAHOO: I LEVEL: 1.given a matrix wid rows full of 0s n 1s n 0s follows 1s n never precede rows r of the form 1*0*. find the row wid max no. of 1s n the max no. of consecutive 1s. 2. code to find the depth of the tree. 3. implementation of priority q...heap n its structure diff bt PROCESS N THREAD--A VERY BASIC N VERY IMPORTANT QUESTION..SURE GUYS.. An INTERVIEW QUESTION HAS ALREADY BEEN LEAKED...b clear in it n wen to prefer each.. prjs n modifications in it.. static, fn ptr, c,c++ basics.. 8/6/2006

Gmail - Fwd: [softwarriors_cse] Fwd: my set question bank--with datastructure q/a

Page 5 of 10

some of the unix quests n commands.. n convince them wid valid reasons tat u join them if selected n no MS/MBA hint: 1. in 0(n)- 4m first row move 2wds left until thrs a 1 else cum down to the next row n start 4m tat col will be like staircase... 1111000 ans : 1111 1100000 0 1110000 0 1111110 11 0000000 0 so 6 is the ans. --------------------------------------------------II LEVEL: (full coding n *they chkd the *output!!) Design a query processor given numerous numerous records of very higher sizes. each record will have a large number of key-value pairs followed by actual data. all these key-value pairs 2gether uniqly idntfy each datum. given a query of key-value pairs with return the data... and,or,lessthan....(all relational ops)

many gave a binary search tree, linked list, hashing with linked list options.... n they asked many 2 redesign b4 allowing 2 code.. the soln with B-tree,B+-tree(numerous numerous recs) is the preferred one...since range search(rel ops) is easy here. i gave a trie soln, it was accepted design is : for each key-end node have a array of values it may take n for each key-value pairs hav a array of records that hav this pair.. this works in 0(n). but i didnt code nicely n zero output even after giving hard coded ips.. but was selected... !!!!ALL THE BEST!!!! ************************************************* GOOGLE: written-20 basic quests in c,c++, sorts but shortlisted those with > 18 I level: basic c,c++ quests..- templates,namespace,etc.. prjs n qs in tat. how will u find the quotient without using division operator, hint: use binary search tech. ie take a middle of the range(initially the range is 0 to 2^32-1) and multiply with divisor to see if u get dividend, if its lesser than dividend, range is upperhalf, else lower half.. given many arrays in distributed sites, how will u find median of allnos.(as xplaind in phone) x,y u r to write a fn. that returns x if gn y, y if gn x, any other if gn z!=x,y fn(z) return z^x^y; or return (x*y)/z; or return (x+y)-z; 2.given a word doc file, return the word that is repeated 4 the largest no. of times... 8/6/2006

Gmail - Fwd: [softwarriors_cse] Fwd: my set question bank--with datastructure q/a

Page 6 of 10

i gave trie n binary search tree sols... but he is not convinced..think of a better soln. 3. gn alphabet set {0,1,2} gn a length of str find d string that does not have a same pattern repeated consecutively in w*xxy* [x is a string of any len>0] eg. 4 a len of 8 - 1 sol is 01210201...believe he said its possib 2 construct a string wid a len=300 millions.. i gave a dp soln..wid a table of 2 rows n cols being the lettr 4m alphabt set tat starts d str askd.. rows hdg being the n-1,n len strs. n each cell is array of strs meeting the criteria gn. logic is accepted.. ----------------------------------II LEVEL their process not only is interesting but very tedious,prolonged..believe, its 8 months 4 me... 1.the same 1*0* q. refer yahoo secn. sum quests 4m my prj.. n Newmelchi(our sr. 2002 passed out) is really very very brilliant n found out the mistakes in ur logic n prj as fast as Sudaakeran(his classmate now in AMAZON). 2. enumerate all the different ways of giving ur balance given tat u hav all sorts of coins in large nos. ie u hav 1,2,3..... all coins in infinite no.. n 4 eg. u cud give 5rs as all 1s 3 1s, 1 2 1 1s, 2 2s 2 1s, 1 3 1 1s, 1 4 1 2, 1 3 1 5. u can use either recursion or faster dp soln. 3.given a pack of cards, how will u pick a card randomly but all remaining cards shd hav equal probability of getting picked. 4.1 probability question. ========================================== LEVEL 3,4 -telephonic askd abt projects, simple C,C++ quests, sorting techs, why do u prefer heap over merge. diff bt process n thread. to scan a image - which will b the best way 2 do so..of course flood fill is too lengthy n slanting scan is the best-i was said. how many times does merge fn in merge sort is calld - n-1 times. how will u get d 'k' largest elements 4m a set of sorted arrays.(heap techniq -lvl 3) how will u merge the gn set of sorted arrays.(heap techniq - lvl 4) =========================================== 5-8 ON-SITE iview #1. askd 2 explain 'diff' n the implementation of 'diff' in unix.wat algm had been used in it. - i said Edit-Distance n then ruled out mine giving its difficulties n LCS is the correct one n askd to write d code 4 LCS. #2. 2 rooms connected thru a single door allowing only one to move across it in a given time. a set of ppl r ther. how will u have all combinations of ppl in either rooms with only one move possib at a time n the same combination shd not repeat in either rooms. i gave many solns but everythg had a flaw n finally he gave me the correct soln - treat as bits n "hamming code" is the correct ans. then he askd 2 modify code 4 hamming code to satisfy the gn criteria 8/6/2006

Gmail - Fwd: [softwarriors_cse] Fwd: my set question bank--with datastructure q/a

Page 7 of 10

#3. questions wer askd 4m project in all the levels. #4. Networks: complete scenario of wat happens wen u type a url in ur adrs bar n askd how will it b implemented.askd nw protocols-very abstract:mere mentioning of the protocol n its generalised purpose is enough. #5. how will u find the MTU(max transmn unit) of a network. hint: use dont frag bits. n askd how cud it b optimised - binary search techniq. also askd how TCP congestion window pbm cud b avoided. - i blabbered sthg n he accepted. #6. 1 question 4m probability - i dint tell. #7. how will u delete a node 4m a binary tree. #8. in a quad-tree(with 4 or 0 children) he askd me 2 write a code 2 find the eastern,western neighbors of a gn node n complicated it further.. but its easy n u cud give a recursive soln. #9. gn a large set of nos tat r coming 4m various sites, how will u store. many solns of file storage, tree storage n mergin them. everythg is ruled out saying the nos r more than 4GB n so finally gave the bit soln n in the hdisk have a file storing how many times each no hav occurd n optimise its incremental, storage n retreival. #10. how will u find the "search query typed by the user is wrong", wat algm u use - edit distance n also how it cud b optimised. #11. gn a set of petrol bunks n pipes; wer will u install the central tank such tat the cost of pipes is minimised (all pipes r laid vertically n no zigzags). soln:choose the central bunk(equal no of bunks above n blow it) n draw a horiz pipe thru this central bunk n lay vertical pipes to all other stations. he askd a mathematical proof n i managed. #12. gn a farm field wid 8 feet grasses n small stationary swans lay thruout the field n u hav a set of volunteers-how will u use them effectively 2 find out d no of swans to the closest approximation n swans will make a sound @ irregular intervals. i was panicd n askd if the swan's frequency of the sound, frequency of making sound,etc r known. he askd me to make as many assumptions as possible n explain why i made tat. i gave a square, circle to place volunteers at the corners n gave mathematical proof 4 closeness to correct no of swans. then he wanted me to give me all possib solns i think of,, n i was keep on giving anythg n it was nice 2 both of us. #13. given a search query - how will u process it optimally to give the pages n askd how will i include personalisation feature.. Really Tough #14. how will u find if the pattern - ww(reverse)s* is in a file in 0(n). w-a string of any length-l w(reverse)- reverse of w s*- any string of any len i gave him n^3, n^2 solns but he didnt even hear it n insisted on linear time soln n askd me 2 assume tat i hav a preprocessed array as in the case of KMP, yet i'm unable 2 deliver the ans. beleive me - even our maestros : karthik,madhan n lenin cudnt answer this. #15. the initial assembly of towers of hanoi has been modified such that even the small towers can b beneath the larger towers n u hav to transfer all the towers 2 the third peg with the usual condition of placing the larger beneath the smaller not being violated anywer. (more than 40 mins v spent in this quest) !!!ALL D BEST!!! 8/6/2006

Gmail - Fwd: [softwarriors_cse] Fwd: my set question bank--with datastructure q/a

Page 8 of 10

================================================ ADOBE The written test was conducted by an agency. The aptitude test was very easy. However the technical paper was set by Adobe, bangalore. Written test 1. Height of a tree 2. Find a path of a tree that totals up to a given sum. 3. To produce a mirror image 4. Write an algorithm that produces the 2nd largest element in an array. 5. Bit-wise operator questions Given a number. Produce its immediate next multiple of 8 for EgIf n is 24 , then answer is 32 If n is 9, then answer is 16 Use bit wise operators. 6. Write an algorithm to find out whether the system is little endian or big endian 7.Bit-wise operator question Write an algorithm to turn off the rightmost bit For eg10110011 answer is 10110010 10110010 answer is 10110000 8.Algorithm to convert a number to hexadecimal 9.Given a b c d e f g h i to produce i f c h e b g d a 10. Given 2 sorted arrays. They may contain duplicates. Merge them into 1 sorted array. This resulting array should not contain any duplicates. 11.Allocate and deallocate space for 2D arrays using pointers. 12. What is de program doing?- it was the code for counting the no of 1's using bit wise operators.( This code is available in Test Ur C skills) INTERVIEW QUESTIONS 1. Reversing a linked list without recursion 2.You are given a random array and a value X.Find any 2 nos in de array that sums upto the value X. 3.In C++ , implement cout using printf ( operator overloading) 4.How do u implement C++ in C? -( concentrate on the object oriented features of C++) 5.Implementing a stack using a linked list. Implementing a queue using a linked list. Implementing a queue using stacks. 6.Project related questions. 7.OS questions 8.Networks questions 9.Puzzles. MICROSOFT 8/6/2006

Gmail - Fwd: [softwarriors_cse] Fwd: my set question bank--with datastructure q/a

Page 9 of 10

WRITTEN TEST 1. strtok- implementation code was given . Asked to write wat that code does. 2.To count the no of occurences of each word ina given input with all possible test cases. i dont remember the other qustions.Sorry!! INTERVIEW 1.Given an array of 0's and 1's. Sort them 2.An algorithm to swap every 2 nodes in a link list. 3.Finding the median in a link list incase of odd and even values. 4. 1 Microprocessor question I dont remember the other questions......

YAHOO WRITTEN TEST 1.Merging k sorted lists. 2.given data as follows: cricketer .... .... country .... .... .... .... runs .... ...... avg

3.Write an algorithm that always gives the batsman with the highest average as the result. 4.Write an algorithm to flatten a tree. Some C, C++ questions . asked to give outputs. quite easy. INTERVIEW QUESTIONS 1. To find out the nth node from the end in a link list. 2.Implement strcat(), atoi(). most of the questions were based on projects, OS, Networks and Unix.they drill u here. u cant lie about ur projects. PROGRAMMING ROUND- 2 hrs. can show the output in either C, C++, Java Given a file in the following format A 100 B 200 B 250 .......................... Variable length records If u give a query like " retrieve records where A=100 and B=200, the program should be able to retrieve all such records. operators allowed in the query - AND, OR , NOT any no of operators can be given in a single query. ORACLE WRITTEN TEST no technical, only aptitude .Very easy. INTERVIEW QUESTIONS 1. Asked to implement tic tac toe problem. 2.Insertion , deletion and all operations in a doubly linked list. 3.Project related questions. 4. DBMS Questions-WHat are the different types of join? what is the difference between the different types? 5. Computer Architecture questionsWhat is de use of a cache? wat are the points to be considered if a secondary level cache is to be introduced? 6.Overall working of a computer- the internal working. 7.OS questions. 8/6/2006

Gmail - Fwd: [softwarriors_cse] Fwd: my set question bank--with datastructure q/a

Page 10 of 10

8.Compiler questions. 9.Postorder traversal without recursion. 10.Breaking the skew of a tree and then building it. 11.Some string formatting questions. 12. Implementing Josephus problem - refer Tanenbaum

-with love, Arun S

2 attachments Algorithms_and_coding.doc 39K datastructuresquest.doc 426K 8/6/2006