A data compression software utilizes various steps to compress a string of data. One of the steps involves finding the count of characters that are not repeated in the string. Write an algorithm for the software developer to find the count of characters that are not repeated in the string.
Answers
Solution -
We Have ,
\begin{gathered} \large \sf{a_{5} +a_{7} = 52}\\ \\ \large \sf{ = a + 4d + a + 6d= 52}\\ \\ \large \sf2a + 10d \: \: - - - (1)\\ \\ \large \sf{a_{11} = a + 10d = 46} \\ \\ \end{gathered}
a
5
+a
7
=52
=a+4d+a+6d=52
2a+10d−−−(1)
a
11
=a+10d=46
♠ Multiplying Both Sides by 2 :
\begin{gathered}\large :\longmapsto\sf 2a + 20d = 92\: \: - - - (2) \\ \end{gathered}
:⟼2a+20d=92−−−(2)
♠ Subtracting (1) From (2) , We get :-
\begin{gathered}\sf10d = 40 \\ \\ \sf d = \cancel{\frac{40}{10} }\\ \\ \purple{ \Large :\longmapsto \underline {\boxed{{\bf d = 4} }}}\end{gathered}
10d=40
d=
10
40
:⟼
d=4
A data compression software utilizes various steps to compress a string of data. One of the steps involves finding the count of characters that are not repeated in the string. Write an algorithm for the software developer to find the count of characters that are not repeated in the string.
C Program
#include<stdio.h>
#include<string.h>
main()
{
char str[30];
printf("Enter your String:");
scanf("%[^\n]",str);
int arr[256]={0},i;
for(i=0;i<strlen(str);i++)
{
if(str[i]!=' ')
arr[str[i]]++;
}
char ch=' ';
printf("All Non-repeating character in a given string is:");
for(i=0;i<strlen(str);i++)
{
if(arr[str[i]]==1){
ch=str[i];
printf("%c ",ch);
}
}
}
- Characters that appear only once in the string are said to be non-repeating characters. Using one for loop to determine each character's frequency and a second for loop to display the characters that have the highest frequency count, we can identify non-repeating characters in a string.
- By splitting at the substring with max n+1 splits, you can determine the nth instance of a substring in a string. The substring appears more than n times if the size of the resulting list is bigger than n+1.
#SPJ2