big-o

Recurrence Relation: Finding Big O

Hello, I'm trying to find Big O of this recurrence relation: T(n) = T(n-1) + n^c // where c is >=1 So I decided to solve this by using a recursion tree, which I have broken down as follows: n^c -> (n-1)^c -> (n-2)^c -> ... -> (n-i)^c I then formed the following sum: from 0 to n-1: (n-i)^c Reducing this sum gives: (n-(n-1))^c...

Big-O: How do you know what algorithm to give for a specific time complexity?

So when someone asks you to give a O(n) or a O(nlogn) algorithm to compute something, how do you know what to answer? It seems the only way of being able to answer this sort of question is knowing the time complexities of various algorithms beforehand, rather than thinking up something on the spot. Am I correct in assuming this? ...

Help with big O notation

Hi, I've been having some problems trying to grasp the concept of big O notation. So, by definition big O is as follows, T(n) ∈ O(G(n)) if T(n) <= G(n) * C. Since the the constant "C" can be any integer > 0, wouldn't this following example be true as well? Example: n log n ∈ O(log n) n log n <= log n * c Where C is equal to the va...

Big O Log problem solving

I have question that comes from a algorithms book I'm reading and I am stumped on how to solve it (it's been a long time since I've done log or exponent math). The problem is as follows: Suppose we are comparing implementations of insertion sort and merge sort on the same machine. For inputs of size n, insertion sort runs in 8n^2 steps,...

how to do big-O analysis when 2 algorithms are involved

I'm confused about how to do big-O analysis for the following problem - find an element from an array of integers. ( an example problem) my solution sort the array using bubble sort ( n^2 ) binary search on the array for a given element (logn) now the big-O for this is n^2 or n^2 + logn ? Should we only consider the higher term ? ...

Big-O complexity of nested for loops

I'm confused about the complexity of the following (the operation performed inside the inner loop is in constant time): for(int i=0; i<n; i++) for(int j=i; j<n; j++) is this O(n^2) or O(n)? I figure O(n^2). Any ideas? also the following makes me curious: for(int i=0; i<n; i++) for(j=0; j<i; j++) ...

Big-Oh : How can O(n) + O(n) + ... + O(n) be equal to O(n^2)?

Hi, I'm having a hard time understanding the following statements from Algorithms by S. Dasgupta, C.H. Papadimitriou, and U.V. Vazirani - page 24 that they represent the sum of O(n) as O(n2). But my understanding of O(n) is a linear function of n, and it can never be quadratic no matter how many times the linear fucntions are added (for ...

time, space complexity and O notation problem

Possible Duplicate: Plain English explanation of Big O I can't find any sufficient help for learn or understand about O-notation, and how learn about time or space complexity. So please suggest me , where can I start this. Its really need to me, for now these time.So please give me solution quick. Thanks a lot in advance. ...

Master's Method, which Case?

I've been viewing some video lectures from MIT's opencourseware website, and on the third lecture video the lecturer goes over Recursive Matrix Multiplication and comes up with the time complexity being: T(n) = THETA(n^3). It's obvious to me that I really need to review some of my math, but I really don't see the connection from that a...

Fast algorithm for line of sight calculation in an RTS game

I'm making a simple RTS game. I want it to run very fast because it should work with thousands of units and 8 players. Everything seems to work flawlessly but it seems the line of sight calculation is a bottleneck. It's simple: if an enemy unit is closer than any of my unit's LOS range it will be visible. Currently I use a quite naive ...

Problem from Growth of function

Hello. I am reading thee book "Discrete Mathematics and its Application" by Kenneth H. Rosen I am now in the chapter Growth of Functions and trying the Exercise of that.[5th Edition page 142] I am stuck here: Determine whether these functions are in O(x^2) [(big oh of x's square] [1] f(x) = 2^x, [2] f(x) = (x^4)/2 [3] f(x) = floor(...

What's the big O of this little code snippet?

for i := 1 to n do j := 2; while j < i do j := j^4; I'm really confused when it comes to Big-O notation, so I'd like to know if it's O(n log n). That's my gut, but I can't prove it. I know the while loop is probably faster than log n, but I don't know by how much! Edit: the caret denotes exponent. ...

Incidence matrix instead of adjacency matrix

What kind of problems on graphs is faster (in terms of big-O) to solve using incidence matrix data structures instead of more widespread adjacency matrices? ...

Big O for code snippet

Hello it has been some time sins i have used Big O notation, so i'm a bit rusty. I know that having 1 loop, that loops n times is O(n), and having 1 loop that loops n time within another loop that loops n times is O(n^2). But in the following code snippet do i have a loop that loops n times, and within that a loop that loops n-i times....

How to determine the complexity of an algorithm function?

How do you know if a algorithm function takes linear/constant/logarithmic time for a specific operation? does it depend on the cpu cycles? ...

Show the step to find the total operations of the algorithm

Bellow is some Java code for the question: int total1 = 0; int total2 = 0; for (int x = 0; x <= n; x++) total1 = total1 + x; for (int y = 1; y < n; y++) total2 += total1 * y; Based on the question above, I do an answer likes bellow. Please help me check my answer right or wrong. Thanks for your helping. Operation Numbe...

Identifying which Algorithm is which and explaining the running times

For a given problem with input size n, Algorithms A,B,C are executed. In terms of running time, one of the algorithms is O(n), one O(nlogn) and one O(n^2). Some measured running times of these algorithms are given below Input Size 512 1024 2048 A 70 ...

How does Big O relate to N+1?

Big 0 attempts to answer the question of inefficiency in algorithmic complexity. N+1 describes inefficiency as it relates to database queries in terms of separate queries to populate each item in a collection. I'm currently trying to get my head around each of these concepts in different contexts at work, and I'm wondering now if somebo...

What is Big O Notation?

Possible Duplicate: Plain English explanation of Big O I know Big O notation is used to assess how efficient an algorithm is, but I do not understand how you read Big O notation or what exactly how efficient an algorithm is. Can somebody perhaps explain the basics of Big O notation? Thanks. ...

Finding a lower bound for an algorithm using the guess/verify method

Hi everyone, I am trying to work out a few guesses on algorithm complexity, but every time I attempt to guess using an exponential time, my guess/verify method seems to fail. I am sure I am doing something absurdly wrong, I just can't find it myself. For Example, if I have the recurrence T(n) = 2T(n-1) + T(n-2) + 1 , where T(1) = 0 and ...