Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

could you please explain every line in the following code? does it run on O(n)? why? Presentation exercise 1 Write a method that, given two

could you please explain every line in the following code? does it run on O(n)? why? image text in transcribed
image text in transcribed
Presentation exercise 1 Write a method that, given two Strings, checks whether one is a permutation of the other. You can assume that the two strings only contain letters of the English alphabet. Your method should not be case sensitive. If n is the number of characters in the strings, can you write a method that performs this task using a number of steps which can be represented by the function c*n+o, where both and a are constants? (i.e. can you write a method that runs in O(n) ?) Java code public class Presentationl{ public static void main(String[] args) System.out.println(permutation("Charles", "ArchLes")); System.out.println(permutation("df", "fY"); System.out.println(permutation("asdf", "fdsg")); System.out.println(permutation("JOHN", "OHNj")); System.out.println(permutation("wow", "woow")); 3 public static boolean permutation(String si, String s2) { if(s1.length() != s2.length() return false; int count[] = new int[26]; char ch; for(int i=0; i='a' && ch='A' && ch='a' && ch='A' && ch return true; )

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

3rd Edition

0128012757, 978-0128012758

More Books

Students also viewed these Databases questions

Question

Does soil creep operate in warmer climates as well?

Answered: 1 week ago

Question

a. What is the purpose of the team?

Answered: 1 week ago

Question

a. How are members selected to join the team?

Answered: 1 week ago

Question

b. What are its goals and objectives?

Answered: 1 week ago