How to find the time complexity?
Let’s learn how to find the time complexity. The most accurate or helpful solution is served by Stack Overflow.
There are ten answers to this question.
Best solution
I am having difficulty finding space and time complexity for this code that i wrote to find number of palindromes in a string. /** This program finds palindromes in a string. */ #include <stdio.h> #include <string.h> #include <stdlib.h> int checkPalin(char *str, int len) { int result = 0, loop; for ( loop = 0; loop < len/2; loop++) { if ( *(str+loop) == *(str+((len - 1) - loop)) ) result = 1; else { result = 0; break; } } return result; } int main() { char *string = ...
Answer:
Don't forget that each call to checkPalin (which you do each time through the inner loop of main) executes...
infinitloop at Stack Overflow Mark as irrelevant Undo
Other solutions
Consider a Array A of size M. A[0], A[1], A[2], ......,A[n-1],A[n],A[n+1],......,A[M-1]. Elements A[0],...........,A[N] are negative and A[n+1],..........,A[M-1] are positive .What is the O(lg N) algorithm that find the position N. Input : A[],M Output...
Answer:
Simple. Check numbers of the form 2^k -1. On finding the 1st positive number, So a modified binary search...
Kunal Tyagi at Quora Mark as irrelevant Undo
I am inserting N strings each of length K. Had it been integers, the complexity would be log(N). But here we are storing strings, each of size K. What will be the complexity to find a string in this scenario?
Answer:
The complexity of std::set::find() being [math]O(log(n))[/math] simply means that there will be of the...
Anmol Singh Jaggi at Quora Mark as irrelevant Undo
Answer:
Check this Site by Topcoder http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=complexity...
wiki.answers.com Mark as irrelevant Undo
This was an interview question at one of the start ups
Answer:
Procedure 1) Convert each number to base-3. Let's say the longest number has k digits (in base-3) 2...
Leo Polovets at Quora Mark as irrelevant Undo
Answer:
This problem has a much faster solution than the one (probably) required in the question. For a given...
Michal Forišek at Quora Mark as irrelevant Undo
Answer:
Backtracking algorithm generally follows an exhaustive search on the sample space where N, N^2, N^K...
Shiwakant Bharti at Quora Mark as irrelevant Undo
Answer:
This can be solved in nlogn using a BIT / segment tree . http://codeforces.com/contest/61... This question...
Rajat De at Quora Mark as irrelevant Undo
Answer:
Just adding an optimization to David's answer. 1) Iterate over the first array "a" and put...
Sourabh Bansod at Quora Mark as irrelevant Undo
Answer:
There can be no short answer to this question. Firstly, one needs to choose the appropriate notion of...
Hans Hyttel at Quora Mark as irrelevant Undo
Related Q & A:
- How do I do time.sleep in certain thread in Python?Best solution by stackoverflow.com
- How to get real time quotes for NSE stocks?Best solution by Yahoo! Answers
- Where to find part time jobs in Orlando Florida?Best solution by simplyhired.com
- How to improve 5k time??Best solution by Yahoo! Answers
- What's a good website to find part time jobs?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.