BY,
LAKSHMI.S,
ASSISTANT PROFESSOR,
DEPARTMENT OF COMPUTER SCIENCE,
SRI ADI CHUNCHANAGIRI WOMEN’S COLLEGE, CUMBUM.
A data structure is a specialized format for organizing, processing,
retrieving and storing data. There are several basic and advanced
types of data structures, all designed to arrange data to suit a
specific purpose. Data structures make it easy for users to access
and work with the data they need in appropriate ways.
 The valid algorithm takes a finite amount of time for execution. The time
required by the algorithm to solve given problem is called time
complexity of the algorithm. Time complexity is very useful measure in
algorithm analysis.
 It is the time needed for the completion of an algorithm. To estimate the
time complexity, we need to consider the cost of each fundamental
instruction and the number of times the instruction is executed.
 Problem-solving using computer requires memory to hold temporary data or
final result while the program is in execution. The amount of memory
required by the algorithm to solve given problem is called space
complexity of the algorithm.
 The space complexity of an algorithm quantifies the amount of space taken
by an algorithm to run as a function of the length of the input. Consider an
example: Suppose a problem to find the frequency of array elements.
 It is the amount of memory needed for the completion of an
algorithm.
 To estimate the memory requirement we need to focus on two parts:
 (1) A fixed part: It is independent of the input size. It includes
memory for instructions (code), constants, variables, etc.
 (2) A variable part: It is dependent on the input size. It includes
memory for recursion stack, referenced variables, etc.
Aspect Time Complexity Space Complexity
Definition
Measures the execution time of an algorithm relative
to input size.
Measures the memory usage of an algorithm relative to input
size.
Focus Amount of time an algorithm takes to complete.
Amount of memory (RAM) an algorithm requires for
execution.
Primary Concern Efficiency in terms of time. Efficiency in terms of memory usage.
Analysis Approach
Number of operations or computational steps
relative to input size.
Memory allocation for variables, data structures, and function
calls relative to input size.
Input Size Impact Larger inputs usually lead to longer execution times.
Larger inputs may require more memory for storing data
structures or managing recursion.
Optimization Goal
Reducing the number of computational operations or
steps.
Minimizing the amount of memory needed for data storage and
processing.
Typical Example
Finding an element using binary search (O(log n)
time complexity).
Creating a 2D array of size n x n (O(n²) space complexity).
An array is a powerful data structure that allows users to store and
manipulate a collection of elements, all of the same data type in a single
variable. Simply, it is a collection of elements of the same data type
stored at contagious memory locations that can be randomly accessed
with their index number. It’s one of the most popular and simple data
structures and is often used to implement other data structures
like stacks and queues.
There are some of the properties of an array that are listed as follows
 Each element in an array is of the same data type and carries the same size that is 4
bytes.
 Elements in the array are stored at contiguous memory locations from which the first
element is stored at the smallest memory location.
 Elements of the array can be randomly accessed since we can calculate the address of
each element of the array with the given base address and the size of the data element.
Different applications of an array are as follows:
• An array is used in solving matrix problems.
• Database records are also implemented by an array.
• It helps in implementing a sorting algorithm.
• It is also used to implement other data structures like Stacks, Queues,
Heaps, Hash tables, etc.
• An array can be used for CPU scheduling.
• Can be applied as a lookup table in computers.
• Arrays can be used in speech processing where every speech signal is an array.
• The screen of the computer is also displayed by an array. Here we use a multidimensional
array.
• The array is used in many management systems like a library, students, parliament, etc.
• The array is used in the online ticket booking system. Contacts on a cell phone are
displayed by this array.
• In games like online chess, where the player can store his past moves as well as current
moves. It indicates a hint of position.
• To save images in a specific dimension in the android Like 360*1200

DataSructure-Time and Space Complexity.pptx

  • 1.
    BY, LAKSHMI.S, ASSISTANT PROFESSOR, DEPARTMENT OFCOMPUTER SCIENCE, SRI ADI CHUNCHANAGIRI WOMEN’S COLLEGE, CUMBUM.
  • 2.
    A data structureis a specialized format for organizing, processing, retrieving and storing data. There are several basic and advanced types of data structures, all designed to arrange data to suit a specific purpose. Data structures make it easy for users to access and work with the data they need in appropriate ways.
  • 3.
     The validalgorithm takes a finite amount of time for execution. The time required by the algorithm to solve given problem is called time complexity of the algorithm. Time complexity is very useful measure in algorithm analysis.  It is the time needed for the completion of an algorithm. To estimate the time complexity, we need to consider the cost of each fundamental instruction and the number of times the instruction is executed.
  • 4.
     Problem-solving usingcomputer requires memory to hold temporary data or final result while the program is in execution. The amount of memory required by the algorithm to solve given problem is called space complexity of the algorithm.  The space complexity of an algorithm quantifies the amount of space taken by an algorithm to run as a function of the length of the input. Consider an example: Suppose a problem to find the frequency of array elements.
  • 5.
     It isthe amount of memory needed for the completion of an algorithm.  To estimate the memory requirement we need to focus on two parts:  (1) A fixed part: It is independent of the input size. It includes memory for instructions (code), constants, variables, etc.  (2) A variable part: It is dependent on the input size. It includes memory for recursion stack, referenced variables, etc.
  • 6.
    Aspect Time ComplexitySpace Complexity Definition Measures the execution time of an algorithm relative to input size. Measures the memory usage of an algorithm relative to input size. Focus Amount of time an algorithm takes to complete. Amount of memory (RAM) an algorithm requires for execution. Primary Concern Efficiency in terms of time. Efficiency in terms of memory usage. Analysis Approach Number of operations or computational steps relative to input size. Memory allocation for variables, data structures, and function calls relative to input size. Input Size Impact Larger inputs usually lead to longer execution times. Larger inputs may require more memory for storing data structures or managing recursion. Optimization Goal Reducing the number of computational operations or steps. Minimizing the amount of memory needed for data storage and processing. Typical Example Finding an element using binary search (O(log n) time complexity). Creating a 2D array of size n x n (O(n²) space complexity).
  • 7.
    An array isa powerful data structure that allows users to store and manipulate a collection of elements, all of the same data type in a single variable. Simply, it is a collection of elements of the same data type stored at contagious memory locations that can be randomly accessed with their index number. It’s one of the most popular and simple data structures and is often used to implement other data structures like stacks and queues.
  • 9.
    There are someof the properties of an array that are listed as follows  Each element in an array is of the same data type and carries the same size that is 4 bytes.  Elements in the array are stored at contiguous memory locations from which the first element is stored at the smallest memory location.  Elements of the array can be randomly accessed since we can calculate the address of each element of the array with the given base address and the size of the data element.
  • 10.
    Different applications ofan array are as follows: • An array is used in solving matrix problems. • Database records are also implemented by an array. • It helps in implementing a sorting algorithm. • It is also used to implement other data structures like Stacks, Queues, Heaps, Hash tables, etc. • An array can be used for CPU scheduling. • Can be applied as a lookup table in computers.
  • 11.
    • Arrays canbe used in speech processing where every speech signal is an array. • The screen of the computer is also displayed by an array. Here we use a multidimensional array. • The array is used in many management systems like a library, students, parliament, etc. • The array is used in the online ticket booking system. Contacts on a cell phone are displayed by this array. • In games like online chess, where the player can store his past moves as well as current moves. It indicates a hint of position. • To save images in a specific dimension in the android Like 360*1200