1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Soloha48 [4]
3 years ago
14

Write a function that checks whether two words are anagrams. Two words are anagrams if they contain the same letters. For exampl

e, silent and listen are anagrams. The header of the function is: def isAnagram(s1, s2): (Hint: Obtain two lists for the two strings. Sort the lists and check if two lists are identical.)
Computers and Technology
1 answer:
marysya [2.9K]3 years ago
7 0

<u>C++ program for the checking if 2 strings are anagram :- </u>

#include<bits/stdc++.h>

using namespace std;

void isAnagram(string s1,string s2) //defining function

{

int an1[256]={},an2[256]={};//declare two count arrays of size 256 an1 and an2.

bool test=true;//taking a bool variable test = true for displaying the result..

for(int i=0;s1[i]&s2[i];i++) // iterating over both the strings.

{

an1[s1[i]]++;//increasing the count of the characters as per their ascii values in count array an1.

an2[s2[i]]++;//increasing the count of the characters as per their ascii values in count array an2.

}

for(int i=0;i<256;i++)//iterating over the count arrays..

{

if(an1[i]!=an2[i])//condition for not anagram.

{

cout<<"not an anagram"<<endl;

test=false;//making test false..

break;//coming out of the loop.

}

}

if(test)//if test is true only then printing..

cout<<"is an anagram"<<endl;

}

int main()

{

string s1,s2;//declaring two strings.

cout<<"Enter both the strings"<<endl;

cin>>s1>>s2;//prompting the strings..

if(s1.length()==s2.length()) //checking whether the lengths of string is same or not

isAnagram(s1,s2); //calling function

else

cout<<"not an anagram"<<endl;

return 0;

}

<u>Explanation</u>

A string is said to be an anagram string of other string if it has same characters but in different order or exactly the same.

for example:-  

string 1="silent"  

string 2="listen"

string 2 is an anagram of string 1.

void isAnagram(string s1,string s2) - This is the function having name isAnagram of void return type having parameters s1 and s2.

You might be interested in
Provide a brief, high-level description of how the Internet’s connection-oriented service provides reliable transport.
mario62 [17]

Answer:

  Connection-oriented is the method which is implemented in the transport and data link layer. It is basically depend upon the physical connection in the network system.

Transmission control protocol (TCP) is the connection oriented and user datagram protocol (UDP) is the connection less network transport layer. The TCP and UDP both are operate in the internet protocol (IP).

It basically require connection and it can be establish before sending data. This is also known as reliable network connection service. The connection oriented service establish connection between the different connection terminal before sending any data or information. It can easily handle traffic efficiently.

7 0
3 years ago
Contast between backups controlled within the SAN and backups controlled from the application server.
luda_lava [24]

Answer and Explanation:

Backup control within the SAN is one which confines the backup to the SAN and does not pass it via corporate network.

Backup traffic within the SAN are  easier to maintain and easily handled in contrast to the application server.

Backup in SAN is governed by  such applications and mechanism which allows the easy handling of the backup traffic which is not provided by the application servers.

In case of occurrence of any failure,  unlike application server, SAN provides smooth and fast migration

SAN holds data in cluster  by the use of backup techniques not used in application server.

6 0
3 years ago
Advantages of ASCII over EBDCDIC​
KiRa [710]
<h3>Efficiency. Moreover, the same character in ASCII requires 7 bits, but EBCDIC required 8 bits. Therefore, ASCII is more efficient than EBCDIC.</h3>

7 0
3 years ago
Suppose a variable is passed By Value to a parameter of a Sub procedure, and the parameter has its value changed inside the Sub
algol [13]

Answer:

"The value of the variable will remain the same which is already have when the sub-processor is called".

Explanation:

The above question said that:-

void fun(int a)

{

  a=a+1;

}

void main()

{

  int a=5;

  fun(a);

}

//what will be the value of a in the main function after the fun function is excuted.

  • Then the answer is: the value of a will be 5 in the main function.
  • It is because when the fun function is called, then a variable that is defined in the fun function is a local variable for fun function. That scope after the fun function is null.
  • The a variable inside the fun function is a different variable and the main function a variable is also a different variable.
  • So when the user prints the value of a variable inside the fun function, it will give the result as 6.
  • But when he prints the value of a variable inside the main function, then it will give the value as 5.
4 0
3 years ago
Logical are functions used when looking for an entry or value in the spreadsheet. what is it?
Mila [183]

Explanation:

Logical functions provide decision-making tools for information in a spreadsheet. They allow you to look at the contents of a cell, or to perform a calculation, and then test that result against a required figure or value.

5 0
3 years ago
Other questions:
  • Write code to assign the number of characters in the string rv to a variable num_chars.
    10·1 answer
  • An organization’s IRP prioritizes containment over eradication. An incident has been discovered where an attacker outside of the
    5·1 answer
  • How does a color change if you add more gray to it
    7·1 answer
  • Which option in presentation software can you use to apply a “fly in” effect to the objects on a slide? A)flowchart B)shapes C)
    11·2 answers
  • Based on your prior knowledge, match each civilization to the region it occupied.<br>​
    12·1 answer
  • Cisco has created a proprietary layer 2 protocol used to manage VLAN configuration between switches called:________a. VLAN Confi
    11·1 answer
  • Suppose during a TCP connection between A and B, B acting as a TCP receiver, sometimes discards segments received out of sequenc
    14·1 answer
  • What mathematical equation was created by a founder of intel?.
    11·1 answer
  • The ____________ command / function is used in Python graphics and text-based programming code.
    9·1 answer
  • Online education students need to be taught
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!