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
Westkost [7]
3 years ago
13

Two strings, and , are called anagrams if they contain all the same characters in the same frequencies. For example, the anagram

s of CAT are CAT, ACT, TAC, TCA, ATC, and CTA. Complete the function in the editor. If and are case-insensitive anagrams, print "Anagrams"; otherwise, print "Not Anagrams" instead.
Computers and Technology
1 answer:
GenaCL600 [577]3 years ago
8 0

Answer:

static boolean isAnagram(String a, String b) {

<em> </em><em> </em><em>// 1 - Strings inequal in length can never be Anagram</em>

        if (a.length() != b.length()) {

             return false;

        }

<em> </em><em>        // 2 - Convert both Strings to Lower Case</em>

       a = a.toLowerCase();

        b = b.toLowerCase();

<em> </em><em>        // 3 - Create an Array to store character count</em>

        int charCount[] = new int[26];

<em>  </em><em>// 4 - Count Each Character</em>

        for (int i = 0; i < a.length(); i++) {

             charCount[a.charAt(i) - 97]++;

             charCount[b.charAt(i) - 97]--;

        }

       

<em>        </em><em> </em><em>// 5 - Check  for mismatching characters</em>

        for (int i = 0; i < charCount.length; i++) {

             if (charCount[i] != 0) {

                 return false;

            }

        }

       return true;

}

Explanation:

Complete Questions:

Two strings, a and b, are called anagrams if they contain all the same characters in the same frequencies. For example, the anagrams of CAT are CAT, ACT, TAC, TCA, ATC, and CTA. Complete the function in the editor. If and are case-insensitive anagrams, print "Anagrams"; otherwise, print "Not Anagrams" instead.

Function:

static boolean isAnagram(String a, String b) {

       // Complete the function

}

This algorithm has five steps to calculate whether two given strings are anagram or not.

  1. Check Strings length - If two strings don't have equal length, then they can never be anagrams. Because, anagrams contain <em>same characters in the same frequencies.</em>
  2. Convert both strings to lower case - in programming, <em>'A' is not equal to 'a'</em>. So, we need to make sure we have letters in same case to avoid such errors.
  3. Create an Array for character count - We need some method to ensure that the strings are anagrams. So, here we will count the characters and decide if the strings are anagrams (as discussed in next point)
  4. Count each character - If <u><em>String a</em></u><em> </em>has any character, we will <u><em>increase</em></u> the count of that character by 1. If <u><em>String b</em></u> has any character, we will <u><em>decrease</em></u> the count of that character by 1. At the end, if both strings have same characters in the same frequencies, all our character counts will be equal to 0.
  5. Check for mismatching characters - We check if all our character counts are equal to 0. If not, the function will return false, otherwise it will return true.
You might be interested in
Write a program that ask a user to input radius of a circle and display circumference of a circle
uranmaximum [27]

Answer:

Explanation:

8

4 0
3 years ago
Why are people's visions of utopias and dystopias subjective?
Leno4ka [110]

Answer:

D. Because the technology needed for one person's utopia may be what creates disaster for another person's dystopia.

Explanation:

3 0
3 years ago
After data is collected, how is it analyzed?
professor190 [17]

Answer:

It’s input into a computer and saved for future use

Explanation:

Step 1: Identify issues and/or opportunities for collecting data

The first step is to identify issues and/or opportunities for collecting data and to decide what next steps to take. To do this, it may be helpful to conduct an internal and external assessment to understand what is happening inside and outside of your organization.

-----------------------------------------------------------------------------------------------------------------

Step 2: Select issues and/or opportunities and set goals

The focus of Step 2 is choosing a priority issues and/or opportunities for collecting data, and then setting goals and objectives.

The organization reviews the issues and/or opportunities identified from the internal and external assessment done in Step 1, and picks one or more specific issues and/or opportunities for starting a data collection project from among the list of priorities. Some of the questions an organization can consider when deciding to prioritize an issue and/or opportunity for gathering data

-----------------------------------------------------------------------------------------------------------------

Step 3: Plan an approach and methods

In Step 3, organizations will make decisions about who will be surveyed, how data will be collected, the sources of data that will be used, and the duration of the data collection project, among other questions. These decisions may be made in consultation with an expert. The methods and approaches will flow from the goals set in Step 2, and will vary significantly depending on a number of factors, including the organization’s context, size, resources, and the purpose and complexity of the issue(s) or opportunity(ies) selected.

-----------------------------------------------------------------------------------------------------------------

Step 4: Collect data

When planning on how best to collect data in Step 4, it is important to be aware of the practical considerations and best practices for addressing logistical challenges organizations often face at this stage of the process. Implementing a data collection plan requires attention to matters such as:

  • Getting buy-in from senior leadership and key stakeholders, in or outside of the organization. This group could include boards of directors, management committees, union representatives, employees, community groups, tenants, customers and service users.
  • Establishing a steering committee or selecting a person(s) to be consulted and held accountable for all major decisions about the data collection process, such as design, logistics, communication management, coordination and finances.
  • Determining who will collect the data (e.g., experts or trained employees).
  • Identifying the logistics, resources, technology and people needed to develop and implement a data collection initiative.
  • Anticipating and addressing key stakeholder concerns and questions about the project.
  • Designing a communication and consultation strategy that will explain the data collection initiative and encourage the highest possible participation rate.
  • Protecting privacy and personal information by using carefully controlled procedures for collecting, storing and accessing data that comply with privacy, human rights and other legislation. Dignity and confidentiality must be respected.
  • Minimizing the impact and inconvenience for the people affected in the workplace or service environment, which includes choosing the best time to collect the data.
  • Aiming for flexibility to allow for changes without great expense or inconvenience.
  • Considering a test period or a pilot phase to allow you to improve and modify data collection methods, as may be needed.

-----------------------------------------------------------------------------------------------------------------

Step 5: Analyze and interpret data

Step 5 involves analyzing and interpreting the data collected. Whether quantitative and/or qualitative methods of gathering data are used, the analysis can be complex, or less so, depending on the methods used and the amount of data collected.

-----------------------------------------------------------------------------------------------------------------

Explaining the technical steps involved in analyzing and interpreting data is beyond the scope of this guide. An organization will have to determine whether it has the internal capacity and expertise to analyze and interpret data itself, or whether it will need the help of an external consultant.

-----------------------------------------------------------------------------------------------------------------

Step 6: Act on results

Once an organization has analyzed and interpreted the results of the data collected, it may decide to act on the data, collect more of the same type of data or modify its approach.

8 0
3 years ago
List any three importance of computer​
Naddika [18.5K]

Answer:

here is the answer

Explanation:

1) accurate

2) fast

3) can accomplish tasks more effencily

5 0
3 years ago
Write a C program to compute the average age of nth student
Hitman42 [59]

Answer:

Following are the code in c language

#include <stdio.h> // header file  

int main() // main function

{

 int n1,i;

 float avg,x,s=0; // variable declaration

printf("\nEnter How many Number terms you want:");

 scanf("%d",&n1); // input terms by user

 for(i=0;i<n1;++i)

{

 scanf("%f",&x); // user input

s= s +x; //calculate sum

}

avg = s/n1;// calculate average of n number

printf("\nThe average of n number is:");

 printf("%f",avg); // display average

return 0;

}

Output

Enter How many Number terms you want:3

3

4

3

The average of n number is:3.333333

3 0
3 years ago
Other questions:
  • Tag groups can be nested up to ____ levels deep, with up to _______ tag subgroups under a single parent.
    14·1 answer
  • How to save customised keyboard shortcuts on word
    11·1 answer
  • Will a pair of bar magnet ,with keepers on the two ends, act as a magnet
    13·1 answer
  • Consider the following MARIE Code: 100 If, Load X /Load the first value 101 Subt Y /Subtract the value of Y, store result in AC
    8·1 answer
  • What is the first step to apply the line and page breaks options to groups of paragraphs in a Word document?
    10·2 answers
  • What is the purpose of a poster frame?
    5·2 answers
  • Explain the following terms <br><br>copyleft:<br><br>creative Commons:<br><br>GNU/GPL:​
    8·1 answer
  • Trebuie sa scrii niște instrucțiuni în JavaScript care adaugă în DIV lungimea HTML-ului din interiorul tag-ului cu ID​
    14·1 answer
  • Which 2 tools are useful to remote employees and coworkers.
    10·1 answer
  • Give me reasons why Harry Potter is bad and anime is better
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!