Algorithm & Time and Space Complexity

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

DS - (26-04)

============

Algorithm :

An algorithm is a set of instructions to solve


a particular problem in finite number of steps.
-----------------------------------------------------

Characteristics of Algorithm
----------------------------

1) Input
2) Output
3) Finiteness (limited steps)
4) Definiteness
5) Effectiveness

=====================================================

Ex : Write a Algorithm for a square of number

step 1 : Declare a two variable for storing


integer value

step 2 : Taking integer input from user

step 3 : Multiple user input with itself and


store the result in another variable.

step 4 : Display the resulting variable

==================================
#sudo code
==================================
Time Complexity :

Time complexity of an algorithm qualifies the


amount of time taken by an algorithm to run
as a function of the length of the input

(The amount of time taken by an algorithm to


run a program )
-----------------------------------------------------
Space Complexity :

Space complexity of an algorithm qualifies the


amount of space or memory taken by an alogorithm
to run as function of the length of the input.

(The amount of space taken by the alogrithm to


run a program )

=====================================================
Time and Space Complexity depands on
Hardware
OS
Processor
(also on us that how much space we are alocating
for our program in a case of space complexity)
=====================================================
4*4 - non-linear (it incrase x to x^2)
4+4+4+4 - Linear (it increse x to x)
=====================================================

Datastructre is require to perform operation on database

=====================================================
Datastructure operations
-------------------------

-->Creation
-->Tranversing
-->Searching
-->Insertion
-->Deletion
-->Sorting
-->Merging

=====================================================

Today's Quote : Life is a just journey,So do what you


do when you had gone to journey..
:)

======================================================

You might also like