Time and Space complexity

  • to store program instructions.
  • to store constant values.
  • to store variable values.
  • And a few other things like function calls, jumping statements, etc.
int fact=1;              //fact=4 byte
for(int i=1;i<=n;++i) //n=4 byte
{
fact *=i; //i=4 byte
}
return fact; //aux space =4 byte
//space=16 byte
int count = 0;
for (int i = 0; i < N; i++)
for (int j = 0; j < i; j++)
count++;
  1. find out the growing variable.
  2. eliminate the constant terms.

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How we used deep work to build an ad network in 30 minutes

Laravel Query Builder Join & cast Integer

ANSIBLE PLAYBOOK TO CONFIGURE HADOOP CLUSTER.

Just A Few New Stuff That Happened To DevOps Recently!

How-To: Manually restart django development server

Why Clustering your Google Map markers in the server side?

Building Distributed Cloud using Kubernetes based Platforms

A Microservice Based Collaboration Application For Airport Passengers and Transport Providers

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abhinav Kumar gupta

Abhinav Kumar gupta

More from Medium

HOUSE RENTS AND MONTHLY SALARIES BY STATES IN GERMANY

This could be the simplest way Somaliland/Somalia can solve the water problems.

Capitalism — and the Art of Gaming the System

The American dream & The German nightmare (Part 1)