SlideShare ist ein Scribd-Unternehmen logo
1 von 30
Data Structures I (CPCS-204) 
Week # 1: Overview & Review
Course objectives 
 Be familiar with problem solving 
 Be able to develop (and implement) algorithms 
 Be able to trace algorithms 
 Be able to select appropriate data structures and 
algorithms for given problems
Course Outline 
 Fundamentals of data structures and algorithms 
 Static and dynamic data structures 
 Basic searching and sorting algorithms 
 Recursion 
 Abstract data types 
 Stacks and queues 
 Trees
Readings/references 
 Text Book: 
 Data Structures & Algorithms in JAVA (4th Edition), by M. Goodrich & 
R. Tamassia, JohnWiley & Sons, inc., 2006. 
 Additional Readings: 
 Data Structures and Problem Solving with JAVA (3rd Edition), by Mark 
AllenWeiss, AddisonWesley, 2006. 
 Lecture slides and handouts
Grading/Evaluation 
Exams = 60% 
First Exam = 15 
Second Exam = 15 
Final Exam = 30 
Lab/ Practical = 30% 
Participation = 05% 
Quizzes = 05%
What is data? 
 Data 
 A collection of facts from which conclusion may be 
drawn 
 e.g. Data: Temperature 35°C; Conclusion: It is hot. 
 Types of data 
 Textual: For example, your name (Muhammad) 
 Numeric: For example, your ID (090254) 
 Audio: For example, your voice 
 Video: For example, your voice and picture 
 (...)
What is data structure? 
 A particular way of storing and organizing 
data in a computer so that it can be used 
efficiently and effectively. 
 Data structure is the logical or mathematical 
model of a particular organization of data. 
 A group of data elements grouped together 
under one name. 
 For example, an array of integers
Array 
Linked List 
Tree 
Types of data structures 
Queue Stack 
There are many, but we named a few. We’ll learn these 
data structures in great detail!
The Need for Data Structures 
 Goal: to organize data 
 Criteria: to facilitate efficient 
 storage of data 
 retrieval of data 
 manipulation of data 
 Design Issue: 
 select and design appropriate data types 
(This is the main motivation to learn and understand data 
structures)
Data Structure Operations 
(Demonstrate using class room example!) 
 Traversing 
 Accessing each data element exactly once so that 
certain items in the data may be processed 
 Searching 
 Finding the location of the data element (key) in the 
structure 
 Insertion 
 Adding a new data element to the structure
Data Structure Operations (cont.) 
 Deletion 
 Removing a data element from the structure 
 Sorting 
 Arrange the data elements in a logical order 
(ascending/descending) 
 Merging 
 Combining data elements from two or more data 
structures into one
What is algorithm? 
 A finite set of instructions which accomplish a 
particular task 
 A method or process to solve a problem 
 Transforms input of a problem to output 
Algorithm = Input + Process + Output 
Algorithm development is an art – it needs practice, 
practice and only practice!
What is a good algorithm? 
 It must be correct 
 It must be finite (in terms of time and size) 
 It must terminate 
 It must be unambiguous 
 Which step is next? 
 It must be space and time efficient 
A program is an instance of an algorithm, 
written in some specific programming language
A simple algorithm 
 Problem: Find maximum of a, b, c 
 Algorithm 
 Input = a, b, c 
 Output = max 
 Process 
o Let max = a 
o If b > max then 
max = b 
o If c > max then 
max = c 
o Display max 
Order is very important!!!
Algorithm development: Basics 
 Clearly identify: 
 what output is required? 
 what is the input? 
 What steps are required to transform input into 
output 
o The most crucial bit 
o Needs problem solving skills 
o A problem can be solved in many different ways 
oWhich solution, amongst the different possible 
solutions is optimal?
How to express an algorithm? 
 A sequence of steps to solve a problem 
We need a way to express this sequence of steps 
 Natural language (NL) is an obvious choice, but not a 
good choice. Why? 
o NLs are notoriously ambiguous (unclear) 
 Programming language (PL) is another choice, but 
again not a good choice. Why? 
o Algorithm should be PL independent 
We need some balance 
oWe need PL independence 
oWe need clarity 
o Pseudo-code provides the right balance
What is pseudo-code? 
 Pseudo-code is a short hand way of describing a 
computer program 
 Rather than using the specific syntax of a 
computer language, more general wording is used 
 It is a mixture of NL and PL expressions, in a 
systematic way 
 Using pseudo-code, it is easier for a non-programmer 
to understand the general workings of 
the program
Pseudo-code: general guidelines 
 Use PLs constructs that are consistent with 
modern high level languages, e.g. C++, Java, ... 
 Use appropriate comments for clarity 
 Be simple and precise
Ingredients of Pseudo-code 
 Expressions 
 Standard mathematical symbols are used 
o Left arrow sign (←) as the assignment operator in 
assignment statements (equivalent to the = operator in Java) 
o Equal sign (=) as the equality relation in Boolean 
expressions (equivalent to the "= =" relation in Java) 
o For example 
Sum ← 0 
Sum ← Sum + 5 
What is the final value of sum?
Ingredients of Pseudo-code (cont.) 
 Decision structures (if-then-else logic) 
 if condition then true-actions [else false-actions] 
 We use indentation to indicate what actions should be 
included in the true-actions and false-actions 
 For example 
if marks > 50 then 
print “Congratulation, you are passed!” 
else 
print “Sorry, you are failed!” 
end if 
What will be the output if marks are equal to 75?
Ingredients of Pseudo-code (cont.) 
 Loops (Repetition) 
 Pre-condition loops 
o While loops 
• while condition do actions 
• We use indentation to indicate what actions should be included in 
the loop actions 
• For example 
while counter < 5 do 
print “Welcome to CS204!” 
counter ← counter + 1 
end while 
What will be the output if counter is initialised to 0, 7?
Ingredients of Pseudo-code (cont.) 
 Loops (Repetition) 
 Pre-condition loops 
o For loops 
• for variable-increment-definition do actions 
• For example 
for counter ← 0; counter < 5; counter ← counter + 2 do 
print “Welcome to CS204!” 
end for 
What will be the output?
Ingredients of Pseudo-code (cont.) 
 Loops (Repetition) 
 Post-condition loops 
o Do loops 
• do actions while condition 
• For example 
do 
print “Welcome to CS204!” 
counter ← counter + 1 
while counter < 5 
What will be the output, if counter was initialised to 10? 
The body of a post-condition loop must execute at least once
Ingredients of Pseudo-code (cont.) 
 Method declarations 
 Return_type method_name (parameter_list) method_body 
 For example 
integer sum ( integer num1, integer num2) 
start 
result ← num1 + num2 
end 
 Method calls 
 object.method (args) 
 For example 
mycalculator.sum(num1, num2)
Ingredients of Pseudo-code (cont.) 
 Method returns 
 return value 
 For example 
integer sum ( integer num1, integer num2) 
start 
result ← num1 + num2 
return result 
end
Ingredients of Pseudo-code (cont.) 
 Comments 
 /* Multiple line comments go here. */ 
 // Single line comments go here 
 Some people prefer braces {}, for comments 
 Arrays 
 A[i] represents the ith cell in the array A. 
 The cells of an n-celled array A are indexed from A[0] 
to A[n − 1] (consistent with Java).
Algorithm Design: Practice 
 Example 1: Determining even/odd number 
 A number divisible by 2 is considered an even 
number, while a number which is not divisible by 2 is 
considered an odd number. Write pseudo-code to 
display first N odd/even numbers. 
 Example 2: ComputingWeeklyWages 
 Gross pay depends on the pay rate and the number of 
hours worked per week. However, if you work more 
than 40 hours, you get paid time-and-a-half for all 
hours worked over 40. Write the pseudo-code to 
compute gross pay given pay rate and hours worked
Even/ Odd Numbers 
Input range 
for num←0; num<=range; num←num+1 do 
if num % 2 = 0 then 
print num is even 
else 
print num is odd 
endif 
endfor
Computing weekly wages 
Input hours_worked, pay_rate 
if hours_worked <= 40 then 
gross_pay ← pay_rate x hours_worked 
else 
basic_pay ← pay_rate x 40 
over_time ← hours_worked – 40 
over_time_pay ← 1.5 x pay_rate x over_time 
gross_pay ← basic_pay + over_time_pay 
endfor 
print gross_pay
Outlook 
Next week, we’ll discuss algorithm analysis

Weitere ähnliche Inhalte

Was ist angesagt?

Algorithm Complexity and Main Concepts
Algorithm Complexity and Main ConceptsAlgorithm Complexity and Main Concepts
Algorithm Complexity and Main ConceptsAdelina Ahadova
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithmsHoang Nguyen
 
DATA STRUCTURE AND ALGORITHM FULL NOTES
DATA STRUCTURE AND ALGORITHM FULL NOTESDATA STRUCTURE AND ALGORITHM FULL NOTES
DATA STRUCTURE AND ALGORITHM FULL NOTESAniruddha Paul
 
Lecture 4 asymptotic notations
Lecture 4   asymptotic notationsLecture 4   asymptotic notations
Lecture 4 asymptotic notationsjayavignesh86
 
Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Deepak John
 
Recursion - Algorithms and Data Structures
Recursion - Algorithms and Data StructuresRecursion - Algorithms and Data Structures
Recursion - Algorithms and Data StructuresPriyanka Rana
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithmsJulie Iskander
 
Algorithem complexity in data sructure
Algorithem complexity in data sructureAlgorithem complexity in data sructure
Algorithem complexity in data sructureKumar
 
Recursion | C++ | DSA
Recursion | C++ | DSARecursion | C++ | DSA
Recursion | C++ | DSASumit Pandey
 
Asymptotic Notation and Data Structures
Asymptotic Notation and Data StructuresAsymptotic Notation and Data Structures
Asymptotic Notation and Data StructuresAmrinder Arora
 
Lecture 5: Asymptotic analysis of algorithms
Lecture 5: Asymptotic analysis of algorithmsLecture 5: Asymptotic analysis of algorithms
Lecture 5: Asymptotic analysis of algorithmsVivek Bhargav
 
Data structure using c module 1
Data structure using c module 1Data structure using c module 1
Data structure using c module 1smruti sarangi
 
Module 01 Stack and Recursion
Module 01 Stack and RecursionModule 01 Stack and Recursion
Module 01 Stack and RecursionTushar B Kute
 
Design and Analysis of algorithms
Design and Analysis of algorithmsDesign and Analysis of algorithms
Design and Analysis of algorithmsDr. Rupa Ch
 

Was ist angesagt? (20)

Algorithm Complexity and Main Concepts
Algorithm Complexity and Main ConceptsAlgorithm Complexity and Main Concepts
Algorithm Complexity and Main Concepts
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
DATA STRUCTURE AND ALGORITHM FULL NOTES
DATA STRUCTURE AND ALGORITHM FULL NOTESDATA STRUCTURE AND ALGORITHM FULL NOTES
DATA STRUCTURE AND ALGORITHM FULL NOTES
 
Lecture 4 asymptotic notations
Lecture 4   asymptotic notationsLecture 4   asymptotic notations
Lecture 4 asymptotic notations
 
Chapter 4 ds
Chapter 4 dsChapter 4 ds
Chapter 4 ds
 
Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1
 
Recursion - Algorithms and Data Structures
Recursion - Algorithms and Data StructuresRecursion - Algorithms and Data Structures
Recursion - Algorithms and Data Structures
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
Algorithem complexity in data sructure
Algorithem complexity in data sructureAlgorithem complexity in data sructure
Algorithem complexity in data sructure
 
Recursion | C++ | DSA
Recursion | C++ | DSARecursion | C++ | DSA
Recursion | C++ | DSA
 
Big o notation
Big o notationBig o notation
Big o notation
 
Asymptotic Notation and Data Structures
Asymptotic Notation and Data StructuresAsymptotic Notation and Data Structures
Asymptotic Notation and Data Structures
 
Lecture 5: Asymptotic analysis of algorithms
Lecture 5: Asymptotic analysis of algorithmsLecture 5: Asymptotic analysis of algorithms
Lecture 5: Asymptotic analysis of algorithms
 
Data structure using c module 1
Data structure using c module 1Data structure using c module 1
Data structure using c module 1
 
Module 01 Stack and Recursion
Module 01 Stack and RecursionModule 01 Stack and Recursion
Module 01 Stack and Recursion
 
Complexity of Algorithm
Complexity of AlgorithmComplexity of Algorithm
Complexity of Algorithm
 
Searching Algorithms
Searching AlgorithmsSearching Algorithms
Searching Algorithms
 
Design and Analysis of algorithms
Design and Analysis of algorithmsDesign and Analysis of algorithms
Design and Analysis of algorithms
 
Data Structure and Algorithms
Data Structure and AlgorithmsData Structure and Algorithms
Data Structure and Algorithms
 
Design & Analysis Of Algorithm
Design & Analysis Of AlgorithmDesign & Analysis Of Algorithm
Design & Analysis Of Algorithm
 

Andere mochten auch

Data Mining Scoring Engine development process
Data Mining Scoring Engine development processData Mining Scoring Engine development process
Data Mining Scoring Engine development processDylan Wan
 
Datastructure notes
Datastructure notesDatastructure notes
Datastructure notesSrikanth
 
Introduction to Pseudocode
Introduction to PseudocodeIntroduction to Pseudocode
Introduction to PseudocodeDamian T. Gordon
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and FlowchartsDeva Singh
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURESbca2010
 

Andere mochten auch (6)

Ds intro
Ds introDs intro
Ds intro
 
Data Mining Scoring Engine development process
Data Mining Scoring Engine development processData Mining Scoring Engine development process
Data Mining Scoring Engine development process
 
Datastructure notes
Datastructure notesDatastructure notes
Datastructure notes
 
Introduction to Pseudocode
Introduction to PseudocodeIntroduction to Pseudocode
Introduction to Pseudocode
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
 

Ähnlich wie Data Structures- Part1 overview and review

lec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptlec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptSourabhPal46
 
lec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptlec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptMard Geer
 
Algorithm & data structure lec2
Algorithm & data structure lec2Algorithm & data structure lec2
Algorithm & data structure lec2Abdul Khan
 
Intro to DSAA.ppt
Intro to DSAA.pptIntro to DSAA.ppt
Intro to DSAA.pptjumar dimas
 
DA lecture 3.pptx
DA lecture 3.pptxDA lecture 3.pptx
DA lecture 3.pptxSayanSen36
 
Lecture 01-2.ppt
Lecture 01-2.pptLecture 01-2.ppt
Lecture 01-2.pptRaoHamza24
 
Design and Analysis of Algorithm ppt for unit one
Design and Analysis of Algorithm ppt for unit oneDesign and Analysis of Algorithm ppt for unit one
Design and Analysis of Algorithm ppt for unit onessuserb7c8b8
 
Base sas interview questions
Base sas interview questionsBase sas interview questions
Base sas interview questionsDr P Deepak
 
Data structure and algorithm.
Data structure and algorithm. Data structure and algorithm.
Data structure and algorithm. Abdul salam
 
9 big o-notation
9 big o-notation9 big o-notation
9 big o-notationirdginfo
 
DAA-Unit1.pptx
DAA-Unit1.pptxDAA-Unit1.pptx
DAA-Unit1.pptxNishaS88
 
Base sas interview questions
Base sas interview questionsBase sas interview questions
Base sas interview questionsSunil0108
 
01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptx01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptxssuser586772
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithmlilyMalar1
 

Ähnlich wie Data Structures- Part1 overview and review (20)

lec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptlec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.ppt
 
lec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptlec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.ppt
 
Algorithm & data structure lec2
Algorithm & data structure lec2Algorithm & data structure lec2
Algorithm & data structure lec2
 
Intro to DSAA.ppt
Intro to DSAA.pptIntro to DSAA.ppt
Intro to DSAA.ppt
 
DA lecture 3.pptx
DA lecture 3.pptxDA lecture 3.pptx
DA lecture 3.pptx
 
chapter 1
chapter 1chapter 1
chapter 1
 
Lecture 01-2.ppt
Lecture 01-2.pptLecture 01-2.ppt
Lecture 01-2.ppt
 
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
 
Algorithm Design and Analysis
Algorithm Design and AnalysisAlgorithm Design and Analysis
Algorithm Design and Analysis
 
Design and Analysis of Algorithm ppt for unit one
Design and Analysis of Algorithm ppt for unit oneDesign and Analysis of Algorithm ppt for unit one
Design and Analysis of Algorithm ppt for unit one
 
Base sas interview questions
Base sas interview questionsBase sas interview questions
Base sas interview questions
 
Data structure and algorithm.
Data structure and algorithm. Data structure and algorithm.
Data structure and algorithm.
 
DSA
DSADSA
DSA
 
Data structure
Data structureData structure
Data structure
 
Unit 1.pptx
Unit 1.pptxUnit 1.pptx
Unit 1.pptx
 
9 big o-notation
9 big o-notation9 big o-notation
9 big o-notation
 
DAA-Unit1.pptx
DAA-Unit1.pptxDAA-Unit1.pptx
DAA-Unit1.pptx
 
Base sas interview questions
Base sas interview questionsBase sas interview questions
Base sas interview questions
 
01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptx01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptx
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithm
 

Mehr von Abdullah Al-hazmy

Data Structures- Part5 recursion
Data Structures- Part5 recursionData Structures- Part5 recursion
Data Structures- Part5 recursionAbdullah Al-hazmy
 
Data Structures- Part4 basic sorting algorithms
Data Structures- Part4 basic sorting algorithmsData Structures- Part4 basic sorting algorithms
Data Structures- Part4 basic sorting algorithmsAbdullah Al-hazmy
 
Data Structures- Part3 arrays and searching algorithms
Data Structures- Part3 arrays and searching algorithmsData Structures- Part3 arrays and searching algorithms
Data Structures- Part3 arrays and searching algorithmsAbdullah Al-hazmy
 
Data Structures- Part9 trees simplified
Data Structures- Part9 trees simplifiedData Structures- Part9 trees simplified
Data Structures- Part9 trees simplifiedAbdullah Al-hazmy
 
Data Structures- Part8 stacks and queues
Data Structures- Part8 stacks and queuesData Structures- Part8 stacks and queues
Data Structures- Part8 stacks and queuesAbdullah Al-hazmy
 
Data Structures- Part7 linked lists
Data Structures- Part7 linked listsData Structures- Part7 linked lists
Data Structures- Part7 linked listsAbdullah Al-hazmy
 

Mehr von Abdullah Al-hazmy (6)

Data Structures- Part5 recursion
Data Structures- Part5 recursionData Structures- Part5 recursion
Data Structures- Part5 recursion
 
Data Structures- Part4 basic sorting algorithms
Data Structures- Part4 basic sorting algorithmsData Structures- Part4 basic sorting algorithms
Data Structures- Part4 basic sorting algorithms
 
Data Structures- Part3 arrays and searching algorithms
Data Structures- Part3 arrays and searching algorithmsData Structures- Part3 arrays and searching algorithms
Data Structures- Part3 arrays and searching algorithms
 
Data Structures- Part9 trees simplified
Data Structures- Part9 trees simplifiedData Structures- Part9 trees simplified
Data Structures- Part9 trees simplified
 
Data Structures- Part8 stacks and queues
Data Structures- Part8 stacks and queuesData Structures- Part8 stacks and queues
Data Structures- Part8 stacks and queues
 
Data Structures- Part7 linked lists
Data Structures- Part7 linked listsData Structures- Part7 linked lists
Data Structures- Part7 linked lists
 

Kürzlich hochgeladen

Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...KokoStevan
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfSanaAli374401
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 

Kürzlich hochgeladen (20)

Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 

Data Structures- Part1 overview and review

  • 1. Data Structures I (CPCS-204) Week # 1: Overview & Review
  • 2. Course objectives  Be familiar with problem solving  Be able to develop (and implement) algorithms  Be able to trace algorithms  Be able to select appropriate data structures and algorithms for given problems
  • 3. Course Outline  Fundamentals of data structures and algorithms  Static and dynamic data structures  Basic searching and sorting algorithms  Recursion  Abstract data types  Stacks and queues  Trees
  • 4. Readings/references  Text Book:  Data Structures & Algorithms in JAVA (4th Edition), by M. Goodrich & R. Tamassia, JohnWiley & Sons, inc., 2006.  Additional Readings:  Data Structures and Problem Solving with JAVA (3rd Edition), by Mark AllenWeiss, AddisonWesley, 2006.  Lecture slides and handouts
  • 5. Grading/Evaluation Exams = 60% First Exam = 15 Second Exam = 15 Final Exam = 30 Lab/ Practical = 30% Participation = 05% Quizzes = 05%
  • 6. What is data?  Data  A collection of facts from which conclusion may be drawn  e.g. Data: Temperature 35°C; Conclusion: It is hot.  Types of data  Textual: For example, your name (Muhammad)  Numeric: For example, your ID (090254)  Audio: For example, your voice  Video: For example, your voice and picture  (...)
  • 7. What is data structure?  A particular way of storing and organizing data in a computer so that it can be used efficiently and effectively.  Data structure is the logical or mathematical model of a particular organization of data.  A group of data elements grouped together under one name.  For example, an array of integers
  • 8. Array Linked List Tree Types of data structures Queue Stack There are many, but we named a few. We’ll learn these data structures in great detail!
  • 9. The Need for Data Structures  Goal: to organize data  Criteria: to facilitate efficient  storage of data  retrieval of data  manipulation of data  Design Issue:  select and design appropriate data types (This is the main motivation to learn and understand data structures)
  • 10. Data Structure Operations (Demonstrate using class room example!)  Traversing  Accessing each data element exactly once so that certain items in the data may be processed  Searching  Finding the location of the data element (key) in the structure  Insertion  Adding a new data element to the structure
  • 11. Data Structure Operations (cont.)  Deletion  Removing a data element from the structure  Sorting  Arrange the data elements in a logical order (ascending/descending)  Merging  Combining data elements from two or more data structures into one
  • 12. What is algorithm?  A finite set of instructions which accomplish a particular task  A method or process to solve a problem  Transforms input of a problem to output Algorithm = Input + Process + Output Algorithm development is an art – it needs practice, practice and only practice!
  • 13. What is a good algorithm?  It must be correct  It must be finite (in terms of time and size)  It must terminate  It must be unambiguous  Which step is next?  It must be space and time efficient A program is an instance of an algorithm, written in some specific programming language
  • 14. A simple algorithm  Problem: Find maximum of a, b, c  Algorithm  Input = a, b, c  Output = max  Process o Let max = a o If b > max then max = b o If c > max then max = c o Display max Order is very important!!!
  • 15. Algorithm development: Basics  Clearly identify:  what output is required?  what is the input?  What steps are required to transform input into output o The most crucial bit o Needs problem solving skills o A problem can be solved in many different ways oWhich solution, amongst the different possible solutions is optimal?
  • 16. How to express an algorithm?  A sequence of steps to solve a problem We need a way to express this sequence of steps  Natural language (NL) is an obvious choice, but not a good choice. Why? o NLs are notoriously ambiguous (unclear)  Programming language (PL) is another choice, but again not a good choice. Why? o Algorithm should be PL independent We need some balance oWe need PL independence oWe need clarity o Pseudo-code provides the right balance
  • 17. What is pseudo-code?  Pseudo-code is a short hand way of describing a computer program  Rather than using the specific syntax of a computer language, more general wording is used  It is a mixture of NL and PL expressions, in a systematic way  Using pseudo-code, it is easier for a non-programmer to understand the general workings of the program
  • 18. Pseudo-code: general guidelines  Use PLs constructs that are consistent with modern high level languages, e.g. C++, Java, ...  Use appropriate comments for clarity  Be simple and precise
  • 19. Ingredients of Pseudo-code  Expressions  Standard mathematical symbols are used o Left arrow sign (←) as the assignment operator in assignment statements (equivalent to the = operator in Java) o Equal sign (=) as the equality relation in Boolean expressions (equivalent to the "= =" relation in Java) o For example Sum ← 0 Sum ← Sum + 5 What is the final value of sum?
  • 20. Ingredients of Pseudo-code (cont.)  Decision structures (if-then-else logic)  if condition then true-actions [else false-actions]  We use indentation to indicate what actions should be included in the true-actions and false-actions  For example if marks > 50 then print “Congratulation, you are passed!” else print “Sorry, you are failed!” end if What will be the output if marks are equal to 75?
  • 21. Ingredients of Pseudo-code (cont.)  Loops (Repetition)  Pre-condition loops o While loops • while condition do actions • We use indentation to indicate what actions should be included in the loop actions • For example while counter < 5 do print “Welcome to CS204!” counter ← counter + 1 end while What will be the output if counter is initialised to 0, 7?
  • 22. Ingredients of Pseudo-code (cont.)  Loops (Repetition)  Pre-condition loops o For loops • for variable-increment-definition do actions • For example for counter ← 0; counter < 5; counter ← counter + 2 do print “Welcome to CS204!” end for What will be the output?
  • 23. Ingredients of Pseudo-code (cont.)  Loops (Repetition)  Post-condition loops o Do loops • do actions while condition • For example do print “Welcome to CS204!” counter ← counter + 1 while counter < 5 What will be the output, if counter was initialised to 10? The body of a post-condition loop must execute at least once
  • 24. Ingredients of Pseudo-code (cont.)  Method declarations  Return_type method_name (parameter_list) method_body  For example integer sum ( integer num1, integer num2) start result ← num1 + num2 end  Method calls  object.method (args)  For example mycalculator.sum(num1, num2)
  • 25. Ingredients of Pseudo-code (cont.)  Method returns  return value  For example integer sum ( integer num1, integer num2) start result ← num1 + num2 return result end
  • 26. Ingredients of Pseudo-code (cont.)  Comments  /* Multiple line comments go here. */  // Single line comments go here  Some people prefer braces {}, for comments  Arrays  A[i] represents the ith cell in the array A.  The cells of an n-celled array A are indexed from A[0] to A[n − 1] (consistent with Java).
  • 27. Algorithm Design: Practice  Example 1: Determining even/odd number  A number divisible by 2 is considered an even number, while a number which is not divisible by 2 is considered an odd number. Write pseudo-code to display first N odd/even numbers.  Example 2: ComputingWeeklyWages  Gross pay depends on the pay rate and the number of hours worked per week. However, if you work more than 40 hours, you get paid time-and-a-half for all hours worked over 40. Write the pseudo-code to compute gross pay given pay rate and hours worked
  • 28. Even/ Odd Numbers Input range for num←0; num<=range; num←num+1 do if num % 2 = 0 then print num is even else print num is odd endif endfor
  • 29. Computing weekly wages Input hours_worked, pay_rate if hours_worked <= 40 then gross_pay ← pay_rate x hours_worked else basic_pay ← pay_rate x 40 over_time ← hours_worked – 40 over_time_pay ← 1.5 x pay_rate x over_time gross_pay ← basic_pay + over_time_pay endfor print gross_pay
  • 30. Outlook Next week, we’ll discuss algorithm analysis