Amazon placement Round 2 August 2013
Student 2 - Round 2
Q1. A string of length n and an integer m was given, give an algo. to rotate the string counter clockwise by m. Give all the check conditions for input m. Then the interviewer asked to write a code for the same with a strict guideline that there should not be any mistake in the code . Q2 : heap, min and max heap, insertion and deletion in a heap. Time complexity of inserting n elements in a heap.
Suppose the given string is "ABCDE" and lets say m=2. Here n=5=strlen.The algo goes like this :
ReplyDelete-- reverse string from 0->(m-1) position BACDE
-- reverse string from m->(n-1) position BAEDC
-- reverse string from 0->(n-1) position CDEAB , the required O/P.
For Q2, just to make it clear, only DeleteMax or DeleteMin is supported by standard heaps which takes log(n) time.To be specific any random deletion of node is not practical with heap DS.
ReplyDeleteInsertion takes log(n) as well.
please send me the study material for AMAZON on campus placement
ReplyDeleteaayushrangwala@gmail.com
This comment has been removed by the author.
ReplyDeleteplease send me the material regarding Amazon placement.My mail id is shivaanigovindarajan@gmail.com
ReplyDelete