Recent questions tagged strings

0 0 votes
0 0 answers
46
46 views
A binary string $s$ of length $2026$ starts with bit $\color{red}{0}$ and ends with bit $\color{red}1$. Let $N_{00}, N_{01}, N_{10}$, and $N_{11}$ denote the number of ti...
0 0 votes
0 0 answers
39
39 views
You are given a long sheet of (ruled) paper with the string $\mathrm{MI}$ written on the first line. You are asked to fill in lines $2,3,4, \ldots$ (in order) with other ...
0 0 votes
0 0 answers
37
37 views
For a set $X, X^{*}$ denotes the set of all strings formed using $X$, including the empty string. By $x y$, we mean the concatenation of $x$ and $y$, i.e., the string $x$...
0 0 votes
0 0 answers
42
42 views
Consider a finite alphabet $\Sigma=\{0,1\}$. For a string $w \in \Sigma^{*}$, we write $|w|$ for the length of $w$. For $u, v \in \Sigma^{*}$, we write $u \cdot v$ for th...
9 9 votes
2 2 answers
362
362 views
What is the output of the following code?#include <stdio.h void fun(int *p) { *p = *p + 1; p++; *p = *p + 2; } int main() { int arr[] = {5, 10, 15}; fun(arr + 1); printf(...
9 9 votes
2 2 answers
349
349 views
What is the output of the following code?#include <stdio.h void update(int a[]) { a[0] = a[0] + a ; *(a + 1) = *(a + 1) + 5; } int main() { int arr[] = {2, 4, 6}; update(...
9 9 votes
2 2 answers
364
364 views
What is the output of the following code?#include <stdio.h void change(char *p) { p = 'X'; *(p + 3) = '\0'; } int main() { char str[] = "GATE"; change(str); printf("%s",...
7 7 votes
2 2 answers
344
344 views
What is the output of the following code?#include <stdio.h int main() { char str[] = "HELLO"; char *p = str + 1; *(p + 2) = 'A'; printf("%s %c", str, *p); return 0; }$\te...
6 6 votes
2 2 answers
357
357 views
What is the output of the following code?#include <stdio.h int main() { char str[] = {'C', 'S', 'E', '\0', 'X'}; printf("%s %c", str, str[4]); return 0; }$\texttt{CSE X}$...
2 2 votes
1 1 answer
146
146 views
Consider the following Python code:a = " #GATE #" b = " *DA *" print(a.lstrip("#"), a.rstrip("#"), b.lstrip("*").rstrip("*"))What is the output of the code above? #GATE G...
3 3 votes
2 2 answers
146
146 views
Consider the following Python code:s = "GO Classes for GATE DA" parts = s.split() print(parts , parts[-2] + parts[-1], len(parts))What is the output of the code above?GO ...
1 1 vote
1 1 answer
124
124 views
Consider the following Python code:s = "abcdefg" part1 = s[5:1:-2] part2 = s[::-3] print(part1, part2)What is the output of the code above?fdb gdafd gdafd gadeg gda
2 2 votes
1 1 answer
130
130 views
Consider the following Python code:s = "GOClasses" a = s[:2] b = s[2:] c = s[:0] d = s[5:] print(a + b, c == "", d)What is the output of the code above?GO True ClassesGOC...
2 2 votes
1 1 answer
140
140 views
Consider the following Python code:s = "HelloWorld" a = s[6:2] b = s[3:3] print(a == b, len(a + b))What is the output of the code above?True 0False 0True 2IndexError
4 4 votes
1 1 answer
155
155 views
Consider the following Python code:s = "GOClasses" first = s[0] last = s[len(s) - 1] middle = s[len(s) // 2] print(first + middle + last)What is the output of the code ab...
1 1 vote
1 1 answer
139
139 views
Consider the following Python code:print("Gate" < "gate", "DA" < "Data", "abc" "ab")What is the output of the code above?True True TrueFalse True TrueTrue False TrueTrue...
1 1 vote
1 1 answer
135
135 views
Consider the following Python code:text = "banana bandana" a = text.find("ana") b = text.find("ana", a + 1) c = text.find("xyz") print(a, b, c)What is the output of the c...
2 2 votes
1 1 answer
118
118 views
Consider the following Python code:a = " GATE DA " b = " *Data *" print(a.strip() + "-" + b.strip("*").lower())What is the output of the code above?GATE DA-dataGATE DA -d...
1 1 vote
2 2 answers
153
153 views
Consider the following Python code:s = "GATE Data" result = s.lower().replace("gate", "GO").capitalize() print(result)What is the output of the code above?GO dataGo datag...
3 3 votes
1 1 answer
144
144 views
Consider the following Python code:s = "python" t = s s = s[:2] + "X" + s[3:] print(s, t)What is the output of the code above?pyXhon pythonpyXhon pyXhonpython pythonTypeE...
4 4 votes
1 1 answer
125
125 views
Consider the following Python code:s1 = "Data" s2 = s1 + "base" pattern = "ta" + ("b" * 1) + "ase" tag = s1 + "!" * 2 print(s1 in s2, pattern in s2, "data" in s2, tag)Wha...
3 3 votes
1 1 answer
118
118 views
Consider the following Python code:s = "PythonDPP" print(s[-2:-8:-2])What is the output of the code above?PnhPDtPPDnohty
3 3 votes
1 1 answer
125
125 views
Consider the following Python code:s = "GATE2027" part1 = s[1:7:2] part2 = s[:4] print(part1 + part2)What is the output of the code above?AE0GATEAT2GATEAE2GATEATE202
3 3 votes
1 1 answer
127
127 views
Consider the following Python code:s = "GOClassesforGateDA" result = s + s[-3] + s[len(s) - 1] print(result)What is the output of the code above?CeACDAOeACss
0 0 votes
2 2 answers
293
293 views
Which of the following is not a palindromic subsequence of the string "$\text{ababcdabba}$"?$\text{abcba}$$\text{abba}$$\text{abbbba}$$\text{adba}$
36 36 votes
8 8 answers
14.5k
14.5k views
​​​​​Consider the following C program:#include <stdio.h void stringcopy (char *, char *); int main() { char a[30] = "@#Hello World!"; stringcopy(a, a+2); printf("%s\n",a)...
2 2 votes
2 2 answers
938
938 views
From a character string of length m , the number of sub-strings of all lengths that can be formed are:$\mathrm{m}^{2}$$\mathrm{m}$$\mathrm{m}(\mathrm{m}+1) / 2$$\mathrm{m...