SlideShare a Scribd company logo
Chapter 1 Data structure.pptx
1.1. Introduction to Data Structures and Algorithms Analysis
 A program is written in order to solve a problem. A solution to a problem
actually consists of two things:
I. A way to organize the data
II. Sequence of steps to solve the problem
 The way data are organized in a computer’s memory is said to be data
structure and
 The sequence of computational steps to solve a problem is said to be an
algorithm.
 Therefore, a program is nothing but data structures plus algorithms.
 A data structure is a systematic way of organizing and accessing data and
 an algorithm is a step-by-step procedure for performing some task in a
finite amount of time.
Introduction to Data Structures
 The first step to solve the problem is obtaining one’s own
abstract view, or model, of the problem.
 This process of modeling is called abstraction.
 The model defines an abstract view to the problem.
 This implies that the model focuses only on problem related
stuff and
 A programmer tries to define the properties of the problem.
3
Cont.
 These properties Abstract data include
 The data which are affected and
 The operations that are involved in the problem.
 With abstraction you create a well-defined entity that can be
properly handled.
 These entities define the data structure of the program.
 An entity with the properties just described is called an abstract
data type (ADT).
4

Recommended for you

Brute force method
Brute force methodBrute force method
Brute force method

The document discusses brute force and exhaustive search approaches to solving problems. It provides examples of how brute force can be applied to sorting, searching, and string matching problems. Specifically, it describes selection sort and bubble sort as brute force sorting algorithms. For searching, it explains sequential search and brute force string matching. It also discusses using brute force to solve the closest pair, convex hull, traveling salesman, knapsack, and assignment problems, noting that brute force leads to inefficient exponential time algorithms for TSP and knapsack.

Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure

This document provides an introduction to data structures. It defines data structures as a way of organizing data so that it can be used efficiently. The document then discusses basic terminology, why data structures are important, how they are studied, and how they are classified as simple or compound, and linear or non-linear. It proceeds to describe common data structures like arrays, stacks, queues, linked lists, trees, and graphs, and how they support basic operations. The document concludes by discussing how to select an appropriate data structure based on the problem constraints and required operations.

data structuredatastructure
Normalization
NormalizationNormalization
Normalization

Normalization is a process of organizing data to reduce redundancy and improve data integrity. It involves decomposing relations with anomalies into smaller, well-structured relations by identifying functional dependencies and applying normal forms. The normal forms are first normal form (1NF), second normal form (2NF), third normal form (3NF) and Boyce-Codd normal form (BCNF). Each normal form adds additional rules to reduce redundancy through a multi-step process of identifying dependencies and extracting subsets of data into new relations.

1nf2nf3nf
Abstract Data Types
 An abstract data type (ADT) is a set of objects together with a set of
operations.
 An ADT is a mathematical model of a data structure that specifies the
type of the data stored, the operations supported on them
 Objects such as lists, sets, and graphs, along with their operations, can
be viewed as ADTs, just as integers, real’s, and booleans are data types.
 The ADT specifies:
1. What can be stored in the Abstract Data Type?
2. What operations can be done on/by the Abstract Data Type?
5
Abstraction
 Abstraction is a process of classifying characteristics as
relevant and irrelevant for the particular purpose at hand and
ignoring the irrelevant ones.
 The abstraction is to distill a complicated system down to its
most fundamental parts and
 describe these parts in a simple, precise language.
 Typically, describing the parts of a system involves naming
them and explaining their functionality.
6
Algorithms
 An algorithm is a well-defined computational procedure that
takes :
 some value or a set of values as input and
 produces some value or a set of values as output.
 Data structures model the static part of the world.
 They are unchanging while the world is changing.
 In order to model the dynamic part of the world we need to
work with algorithms.
 Algorithms are the dynamic part of a program’s world model.
 An algorithm transforms data structures from one state to
another state in two ways:
 An algorithm may change the value held by a data structure
 An algorithm may change the data structure itself 7
Properties of an algorithm
What makes an algorithm good?
 Finiteness: Algorithm must complete after a finite number of steps.
 Definiteness: Each step must be clearly defined, having one and only
one interpretation. At each point in computation, one should be able
to tell exactly what happens next.
 Sequence: Each step must have a unique defined preceding and
succeeding step. The first step (start step) and last step (halt step)
must be clearly noted.
 Feasibility: It must be possible to perform each instruction.
 Correctness: It must compute correct answer for all possible legal
inputs.
8

Recommended for you

Data Structures
Data StructuresData Structures
Data Structures

The document discusses data structures and arrays. It begins by defining data, data structures, and how data structures affect program design. It then categorizes data structures as primitive and non-primitive. Linear and non-linear data structures are described as examples of non-primitive structures. The document focuses on arrays as a linear data structure, covering array declaration, representation in memory, calculating size, types of arrays, and basic operations like traversing, searching, inserting, deleting and sorting. Two-dimensional arrays are also introduced.

data structureintroduction to data structuresdata structures using c++
Searching algorithms
Searching algorithmsSearching algorithms
Searching algorithms

The document discusses different searching algorithms. It describes sequential search which compares the search key to each element in the list sequentially until a match is found. The best case is 1 comparison, average is N/2 comparisons, and worst case is N comparisons. It also describes binary search which divides the sorted list in half at each step, requiring log(N) comparisons in the average and worst cases. The document also covers indexing which structures data for efficient retrieval based on key values and includes clustered vs unclustered indexes.

linked lists in data structures
linked lists in data structureslinked lists in data structures
linked lists in data structures

Linked Lists: Introduction Linked lists Representation of linked list operations on linked list Comparison of Linked Lists with Arrays and Dynamic Arrays Types of Linked Lists and operations-Circular Single Linked List, Double Linked List, Circular Double Linked List

linked listtypes of linked listcircular linked list
Cont.
 Language Independence: It must not depend on any one
programming language.
 Completeness: It must solve the problem completely.
 Effectiveness: It must be possible to perform each step exactly and in
a finite amount of time.
 Efficiency: It must solve with the least amount of computational
resources such as time and space.
 Generality: Algorithm should be valid on all possible inputs.
 Input/Output: There must be a specified number of input values, and
one or more result values.
9
Algorithm Analysis Concepts
 Algorithm analysis refers to the process of determining the
amount of computing time and storage space required by
different algorithms.
 In other words, it’s a process of predicting the resource
requirement of algorithms in a given environment.
 It is the study of efficiency of programs.
 Input size of the program, machine type used, implementation
quality, running time of algorithm and others affect the
efficiency of a program.
10
… Cont.
 In order to solve a problem, there are many possible algorithms.
 One has to be able to choose the best algorithm for the problem
at hand using some scientific method.
 To classify some data structures and algorithms as good, we
need precise ways of analyzing them in terms of resource
requirement. The main resources are:
 Running Time
 Memory Usage
 Communication Bandwidth
 Algorithm analysis tries to estimate these resources required to
solve a problem at hand.
 Running time is usually treated as the most important since
computational time is the most precious resource in most
problem domains.
11
--- Cont
 There are two approaches to measure the efficiency of algorithms:
 Empirical (Experimental) method: Programming competing
algorithms and trying them on different instances. This method is
used for absolute time measurement.
 Analytical (Theoretical) Method: Determining the quantity of
resources required mathematically (like execution time, memory
space, etc.) needed by each algorithm.
 However, it is difficult to use actual clock-time as a consistent
measure of an algorithm’s efficiency, because clock-time can vary
based on many things. For example,
 Specific processor speed
 Current processor load
 Specific data for a particular run of the program
 Input Size
 Input Properties
 Operating Environment
12

Recommended for you

Linear Search
Linear SearchLinear Search
Linear Search

1. Linear search is a method for finding a particular value in a list that checks each element in sequence until the desired element is found or the list is exhausted. 2. The best case for linear search is O(1) when the target is found at the first location. The worst case is O(n) when the target is at the end or not present. 3. The average time complexity of linear search is O(n) as the target has an equal chance of being in any position, so on average half the list must be searched.

Splay tree
Splay treeSplay tree
Splay tree

Algorithm and data structures topic is Splay Tree. A full comparison between splay tree and AVL tree and learn to create splay tree with expamples

algorithmssplay treeavl tree
Tree - Data Structure
Tree - Data StructureTree - Data Structure
Tree - Data Structure

This document provides an overview of trees as a non-linear data structure. It begins by discussing how trees are used to represent hierarchical relationships and defines some key tree terminology like root, parent, child, leaf, and subtree. It then explains that a tree consists of nodes connected in a parent-child relationship, with one root node and nodes that may have any number of children. The document also covers tree traversal methods like preorder, inorder, and postorder traversal. It introduces binary trees and binary search trees, and discusses operations on BSTs like search, insert, and delete. Finally, it provides a brief overview of the Huffman algorithm for data compression.

csitnepalbsccsit
Complexity Analysis
 Complexity Analysis is the systematic study of the cost of
computation, measured either in time units or in operations
performed, or in the amount of storage space required.
 The goal is to have a meaningful measure that permits
comparison of algorithms independent of operating platform.
 There are two things to consider:
 Time Complexity: Determine the approximate number of
operations and time required to solve a problem of size n.
 The running times of operations on the data structure should
be as small as possible.
 Space Complexity: Determine the approximate memory
required to solve a problem of size n.
 The data structure should use as little memory as possible.
13
Running time
 The critical resource for a program is most often its running
time.
 Running time is the amount of time that any algorithm takes to
run.
 However, you cannot pay attention to running time alone.
 You must also be concerned with other factors such as the space
required to run the program (main memory and disk space).
 The primary analysis tool we use in this course involves
characterizing the running times of algorithms and data
structure operations.
 Running time is a natural measure of “goodness,” since time is
a precious resource
- computer solutions should run as fast as possible.
14
1.2.2. Complexity of Algorithms
 There is no generally accepted set of rules for algorithm
analysis.
 However, an exact count of operations is commonly used.
 Arbitrary time unit is assumed for analyzing the algorithm,
and we have the following set of analysis rules.
Rule 1: Basic operations
 The execution of the following operations takes one (1) time
unit.
 Assignment Operation
 Single Input/ Output Operation
 Single Boolean Operations
 Single Arithmetic Operations
 Function Return 15
… Cont.
 Rule 2: Selection statements
 Running time of a selection statement (if, switch) is the time for the
condition evaluation + the maximum of the running times for the individual
clauses.
 Rule 3: Loops
 Running time for a loop is equal to the running time for the statements inside
the loop body multiplied (*) by number of iterations of the loop.
 Rule 4: Nested Loops
 The total running time of a statement inside a group of nested loops is the
running time of the statements multiplied by the product of the sizes of all
the loops.
 Rule 5: Function call
 Running time of a function call is 1 for setup + the time for any parameter
calculations + the time required for the execution of the function body.
 Rule 6: Consecutive statements
 For consecutive statements, the running time will be computed as the sum of
the running time of the separate blocks of code.
16

Recommended for you

stack & queue
stack & queuestack & queue
stack & queue

This document discusses stacks and queues as linear data structures. It defines stacks as last-in, first-out (LIFO) collections where the last item added is the first removed. Queues are first-in, first-out (FIFO) collections where the first item added is the first removed. Common stack and queue operations like push, pop, insert, and remove are presented along with algorithms and examples. Applications of stacks and queues in areas like expression evaluation, string reversal, and scheduling are also covered.

Linklist
LinklistLinklist
Linklist

SINGLY LINKLIST (INSERTION,DELETION,SORT,SEARCH) STACK(PUSH,POP) QUEUE(ADD,REMOVE) CIRCULAR LINKLIST DOUBLE ENDED QUEUE CIRCULAR QUEUE PRIORITY QUEUE DOUBLY LINKLIST(INSERTION,DELETION,SORT,SEARCH)

stacklinklistcircular linklist
Data Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search TreeData Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search Tree

Binary search trees (BSTs) are data structures that allow for efficient searching, insertion, and deletion. Nodes in a BST are organized so that all left descendants of a node are less than the node's value and all right descendants are greater. This property allows values to be found, inserted, or deleted in O(log n) time on average. Searching involves recursively checking if the target value is less than or greater than the current node's value. Insertion follows the search process and adds the new node in the appropriate place. Deletion handles three cases: removing a leaf, node with one child, or node with two children.

#dsa
Example 1
The following examples show us how running time of the code fragments is computed.
Examples 1:
int count ( )
{
int k=0;
cout<< “Enter an integer”;
cin>>n;
for (i=0; i<n; i++)
k=k+1;
return 0;
}
Time Units to Compute
1 for the assignment statement: int k=0
1 for the output statement.
1 for the input statement.
For the loop (for):
1 assignment (i = 0), n+1 tests, and n increments.
n loops of 2 units for an assignment and addition.
1 for the return statement.
-------------------------------------------------------------------
T (n)= 1+1+1+(1+n+1+n)+2n+1 = 4n+6 = O(n)
17
Example 2:
int total(int n)
{
int sum=0;
for (int i=1;i<=n;i++)
sum=sum+1;
return sum;
}
Time Units to Compute
1 for the assignment statement: int sum=0
In the for loop:
1 assignment, n+1 tests, and n increments.
n loops of 2 units for an assignment and addition.
1 for the return statement.
-------------------------------------------------------------------
T (n)= 1+ (1+n+1+n)+2n+1 = 4n+4 = O(n)
18
Example 3:
void func( )
{ int x=0, i=0, j=1;
cout<< “Enter an Integer value”;
cin>>n;
while (i<n)
{ x++;
i++; }
while (j<n)
j++; }
Time Units to Compute
1 for the first assignment statement: x=0;
1 for the second assignment statement: i=0;
1 for the third assignment statement: j=1;
1 for the output statement.
1 for the input statement.
In the first while loop: n+1 tests
n loops of 2 units for the two increment (addition) operations
In the second while loop:
n tests
n-1 increments
-------------------------------------------------------------------
T (n)= 1+1+1+1+1+(n+1+2n)+(n+n-1) = 5n+5 = O(n) 19
Example 4:
int sum (int n)
{
int partial_sum = 0;
for (int i = 1; i <= n; i++)
partial_sum = partial_sum +(i * i * i);
return partial_sum;
}
Time Units to Compute
1 for the assignment.
1 assignment, n+1 tests, and n increments for the loop expression (for).
n loops of 4 units for an assignment, addition, and two multiplications.
1 for the return statement.
-------------------------------------------------------------------
T (n) = 1+(1+n+1+n)+4n+1 = 6n+4 = O(n)
20

Recommended for you

3.2 insertion sort
3.2 insertion sort3.2 insertion sort
3.2 insertion sort

Insertion sort is a sorting algorithm that works by building a sorted array (or list) one item at a time. It maintains two groups, a sorted group and an unsorted group. It removes one element from the unsorted group, finds the location it belongs within the sorted group, and inserts it there. This continues until the unsorted group is empty, leaving a fully sorted list. The worst-case running time is O(n^2) as each insertion may require traversing the entire sorted portion. However, the average case is O(n) for nearly sorted data. A lower bound analysis shows that any algorithm relying on adjacent swaps has a worst case lower bound of Ω(n^2).

data structure-insertion sort
Self organising list
Self organising listSelf organising list
Self organising list

Self-organizing lists reorder elements based on access frequency to improve search efficiency. Elements with higher access probabilities are moved towards the front using heuristics like move-to-front, transposition, and counting access frequencies. This reduces average access time compared to random ordering. The worst case is searching for an element at the end, while the best case is finding a frequently accessed element at the front.

Linear search-and-binary-search
Linear search-and-binary-searchLinear search-and-binary-search
Linear search-and-binary-search

This document provides an overview of linear search and binary search algorithms. It explains that linear search sequentially searches through an array one element at a time to find a target value. It is simple to implement but has poor efficiency as the time scales linearly with the size of the input. Binary search is more efficient by cutting the search space in half at each step. It works on a sorted array by comparing the target to the middle element and determining which half to search next. The time complexity of binary search is logarithmic rather than linear.

Example 5:
void func ( )
{
int i =1, sum = 0;
while (i < = n)
{
for (int j =0;j<n; j++)
{ sum = i + j; }
i ++;
}}
Time Units to Compute
1 for the first assignment (i = 1).
1 for the second assignment (sum = 0).
In the while loop
n+1 tests
n loops of the following
For the for loop
1 assignment, n+1 tests, and n increments.
n loops of 2 units for an assignment and addition.
1 for the increment operation.
-------------------------------------------------------------------
T (n) = 1+1+(n+1)+n[(1+n+1+n+2n)+1] = 4n2+4n+3 = O(n2) 21
Example 6:
int k=0;
for (int i=1; i<n; i*=2)
for(int j=1;j<=n;j++)
k++;
Time Units to Compute
1 for the first assignment (k = 0).
For the first loop (for)
1 assignment, 1+ tests, and multiplication of i*=2.
iterations of the following
For the second loop (for)
1 assignment, n+1 tests, and n increments.
n loops of one unit (increment operation)
-------------------------------------------------------------------
T (n) = 1+1+1+ ++[(1+n+1+n)+n] = 3n+4+3= O(n)
22
1.2.3. Formal Approach to Analysis
 In the above examples we have seen that analysis is a bit
complex.
 However, it can be simplified by using some formal approach in
which case we can ignore initializations, loop control, and book
keeping.
 For Loops: Formally
 In general, a for loop translates to a summation.
 The index and bounds of the summation are the same as the
index and bounds of the for loop.
 Suppose we count the number of additions that are done. There is 1
addition per iteration of the loop, hence N additions in total.
23
for (int i = 1; i <= N; i++) {
sum = sum+i;
}
N
N
i


1
1
Nested Loops: Formally
 Nested for loops translate into multiple summations, one for each for loop.
 Again, count the number of additions. The outer summation is for the outer for loop.
24
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= M; j++) {
sum = sum+i+j;
}
}
MN
M
N
i
N
i
M
j
2
2
2
1
1 1

 
 
 
Consecutive Statements: Formally
 Add the running times of the separate blocks of your code
for (int i = 1; i <= N; i++) {
sum = sum+i;
}
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= N; j++) {
sum = sum+i+j;
}
}
2
1 1
1
2
2
1 N
N
N
i
N
j
N
i
















  


Recommended for you

Introduction to Data Structures Sorting and searching
Introduction to Data Structures Sorting and searchingIntroduction to Data Structures Sorting and searching
Introduction to Data Structures Sorting and searching

This document provides an overview of data structures and algorithms. It begins by defining a data structure as a way of storing and organizing data in a computer so that it can be used efficiently by algorithms. Data structures can be primitive, directly operated on by machine instructions, or non-primitive, developed from primitive structures. Linear structures maintain adjacency between elements while non-linear do not. Common operations on data structures include adding, deleting, traversing, sorting, searching, and updating elements. The document also defines algorithms and their properties, including finiteness, definiteness, inputs, outputs, and effectiveness. It discusses analyzing algorithms based on time and space complexity and provides examples of different complexities including constant, logarithmic, linear, quadratic,

data structuressortingsearching
Binary search
Binary searchBinary search
Binary search

Binary search is an algorithm that finds the position of a target value within a sorted array. It works by recursively dividing the array range in half and searching only within the appropriate half. The time complexity is O(log n) in the average and worst cases and O(1) in the best case, making it very efficient for searching sorted data. However, it requires the list to be sorted for it to work.

design analysis and algorithm
Introduction to Data Structure and algorithm.pptx
Introduction to Data Structure and algorithm.pptxIntroduction to Data Structure and algorithm.pptx
Introduction to Data Structure and algorithm.pptx

Algorithm is sequence of steps. Data structure is the way of solving problem using the algorithm it is the program.

Compute Running time with given input
 Example:
 Suppose we have hardware capable of executing 106
instructions per second. How long would it take to execute an
algorithm whose complexity function was T (n) = 2n2 on an
input size of n=108?
 Solution
 The total number of operations to be performed would be T
(108):
T(108) = 2*(108)2 =2*1016
The required number of seconds required would be given by
T(108)/106 so:
Running time =2*1016/106 = 2*1010
 The number of seconds per day is 86,400 so this is about
231,480 days (634 years).
25
Exercises
Determine the run time equation and complexity of each of the following code segments.
1. for (i=0;i<n;i++)
for (j=0;j<n; j++)
sum=sum+i+j;
2. for(int i=1; i<=n; i++)
for (int j=1; j<=i; j++)
sum++;
What is the value of the sum if n=20?
3. int k=0;
for (int i=0; i<n; i++)
for (int j=i; j<n; j++)
k++;
What is the value of k when n is equal to 20?
4. int k=0;
for (int i=1; i<n; i*=2)
for(int j=1; j<n; j++)
k++;
What is the value of k when n is equal to 20?
26
Home Work
5. int x=0;
for(int i=1;i<n;i=i+5)
x++;
What is the value of x when n=25?
6. int x=0;
for(int k=n;k>=n/3;k=k-5)
x++;
What is the value of x when n=25?
7. int x=0;
for (int i=1; i<n;i=i+5)
for (int k=n;k>=n/3;k=k-5)
x++;
What is the value of x when n=25?
8. int x=0;
for(int i=1;i<n;i=i+5)
for(int j=0;j<i;j++)
for(int k=n;k>=n/2;k=k-3)
x++;
What is the correct big-Oh Notation for the above code segment?
27
1.3. Measures of Times
 The running time of an algorithm can be define into three
possible functions Tbest(n), Tavg(n) and Tworst(n)
 Average Case (Tavg): The amount of time the algorithm takes
on an "average" set of inputs.
 Worst Case (Tworst): The amount of time the algorithm takes on
the worst possible set of inputs.
 Best Case (Tbest): The amount of time the algorithm takes on
the smallest possible set of inputs.
28

Recommended for you

Data Structure and Algorithm chapter two, This material is for Data Structure...
Data Structure and Algorithm chapter two, This material is for Data Structure...Data Structure and Algorithm chapter two, This material is for Data Structure...
Data Structure and Algorithm chapter two, This material is for Data Structure...

The document discusses algorithm analysis and different searching and sorting algorithms. It introduces sequential search and binary search as simple searching algorithms. Sequential search, also called linear search, examines each element of a list sequentially until a match is found. It has average time complexity of O(n) as it may need to examine all n elements in the worst case.

dsaaalgorithm
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdf

The document provides an introduction to algorithms and their analysis. It defines an algorithm and lists its key criteria. It discusses different representations of algorithms including flowcharts and pseudocode. It also outlines the main areas of algorithm analysis: devising algorithms, validating them, analyzing performance, and testing programs. Finally, it provides examples of algorithms and their analysis including calculating time complexity based on counting operations.

Data Structures and Algorithms Unit 01
Data Structures and Algorithms Unit 01Data Structures and Algorithms Unit 01
Data Structures and Algorithms Unit 01

Download Complete Material - https://www.instamojo.com/prashanth_ns/ This Data Structures and Algorithms contain 15 Units and each Unit contains 60 to 80 slides in it. Contents… • Introduction • Algorithm Analysis • Asymptotic Notation • Foundational Data Structures • Data Types and Abstraction • Stacks, Queues and Deques • Ordered Lists and Sorted Lists • Hashing, Hash Tables and Scatter Tables • Trees and Search Trees • Heaps and Priority Queues • Sets, Multi-sets and Partitions • Dynamic Storage Allocation: The Other Kind of Heap • Algorithmic Patterns and Problem Solvers • Sorting Algorithms and Sorters • Graphs and Graph Algorithms • Class Hierarchy Diagrams • Character Codes

1.4. Asymptotic Analysis
 Asymptotic analysis is concerned with how the running time of an
algorithm increases with the size of the input in the limit, as the size of
the input increases without bound.
 We will see the most important functions used in the analysis of
algorithms.
O(1) – Constant Time
 Pronounced: "Order 1", "O of 1", "big O of 1"
 The runtime is constant, i.e., independent of the number of input
elements n.
 When evaluating overall running time, we typically ignore these
statements since they don’t factor into the complexity.
 This is the function, f (n) = c.
29
O(n) – Linear Time
 Pronounced: "Order n", "O of n", "big O of n"
 The time grows linearly with the number of input elements n:
If n doubles, then the time approximately doubles, too.
 O(n²) – Quadratic Time(square time)
 Pronounced: "Order n squared", "O of n squared", "big O of n squared"
 The time grows linearly to the square of the number of input elements:
 If the number of input elements n doubles, then the time roughly
quadruples.
30
Cont.
 O(n²) Examples
 Examples of quadratic time are simple sorting
algorithms like Insertion Sort, Selection Sort,
and Bubble Sort.
 O(log n) – Logarithmic Time
 Pronounced: "Order log n", "O of log n", "big O of log
n"
 The effort increases approximately by a constant
amount when the number of input elements doubles.
 An example of logarithmic growth is the binary
search for a specific element in a sorted array of size n.
31
Asymptotic Analysis known function
32

Recommended for you

Unit 1 dsa
Unit 1 dsaUnit 1 dsa
Unit 1 dsa

The document discusses algorithms and data structures. It defines an algorithm as a step-by-step procedure for solving a problem using a computer in a finite number of steps. It categorizes common types of algorithms as search, sort, insert, update, and delete algorithms. The document also defines a data structure as a way to store and organize data for efficient use. It distinguishes between linear and non-linear as well as static and dynamic data structures. Finally, it discusses algorithm design strategies like divide and conquer, merge sort, and dynamic programming.

data structure and algorithmdata structuredsa
Daa notes 1
Daa notes 1Daa notes 1
Daa notes 1

This slides contains assymptotic notations, recurrence relation like subtitution method, iteration method, master method and recursion tree method and sorting algorithms like merge sort, quick sort, heap sort, counting sort, radix sort and bucket sort.

Lec1
Lec1Lec1
Lec1

The document discusses data structures and their importance in organizing data efficiently for computer programs. It defines what a data structure is and how choosing the right one can improve a program's performance. Several examples are provided to illustrate how analyzing a problem's specific needs guides the selection of an optimal data structure.

Cont .
 There are five notations used to describe a running time
function. These are:
 Big-Oh Notation (O)
 Big-Omega Notation (W)
 Theta Notation (Q)
 Little-o Notation (o)
 Little-Omega Notation (w)
33
The Big-Oh Notation
 Big-Oh notation is a way of comparing algorithms and
 It is used for computing the complexity of algorithms; i.e.,
 the amount of time that it takes for computer program to run.
 It’s only concerned with what happens for very a large value of n.
 Amount of work the CPU has to do (time complexity)
as the input size grows (towards infinity).
 Formal Definition: f (n)= O (g (n)) if there exist c, k ∊ ℛ+ such that for all n≥
k, f (n) ≤ c.g (n).
 Examples: The following points are facts that you can use for Big-Oh
problems:
 1<=n for all n>=1
 n<=n2 for all n>=1
 2n <=n! for all n>=4
 log2n<=n for all n>=2
 n<=nlog2n for all n>=2 34
 Read The remaining notations of running time
35

More Related Content

What's hot

Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship Model
Slideshare
 
Searching algorithm
Searching algorithmSearching algorithm
Searching algorithm
MG Thushara Pradeesh
 
Splay Tree
Splay TreeSplay Tree
Brute force method
Brute force methodBrute force method
Brute force method
priyankabhansali217
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
Zaid Shabbir
 
Normalization
NormalizationNormalization
Normalization
Amrit Kaur
 
Data Structures
Data StructuresData Structures
Data Structures
Prof. Dr. K. Adisesha
 
Searching algorithms
Searching algorithmsSearching algorithms
Searching algorithms
Trupti Agrawal
 
linked lists in data structures
linked lists in data structureslinked lists in data structures
linked lists in data structures
DurgaDeviCbit
 
Linear Search
Linear SearchLinear Search
Linear Search
SWATHIR72
 
Splay tree
Splay treeSplay tree
Splay tree
hina firdaus
 
Tree - Data Structure
Tree - Data StructureTree - Data Structure
Tree - Data Structure
Ashim Lamichhane
 
stack & queue
stack & queuestack & queue
stack & queue
manju rani
 
Linklist
LinklistLinklist
Data Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search TreeData Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search Tree
ManishPrajapati78
 
3.2 insertion sort
3.2 insertion sort3.2 insertion sort
3.2 insertion sort
Krish_ver2
 
Self organising list
Self organising listSelf organising list
Self organising list
Shashank Singh
 
Linear search-and-binary-search
Linear search-and-binary-searchLinear search-and-binary-search
Linear search-and-binary-search
International Islamic University
 
Introduction to Data Structures Sorting and searching
Introduction to Data Structures Sorting and searchingIntroduction to Data Structures Sorting and searching
Introduction to Data Structures Sorting and searching
Mvenkatarao
 
Binary search
Binary searchBinary search
Binary search
AparnaKumari31
 

What's hot (20)

Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship Model
 
Searching algorithm
Searching algorithmSearching algorithm
Searching algorithm
 
Splay Tree
Splay TreeSplay Tree
Splay Tree
 
Brute force method
Brute force methodBrute force method
Brute force method
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
Normalization
NormalizationNormalization
Normalization
 
Data Structures
Data StructuresData Structures
Data Structures
 
Searching algorithms
Searching algorithmsSearching algorithms
Searching algorithms
 
linked lists in data structures
linked lists in data structureslinked lists in data structures
linked lists in data structures
 
Linear Search
Linear SearchLinear Search
Linear Search
 
Splay tree
Splay treeSplay tree
Splay tree
 
Tree - Data Structure
Tree - Data StructureTree - Data Structure
Tree - Data Structure
 
stack & queue
stack & queuestack & queue
stack & queue
 
Linklist
LinklistLinklist
Linklist
 
Data Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search TreeData Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search Tree
 
3.2 insertion sort
3.2 insertion sort3.2 insertion sort
3.2 insertion sort
 
Self organising list
Self organising listSelf organising list
Self organising list
 
Linear search-and-binary-search
Linear search-and-binary-searchLinear search-and-binary-search
Linear search-and-binary-search
 
Introduction to Data Structures Sorting and searching
Introduction to Data Structures Sorting and searchingIntroduction to Data Structures Sorting and searching
Introduction to Data Structures Sorting and searching
 
Binary search
Binary searchBinary search
Binary search
 

Similar to Chapter 1 Data structure.pptx

Introduction to Data Structure and algorithm.pptx
Introduction to Data Structure and algorithm.pptxIntroduction to Data Structure and algorithm.pptx
Introduction to Data Structure and algorithm.pptx
esuEthopi
 
Data Structure and Algorithm chapter two, This material is for Data Structure...
Data Structure and Algorithm chapter two, This material is for Data Structure...Data Structure and Algorithm chapter two, This material is for Data Structure...
Data Structure and Algorithm chapter two, This material is for Data Structure...
bekidea
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdf
NayanChandak1
 
Data Structures and Algorithms Unit 01
Data Structures and Algorithms Unit 01Data Structures and Algorithms Unit 01
Data Structures and Algorithms Unit 01
Prashanth Shivakumar
 
Unit 1 dsa
Unit 1 dsaUnit 1 dsa
Daa notes 1
Daa notes 1Daa notes 1
Daa notes 1
smruti sarangi
 
Lec1
Lec1Lec1
Lec1
Lec1Lec1
Lec1
Saad Gabr
 
Lec1
Lec1Lec1
Data Abstraction (Chapter 1)
Data Abstraction (Chapter 1)Data Abstraction (Chapter 1)
Data Abstraction (Chapter 1)
LeulTewolde
 
Algorithm analysis in fundamentals of data structure
Algorithm analysis in fundamentals of data structureAlgorithm analysis in fundamentals of data structure
Algorithm analysis in fundamentals of data structure
Vrushali Dhanokar
 
Fundamentals of the Analysis of Algorithm Efficiency
Fundamentals of the Analysis of Algorithm EfficiencyFundamentals of the Analysis of Algorithm Efficiency
Fundamentals of the Analysis of Algorithm Efficiency
Saranya Natarajan
 
SCHEDULING DIFFERENT CUSTOMER ACTIVITIES WITH SENSING DEVICE
SCHEDULING DIFFERENT CUSTOMER ACTIVITIES WITH SENSING DEVICESCHEDULING DIFFERENT CUSTOMER ACTIVITIES WITH SENSING DEVICE
SCHEDULING DIFFERENT CUSTOMER ACTIVITIES WITH SENSING DEVICE
ijait
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
Dhaval Kaneria
 
Cupdf.com introduction to-data-structures-and-algorithm
Cupdf.com introduction to-data-structures-and-algorithmCupdf.com introduction to-data-structures-and-algorithm
Cupdf.com introduction to-data-structures-and-algorithm
TarikuDabala1
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
Dhaval Kaneria
 
U nit i data structure-converted
U nit   i data structure-convertedU nit   i data structure-converted
U nit i data structure-converted
Shri Shankaracharya College, Bhilai,Junwani
 
DA lecture 3.pptx
DA lecture 3.pptxDA lecture 3.pptx
DA lecture 3.pptx
SayanSen36
 
Data structure introduction
Data structure introductionData structure introduction
Data structure introduction
NavneetSandhu0
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdf
MemMem25
 

Similar to Chapter 1 Data structure.pptx (20)

Introduction to Data Structure and algorithm.pptx
Introduction to Data Structure and algorithm.pptxIntroduction to Data Structure and algorithm.pptx
Introduction to Data Structure and algorithm.pptx
 
Data Structure and Algorithm chapter two, This material is for Data Structure...
Data Structure and Algorithm chapter two, This material is for Data Structure...Data Structure and Algorithm chapter two, This material is for Data Structure...
Data Structure and Algorithm chapter two, This material is for Data Structure...
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdf
 
Data Structures and Algorithms Unit 01
Data Structures and Algorithms Unit 01Data Structures and Algorithms Unit 01
Data Structures and Algorithms Unit 01
 
Unit 1 dsa
Unit 1 dsaUnit 1 dsa
Unit 1 dsa
 
Daa notes 1
Daa notes 1Daa notes 1
Daa notes 1
 
Lec1
Lec1Lec1
Lec1
 
Lec1
Lec1Lec1
Lec1
 
Lec1
Lec1Lec1
Lec1
 
Data Abstraction (Chapter 1)
Data Abstraction (Chapter 1)Data Abstraction (Chapter 1)
Data Abstraction (Chapter 1)
 
Algorithm analysis in fundamentals of data structure
Algorithm analysis in fundamentals of data structureAlgorithm analysis in fundamentals of data structure
Algorithm analysis in fundamentals of data structure
 
Fundamentals of the Analysis of Algorithm Efficiency
Fundamentals of the Analysis of Algorithm EfficiencyFundamentals of the Analysis of Algorithm Efficiency
Fundamentals of the Analysis of Algorithm Efficiency
 
SCHEDULING DIFFERENT CUSTOMER ACTIVITIES WITH SENSING DEVICE
SCHEDULING DIFFERENT CUSTOMER ACTIVITIES WITH SENSING DEVICESCHEDULING DIFFERENT CUSTOMER ACTIVITIES WITH SENSING DEVICE
SCHEDULING DIFFERENT CUSTOMER ACTIVITIES WITH SENSING DEVICE
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
 
Cupdf.com introduction to-data-structures-and-algorithm
Cupdf.com introduction to-data-structures-and-algorithmCupdf.com introduction to-data-structures-and-algorithm
Cupdf.com introduction to-data-structures-and-algorithm
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
 
U nit i data structure-converted
U nit   i data structure-convertedU nit   i data structure-converted
U nit i data structure-converted
 
DA lecture 3.pptx
DA lecture 3.pptxDA lecture 3.pptx
DA lecture 3.pptx
 
Data structure introduction
Data structure introductionData structure introduction
Data structure introduction
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdf
 

More from wondmhunegn

sql-basic.ppt
sql-basic.pptsql-basic.ppt
sql-basic.ppt
wondmhunegn
 
Microsoft Access.ppt
Microsoft Access.pptMicrosoft Access.ppt
Microsoft Access.ppt
wondmhunegn
 
Module 2 Slides.ppt
Module 2 Slides.pptModule 2 Slides.ppt
Module 2 Slides.ppt
wondmhunegn
 
ETE105_lecture 3.ppt
ETE105_lecture 3.pptETE105_lecture 3.ppt
ETE105_lecture 3.ppt
wondmhunegn
 
BasicComputerParts.ppt
BasicComputerParts.pptBasicComputerParts.ppt
BasicComputerParts.ppt
wondmhunegn
 
tree.ppt
tree.ppttree.ppt
tree.ppt
wondmhunegn
 
IS230 - Chapter 4 - Keys and Relationship - Revised.ppt
IS230 - Chapter 4 - Keys and Relationship - Revised.pptIS230 - Chapter 4 - Keys and Relationship - Revised.ppt
IS230 - Chapter 4 - Keys and Relationship - Revised.ppt
wondmhunegn
 
MS-Access Tables Forms Queries Reports.ppt
MS-Access Tables Forms Queries Reports.pptMS-Access Tables Forms Queries Reports.ppt
MS-Access Tables Forms Queries Reports.ppt
wondmhunegn
 
DatabaseFundamentals.ppt
DatabaseFundamentals.pptDatabaseFundamentals.ppt
DatabaseFundamentals.ppt
wondmhunegn
 
Data Types and Field Properties.ppt
Data Types and Field Properties.pptData Types and Field Properties.ppt
Data Types and Field Properties.ppt
wondmhunegn
 
Template.pptx
Template.pptxTemplate.pptx
Template.pptx
wondmhunegn
 

More from wondmhunegn (11)

sql-basic.ppt
sql-basic.pptsql-basic.ppt
sql-basic.ppt
 
Microsoft Access.ppt
Microsoft Access.pptMicrosoft Access.ppt
Microsoft Access.ppt
 
Module 2 Slides.ppt
Module 2 Slides.pptModule 2 Slides.ppt
Module 2 Slides.ppt
 
ETE105_lecture 3.ppt
ETE105_lecture 3.pptETE105_lecture 3.ppt
ETE105_lecture 3.ppt
 
BasicComputerParts.ppt
BasicComputerParts.pptBasicComputerParts.ppt
BasicComputerParts.ppt
 
tree.ppt
tree.ppttree.ppt
tree.ppt
 
IS230 - Chapter 4 - Keys and Relationship - Revised.ppt
IS230 - Chapter 4 - Keys and Relationship - Revised.pptIS230 - Chapter 4 - Keys and Relationship - Revised.ppt
IS230 - Chapter 4 - Keys and Relationship - Revised.ppt
 
MS-Access Tables Forms Queries Reports.ppt
MS-Access Tables Forms Queries Reports.pptMS-Access Tables Forms Queries Reports.ppt
MS-Access Tables Forms Queries Reports.ppt
 
DatabaseFundamentals.ppt
DatabaseFundamentals.pptDatabaseFundamentals.ppt
DatabaseFundamentals.ppt
 
Data Types and Field Properties.ppt
Data Types and Field Properties.pptData Types and Field Properties.ppt
Data Types and Field Properties.ppt
 
Template.pptx
Template.pptxTemplate.pptx
Template.pptx
 

Recently uploaded

Daryaganj @ℂall @Girls ꧁❤ 9873940964 ❤꧂VIP Jina Singh Top Model Safe
Daryaganj @ℂall @Girls ꧁❤ 9873940964 ❤꧂VIP Jina Singh Top Model SafeDaryaganj @ℂall @Girls ꧁❤ 9873940964 ❤꧂VIP Jina Singh Top Model Safe
Daryaganj @ℂall @Girls ꧁❤ 9873940964 ❤꧂VIP Jina Singh Top Model Safe
butwhat24
 
Lajpat Nagar @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Arti Singh Top Model Safe
Lajpat Nagar @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Arti Singh Top Model SafeLajpat Nagar @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Arti Singh Top Model Safe
Lajpat Nagar @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Arti Singh Top Model Safe
aarusi sexy model
 
Victoria University degree offer diploma Transcript
Victoria University  degree offer diploma TranscriptVictoria University  degree offer diploma Transcript
Victoria University degree offer diploma Transcript
taqyea
 
Introduction to the Red Hat Portfolio.pdf
Introduction to the Red Hat Portfolio.pdfIntroduction to the Red Hat Portfolio.pdf
Introduction to the Red Hat Portfolio.pdf
kihus38
 
Nehru Place @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Jya Khan Top Model Safe
Nehru Place @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Jya Khan Top Model SafeNehru Place @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Jya Khan Top Model Safe
Nehru Place @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Jya Khan Top Model Safe
bookmybebe1
 
NPS_Presentation_V3.pptx it is regarding National pension scheme
NPS_Presentation_V3.pptx it is regarding National pension schemeNPS_Presentation_V3.pptx it is regarding National pension scheme
NPS_Presentation_V3.pptx it is regarding National pension scheme
ASISHSABAT3
 
Delhi @ℂall @Girls ꧁❤ 9711199012 ❤꧂Glamorous sonam Mehra Top Model Safe
Delhi @ℂall @Girls ꧁❤ 9711199012 ❤꧂Glamorous sonam Mehra Top Model SafeDelhi @ℂall @Girls ꧁❤ 9711199012 ❤꧂Glamorous sonam Mehra Top Model Safe
Delhi @ℂall @Girls ꧁❤ 9711199012 ❤꧂Glamorous sonam Mehra Top Model Safe
dipti singh$A17
 
Malviya Nagar @ℂall @Girls ꧁❤ 9873940964 ❤꧂VIP Jina Singh Top Model Safe
Malviya Nagar @ℂall @Girls ꧁❤ 9873940964 ❤꧂VIP Jina Singh Top Model SafeMalviya Nagar @ℂall @Girls ꧁❤ 9873940964 ❤꧂VIP Jina Singh Top Model Safe
Malviya Nagar @ℂall @Girls ꧁❤ 9873940964 ❤꧂VIP Jina Singh Top Model Safe
butwhat24
 
Simon Fraser University degree offer diploma Transcript
Simon Fraser University  degree offer diploma TranscriptSimon Fraser University  degree offer diploma Transcript
Simon Fraser University degree offer diploma Transcript
taqyea
 
Seamlessly Pay Online, Pay In Stores or Send Money
Seamlessly Pay Online, Pay In Stores or Send MoneySeamlessly Pay Online, Pay In Stores or Send Money
Seamlessly Pay Online, Pay In Stores or Send Money
gargtinna79
 
Supervised Learning (Data Science).pptx
Supervised Learning  (Data Science).pptxSupervised Learning  (Data Science).pptx
Supervised Learning (Data Science).pptx
TARIKU ENDALE
 
Saket @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Neha Singla Top Model Safe
Saket @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Neha Singla Top Model SafeSaket @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Neha Singla Top Model Safe
Saket @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Neha Singla Top Model Safe
shruti singh$A17
 
Rohini @ℂall @Girls ꧁❤ 9873940964 ❤꧂VIP Megha Singla Top Model Safe
Rohini @ℂall @Girls ꧁❤ 9873940964 ❤꧂VIP Megha Singla Top Model SafeRohini @ℂall @Girls ꧁❤ 9873940964 ❤꧂VIP Megha Singla Top Model Safe
Rohini @ℂall @Girls ꧁❤ 9873940964 ❤꧂VIP Megha Singla Top Model Safe
depikasharma
 
Lajpat Nagar @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Ruhi Singla Top Model Safe
Lajpat Nagar @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Ruhi Singla Top Model SafeLajpat Nagar @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Ruhi Singla Top Model Safe
Lajpat Nagar @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Ruhi Singla Top Model Safe
jiya khan$A17
 
Australian Catholic University degree offer diploma Transcript
Australian Catholic University  degree offer diploma TranscriptAustralian Catholic University  degree offer diploma Transcript
Australian Catholic University degree offer diploma Transcript
taqyea
 
Laxmi Nagar @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Yogita Mehra Top Model Safe
Laxmi Nagar @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Yogita Mehra Top Model SafeLaxmi Nagar @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Yogita Mehra Top Model Safe
Laxmi Nagar @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Yogita Mehra Top Model Safe
yogita singh$A17
 
How We Added Replication to QuestDB - JonTheBeach
How We Added Replication to QuestDB - JonTheBeachHow We Added Replication to QuestDB - JonTheBeach
How We Added Replication to QuestDB - JonTheBeach
javier ramirez
 
Cloud Analytics Use Cases - Telco Products
Cloud Analytics Use Cases - Telco ProductsCloud Analytics Use Cases - Telco Products
Cloud Analytics Use Cases - Telco Products
luqmansyauqi2
 
AIRLINE_SATISFACTION_Data Science Solution on Azure
AIRLINE_SATISFACTION_Data Science Solution on AzureAIRLINE_SATISFACTION_Data Science Solution on Azure
AIRLINE_SATISFACTION_Data Science Solution on Azure
SanelaNikodinoska1
 
University of Toronto degree offer diploma Transcript
University of Toronto  degree offer diploma TranscriptUniversity of Toronto  degree offer diploma Transcript
University of Toronto degree offer diploma Transcript
taqyea
 

Recently uploaded (20)

Daryaganj @ℂall @Girls ꧁❤ 9873940964 ❤꧂VIP Jina Singh Top Model Safe
Daryaganj @ℂall @Girls ꧁❤ 9873940964 ❤꧂VIP Jina Singh Top Model SafeDaryaganj @ℂall @Girls ꧁❤ 9873940964 ❤꧂VIP Jina Singh Top Model Safe
Daryaganj @ℂall @Girls ꧁❤ 9873940964 ❤꧂VIP Jina Singh Top Model Safe
 
Lajpat Nagar @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Arti Singh Top Model Safe
Lajpat Nagar @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Arti Singh Top Model SafeLajpat Nagar @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Arti Singh Top Model Safe
Lajpat Nagar @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Arti Singh Top Model Safe
 
Victoria University degree offer diploma Transcript
Victoria University  degree offer diploma TranscriptVictoria University  degree offer diploma Transcript
Victoria University degree offer diploma Transcript
 
Introduction to the Red Hat Portfolio.pdf
Introduction to the Red Hat Portfolio.pdfIntroduction to the Red Hat Portfolio.pdf
Introduction to the Red Hat Portfolio.pdf
 
Nehru Place @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Jya Khan Top Model Safe
Nehru Place @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Jya Khan Top Model SafeNehru Place @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Jya Khan Top Model Safe
Nehru Place @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Jya Khan Top Model Safe
 
NPS_Presentation_V3.pptx it is regarding National pension scheme
NPS_Presentation_V3.pptx it is regarding National pension schemeNPS_Presentation_V3.pptx it is regarding National pension scheme
NPS_Presentation_V3.pptx it is regarding National pension scheme
 
Delhi @ℂall @Girls ꧁❤ 9711199012 ❤꧂Glamorous sonam Mehra Top Model Safe
Delhi @ℂall @Girls ꧁❤ 9711199012 ❤꧂Glamorous sonam Mehra Top Model SafeDelhi @ℂall @Girls ꧁❤ 9711199012 ❤꧂Glamorous sonam Mehra Top Model Safe
Delhi @ℂall @Girls ꧁❤ 9711199012 ❤꧂Glamorous sonam Mehra Top Model Safe
 
Malviya Nagar @ℂall @Girls ꧁❤ 9873940964 ❤꧂VIP Jina Singh Top Model Safe
Malviya Nagar @ℂall @Girls ꧁❤ 9873940964 ❤꧂VIP Jina Singh Top Model SafeMalviya Nagar @ℂall @Girls ꧁❤ 9873940964 ❤꧂VIP Jina Singh Top Model Safe
Malviya Nagar @ℂall @Girls ꧁❤ 9873940964 ❤꧂VIP Jina Singh Top Model Safe
 
Simon Fraser University degree offer diploma Transcript
Simon Fraser University  degree offer diploma TranscriptSimon Fraser University  degree offer diploma Transcript
Simon Fraser University degree offer diploma Transcript
 
Seamlessly Pay Online, Pay In Stores or Send Money
Seamlessly Pay Online, Pay In Stores or Send MoneySeamlessly Pay Online, Pay In Stores or Send Money
Seamlessly Pay Online, Pay In Stores or Send Money
 
Supervised Learning (Data Science).pptx
Supervised Learning  (Data Science).pptxSupervised Learning  (Data Science).pptx
Supervised Learning (Data Science).pptx
 
Saket @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Neha Singla Top Model Safe
Saket @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Neha Singla Top Model SafeSaket @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Neha Singla Top Model Safe
Saket @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Neha Singla Top Model Safe
 
Rohini @ℂall @Girls ꧁❤ 9873940964 ❤꧂VIP Megha Singla Top Model Safe
Rohini @ℂall @Girls ꧁❤ 9873940964 ❤꧂VIP Megha Singla Top Model SafeRohini @ℂall @Girls ꧁❤ 9873940964 ❤꧂VIP Megha Singla Top Model Safe
Rohini @ℂall @Girls ꧁❤ 9873940964 ❤꧂VIP Megha Singla Top Model Safe
 
Lajpat Nagar @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Ruhi Singla Top Model Safe
Lajpat Nagar @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Ruhi Singla Top Model SafeLajpat Nagar @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Ruhi Singla Top Model Safe
Lajpat Nagar @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Ruhi Singla Top Model Safe
 
Australian Catholic University degree offer diploma Transcript
Australian Catholic University  degree offer diploma TranscriptAustralian Catholic University  degree offer diploma Transcript
Australian Catholic University degree offer diploma Transcript
 
Laxmi Nagar @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Yogita Mehra Top Model Safe
Laxmi Nagar @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Yogita Mehra Top Model SafeLaxmi Nagar @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Yogita Mehra Top Model Safe
Laxmi Nagar @ℂall @Girls ꧁❤ 9873777170 ❤꧂VIP Yogita Mehra Top Model Safe
 
How We Added Replication to QuestDB - JonTheBeach
How We Added Replication to QuestDB - JonTheBeachHow We Added Replication to QuestDB - JonTheBeach
How We Added Replication to QuestDB - JonTheBeach
 
Cloud Analytics Use Cases - Telco Products
Cloud Analytics Use Cases - Telco ProductsCloud Analytics Use Cases - Telco Products
Cloud Analytics Use Cases - Telco Products
 
AIRLINE_SATISFACTION_Data Science Solution on Azure
AIRLINE_SATISFACTION_Data Science Solution on AzureAIRLINE_SATISFACTION_Data Science Solution on Azure
AIRLINE_SATISFACTION_Data Science Solution on Azure
 
University of Toronto degree offer diploma Transcript
University of Toronto  degree offer diploma TranscriptUniversity of Toronto  degree offer diploma Transcript
University of Toronto degree offer diploma Transcript
 

Chapter 1 Data structure.pptx

  • 2. 1.1. Introduction to Data Structures and Algorithms Analysis  A program is written in order to solve a problem. A solution to a problem actually consists of two things: I. A way to organize the data II. Sequence of steps to solve the problem  The way data are organized in a computer’s memory is said to be data structure and  The sequence of computational steps to solve a problem is said to be an algorithm.  Therefore, a program is nothing but data structures plus algorithms.  A data structure is a systematic way of organizing and accessing data and  an algorithm is a step-by-step procedure for performing some task in a finite amount of time.
  • 3. Introduction to Data Structures  The first step to solve the problem is obtaining one’s own abstract view, or model, of the problem.  This process of modeling is called abstraction.  The model defines an abstract view to the problem.  This implies that the model focuses only on problem related stuff and  A programmer tries to define the properties of the problem. 3
  • 4. Cont.  These properties Abstract data include  The data which are affected and  The operations that are involved in the problem.  With abstraction you create a well-defined entity that can be properly handled.  These entities define the data structure of the program.  An entity with the properties just described is called an abstract data type (ADT). 4
  • 5. Abstract Data Types  An abstract data type (ADT) is a set of objects together with a set of operations.  An ADT is a mathematical model of a data structure that specifies the type of the data stored, the operations supported on them  Objects such as lists, sets, and graphs, along with their operations, can be viewed as ADTs, just as integers, real’s, and booleans are data types.  The ADT specifies: 1. What can be stored in the Abstract Data Type? 2. What operations can be done on/by the Abstract Data Type? 5
  • 6. Abstraction  Abstraction is a process of classifying characteristics as relevant and irrelevant for the particular purpose at hand and ignoring the irrelevant ones.  The abstraction is to distill a complicated system down to its most fundamental parts and  describe these parts in a simple, precise language.  Typically, describing the parts of a system involves naming them and explaining their functionality. 6
  • 7. Algorithms  An algorithm is a well-defined computational procedure that takes :  some value or a set of values as input and  produces some value or a set of values as output.  Data structures model the static part of the world.  They are unchanging while the world is changing.  In order to model the dynamic part of the world we need to work with algorithms.  Algorithms are the dynamic part of a program’s world model.  An algorithm transforms data structures from one state to another state in two ways:  An algorithm may change the value held by a data structure  An algorithm may change the data structure itself 7
  • 8. Properties of an algorithm What makes an algorithm good?  Finiteness: Algorithm must complete after a finite number of steps.  Definiteness: Each step must be clearly defined, having one and only one interpretation. At each point in computation, one should be able to tell exactly what happens next.  Sequence: Each step must have a unique defined preceding and succeeding step. The first step (start step) and last step (halt step) must be clearly noted.  Feasibility: It must be possible to perform each instruction.  Correctness: It must compute correct answer for all possible legal inputs. 8
  • 9. Cont.  Language Independence: It must not depend on any one programming language.  Completeness: It must solve the problem completely.  Effectiveness: It must be possible to perform each step exactly and in a finite amount of time.  Efficiency: It must solve with the least amount of computational resources such as time and space.  Generality: Algorithm should be valid on all possible inputs.  Input/Output: There must be a specified number of input values, and one or more result values. 9
  • 10. Algorithm Analysis Concepts  Algorithm analysis refers to the process of determining the amount of computing time and storage space required by different algorithms.  In other words, it’s a process of predicting the resource requirement of algorithms in a given environment.  It is the study of efficiency of programs.  Input size of the program, machine type used, implementation quality, running time of algorithm and others affect the efficiency of a program. 10
  • 11. … Cont.  In order to solve a problem, there are many possible algorithms.  One has to be able to choose the best algorithm for the problem at hand using some scientific method.  To classify some data structures and algorithms as good, we need precise ways of analyzing them in terms of resource requirement. The main resources are:  Running Time  Memory Usage  Communication Bandwidth  Algorithm analysis tries to estimate these resources required to solve a problem at hand.  Running time is usually treated as the most important since computational time is the most precious resource in most problem domains. 11
  • 12. --- Cont  There are two approaches to measure the efficiency of algorithms:  Empirical (Experimental) method: Programming competing algorithms and trying them on different instances. This method is used for absolute time measurement.  Analytical (Theoretical) Method: Determining the quantity of resources required mathematically (like execution time, memory space, etc.) needed by each algorithm.  However, it is difficult to use actual clock-time as a consistent measure of an algorithm’s efficiency, because clock-time can vary based on many things. For example,  Specific processor speed  Current processor load  Specific data for a particular run of the program  Input Size  Input Properties  Operating Environment 12
  • 13. Complexity Analysis  Complexity Analysis is the systematic study of the cost of computation, measured either in time units or in operations performed, or in the amount of storage space required.  The goal is to have a meaningful measure that permits comparison of algorithms independent of operating platform.  There are two things to consider:  Time Complexity: Determine the approximate number of operations and time required to solve a problem of size n.  The running times of operations on the data structure should be as small as possible.  Space Complexity: Determine the approximate memory required to solve a problem of size n.  The data structure should use as little memory as possible. 13
  • 14. Running time  The critical resource for a program is most often its running time.  Running time is the amount of time that any algorithm takes to run.  However, you cannot pay attention to running time alone.  You must also be concerned with other factors such as the space required to run the program (main memory and disk space).  The primary analysis tool we use in this course involves characterizing the running times of algorithms and data structure operations.  Running time is a natural measure of “goodness,” since time is a precious resource - computer solutions should run as fast as possible. 14
  • 15. 1.2.2. Complexity of Algorithms  There is no generally accepted set of rules for algorithm analysis.  However, an exact count of operations is commonly used.  Arbitrary time unit is assumed for analyzing the algorithm, and we have the following set of analysis rules. Rule 1: Basic operations  The execution of the following operations takes one (1) time unit.  Assignment Operation  Single Input/ Output Operation  Single Boolean Operations  Single Arithmetic Operations  Function Return 15
  • 16. … Cont.  Rule 2: Selection statements  Running time of a selection statement (if, switch) is the time for the condition evaluation + the maximum of the running times for the individual clauses.  Rule 3: Loops  Running time for a loop is equal to the running time for the statements inside the loop body multiplied (*) by number of iterations of the loop.  Rule 4: Nested Loops  The total running time of a statement inside a group of nested loops is the running time of the statements multiplied by the product of the sizes of all the loops.  Rule 5: Function call  Running time of a function call is 1 for setup + the time for any parameter calculations + the time required for the execution of the function body.  Rule 6: Consecutive statements  For consecutive statements, the running time will be computed as the sum of the running time of the separate blocks of code. 16
  • 17. Example 1 The following examples show us how running time of the code fragments is computed. Examples 1: int count ( ) { int k=0; cout<< “Enter an integer”; cin>>n; for (i=0; i<n; i++) k=k+1; return 0; } Time Units to Compute 1 for the assignment statement: int k=0 1 for the output statement. 1 for the input statement. For the loop (for): 1 assignment (i = 0), n+1 tests, and n increments. n loops of 2 units for an assignment and addition. 1 for the return statement. ------------------------------------------------------------------- T (n)= 1+1+1+(1+n+1+n)+2n+1 = 4n+6 = O(n) 17
  • 18. Example 2: int total(int n) { int sum=0; for (int i=1;i<=n;i++) sum=sum+1; return sum; } Time Units to Compute 1 for the assignment statement: int sum=0 In the for loop: 1 assignment, n+1 tests, and n increments. n loops of 2 units for an assignment and addition. 1 for the return statement. ------------------------------------------------------------------- T (n)= 1+ (1+n+1+n)+2n+1 = 4n+4 = O(n) 18
  • 19. Example 3: void func( ) { int x=0, i=0, j=1; cout<< “Enter an Integer value”; cin>>n; while (i<n) { x++; i++; } while (j<n) j++; } Time Units to Compute 1 for the first assignment statement: x=0; 1 for the second assignment statement: i=0; 1 for the third assignment statement: j=1; 1 for the output statement. 1 for the input statement. In the first while loop: n+1 tests n loops of 2 units for the two increment (addition) operations In the second while loop: n tests n-1 increments ------------------------------------------------------------------- T (n)= 1+1+1+1+1+(n+1+2n)+(n+n-1) = 5n+5 = O(n) 19
  • 20. Example 4: int sum (int n) { int partial_sum = 0; for (int i = 1; i <= n; i++) partial_sum = partial_sum +(i * i * i); return partial_sum; } Time Units to Compute 1 for the assignment. 1 assignment, n+1 tests, and n increments for the loop expression (for). n loops of 4 units for an assignment, addition, and two multiplications. 1 for the return statement. ------------------------------------------------------------------- T (n) = 1+(1+n+1+n)+4n+1 = 6n+4 = O(n) 20
  • 21. Example 5: void func ( ) { int i =1, sum = 0; while (i < = n) { for (int j =0;j<n; j++) { sum = i + j; } i ++; }} Time Units to Compute 1 for the first assignment (i = 1). 1 for the second assignment (sum = 0). In the while loop n+1 tests n loops of the following For the for loop 1 assignment, n+1 tests, and n increments. n loops of 2 units for an assignment and addition. 1 for the increment operation. ------------------------------------------------------------------- T (n) = 1+1+(n+1)+n[(1+n+1+n+2n)+1] = 4n2+4n+3 = O(n2) 21
  • 22. Example 6: int k=0; for (int i=1; i<n; i*=2) for(int j=1;j<=n;j++) k++; Time Units to Compute 1 for the first assignment (k = 0). For the first loop (for) 1 assignment, 1+ tests, and multiplication of i*=2. iterations of the following For the second loop (for) 1 assignment, n+1 tests, and n increments. n loops of one unit (increment operation) ------------------------------------------------------------------- T (n) = 1+1+1+ ++[(1+n+1+n)+n] = 3n+4+3= O(n) 22
  • 23. 1.2.3. Formal Approach to Analysis  In the above examples we have seen that analysis is a bit complex.  However, it can be simplified by using some formal approach in which case we can ignore initializations, loop control, and book keeping.  For Loops: Formally  In general, a for loop translates to a summation.  The index and bounds of the summation are the same as the index and bounds of the for loop.  Suppose we count the number of additions that are done. There is 1 addition per iteration of the loop, hence N additions in total. 23 for (int i = 1; i <= N; i++) { sum = sum+i; } N N i   1 1
  • 24. Nested Loops: Formally  Nested for loops translate into multiple summations, one for each for loop.  Again, count the number of additions. The outer summation is for the outer for loop. 24 for (int i = 1; i <= N; i++) { for (int j = 1; j <= M; j++) { sum = sum+i+j; } } MN M N i N i M j 2 2 2 1 1 1        Consecutive Statements: Formally  Add the running times of the separate blocks of your code for (int i = 1; i <= N; i++) { sum = sum+i; } for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) { sum = sum+i+j; } } 2 1 1 1 2 2 1 N N N i N j N i                    
  • 25. Compute Running time with given input  Example:  Suppose we have hardware capable of executing 106 instructions per second. How long would it take to execute an algorithm whose complexity function was T (n) = 2n2 on an input size of n=108?  Solution  The total number of operations to be performed would be T (108): T(108) = 2*(108)2 =2*1016 The required number of seconds required would be given by T(108)/106 so: Running time =2*1016/106 = 2*1010  The number of seconds per day is 86,400 so this is about 231,480 days (634 years). 25
  • 26. Exercises Determine the run time equation and complexity of each of the following code segments. 1. for (i=0;i<n;i++) for (j=0;j<n; j++) sum=sum+i+j; 2. for(int i=1; i<=n; i++) for (int j=1; j<=i; j++) sum++; What is the value of the sum if n=20? 3. int k=0; for (int i=0; i<n; i++) for (int j=i; j<n; j++) k++; What is the value of k when n is equal to 20? 4. int k=0; for (int i=1; i<n; i*=2) for(int j=1; j<n; j++) k++; What is the value of k when n is equal to 20? 26
  • 27. Home Work 5. int x=0; for(int i=1;i<n;i=i+5) x++; What is the value of x when n=25? 6. int x=0; for(int k=n;k>=n/3;k=k-5) x++; What is the value of x when n=25? 7. int x=0; for (int i=1; i<n;i=i+5) for (int k=n;k>=n/3;k=k-5) x++; What is the value of x when n=25? 8. int x=0; for(int i=1;i<n;i=i+5) for(int j=0;j<i;j++) for(int k=n;k>=n/2;k=k-3) x++; What is the correct big-Oh Notation for the above code segment? 27
  • 28. 1.3. Measures of Times  The running time of an algorithm can be define into three possible functions Tbest(n), Tavg(n) and Tworst(n)  Average Case (Tavg): The amount of time the algorithm takes on an "average" set of inputs.  Worst Case (Tworst): The amount of time the algorithm takes on the worst possible set of inputs.  Best Case (Tbest): The amount of time the algorithm takes on the smallest possible set of inputs. 28
  • 29. 1.4. Asymptotic Analysis  Asymptotic analysis is concerned with how the running time of an algorithm increases with the size of the input in the limit, as the size of the input increases without bound.  We will see the most important functions used in the analysis of algorithms. O(1) – Constant Time  Pronounced: "Order 1", "O of 1", "big O of 1"  The runtime is constant, i.e., independent of the number of input elements n.  When evaluating overall running time, we typically ignore these statements since they don’t factor into the complexity.  This is the function, f (n) = c. 29
  • 30. O(n) – Linear Time  Pronounced: "Order n", "O of n", "big O of n"  The time grows linearly with the number of input elements n: If n doubles, then the time approximately doubles, too.  O(n²) – Quadratic Time(square time)  Pronounced: "Order n squared", "O of n squared", "big O of n squared"  The time grows linearly to the square of the number of input elements:  If the number of input elements n doubles, then the time roughly quadruples. 30
  • 31. Cont.  O(n²) Examples  Examples of quadratic time are simple sorting algorithms like Insertion Sort, Selection Sort, and Bubble Sort.  O(log n) – Logarithmic Time  Pronounced: "Order log n", "O of log n", "big O of log n"  The effort increases approximately by a constant amount when the number of input elements doubles.  An example of logarithmic growth is the binary search for a specific element in a sorted array of size n. 31
  • 33. Cont .  There are five notations used to describe a running time function. These are:  Big-Oh Notation (O)  Big-Omega Notation (W)  Theta Notation (Q)  Little-o Notation (o)  Little-Omega Notation (w) 33
  • 34. The Big-Oh Notation  Big-Oh notation is a way of comparing algorithms and  It is used for computing the complexity of algorithms; i.e.,  the amount of time that it takes for computer program to run.  It’s only concerned with what happens for very a large value of n.  Amount of work the CPU has to do (time complexity) as the input size grows (towards infinity).  Formal Definition: f (n)= O (g (n)) if there exist c, k ∊ ℛ+ such that for all n≥ k, f (n) ≤ c.g (n).  Examples: The following points are facts that you can use for Big-Oh problems:  1<=n for all n>=1  n<=n2 for all n>=1  2n <=n! for all n>=4  log2n<=n for all n>=2  n<=nlog2n for all n>=2 34
  • 35.  Read The remaining notations of running time 35