尊敬的 微信汇率:1円 ≈ 0.046166 元 支付宝汇率:1円 ≈ 0.046257元 [退出登录]
SlideShare a Scribd company logo
Lecture No.01
Data Structures and
Algorithms
Rabbia mahum, UET Taxila
Grading Theory
 Mid Term 25%
 Final 50%
 Programming Assignments 10%
 Surprise Quiz's 05%
 Project 10%
Grading Lab
 Mid Term 25%
 Final 50%
 Programming Project 20%
 Presentation and viva voca 05%
Acknowledgement
This Lecture has been prepared from your Reference Course Book titled as
“Data Structure” by Schaum Series.
Other source includes tutorialpoint page and google pages
4
What is Data Structures
 Data Structures are the programmatic way of storing data so that
data can be used efficiently.
 Almost every enterprise application uses various types of data
structures in one or the other way.
5
Why to Learn Data Structure and
Algorithms?
 As applications are getting complex and data rich, there are three
common problems that applications face now-a-days.
1. Data Search
2. Processor speed
3. Multiple requests
6
Why to Learn Data Structure and
Algorithms?
 Data Search − Consider an inventory of 1 million(106) items of a
store. If the application is to search an item, it has to search an item
in 1 million(106) items every time slowing down the search. As data
grows, search will become slower.
7
Why to Learn Data Structure and
Algorithms?
 Processor speed − Processor speed although being very high, falls
limited if the data grows to billion records.
 Multiple requests − As thousands of users can search data
simultaneously on a web server, even the fast server fails while
searching the data.
8
Why to Learn Data Structure and
Algorithms?
 To solve these mentioned problems, data structures come to rescue.
 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.
9
Data Structure: Foundation terms
 Interface − Each data structure has an interface. Interface represents
the set of operations that a data structure supports. An interface only
provides the list of supported operations, type of parameters they can
accept and return type of these operations.
10
Data Structure: Foundation terms
 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.
11
Characteristics of a Data Structure
1. Correctness − Data structure implementation
should implement its interface correctly.
2. Time Complexity − Running time or the execution
time of operations of data structure must be as
small as possible.
3. Space Complexity − Memory usage of a data
structure operation should be as little as possible.
12
What is an Algorithm?
 The word algorithm comes from the name of a Persian author, Abu Ja’far
Mohammed ibn Musa al Khowarizmi (c. 825 A.O.) who wrote a textbook on
mathematics.
 An examination of the latest edition of Webster's dictionary defines its
meaning as "any special method of solving a certain kind of problem.
13
Definition of “Algorithm”
 An Algorithm, intuitively speaking, is a finite step-by-step list of well
defined instructions for solving a particular problem.
 An algorithm is a clearly specified set of simple instructions to be
followed to solve a problem.
14
Definition of “Algorithm”
 Algorithms are generally created independent of underlying languages,
i.e. an algorithm can be implemented in more than one programming
language.
15
Definition of “Algorithm”
 From the data structure point of view, following
are some important categories of algorithms −
1. Search − Algorithm to search an item in a data
structure.
2. Sort − Algorithm to sort items in a certain order.
3. Insert − Algorithm to insert item in a data structure.
4. Update − Algorithm to update an existing item in a data
structure.
5. Delete − Algorithm to delete an existing item from a
data structure.
16
Properties or Constraints
 For example, each operation must be definite, meaning that it must
be perfectly clear what should be done.
 Directions such as "compute 5/0" or "add 6 or 7 to x" are not permitted
because it is not clear what the result is or which of the two possibilities
should be done.
17
Properties or Constraints
 Another important property each operation should have is that it be
effective; each step must be such that it can, at least in principle, be
done by a person using pencil and paper in a finite amount of time.
 Arithmetic operations on integer is an effective while on some real
numbers its not……
18
Properties or Constraints
 An algorithm produces one or more outputs and may have zero or
more inputs which are externally supplied.
 Another important criterion we will assume about algorithms is that
they terminate after a finite number of operations.
19
Algorithmic Notations
 In coming slides you will learn the format that is used to present
algorithms throughout this course. This is best describes by means of an
example.
 Example: An array DATA of numerical values is in memory. We want to
find the location LOC and the value MAX of the largest element of DATA.
20
Algorithmic Notations
 Initially begin with LOC = 1 and MAX = DATA
[1]. Then compare MAX with each successive
element DATA[K] of DATA.
 If DATA[K] exceeds MAX then update LOC and
MAX so that LOC = K and MAX = DATA [K].
 The final values appearing in LOC and MAX give
the location and value of the largest element
of DATA. 21
Algorithmic Notations: Example Largest
Element in the Array
Algorithm 2.1
Algorithmic Notations: Example Largest
Element in the Array
Flow Chart
Algorithmic Notations: The Solution of the
Quadratic Equation
Algorithmic Notations: The Solution of the
Quadratic Equation
 The quantity D = b2 – 4ac is called the
discriminant of the equation. If D is negative,
then there are no real solutions.
 If D = 0, then there is only one (double) real
solution , x = -b/2a
 If D is positive, the formula gives the two
distinct real solutions.
Algorithmic Notations: The Solution of the
Quadratic Equation
Algorithm 2.3
Algorithmic Notations: Linear Search
 Suppose a linear array DATA contains n elements,
and suppose a specific ITEM of information is given.
We want either to find the location LOC of item in
the array DATA, or to send some message, such as
LOC = 0, to indicate that ITEM is not in the DATA.
 The linear search algorithm solves this problem by
comparing ITEM, one by one, with each element in
DATA. That is we compare ITEM with DATA[1],
DATA[2], and so on, until we find LOC such that ITEM
= DATA [LOC].
Algorithm 2.4
Algorithmic Notations: Linear Search
Algorithm 2.4
Algorithmic Notations: Binary Search
 During each stage of binary search algorithm our search
for ITEM is reduced to a segment of elements of DATA
 The BEG and END denote respectively the beginning and
end location of segment under consideration. Where
BEG = 1 or LB and END = n or UB
 The Algorithm compares ITEM with the middle element
DATA[MID] of segment where MID is obtained by
MID = INT (BEG + END ) /2
Algorithmic Notations: Binary Search
 If DATA [MID] = ITEM then search is successful and we
set LOC = MID, otherwise a new segment of DATA is
obtained as follow
 A) If ITEM < DATA [MID] then ITEM can appear on left
side of segment
 DATA [BEG] , DATA [BEG+1] … DATA[MID -1]
B) If ITEM > DATA [MID] then ITEM can appear in right half of the
segment
 DATA [MID] , DATA [MID+1] … DATA[END]
Algorithmic Notations: Binary Search
• If ITEM is not in DATA then eventually we obtain
END < BEG
• This condition signals that the search is unsuccessful, and in such case we assign LOC =
NULL.
Algorithmic Notations: Binary Search
1 2 3 4 5 6 7 8 9 10 11 12 13
11 22 30 33 40 44 55 60 66 77 80 88 99
Algorithmic Notations: Linear Search
Algorithm 2.4

More Related Content

Similar to Lecture#1(Algorithmic Notations).ppt

Lect1.pptx
Lect1.pptxLect1.pptx
Ds
DsDs
Chapter 1 Data structure.pptx
Chapter 1 Data structure.pptxChapter 1 Data structure.pptx
Chapter 1 Data structure.pptx
wondmhunegn
 
Unit 1 dsa
Unit 1 dsaUnit 1 dsa
8.unit-1-fds-2022-23.pptx
8.unit-1-fds-2022-23.pptx8.unit-1-fds-2022-23.pptx
8.unit-1-fds-2022-23.pptx
RavishankarBhaganaga
 
Chapter 1- IT.pptx
Chapter 1- IT.pptxChapter 1- IT.pptx
Chapter 1- IT.pptx
ssuserb78e291
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
JohnStuart83
 
Introduction to Data Structure
Introduction to Data Structure Introduction to Data Structure
Introduction to Data Structure
Prof Ansari
 
Bca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structureBca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structure
Rai University
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfChapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Axmedcarb
 
Mca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structureMca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structure
Rai University
 
RAJAT PROJECT.pptx
RAJAT PROJECT.pptxRAJAT PROJECT.pptx
RAJAT PROJECT.pptx
SayedMohdAsim2
 
Lecture1 data structure(introduction)
Lecture1 data structure(introduction)Lecture1 data structure(introduction)
Data structure and algorithm.
Data structure and algorithm. Data structure and algorithm.
Data structure and algorithm.
Abdul salam
 
Intro.ppt
Intro.pptIntro.ppt
Intro.ppt
Anonymous9etQKwW
 
Intro_2.ppt
Intro_2.pptIntro_2.ppt
Intro_2.ppt
MumitAhmed1
 
Intro.ppt
Intro.pptIntro.ppt
Intro.ppt
SharabiNaif
 
Bca2020 data structure and algorithm
Bca2020   data structure and algorithmBca2020   data structure and algorithm
Bca2020 data structure and algorithm
smumbahelp
 
Bsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structureBsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structure
Rai University
 
Data Structures and Algorithm - Module 1.pptx
Data Structures and Algorithm - Module 1.pptxData Structures and Algorithm - Module 1.pptx
Data Structures and Algorithm - Module 1.pptx
EllenGrace9
 

Similar to Lecture#1(Algorithmic Notations).ppt (20)

Lect1.pptx
Lect1.pptxLect1.pptx
Lect1.pptx
 
Ds
DsDs
Ds
 
Chapter 1 Data structure.pptx
Chapter 1 Data structure.pptxChapter 1 Data structure.pptx
Chapter 1 Data structure.pptx
 
Unit 1 dsa
Unit 1 dsaUnit 1 dsa
Unit 1 dsa
 
8.unit-1-fds-2022-23.pptx
8.unit-1-fds-2022-23.pptx8.unit-1-fds-2022-23.pptx
8.unit-1-fds-2022-23.pptx
 
Chapter 1- IT.pptx
Chapter 1- IT.pptxChapter 1- IT.pptx
Chapter 1- IT.pptx
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 
Introduction to Data Structure
Introduction to Data Structure Introduction to Data Structure
Introduction to Data Structure
 
Bca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structureBca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structure
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfChapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdf
 
Mca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structureMca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structure
 
RAJAT PROJECT.pptx
RAJAT PROJECT.pptxRAJAT PROJECT.pptx
RAJAT PROJECT.pptx
 
Lecture1 data structure(introduction)
Lecture1 data structure(introduction)Lecture1 data structure(introduction)
Lecture1 data structure(introduction)
 
Data structure and algorithm.
Data structure and algorithm. Data structure and algorithm.
Data structure and algorithm.
 
Intro.ppt
Intro.pptIntro.ppt
Intro.ppt
 
Intro_2.ppt
Intro_2.pptIntro_2.ppt
Intro_2.ppt
 
Intro.ppt
Intro.pptIntro.ppt
Intro.ppt
 
Bca2020 data structure and algorithm
Bca2020   data structure and algorithmBca2020   data structure and algorithm
Bca2020 data structure and algorithm
 
Bsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structureBsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structure
 
Data Structures and Algorithm - Module 1.pptx
Data Structures and Algorithm - Module 1.pptxData Structures and Algorithm - Module 1.pptx
Data Structures and Algorithm - Module 1.pptx
 

Recently uploaded

Top 10 Digital Marketing Trends in 2024 You Should Know
Top 10 Digital Marketing Trends in 2024 You Should KnowTop 10 Digital Marketing Trends in 2024 You Should Know
Top 10 Digital Marketing Trends in 2024 You Should Know
Markonik
 
Enhancing Security with Multi-Factor Authentication in Privileged Access Mana...
Enhancing Security with Multi-Factor Authentication in Privileged Access Mana...Enhancing Security with Multi-Factor Authentication in Privileged Access Mana...
Enhancing Security with Multi-Factor Authentication in Privileged Access Mana...
Bert Blevins
 
10 Conversion Rate Optimization (CRO) Techniques to Boost Your Website’s Perf...
10 Conversion Rate Optimization (CRO) Techniques to Boost Your Website’s Perf...10 Conversion Rate Optimization (CRO) Techniques to Boost Your Website’s Perf...
10 Conversion Rate Optimization (CRO) Techniques to Boost Your Website’s Perf...
Web Inspire
 
Pigasus 2.0: FPGA‐Accelerated Intrusion Detection/Prevention System
Pigasus 2.0: FPGA‐Accelerated Intrusion Detection/Prevention SystemPigasus 2.0: FPGA‐Accelerated Intrusion Detection/Prevention System
Pigasus 2.0: FPGA‐Accelerated Intrusion Detection/Prevention System
lowkeyact
 
DocSplit Subsequent Implementation Activation.pptx
DocSplit Subsequent Implementation Activation.pptxDocSplit Subsequent Implementation Activation.pptx
DocSplit Subsequent Implementation Activation.pptx
AmitTuteja9
 
🔥Chennai Call Girls 🫱 8824825030 🫲 High Class Chennai Escorts Service Available
🔥Chennai Call Girls 🫱 8824825030 🫲 High Class Chennai Escorts Service Available🔥Chennai Call Girls 🫱 8824825030 🫲 High Class Chennai Escorts Service Available
🔥Chennai Call Girls 🫱 8824825030 🫲 High Class Chennai Escorts Service Available
manalishivani8
 
Measuring and Understanding the Route Origin Validation (ROV) in RPKI
Measuring and Understanding the Route Origin Validation (ROV) in RPKIMeasuring and Understanding the Route Origin Validation (ROV) in RPKI
Measuring and Understanding the Route Origin Validation (ROV) in RPKI
APNIC
 
Call Girls Dehradun 8824825030 Escort In Dehradun service 24X7
Call Girls Dehradun 8824825030 Escort In Dehradun service 24X7Call Girls Dehradun 8824825030 Escort In Dehradun service 24X7
Call Girls Dehradun 8824825030 Escort In Dehradun service 24X7
manalishivani8
 
一比一原版圣托马斯大学毕业证(UST毕业证书)学历如何办理
一比一原版圣托马斯大学毕业证(UST毕业证书)学历如何办理一比一原版圣托马斯大学毕业证(UST毕业证书)学历如何办理
一比一原版圣托马斯大学毕业证(UST毕业证书)学历如何办理
uqbyfm
 
一比一原版(uom学位证书)北安普顿大学毕业证如何办理
一比一原版(uom学位证书)北安普顿大学毕业证如何办理一比一原版(uom学位证书)北安普顿大学毕业证如何办理
一比一原版(uom学位证书)北安普顿大学毕业证如何办理
9nfobpgg
 
India Cyber Threat Report of 2024 with year
India Cyber Threat Report of 2024 with yearIndia Cyber Threat Report of 2024 with year
India Cyber Threat Report of 2024 with year
AkashKumar1733
 
Call Girls In Chennai 💯Call Us 🔝 8824825030 🔝Independent Chennai Escorts Serv...
Call Girls In Chennai 💯Call Us 🔝 8824825030 🔝Independent Chennai Escorts Serv...Call Girls In Chennai 💯Call Us 🔝 8824825030 🔝Independent Chennai Escorts Serv...
Call Girls In Chennai 💯Call Us 🔝 8824825030 🔝Independent Chennai Escorts Serv...
payalgupta2u
 
Top UI/UX Design Trends for 2024: What Business Owners Need to Know
Top UI/UX Design Trends for 2024: What Business Owners Need to KnowTop UI/UX Design Trends for 2024: What Business Owners Need to Know
Top UI/UX Design Trends for 2024: What Business Owners Need to Know
Onepixll
 
Unlimited Fun With Call Girls Hyderabad ✅ 7737669865 💘 FULL CASH PAYMENT
Unlimited Fun With Call Girls Hyderabad ✅ 7737669865 💘 FULL CASH PAYMENTUnlimited Fun With Call Girls Hyderabad ✅ 7737669865 💘 FULL CASH PAYMENT
Unlimited Fun With Call Girls Hyderabad ✅ 7737669865 💘 FULL CASH PAYMENT
keshavtiwari584
 
Unlimited Short Call Girls Mumbai ✅ 9833363713 FULL CASH PAYMENT
Unlimited Short Call Girls Mumbai ✅ 9833363713 FULL CASH PAYMENTUnlimited Short Call Girls Mumbai ✅ 9833363713 FULL CASH PAYMENT
Unlimited Short Call Girls Mumbai ✅ 9833363713 FULL CASH PAYMENT
rajesh344555
 
169+ Call Girls In Navi Mumbai | 9930245274 | Reliability Escort Service Near...
169+ Call Girls In Navi Mumbai | 9930245274 | Reliability Escort Service Near...169+ Call Girls In Navi Mumbai | 9930245274 | Reliability Escort Service Near...
169+ Call Girls In Navi Mumbai | 9930245274 | Reliability Escort Service Near...
tanichadda371 #v08
 
KubeCon & CloudNative Con 2024 Artificial Intelligent
KubeCon & CloudNative Con 2024 Artificial IntelligentKubeCon & CloudNative Con 2024 Artificial Intelligent
KubeCon & CloudNative Con 2024 Artificial Intelligent
Emre Gündoğdu
 
Unlimited Short Call Girls Navi Mumbai ✅ 9967824496 FULL CASH PAYMENT
Unlimited Short Call Girls Navi Mumbai ✅ 9967824496 FULL CASH PAYMENTUnlimited Short Call Girls Navi Mumbai ✅ 9967824496 FULL CASH PAYMENT
Unlimited Short Call Girls Navi Mumbai ✅ 9967824496 FULL CASH PAYMENT
rajesh344555
 
HistorySrSec2024 daahi sadhin sgg-25.pdf
HistorySrSec2024 daahi sadhin sgg-25.pdfHistorySrSec2024 daahi sadhin sgg-25.pdf
HistorySrSec2024 daahi sadhin sgg-25.pdf
AdiySgh
 
Call Girls Chennai 📲 8824825030 Chennai Escorts (Tamil Girls) service 24X7
Call Girls Chennai 📲 8824825030 Chennai Escorts (Tamil Girls) service 24X7Call Girls Chennai 📲 8824825030 Chennai Escorts (Tamil Girls) service 24X7
Call Girls Chennai 📲 8824825030 Chennai Escorts (Tamil Girls) service 24X7
vrvipin164
 

Recently uploaded (20)

Top 10 Digital Marketing Trends in 2024 You Should Know
Top 10 Digital Marketing Trends in 2024 You Should KnowTop 10 Digital Marketing Trends in 2024 You Should Know
Top 10 Digital Marketing Trends in 2024 You Should Know
 
Enhancing Security with Multi-Factor Authentication in Privileged Access Mana...
Enhancing Security with Multi-Factor Authentication in Privileged Access Mana...Enhancing Security with Multi-Factor Authentication in Privileged Access Mana...
Enhancing Security with Multi-Factor Authentication in Privileged Access Mana...
 
10 Conversion Rate Optimization (CRO) Techniques to Boost Your Website’s Perf...
10 Conversion Rate Optimization (CRO) Techniques to Boost Your Website’s Perf...10 Conversion Rate Optimization (CRO) Techniques to Boost Your Website’s Perf...
10 Conversion Rate Optimization (CRO) Techniques to Boost Your Website’s Perf...
 
Pigasus 2.0: FPGA‐Accelerated Intrusion Detection/Prevention System
Pigasus 2.0: FPGA‐Accelerated Intrusion Detection/Prevention SystemPigasus 2.0: FPGA‐Accelerated Intrusion Detection/Prevention System
Pigasus 2.0: FPGA‐Accelerated Intrusion Detection/Prevention System
 
DocSplit Subsequent Implementation Activation.pptx
DocSplit Subsequent Implementation Activation.pptxDocSplit Subsequent Implementation Activation.pptx
DocSplit Subsequent Implementation Activation.pptx
 
🔥Chennai Call Girls 🫱 8824825030 🫲 High Class Chennai Escorts Service Available
🔥Chennai Call Girls 🫱 8824825030 🫲 High Class Chennai Escorts Service Available🔥Chennai Call Girls 🫱 8824825030 🫲 High Class Chennai Escorts Service Available
🔥Chennai Call Girls 🫱 8824825030 🫲 High Class Chennai Escorts Service Available
 
Measuring and Understanding the Route Origin Validation (ROV) in RPKI
Measuring and Understanding the Route Origin Validation (ROV) in RPKIMeasuring and Understanding the Route Origin Validation (ROV) in RPKI
Measuring and Understanding the Route Origin Validation (ROV) in RPKI
 
Call Girls Dehradun 8824825030 Escort In Dehradun service 24X7
Call Girls Dehradun 8824825030 Escort In Dehradun service 24X7Call Girls Dehradun 8824825030 Escort In Dehradun service 24X7
Call Girls Dehradun 8824825030 Escort In Dehradun service 24X7
 
一比一原版圣托马斯大学毕业证(UST毕业证书)学历如何办理
一比一原版圣托马斯大学毕业证(UST毕业证书)学历如何办理一比一原版圣托马斯大学毕业证(UST毕业证书)学历如何办理
一比一原版圣托马斯大学毕业证(UST毕业证书)学历如何办理
 
一比一原版(uom学位证书)北安普顿大学毕业证如何办理
一比一原版(uom学位证书)北安普顿大学毕业证如何办理一比一原版(uom学位证书)北安普顿大学毕业证如何办理
一比一原版(uom学位证书)北安普顿大学毕业证如何办理
 
India Cyber Threat Report of 2024 with year
India Cyber Threat Report of 2024 with yearIndia Cyber Threat Report of 2024 with year
India Cyber Threat Report of 2024 with year
 
Call Girls In Chennai 💯Call Us 🔝 8824825030 🔝Independent Chennai Escorts Serv...
Call Girls In Chennai 💯Call Us 🔝 8824825030 🔝Independent Chennai Escorts Serv...Call Girls In Chennai 💯Call Us 🔝 8824825030 🔝Independent Chennai Escorts Serv...
Call Girls In Chennai 💯Call Us 🔝 8824825030 🔝Independent Chennai Escorts Serv...
 
Top UI/UX Design Trends for 2024: What Business Owners Need to Know
Top UI/UX Design Trends for 2024: What Business Owners Need to KnowTop UI/UX Design Trends for 2024: What Business Owners Need to Know
Top UI/UX Design Trends for 2024: What Business Owners Need to Know
 
Unlimited Fun With Call Girls Hyderabad ✅ 7737669865 💘 FULL CASH PAYMENT
Unlimited Fun With Call Girls Hyderabad ✅ 7737669865 💘 FULL CASH PAYMENTUnlimited Fun With Call Girls Hyderabad ✅ 7737669865 💘 FULL CASH PAYMENT
Unlimited Fun With Call Girls Hyderabad ✅ 7737669865 💘 FULL CASH PAYMENT
 
Unlimited Short Call Girls Mumbai ✅ 9833363713 FULL CASH PAYMENT
Unlimited Short Call Girls Mumbai ✅ 9833363713 FULL CASH PAYMENTUnlimited Short Call Girls Mumbai ✅ 9833363713 FULL CASH PAYMENT
Unlimited Short Call Girls Mumbai ✅ 9833363713 FULL CASH PAYMENT
 
169+ Call Girls In Navi Mumbai | 9930245274 | Reliability Escort Service Near...
169+ Call Girls In Navi Mumbai | 9930245274 | Reliability Escort Service Near...169+ Call Girls In Navi Mumbai | 9930245274 | Reliability Escort Service Near...
169+ Call Girls In Navi Mumbai | 9930245274 | Reliability Escort Service Near...
 
KubeCon & CloudNative Con 2024 Artificial Intelligent
KubeCon & CloudNative Con 2024 Artificial IntelligentKubeCon & CloudNative Con 2024 Artificial Intelligent
KubeCon & CloudNative Con 2024 Artificial Intelligent
 
Unlimited Short Call Girls Navi Mumbai ✅ 9967824496 FULL CASH PAYMENT
Unlimited Short Call Girls Navi Mumbai ✅ 9967824496 FULL CASH PAYMENTUnlimited Short Call Girls Navi Mumbai ✅ 9967824496 FULL CASH PAYMENT
Unlimited Short Call Girls Navi Mumbai ✅ 9967824496 FULL CASH PAYMENT
 
HistorySrSec2024 daahi sadhin sgg-25.pdf
HistorySrSec2024 daahi sadhin sgg-25.pdfHistorySrSec2024 daahi sadhin sgg-25.pdf
HistorySrSec2024 daahi sadhin sgg-25.pdf
 
Call Girls Chennai 📲 8824825030 Chennai Escorts (Tamil Girls) service 24X7
Call Girls Chennai 📲 8824825030 Chennai Escorts (Tamil Girls) service 24X7Call Girls Chennai 📲 8824825030 Chennai Escorts (Tamil Girls) service 24X7
Call Girls Chennai 📲 8824825030 Chennai Escorts (Tamil Girls) service 24X7
 

Lecture#1(Algorithmic Notations).ppt

  • 1. Lecture No.01 Data Structures and Algorithms Rabbia mahum, UET Taxila
  • 2. Grading Theory  Mid Term 25%  Final 50%  Programming Assignments 10%  Surprise Quiz's 05%  Project 10%
  • 3. Grading Lab  Mid Term 25%  Final 50%  Programming Project 20%  Presentation and viva voca 05%
  • 4. Acknowledgement This Lecture has been prepared from your Reference Course Book titled as “Data Structure” by Schaum Series. Other source includes tutorialpoint page and google pages 4
  • 5. What is Data Structures  Data Structures are the programmatic way of storing data so that data can be used efficiently.  Almost every enterprise application uses various types of data structures in one or the other way. 5
  • 6. Why to Learn Data Structure and Algorithms?  As applications are getting complex and data rich, there are three common problems that applications face now-a-days. 1. Data Search 2. Processor speed 3. Multiple requests 6
  • 7. Why to Learn Data Structure and Algorithms?  Data Search − Consider an inventory of 1 million(106) items of a store. If the application is to search an item, it has to search an item in 1 million(106) items every time slowing down the search. As data grows, search will become slower. 7
  • 8. Why to Learn Data Structure and Algorithms?  Processor speed − Processor speed although being very high, falls limited if the data grows to billion records.  Multiple requests − As thousands of users can search data simultaneously on a web server, even the fast server fails while searching the data. 8
  • 9. Why to Learn Data Structure and Algorithms?  To solve these mentioned problems, data structures come to rescue.  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. 9
  • 10. Data Structure: Foundation terms  Interface − Each data structure has an interface. Interface represents the set of operations that a data structure supports. An interface only provides the list of supported operations, type of parameters they can accept and return type of these operations. 10
  • 11. Data Structure: Foundation terms  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. 11
  • 12. Characteristics of a Data Structure 1. Correctness − Data structure implementation should implement its interface correctly. 2. Time Complexity − Running time or the execution time of operations of data structure must be as small as possible. 3. Space Complexity − Memory usage of a data structure operation should be as little as possible. 12
  • 13. What is an Algorithm?  The word algorithm comes from the name of a Persian author, Abu Ja’far Mohammed ibn Musa al Khowarizmi (c. 825 A.O.) who wrote a textbook on mathematics.  An examination of the latest edition of Webster's dictionary defines its meaning as "any special method of solving a certain kind of problem. 13
  • 14. Definition of “Algorithm”  An Algorithm, intuitively speaking, is a finite step-by-step list of well defined instructions for solving a particular problem.  An algorithm is a clearly specified set of simple instructions to be followed to solve a problem. 14
  • 15. Definition of “Algorithm”  Algorithms are generally created independent of underlying languages, i.e. an algorithm can be implemented in more than one programming language. 15
  • 16. Definition of “Algorithm”  From the data structure point of view, following are some important categories of algorithms − 1. Search − Algorithm to search an item in a data structure. 2. Sort − Algorithm to sort items in a certain order. 3. Insert − Algorithm to insert item in a data structure. 4. Update − Algorithm to update an existing item in a data structure. 5. Delete − Algorithm to delete an existing item from a data structure. 16
  • 17. Properties or Constraints  For example, each operation must be definite, meaning that it must be perfectly clear what should be done.  Directions such as "compute 5/0" or "add 6 or 7 to x" are not permitted because it is not clear what the result is or which of the two possibilities should be done. 17
  • 18. Properties or Constraints  Another important property each operation should have is that it be effective; each step must be such that it can, at least in principle, be done by a person using pencil and paper in a finite amount of time.  Arithmetic operations on integer is an effective while on some real numbers its not…… 18
  • 19. Properties or Constraints  An algorithm produces one or more outputs and may have zero or more inputs which are externally supplied.  Another important criterion we will assume about algorithms is that they terminate after a finite number of operations. 19
  • 20. Algorithmic Notations  In coming slides you will learn the format that is used to present algorithms throughout this course. This is best describes by means of an example.  Example: An array DATA of numerical values is in memory. We want to find the location LOC and the value MAX of the largest element of DATA. 20
  • 21. Algorithmic Notations  Initially begin with LOC = 1 and MAX = DATA [1]. Then compare MAX with each successive element DATA[K] of DATA.  If DATA[K] exceeds MAX then update LOC and MAX so that LOC = K and MAX = DATA [K].  The final values appearing in LOC and MAX give the location and value of the largest element of DATA. 21
  • 22. Algorithmic Notations: Example Largest Element in the Array Algorithm 2.1
  • 23. Algorithmic Notations: Example Largest Element in the Array Flow Chart
  • 24. Algorithmic Notations: The Solution of the Quadratic Equation
  • 25. Algorithmic Notations: The Solution of the Quadratic Equation  The quantity D = b2 – 4ac is called the discriminant of the equation. If D is negative, then there are no real solutions.  If D = 0, then there is only one (double) real solution , x = -b/2a  If D is positive, the formula gives the two distinct real solutions.
  • 26. Algorithmic Notations: The Solution of the Quadratic Equation Algorithm 2.3
  • 27. Algorithmic Notations: Linear Search  Suppose a linear array DATA contains n elements, and suppose a specific ITEM of information is given. We want either to find the location LOC of item in the array DATA, or to send some message, such as LOC = 0, to indicate that ITEM is not in the DATA.  The linear search algorithm solves this problem by comparing ITEM, one by one, with each element in DATA. That is we compare ITEM with DATA[1], DATA[2], and so on, until we find LOC such that ITEM = DATA [LOC]. Algorithm 2.4
  • 28. Algorithmic Notations: Linear Search Algorithm 2.4
  • 29. Algorithmic Notations: Binary Search  During each stage of binary search algorithm our search for ITEM is reduced to a segment of elements of DATA  The BEG and END denote respectively the beginning and end location of segment under consideration. Where BEG = 1 or LB and END = n or UB  The Algorithm compares ITEM with the middle element DATA[MID] of segment where MID is obtained by MID = INT (BEG + END ) /2
  • 30. Algorithmic Notations: Binary Search  If DATA [MID] = ITEM then search is successful and we set LOC = MID, otherwise a new segment of DATA is obtained as follow  A) If ITEM < DATA [MID] then ITEM can appear on left side of segment  DATA [BEG] , DATA [BEG+1] … DATA[MID -1] B) If ITEM > DATA [MID] then ITEM can appear in right half of the segment  DATA [MID] , DATA [MID+1] … DATA[END]
  • 31. Algorithmic Notations: Binary Search • If ITEM is not in DATA then eventually we obtain END < BEG • This condition signals that the search is unsuccessful, and in such case we assign LOC = NULL.
  • 32. Algorithmic Notations: Binary Search 1 2 3 4 5 6 7 8 9 10 11 12 13 11 22 30 33 40 44 55 60 66 77 80 88 99
  • 33. Algorithmic Notations: Linear Search Algorithm 2.4
  翻译: