Relation of time and space complexities of an algorithm, Data Structure & Algorithms

What is complexity of an algorithm? What is the basic relation between the time and space complexities of an algorithm? Justify your answer by giving an example.                         

Complexity of an algorithm is the measure of analysis of the algorithm. Analyzing an Algorithm means predicting the resources that the algorithm needs such as memory, communication bandwidth, time and logic gates. Most often it is computational or calculation time that is measured for finding a more suitable algorithm. This is called as time complexity of the algorithm.  The running time of a program is described or defined as a function of the size of its  input. On a specific input, it is traditionally measured as the number of primitive operations or steps executed.

The analysis of algorithm focuses on time complexity and space complexity both. As compared to time analysis, the analysis of space requirement for an algorithm is generally easier and faster, but wherever necessary, both the techniques can be used. The space is referred to as storage needed in addition to the space required storing the input data.  The amount of memory needed by the program to run to completion is referred to as space complexity. For an algorithm, time complexity depends only upon the size of the input, thus, it is a function of input size 'n'. So the amount of time required by an algorithm to run to its completion is referred as time complexity.

The best algorithm to solve a given problem is the one that requires less memory and takes less time to complete its execution of the algorithm. But in practice it is not always likely to achieve both of these objectives. There may be number of approaches to solve a same problem. One such approach may require more space but takes less time to complete its execution while on other hand the other approach requires less space but

more time to complete its execution. Thus we may have to compromise one thing to improve the other. That is, we may be able to reduce space requirement by increasing running time or we can reduce running time by allocating more memory space. This situation where we compromise one to improve the other is known as Time-space trade off.

 

Posted Date: 7/9/2012 9:50:02 PM | Location : United States







Related Discussions:- Relation of time and space complexities of an algorithm, Assignment Help, Ask Question on Relation of time and space complexities of an algorithm, Get Answer, Expert's Help, Relation of time and space complexities of an algorithm Discussions

Write discussion on Relation of time and space complexities of an algorithm
Your posts are moderated
Related Questions
Your objective is to write a generic doubly linked list class called CS228LinkedList that implements the List interface and uses a type variable T. All methods except for subList a

a. Explain the sum of subset problem. Apply backtracking to solve the following instance of sum of subset problem: w= (3, 4, 5, 6} and d = 13. Briefly define the method using a sta

Given the following search tree, state the order in which the nodes will be searched for breadth first, depth first, hill climbing and best first search, until a solution is reache

If a node in a binary tree is not containing left or right child or it is a leaf node then that absence of child node can be represented by the null pointers. The space engaged by

Binary tree creation struct NODE { struct NODE *left; int value; struct NODE *right; }; create_tree( struct NODE *curr, struct NODE *new ) { if(new->val

The best average behaviour is shown by  Quick Sort

Postorder traversal of a binary tree struct NODE { struct NODE *left; int value;     /* can take any data type */ struct NODE *right; }; postorder(struct NODE

Program gives the program segment by using arrays for the insertion of an element to a queue into the multiqueue. Program: Program segment for the insertion of any element to t

how to reduce the number of passes in selection sort

algorithm for insertion in a queue using pointers