For 1st question :
First sort the array.------------------------ O(n*logn)
then we can easily find 2 elements in the array which sum to X.
---------------O(n)
So, Time complexity of the algo : O(n*logn)

Question 2 is trivial..




On Tue, Jun 28, 2011 at 2:30 AM, vikas <mehta...@gmail.com> wrote:
> 1.Given an array of integers and another integer X - create an algorithm to
> determine if the sum of any two integers in the array would result in x
>
> 2. design a ADT to implement push(), pop() method as stack, and also has a
> getMinElement(). Require that getMinElement() is constant time but
> push()/pop() do not have to be constant time at first. Then for improvement,
> these three methods are all required to be constant time
>
> --
> 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/-/_meOQF9Qu1AJ.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to