19
9/4/18 1 Lecture 1 Introduction to Data Structures and Algorithms ECE 241 – Advanced Programming I Fall 2018 Mike Zink ECE 241 – Data Structures Fall 2018 © 2018 Mike Zink Overview 1 Introduction of data structures and algorithms Information about course

Lecture 1 Introduction to Data Structures and Algorithms 241 F18 Lecture 1.pdf• “The data structure requires 727 bytes.” • How to express memory requirements in a more meaningful

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lecture 1 Introduction to Data Structures and Algorithms 241 F18 Lecture 1.pdf• “The data structure requires 727 bytes.” • How to express memory requirements in a more meaningful

9/4/18

1

Lecture1IntroductiontoDataStructures

andAlgorithms

ECE241–AdvancedProgrammingIFall2018MikeZink

ECE 241 – Data Structures Fall 2018 © 2018 Mike Zink

Overview

1

• Introductionofdatastructuresandalgorithms• Informationaboutcourse

Page 2: Lecture 1 Introduction to Data Structures and Algorithms 241 F18 Lecture 1.pdf• “The data structure requires 727 bytes.” • How to express memory requirements in a more meaningful

9/4/18

2

ECE 241 – Data Structures Fall 2018 © 2018 Mike Zink

What is an algorithm?

• Well-defined computationalprocedure• Takessetofvaluesasinputandproducessetofvaluesasoutput

• Tooltosolvewelldefinedcomputationalproblem

ECE 241 – Data Structures Fall 2018 © 2018 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

Page 3: Lecture 1 Introduction to Data Structures and Algorithms 241 F18 Lecture 1.pdf• “The data structure requires 727 bytes.” • How to express memory requirements in a more meaningful

9/4/18

3

ECE 241 – Data Structures Fall 2018 © 2018 Mike Zink

A Data-centric View of the World

4

• Dataareimportantinmanydisciplines• DNAsequences, images,network traffic,sensorreadings,maps,customerprofiles,etc.

• PastECEfocus:processing• Computation atcore:processors, computers,etc.

• NewECEfocus:data• Dataatcore:datacenters,datasecurity,etc.

• Needstructuredapproachtohandlingdata

ECE 241 – Data Structures Fall 2018 © 2018 Mike Zink

What kind of problems are solved by algorithms?

5

• HumanGenomeProject• Internet:Routing,searches,security• Electroniccommerce• Commercialenterprises• …

Page 4: Lecture 1 Introduction to Data Structures and Algorithms 241 F18 Lecture 1.pdf• “The data structure requires 727 bytes.” • How to express memory requirements in a more meaningful

9/4/18

4

ECE 241 – Data Structures Fall 2018 © 2018 Mike Zink

Human Genome Project

6

• Completemappingandunderstandingofallthegenesofhumanbeings

• ~20,500humangenes• ~3billionchemicalbasepairsthatmakeuphumanDNA

• Requiresalgorithmstostoreandanalyze

ECE 241 – Data Structures Fall 2018 © 2018 Mike Zink

Internet

7

• Routingalgorithmsthatfindshortestpathandadapttochanges

• Searchenginesthatfindpageswithparticularinformation

• Encryptedcommunication• Queuemanagement

Page 5: Lecture 1 Introduction to Data Structures and Algorithms 241 F18 Lecture 1.pdf• “The data structure requires 727 bytes.” • How to express memory requirements in a more meaningful

9/4/18

5

ECE 241 – Data Structures Fall 2018 © 2018 Mike Zink

Electronic Commerce

8

• Adplacements• Recommendations: Netflix,Amazon,etc.• Hashingforauthentication• Electronictrading

ECE 241 – Data Structures Fall 2018 © 2018 Mike Zink

Manufacturing and Commercial Enterprises

9

• Allocationofscarceresources:• Assigningcrewstoflights• Routesforpackagedeliveries• Storageanddistribution ofgoods

Page 6: Lecture 1 Introduction to Data Structures and Algorithms 241 F18 Lecture 1.pdf• “The data structure requires 727 bytes.” • How to express memory requirements in a more meaningful

9/4/18

6

ECE 241 – Data Structures Fall 2018 © 2018 Mike Zink

Why Data Structures?

10

• Waytostoreandorganizedata• Facilitateaccessandmodificationofdata• Differentdatastructureshavestrengthsandweaknesses

• Bettersuitedforaspecificalgorithmthanothers

ECE 241 – Data Structures Fall 2018 © 2018 Mike Zink

Data Structures and Algorithms

11

• Datastructures• Representation andorganizationofdata

• Algorithms• Methods forimplementingoperations ondatastructures

• Datastructuresandalgorithmsarecloselyrelated

• Datastructures areoftentuned forcertainalgorithms

Page 7: Lecture 1 Introduction to Data Structures and Algorithms 241 F18 Lecture 1.pdf• “The data structure requires 727 bytes.” • How to express memory requirements in a more meaningful

9/4/18

7

ECE 241 – Data Structures Fall 2018 © 2018 Mike Zink

Big Data

12

• Extremely largevolumesofdata• Canbecomputationallyanalyzed

• InternetofThings• Socialmediacontent

• Requiresalgorithmsanddatastructurestoanalyze

ECE 241 – Data Structures Fall 2018 © 2018 Mike Zink

Artificial Intelligence

13

• Often”trained”onbigdatasets• Imagerecognition• Voicerecognition

• Reliesonalargesetofalgorithm,varyingincomplexity

• Linearregression• Statistics,probability

Page 8: Lecture 1 Introduction to Data Structures and Algorithms 241 F18 Lecture 1.pdf• “The data structure requires 727 bytes.” • How to express memory requirements in a more meaningful

9/4/18

8

ECE 241 – Data Structures Fall 2018 © 2018 Mike Zink

Complexity Problems

14

• Datasetscanbeverylarge• Operationsmaytakealotoftimeormemory

• Efficientimplementations canmakeabigdifference

• Examplesoflargedatasetsandsizes?

ECE 241 – Data Structures Fall 2018 © 2018 Mike Zink

• Example: Million Song Dataset

15

• http://labrosa.ee.columbia.edu/millionsong/• Datasetofsongs: title,artist,recordingyears,etc.

• Howwouldyoufigureout• Whichartisthasrecordedmostsongs?

• Whichsonghasbeen coveredthemosttimes?• Whatarethemostcommonwords inatitle?

• Whatarepotentialproblems?

Page 9: Lecture 1 Introduction to Data Structures and Algorithms 241 F18 Lecture 1.pdf• “The data structure requires 727 bytes.” • How to express memory requirements in a more meaningful

9/4/18

9

ECE 241 – Data Structures Fall 2018 © 2018 Mike Zink

What will you learn in the course?

16

• Howtothinkabout dataandoperations ondata

• Howtodesigndatastructures forefficientuse

• Howtodeterminetheefficiencyofalgorithms• Asetofcommondatastructures andalgorithmsfortypical

operations ondata(e.g.,searching,sorting,etc.)

• Advanced programmingtechniques (e.g.,recursion,etc.)

• Howto implementalargersoftwareprojectwithaprofessional IDE

ECE 241 – Data Structures Fall 2018 © 2018 Mike Zink

Python

17

• WewillusePython asprogramminglanguage• Datastructuresandalgorithmsareindependentofprogramming

language• Thisisnotaprogrammingcourse

• Wefocusonhigher levelissues• Youshouldalreadyhaveexperience withaprogramming

language(Python,Java,C/C++)• IDEusedinthiscourse:PyCharm

• Professionalenvironment

Page 10: Lecture 1 Introduction to Data Structures and Algorithms 241 F18 Lecture 1.pdf• “The data structure requires 727 bytes.” • How to express memory requirements in a more meaningful

9/4/18

10

ECE 241 – Data Structures Fall 2018 © 2018 Mike Zink

PyCharm

18

• IDEforPyhton• https://www.jetbrains.com/pycharm/• Veryimportanttobecomefamiliarwithtool!!• Seeintroslides forPyCharm (moreduringthisweek’sdiscussion)

ECE 241 – Data Structures Fall 2018 © 2018 Mike Zink

Course Organization

19

• Coursewebsite:http://www.ecs.umass.edu/ece241/

Page 11: Lecture 1 Introduction to Data Structures and Algorithms 241 F18 Lecture 1.pdf• “The data structure requires 727 bytes.” • How to express memory requirements in a more meaningful

9/4/18

11

ECE 241 – Data Structures Fall 2018 © 2018 Mike Zink

Course Events

20

• Eventstoattend• Lectures• Discussions

• Assignments• Homework• Projects

• Exams• 2examsduringsemester• 1finalexam

ECE 241 – Data Structures Fall 2018 © 2018 Mike Zink

Course Policy

21

• Readthesyllabus initsentirety!• Understandexpectations forthiscourse

• Deadlinesarepostedonwebsite• Noextensions forhomeworkorprojects

• Assignments andgradesmanagedthroughMoodle

• Nosharingofcode• Automatedcheckingofsubmissions

Page 12: Lecture 1 Introduction to Data Structures and Algorithms 241 F18 Lecture 1.pdf• “The data structure requires 727 bytes.” • How to express memory requirements in a more meaningful

9/4/18

12

ECE 241 – Data Structures Fall 2018 © 2018 Mike Zink

Office Hours

22

• TA’s:• Wednesdays4PM- 5:30PM• Fridays3PM- 4PM

• Prof.Zink:• Fridays10- 11PM

ECE 241 – Data Structures Fall 2018 © 2018 Mike Zink

Properties of Data Structures and Algorithms

23

Page 13: Lecture 1 Introduction to Data Structures and Algorithms 241 F18 Lecture 1.pdf• “The data structure requires 727 bytes.” • How to express memory requirements in a more meaningful

9/4/18

13

ECE 241 – Data Structures Fall 2018 © 2018 Mike Zink

Quality Measures for Data Structures

24

• Whatdoyouexpectfromagooddatastructure?

ECE 241 – Data Structures Fall 2018 © 2018 Mike Zink

Quality Metrics for Algorithms

25

• Whatdoyouexpectfroma“good”algorithm?

Page 14: Lecture 1 Introduction to Data Structures and Algorithms 241 F18 Lecture 1.pdf• “The data structure requires 727 bytes.” • How to express memory requirements in a more meaningful

9/4/18

14

Correctness

• Insomecasesabsolute• E.g.,what isthesumofallvalues inarray?

• Somealgorithmshavemultiplesolutions• Examples?

• Somealgorithmsmayhavesolutionswherecorrectness ishardtodefine• Examples?

26

Multiple solutions

• Datasetfornumberofwinsbypitcher(2011):• {(Halladay,21),(Jiminez,19),(Lester,19),(Price,19),(Sabathia,21),(Wainwright,20)}

• Whichpitcherhasmostwins?27

Page 15: Lecture 1 Introduction to Data Structures and Algorithms 241 F18 Lecture 1.pdf• “The data structure requires 727 bytes.” • How to express memory requirements in a more meaningful

9/4/18

15

Unclear “correctness”

• Makeimagesquare:

28

?

Running time performance

• “Thealgorithmfinishes in12seconds.”• Howtoexpressperformancemoreaccurately?

29

Page 16: Lecture 1 Introduction to Data Structures and Algorithms 241 F18 Lecture 1.pdf• “The data structure requires 727 bytes.” • How to express memory requirements in a more meaningful

9/4/18

16

Memory use performance

• “Thedatastructurerequires727bytes.”• Howtoexpressmemoryrequirements inamoremeaningfulway?

30

It all depends…

• Qualityofdatastructuredependsonoperation• Example:unsorted “pile”ofpapers

• Veryfastforaddingitem• Notveryfastforfindingitem

• Example:paperssortedby lastname• Slowerforaddingitem• Fasterforfindingitem(ifsearchisbylastname)• However:alsoslowifsearchisbyfirstname

31

Page 17: Lecture 1 Introduction to Data Structures and Algorithms 241 F18 Lecture 1.pdf• “The data structure requires 727 bytes.” • How to express memory requirements in a more meaningful

9/4/18

17

Data types

• Whataretypicaldatatypestostoreinformation?

32

Data types

• Commontypes• Numerictypes: integer,floatingpoint• Boolean• Texttypes: character,string• Composite types• References(“pointer”)

33

Page 18: Lecture 1 Introduction to Data Structures and Algorithms 241 F18 Lecture 1.pdf• “The data structure requires 727 bytes.” • How to express memory requirements in a more meaningful

9/4/18

18

Algorithms and data types• Manyalgorithmscanbeusedwithdifferentdatatypes

• Sortingofintegers• Sortingofstrings• Sortingofcompositetypes

• Mayrequiresmalladaptation incode• Differentcomparisonfunctions• Differentcodefor“movingdataaround”

• Whyisthispoint important?• Idonotwantyoutoleavethiscoursesaying:“Useless.Weonlylearnedhowtosortnumbers!”

34

Objects• Foralgorithmdiscussion,wecanthinkof“objects”inaverygeneralway

• Operationsonobjects• Creation(anddestruction)• Comparison

• Operationsonobjects indatastructures• Insertion• Deletion• Algorithm-specificoperations: search,sort,etc. 35

Page 19: Lecture 1 Introduction to Data Structures and Algorithms 241 F18 Lecture 1.pdf• “The data structure requires 727 bytes.” • How to express memory requirements in a more meaningful

9/4/18

19

ECE 241 – Data Structures Fall 2018 © 2018 Mike Zink

Next Steps

36

• Next lecture“AsymptoticNotation andMergeSort”onThursday

• Firstdiscussion alsoonThursday• Willpost firstHWonThursday

ECE 241 – Data Structures Fall 2018 © 2018 Mike Zink37