Lecture 1 Introduction to Data Structures and Algorithms 241 F19 Lecture 1.pdf · Lecture 1...
Transcript of Lecture 1 Introduction to Data Structures and Algorithms 241 F19 Lecture 1.pdf · Lecture 1...
ECE 241 – Data Structures Fall 2019 © 2019 Mike Zink
Overview
1
• Introductionofdatastructuresandalgorithms• Informationaboutcourse
ECE 241 – Data Structures Fall 2019 © 2019 Mike Zink
What is an algorithm?
• Well-defined computationalprocedure• Takessetofvaluesasinputandproduces setofvaluesasoutput
• Tooltosolvewelldefined computationalproblem
ECE 241 – Data Structures Fall 2019 © 2019 Mike Zink
Algorithm example: Sorting numbers
3
• Input: Asequence ofnnumbers: <a1, a2,…, an>• Output:Apermutation(reordering)<a’1,a’2,…,a’n>ofinputsequence suchthata’1 <=a’2 <=… <=a’n
• Input:<31,41,59,26,41,58>Output:<26,31,41,41,58,59>
• Sincesortingisessential, alargenumberofsortingalgorithmsexist
ECE 241 – Data Structures Fall 2019 © 2019 Mike Zink
A Data-centric View of the World
4
• Dataareimportantinmanydisciplines• DNAsequences, images,networktraffic,sensorreadings,maps,customerprofiles,etc.
• PastECEfocus:processing• Computationatcore:processors,computers,etc.
• NewECEfocus:data• Dataatcore:datacenters,datasecurity,etc.
• Needstructuredapproachtohandlingdata
ECE 241 – Data Structures Fall 2019 © 2019 Mike Zink
What kind of problems are solved by algorithms?
5
• HumanGenomeProject• Internet:Routing,searches, security• Electroniccommerce• Commercial enterprises• …
ECE 241 – Data Structures Fall 2019 © 2019 Mike Zink
Human Genome Project
6
• Completemappingandunderstanding ofallthegenesofhumanbeings
• ~20,500humangenes• ~3billionchemicalbasepairsthatmakeuphumanDNA
• Requiresalgorithmstostoreandanalyze
ECE 241 – Data Structures Fall 2019 © 2019 Mike Zink
Internet
7
• Routingalgorithmsthatfindshortestpathandadapttochanges
• Searchenginesthatfindpageswithparticularinformation
• Encrypted communication• Queuemanagement
ECE 241 – Data Structures Fall 2019 © 2019 Mike Zink
Electronic Commerce
8
• Adplacements• Recommendations: Netflix,Amazon,etc.• Hashingforauthentication• Electronictrading
ECE 241 – Data Structures Fall 2019 © 2019 Mike Zink
Manufacturing and Commercial Enterprises
9
• Allocationofscarceresources:• Assigningcrewstoflights• Routesforpackagedeliveries• Storageanddistributionofgoods
ECE 241 – Data Structures Fall 2019 © 2019 Mike Zink
Why Data Structures?
10
• Waytostoreandorganizedata• Facilitateaccessandmodificationofdata• Differentdatastructureshavestrengthsandweaknesses
• Bettersuitedforaspecificalgorithmthanothers
ECE 241 – Data Structures Fall 2019 © 2019 Mike Zink
Data Structures and Algorithms
11
• Datastructures• Representationandorganizationofdata
• Algorithms• Methodsforimplementingoperationsondatastructures
• Datastructuresandalgorithmsarecloselyrelated
• Datastructuresareoftentunedforcertainalgorithms
ECE 241 – Data Structures Fall 2019 © 2019 Mike Zink
Big Data
12
• Extremely largevolumesofdata• Canbecomputationallyanalyzed
• InternetofThings• Socialmediacontent
• Requiresalgorithmsanddatastructures toanalyze
ECE 241 – Data Structures Fall 2019 © 2019 Mike Zink
Artificial Intelligence
13
• Often”trained”onbigdatasets• Imagerecognition• Voicerecognition
• Reliesonalargesetofalgorithm,varyingincomplexity
• Linearregression• Statistics,probability
ECE 241 – Data Structures Fall 2019 © 2019 Mike Zink
Complexity Problems
14
• Datasetscanbevery large• Operationsmaytakealotoftimeormemory
• Efficientimplementationscanmakeabigdifference
• Examplesoflargedatasetsandsizes?
ECE 241 – Data Structures Fall 2019 © 2019 Mike Zink
• Example: Million Song Dataset
15
• http://labrosa.ee.columbia.edu/millionsong/• Datasetofsongs:title,artist,recordingyears,etc.
• Howwouldyoufigureout• Whichartisthasrecordedmostsongs?• Whichsonghasbeencoveredthemosttimes?
• Whatarethemostcommonwordsinatitle?
• Whatarepotentialproblems?
ECE 241 – Data Structures Fall 2019 © 2019 Mike Zink
What will you learn in the course?
16
• Howtothinkaboutdataandoperationsondata
• Howtodesigndatastructuresforefficientuse
• Howtodeterminetheefficiencyofalgorithms• Asetofcommondatastructuresandalgorithmsfortypical
operationsondata(e.g.,searching,sorting,etc.)
• Advancedprogrammingtechniques(e.g.,recursion,etc.)
• HowtoimplementalargersoftwareprojectwithaprofessionalIDE
ECE 241 – Data Structures Fall 2019 © 2019 Mike Zink
Python
17
• WewillusePythonasprogramminglanguage• Datastructuresandalgorithmsareindependentofprogramming
language• Thisisnotabasicprogrammingcourse
• Wefocusonhigherlevel issues• Youshouldalreadyhaveexperiencewithaprogramming
language(Python,Java,C/C++)• IDEusedinthiscourse:PyCharm
• Professional environment
ECE 241 – Data Structures Fall 2019 © 2019 Mike Zink
PyCharm
18
• IDEforPyhton• https://www.jetbrains.com/pycharm/• Veryimportanttobecome familiarwithtool!!• SeeintroslidesforPyCharm (moreduringthisweek’sdiscussion)
ECE 241 – Data Structures Fall 2019 © 2019 Mike Zink
Course Organization
19
• Coursewebsite:http://www.ecs.umass.edu/ece241/
ECE 241 – Data Structures Fall 2019 © 2019 Mike Zink
Course Events
20
• Eventstoattend• Lectures• Discussions
• Assignments• Homework• Projects
• Exams• 2examsduringsemester• 1finalexam
ECE 241 – Data Structures Fall 2019 © 2019 Mike Zink
Course Policy
21
• Readthesyllabus initsentirety!• Understandexpectations forthiscourse
• Deadlinesarepostedonwebsite• Noextensions forhomeworkorprojects
• AssignmentsandgradesmanagedthroughMoodle
• Nosharingofcode• Automatedcheckingofsubmissions
ECE 241 – Data Structures Fall 2019 © 2019 Mike Zink
Office Hours
22
• TA’s:• Tuesday’s 4PM- 5:30PM• Wednesday’s 3PM- 4PM
• Prof.Zink:• Friday’s9- 11PM
ECE 241 – Data Structures Fall 2019 © 2019 Mike Zink
Properties of Data Structures and Algorithms
23
ECE 241 – Data Structures Fall 2019 © 2019 Mike Zink
Quality Measures for Data Structures
24
• Whatdoyouexpectfromagooddatastructure?
ECE 241 – Data Structures Fall 2019 © 2019 Mike Zink
Quality Metrics for Algorithms
25
• Whatdoyouexpectfroma“good”algorithm?
Correctness
• Insomecasesabsolute• E.g.,whatisthesumofallvaluesinarray?
• Somealgorithmshavemultiplesolutions• Examples?
• Somealgorithmsmayhavesolutionswherecorrectness ishardtodefine• Examples?
26
Multiple solutions
• Datasetfornumberofwinsbypitcher(2011):• {(Halladay,21),(Jiminez,19),(Lester,19),(Price,19),(Sabathia,21),(Wainwright,20)}
• Whichpitcherhasmostwins?27
Running time performance
• “Thealgorithmfinishes in12seconds.”• Howtoexpressperformancemoreaccurately?
29
Memory use performance
• “Thedatastructurerequires727bytes.”• Howtoexpressmemoryrequirementsinamoremeaningfulway?
30
It all depends…
• Qualityofdatastructuredepends onoperation• Example:unsorted“pile”ofpapers
• Veryfastforaddingitem• Notveryfastforfindingitem
• Example:paperssortedbylastname• Slowerforaddingitem• Fasterforfindingitem(ifsearchisbylastname)• However:alsoslowifsearchisbyfirstname
31
Data types
• Common types• Numerictypes:integer,floatingpoint• Boolean• Texttypes:character,string• Compositetypes• References(“pointer”)
33
Algorithms and data types• Manyalgorithmscanbeusedwithdifferentdatatypes
• Sortingofintegers• Sortingofstrings• Sortingofcompositetypes
• Mayrequiresmalladaptation incode• Differentcomparisonfunctions• Differentcodefor“movingdataaround”
• Whyisthispointimportant?• Idonotwantyoutoleavethiscoursesaying:“Useless.Weonlylearnedhowtosortnumbers!”
34
Objects• Foralgorithmdiscussion, wecanthinkof“objects”inaverygeneralway
• Operationsonobjects• Creation(anddestruction)• Comparison
• Operationsonobjects indatastructures• Insertion• Deletion• Algorithm-specificoperations:search,sort,etc. 35
ECE 241 – Data Structures Fall 2019 © 2019 Mike Zink
Next Steps
36
• Nextlecture“AsymptoticNotationandMergeSort”onThursday
• FirstdiscussionalsoonThursday
• WillpostfirstHWonThursday