For Q1:
if length1!=length2 => false
else
take 2 arrays ch1[256] and ch2[256]
For every character c in each string increment the element ch[c] in
the respective array;
now traverse both arrays together.
if each ch1[] element =each ch2[] element => true
else =>false
__________________
Ankit Chaudhary
Computer Engineering
Netaji Subhas Institute of Technology
On Jul 6, 3:50 pm, Abhi <[email protected]> wrote:
> Q1.>>First sort both the strings using counting sort perhaps.
> >>Then starting from the first character, search for it in the second string
>
> using binary search.>>The succeeding character of A will be searched from the
> index in B at
>
> which last character of A was found
>
> Worst case: When both the strings are alike : O(log(m) + log(m-1) + log(m-2)
> ...log(1)) = O(m*log(m))
>
> But Average case will be quite efficient
>
> Abhishek Khattri,
> Computer Engineering,
> Netaji Subhas Institute of Technology
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.