design problem

Discussion in 'C' started by nizzy, Mar 8, 2010.

  1. nizzy

    nizzy New Member

    Joined:
    Mar 8, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    [FONT=&quot]You are given two strings. Write an algorithm that creates a third string such that it contains both the given strings and it should be the smallest possible string. There is no condition regarding order of occurrence of given strings in the third string. Implement your algorithm in C++ using classes.[/FONT]
    [FONT=&quot]For Example: [/FONT]
    [FONT=&quot]a)[FONT=&quot] [/FONT][/FONT][FONT=&quot]S1=”hello” [/FONT]
    [FONT=&quot]S2 = “loot”[/FONT]
    [FONT=&quot]S3= “helloot” [/FONT]
    [FONT=&quot]S3 = “helloloot” //Incorrect as S3 is not the smallest possible string[/FONT]
    [FONT=&quot]b)[FONT=&quot] [/FONT][/FONT][FONT=&quot]S1= “hello”[/FONT]
    [FONT=&quot]S2 = “Delhi”[/FONT]
    [FONT=&quot]S3 = “helloDelhi” or “Delhihello”[/FONT]
    [FONT=&quot]Expectations:[/FONT]
    [FONT=&quot]a.[FONT=&quot] [/FONT][/FONT][FONT=&quot]Write the algorithm to concatenate two given strings. [/FONT]
    [FONT=&quot]b.[FONT=&quot] [/FONT][/FONT][FONT=&quot]Modify your algorithm so that it creates the third possible string.[/FONT]
    [FONT=&quot]c.[FONT=&quot] [/FONT][/FONT][FONT=&quot]Implement your algorithm in C++.[/FONT]
    [FONT=&quot]d.[FONT=&quot] [/FONT][/FONT][FONT=&quot]Make a comparison of above two algorithms on the basis of time and space complexity.[/FONT]
    [FONT=&quot]e.[FONT=&quot] [/FONT][/FONT][FONT=&quot]Can this problem be solved using iteration and recursion? Which one you will prefer and why? [/FONT]
    [FONT=&quot] [/FONT]
     
  2. virxen

    virxen Active Member

    Joined:
    Nov 24, 2009
    Messages:
    387
    Likes Received:
    90
    Trophy Points:
    28
    and the problem is?
    where is your code you have written so far?
     
    shabbir likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice