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
An application programming interface (API) is ________. A) the code the application software uses to take advantage of code writ
Lapatulllka [165]

Answer:

A) the code the application software uses to take advantage of code written by others

Explanation:

An API is a tool widely used in the development of moderm software applications, it is basically a set of protocols and routines that specifies how the software application should interact with others. It provides the interface of the communucation link for the different parts of the program. The intent of APIs is for the simplification of software development and maintenance.

7 0
3 years ago
Is the answer a,b,c,d
MariettaO [177]
Well I got some numbers mixed up but I think it’s B
4 0
3 years ago
which type of processor chip is designed to perform a single function and is typically custom-designed?
jarptica [38.1K]

SoC is kind of processor chip that is designed  to perform a spesific function and is typically custom-designed. Hence, the answer is D.

System on chip (SoC), can be described as a design where processors, controllers, and devices reside on a spesific processor die (or chip). Packaging of SoC saves space and is usually power efficient. A system-on-a-chip (SoC) refers to a microchip with all the desire electronic circuits. Kind of processor chip that is designed to appear a spesific function and is typically custom-designed is known as SoC. SoC has responsible to againts cyber threats. SoC is important because it can immediately respons if there are incident.

The question isn't complete. The complete question is shown below:

Which type of processor chip is designed to perform a single function and is typically custom-designed?

A. ASIC  

B. FPGA

C. x86

D. SoC

Learn more about System on chip (SoC) at brainly.com/question/26528046

#SPJ4

6 0
1 year ago
Which of the following is NOT necessary for organizing data to make it easier to sort?
Elenna [48]

Answer:

All the data must be the same font and font size is not necessary for data sorting.

Explanation:

The most easier and frequently used tool for data organizing and sorting is Microsoft's excel or google spreadsheet. Sorting deals with arrangement of  data values in a particular sequence or order according to defined rules. For example data can be sort in ascending or descending order as per values or names in list.

7 0
3 years ago
What is the range for copper tape
jeyben [28]

Answer:

I like the song "Angel"

3 0
2 years ago
Other questions:
  • Which of the following should you always wear to avoid being thrown from a vehicle and then crushed if it tips over?
    12·2 answers
  • What is the description of a computer ram?
    7·1 answer
  • For the questions below, consider a class called ChessPiece. This class has two instance data, String type and int player. The v
    13·1 answer
  • The part of a rocket engine that allows the combustion gases and flames to leave the rocket engine is the
    14·1 answer
  • An HTML document is composed of ______ that represent distinct items in the Web Page, such as a paragraph, the page heading, or
    9·1 answer
  • A firm offers virtual local area networks and firewalls as an on-demand cloud service. Which service does the firm offer?
    11·2 answers
  • You are responsible for a rail convoy of goods consisting of several boxcars. You start the train and after a few minutes you re
    8·1 answer
  • Helppppppppppp please
    5·2 answers
  • If any one answered this i will give brilientst what is stimulation program​
    6·1 answer
  • Michelle has defined a custom object by creating an object literal. She wants to access the properties of the custom object. Mic
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!