SEM1-DSA - Lesson01-Introduction to Data Structures and Algorithms (1)
SEM1-DSA - Lesson01-Introduction to Data Structures and Algorithms (1)
LESSON 1
• Implementation
• Implementation provides the internal representation of a data structure.
• Implementation also provides the definition of the algorithms used in the operations
of the data structure.
List Array
Store a given number of any type elements int a[11]; //Declare an integer array
● Data can be organized in a data structure in such a way that all items
may not be required to be searched, and the required data can be
searched almost instantly
DATA STRUCTURES AND ALGORITHMS 8
Execution Time Cases
• Worst Case − This is the scenario where a particular data structure
operation takes maximum time it can take (operation time > ƒ(n)).
• Average Case − This is the scenario depicting the average execution time
of an operation of a data structure. If an operation takes ƒ(n) time in
execution, then m operations will take mƒ(n) time.
• Best Case − This is the scenario depicting the least possible execution
time of an operation of a data structure. If an operation takes ƒ(n) time in
execution, then the actual operation may take time as the random
number which would be maximum as ƒ(n).
• The complexity of an algorithm f(n) gives the running time and/or the
storage space required by the algorithm in terms of n as the size of input
data.
DATA STRUCTURES AND ALGORITHMS 18
Space Complexity
• Space complexity of an algorithm represents the amount of memory space
required by the algorithm in its life cycle. The space required by an
algorithm is equal to the sum of the following two components
• A fixed part that is a space required to store certain data and variables, that are
independent of the size of the problem. For example, simple variables and
constants used, program size, ...
• A variable part is a space required by variables, whose size depends on the size of
the problem. For example, dynamic memory allocation, recursion stack space, ...