Professional Documents
Culture Documents
Important Instructions:
1. Write your program in C++.
2. Do not use any inbuilt function of array or string.
3. Input should be given by user (do not define it in your program)
4. Array must be dynamically initialized in C++ style (using new )
5. Don’t write or mark anything on paper.
Q3. Let X = x1x2…xn and Y = y1y2….yn be two character strings. We say that X is a
cyclic shift of Y if there is some r such that X = y r+1…yny1…yr.
WAP to determine whether X is cyclic shift of Y or not.
Q4. L is an array containing n integers, and we want to find the maximum sum for a
contiguous sub-sequence of elements of L.
For example, consider the array with elements.
38 -62 47 -33 28 13 -18 -46 8 21 12 -53 25
The maximum subsequence sum for this array is 55.The maximum subsequence
occurs in positions 3 through 6 (inclusive)
(If all elements of a sub-sequence are negative, we define the maximum sub-sequence to be the
empty sequence with sum equal to zero.)
For example, there are six ways to give 17 cents change: a dime, a nickel, & two pennies; a
dime & seven pennies; three nickels & two pennies; two nickels & seven pennies; one
nickels & 12 pennies; & 17 pennies.
Q6. Write a function that takes a number n as an argument and returns (or
outputs) every possible unique substrings (of the first n letters of the alphabet.
For example, substrings(5) could be:
a ab abc abcd abcde b bc bcd bcde c cd cde d de e
Q7. Write a program to reverse words in sentence.
Page 1
E.g. If input : Welcome to string program
Output: emocleW ot gnirts margorp
Q8. Write a program to cyclic shift a string of length l, by value r without using any
other temporary variable in O(n).
Q9. Write a program to fine the maximum common substring between given three
strings.
Q10. Write a program to find whether a string is cyclic shift of second and third string
i.e. X if cyclic shift of Y & Z
Q11. Make a program that Input month and year and prints out a calendar for that
month in a nice calendar format. Date should be greater than 01/01/2000
For instance, for May 2012, it should print out something like:
MAY 2012
M T W T F S S
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Q12. Write a program to find the maximum common substring between given three
strings.
Q13. Write a program to find whether a string is cyclic shift of second and third string
i.e. X if cyclic shift of Y & Z
Page 2