You are on page 1of 3

Quiz questions

0. Title: String STL 03


Description: Which of the following function is used in a lexical analyzer to break
the strings into smaller chunks?

0.strtok()
1.strcpy()
2.strchr()
3.memset()

1. Title: String STL 04


Description: Which is the correct way to sort a given string ‘S”?

0.sort(S,S+S.size())
1.sort(S.begin(),S.end())
2.S.sort(S,S+S.size())
3.None

2. Title: String STL 05


Description: If we define a magic number between two strings A and B as longest
common subsequence of A and B. then what would be the magic number for a pair of
string A=”AGGTAB” , B=”GXTXAYB”?

0.4
1.5
2.7
3.6

3. Title: String STL 06


Description: Which of the following is the correct way of reversing a string ‘s'?

0.All of them.
1.int i=0,j=s.length()-1; while(i<=j)swap(s[i],s[j]);l++;j--;
2.reverse(s.begin(),s.end())
3.void reverseString(string &s){ if(s.length()<=1)return ;
swap(s[0],s[s.legnth()-1]); reverseString(s.begin()+1,s.rbegin()+1);
}

4. Title: String STL 07


Description: Given a list of N integers but since they are big , they are given as
string in the input. Now you are asked to form a number by concatenating all the
given N numbers in any permutation so that number formed has biggest decimal value.
What would that biggest number for N=4 and list of number {54,546,548,60}?

0.6054854654
1.6054854660
2.5486054654
3.6060606060
5. Title: String STL 08
Description: What does a.find(b) function for a string returns for a pair of string
a and b?

0.Finds the first occurence of a in b


1.Finds the first occurrence of b in a
2.Finds the last occurence of a in b
3.None of these

6. Title: String STL 01


Description: How do you find the size of a string ‘S’?

0.None
1.S.length()
2.s.len()
3.S.size()

7. Title: String STL 02


Description: What is the output of the following code?.
```cpp

Void f(){

char s1[] = "CobingBlocks";


char s2 = 'B';
char *ptr = strchr( s1, s2);
cout << ptr;
}
```

0.Blocks
1.bingBlocks
2.None
3.Some hexadecimal number

8. Title: String STL 09


Description: Which of the following algorithms finds a pattern from a text?

0.KMP
1.Convex Hull
2.Kadane
3.Dutch National Flag Algorithm

9. Title: String STL 10


Description: Find the output of the following program.
```cpp

void f(){

string s=”abhuhba” ;
bool flag=true;
for(int i=0;i<s.length()/2;i++)
if(s[i]!=s[s.length()-1-i])flag=false;
if(flag)cout<<”YES”;

else cout<<”NO”;

```

0.No
1.Yes
2.YES
3.NO

You might also like