in Education by
This common code is said to run in O(N) time assuming isSubstring runs in O(N+M) time. How do we get O(N) time complexity from this? public static boolean isRotation(String s1, String s2) { int len = s1.length(); if (len == s2.length() && len > 0) { String s1s1 = s1 + s1; return isSubstring(s1s1, s2); } return false; } JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Usually when we say linear it means that with really really big number of basic operations our algorithm still performs in O(n). According to time complexity calculation of sublinear function like O(n+m) complexity gets pretty randomized but behaves like linear with large N. So generally we can say O(n)~O(n+m).

Related questions

0 votes
    The complexity of a linear search algorithm is (a) O(n) (b) O(log n) (c) O(n2) (d) ... Questions and Answers, Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    The complexity of Binary search algorithm is (a) O(n) (b) O(log ) (c) O(n2) (d) O(n ... Questions and Answers, Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    The complexity of the average case of an algorithm is (a) Much more complicated to analyze than that ... from Sorting in chapter Query Processing Techniques of Database Management...
asked Oct 10, 2021 in Education by JackTerrance
0 votes
    The Diffie-Hellman algorithm exploits the computational complexity of the __________ problem. (1)Discrete logarithm (2)Integer factorization (3)Exponential logarithm...
asked Mar 21, 2021 in Technology by JackTerrance
0 votes
    What is the time complexity for a given pancake sort given it undergoes “n” flip operations? a) O(n) b) O(n2) c) O(n3) d) O(2n)...
asked Dec 28, 2022 in Technology by JackTerrance
0 votes
    I ran some test to determine if O(==) for Strings is O(len(string)) or O(1). My tests: ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    There is no summary available of the big O notation for operations on the most common data structures ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 22, 2022 in Education by JackTerrance
0 votes
    There is no summary available of the big O notation for operations on the most common data structures ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    B-tree and AVL tree have the same worst case time complexity for insertion and deletion. a) True b) False...
asked Dec 23, 2020 in Technology by JackTerrance
0 votes
    Which algorithm chooses the page that has not been used for the longest period of time whenever the page ... recently used algorithm d) counting based page replacement algorithm...
asked Oct 27, 2022 in Education by JackTerrance
0 votes
    I recently had an interview and was given a small problem that I was to code up. The problem was ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    I recently had an interview and was given a small problem that I was to code up. The problem was ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 25, 2022 in Education by JackTerrance
0 votes
    I recently had an interview and was given a small problem that I was to code up. The problem was ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    The cpu scheduling algorithm best suited for time sharing os is Select the correct answer from above options...
asked Dec 21, 2021 in Education by JackTerrance
...