[PDF] [PDF] Advanced Programming and Algorithms - Chris Baldassano

Simple examples ▷ How to find where a particular term is defined in a book? ▷ Algorithm 1: Open to random pages to find the definition ▷ Valid algorithm, will 



Previous PDF Next PDF





[PDF] Advanced Programming Concepts and Skills - Oracle Help Center

This guide provides overviews, illustrations, procedures, and examples for release A7 3 of J D Edwards software Forms (screens and windows) shown are only 



[PDF] Advanced C - Department of Computer Engineering Sharif

For example, a printing code of 92-1 shows that the first printing of the book occurred in 1992 Composed in AGaramond and MCPdigital by Prentice Hall 



[PDF] C Programming Tutorial

C Hello World Example This chapter describes the basic details about C programming language, how it emerged, what are strengths of C and why we should 



[PDF] A Complete Guide to Programming in C++ - LMPT

language from scratch, and for both novice and advanced C++ programmers The short programming example on the opposite page demonstrates two of the 



[PDF] Advanced Java Programming

Where it makes sense, the same example will be presented using Java 7 syntax as well as Java 8 one 1 2 Instance Construction Java is object-oriented 



[PDF] Advanced Programming and Algorithms - Chris Baldassano

Simple examples ▷ How to find where a particular term is defined in a book? ▷ Algorithm 1: Open to random pages to find the definition ▷ Valid algorithm, will 



Programming in Ada : examples - KiltHub - Carnegie Mellon University

Ada [8] is a language containing many advanced features not available previously in any widely-used programming language These features include: data 



Advanced Topics in C

Advanced Topics in C: Core Concepts in Data Structures The code for the examples shown in this book is available on the Apress web site, www apress com



[PDF] Practical C++ Programming - MIMUW

Advanced programming techniques are explored in Part IV: Advanced is used for programs and the elements of a program and in examples to show the 



[PDF] Advanced programming language design - Department of

16 déc 2013 · Advanced programming languages / Raphael A Finkel p cm ters include an extended example from a particular language to set the stage

[PDF] advanced c programming ppt

[PDF] advanced c# tutorial

[PDF] advanced c++ tutorial pdf

[PDF] advanced calculator app for android

[PDF] advanced cisco router configuration pdf

[PDF] advanced complex analysis pdf

[PDF] advanced computational methods in science and engineering pdf

[PDF] advanced concepts in java

[PDF] advanced css book

[PDF] advanced css tutorial with example pdf

[PDF] advanced css3 tutorial pdf free download

[PDF] advanced dance moves ballet

[PDF] advanced db2 sql queries

[PDF] advanced dos commands pdf

[PDF] advanced english class pdf

Advanced

Programming and

Algorithms

Dr. Baldassano

KX·V (OLPH (GXŃMPLRQ

About Me

XWent to college at Princeton

for Electrical Engineering

XPhD at Stanford

in Computer Science

XNow a research fellow at the

Princeton Neuroscience Institute

Goals of the class

XLearn about the most useful algorithms that power modern computing XLearn how to apply algorithms to solve new problems

XLearn how to develop and analyze new algorithms

Course website

XGo to www.chrisbaldassano.com, click on Teaching, POHQ ´$GYMQŃHG 3URJUMPPLQJ MQG $OJRULPOPVµ XHas my email address , schedule and assignments

Programming languages

X0RVP RI POLV ŃOMVV RLOO ÓXVP XVH ´pseudocodeµ MQG PMON about algorithms at a conceptual level

XFor homework assignments you can use any

SURJUMPPLQJ OMQJXMJH \RX·UH IMPLOLMU RLPO

XI will be using Python for solutions and demos, but the ŃRGH VORXOG NH XQGHUVPMQGMNOH HYHQ LI \RX GRQ·P NQRR

Python

What are algorithms and data

structures?

XAlgorithm: A procedure for solving a problem

XWe are especially interested in efficientalgorithms, that solve problems using as little time and/or resources as possible

XData structure: A way of organizing information

XIf we know the types of operations we want to do on the data, we can organize it in a way that makes these operations fast and/or easy

Simple examples

XHow to find where a particular term is defined in a book? XAlgorithm 1: Open to random pages to find the definition

XValid algorithm, will work eventually!

XBut very inefficient ²could revisit pages multiple times XAlgorithm 2: Start from beginning, go one page at a time to find definition XClose to the best we can do for finding a single word XAlgorithm 3: Go through entire book, create an index of the page number where every word occurs, then use this index to find term XSilly to do for one lookup, but this index makes all future lookups very fast

Data structures

XAll algorithms make use of data structures to keep track of computations in an efficient way XDifferent data structures make different types of operations fast

XExample: lists of numbers

XArray ²fast to read out number at any position, slow to insert new number X´ILQNHG OLVPµ ²fast to insert a new number, slow to read out number at any position XOften there is a tradeoff between memory and time XHI RH QHYHU POURR MQ\ LQIRUPMPLRQ MRM\ POHQ RH RRQ·P have to recomputeit, but it might take up lots of memory

Why study algorithms?

XAll datasets are getting bigger and bigger:

XInternet ²RHN VHMUŃO SMŃNHP URXPLQJ"

XScience ²JHQHPLŃV NUMLQ LPMJLQJ ŃOLPMPH PRGHOLQJ"

XComputers ²ŃLUŃXLP OM\RXP ILOH V\VPHPV"

XComputer graphics ²PRYLHV YLGHR JMPHV YLUPXMO UHMOLP\" XSecurity ²cell phones, e-ŃRPPHUŃH YRPLQJ PMŃOLQHV" XSocial networks ²UHŃRPPHQGMPLRQV QHRV IHHGV" XWe need efficient algorithms to design almost any modern computer system

Why study algorithms?

XTo become a more proficient programmer:

X´H RLOO LQ IMŃP ŃOMLP POMP POH GLIIHUHQŃH NHPRHHQ M NMG programmer and a good one is whether he considers his code or his data structures more important. Bad programmers worry about the code. Good programmers RRUU\ MNRXP GMPM VPUXŃPXUHV MQG POHLU UHOMPLRQVOLSVBµ ³

LinusTorvalds(creator of Linux)

X%HŃMXVH POH\·UH LQPHUHVPLQJ

X´)RU PH JUHMP MOJRULPOPV MUH POH SRHPU\ RI ŃRPSXPMPLRQB Just like verse, they can be terse, allusive, dense, and even mysterious. But once unlocked, they cast a brilliant QHR OLJOP RQ VRPH MVSHŃP RI ŃRPSXPLQJBµ ³Francis

Sullivan

Why study algorithms?

Why study algorithms?

XTo unlock the secrets of life and the universe:

X´FRPSXPHU PRGHOV PLUURULQJ UHMO OLIH OMYH NHŃRPH ŃUXŃLMO IRU PRVP MGYMQŃHV PMGH LQ ŃOHPLVPU\ PRGM\"B 7RGM\ POH computer is just as important a tool for chemists as the PHVP PXNHBµ ³Royal Swedish Academy of Sciences

XTo enable us to solve complex problems:

History of Algorithms

History of Algorithms

Algorithm examples

XGuessing game:

game

XRoute finding:

XGenerating app names:

XGenetic algorithm:

http://rednuht.org/genetic_walkers/

What makes an algorithm

good? XWant efficiency in time²produce an answer as quickly as possible XWant efficiency in memory²use as little RAM as possible XWant efficiency in implementation²the less complex the better XWant this to work on any dataset without hand-tuned conditions XWant algorithms that scale well with size of data XIf data gets 2x bigger, does algorithm require more than 2x as much time/space?

Measuring how an algorithm

scales

X´%LJ-2 QRPMPLRQµ

XO(log N) ²algorithm scales logarithmically with dataset size XO(N) ²algorithm scales linearly with dataset size (good) XO(N * log N) ²algorithm scales slightly worse that linearly XO(N2) ²algorithm scales quadraticallywith dataset size XO(2N) ²algorithm scales exponentially with dataset size

Measuring how an algorithm

scales

Example: Binary Search

XGiven a sorted list of numbers, find where a specific number appears

1 5 1012 14 19 20

XAt every step we can eliminate half the numbers

1 5 10 12 14 19 20

XSo a list twice as big takes only oneadditional step!

XRunning time is O(log N)

Example: Sum-3

XGiven a list of numbers, are there three that sum to 0? -10 5 -2 3 -9 -8 20 XEasy algorithm: try every possible combination of three numbers

XRunning time: O(N3)

XCan we do better?

Sum-3 Algorithm

XFirst sort numbers

-10 -9 -8 -2 3 5 20

X$VVXPH RH·OO XVH ILUVP QXPNHU

XTry pairing with first and last remaining numbers -10-9 -8 -2 3 5 20 XMove in from left and right, depending on whether sum is above or below zero -10-9 -8 -2 3 520 XIf the green numbers hit each other, try again with assuming that the second number is used -10 -9 -8 -2 3 5 20

Sum-3 Algorithm

XHQ POH RRUVP ŃMVH RH·OO OMYH PR PU\ MOO SRVVLNOH ´ILUVP

ŃORLŃHµ UHG QXPNHUV

XFor each of these, we might have to look at every other number

XRunning time: O(N2)

XIf there are 1000 numbers, this is 1000 times faster! XOne trick: we assumed sorting was fast! Turns out we can sort faster than O(N2), so we can ignore this for now

Sieve of Eratosthenes

sieve

WarmupIRU QH[P RHHN·V

class: sorting XPutting a list in order is a classic problem in computer science

X6LPSOHVP MOJRULPOP ´%XNNOHµ VRUP

XCompare every pair of adjacent elements

XIf they are out of order, swap them

XKeep making passes over the list until it is sorted

Bubble sort

Assignment

XImplement bubble sort in any language

XHow long does it take to sort 1,000 numbers? What about

10,000?

XEmail your code and answers to these two questions to me at chrisb@princeton.edu

XDue before next class

X[FYI: Assignments are also posted at chrisbaldassano.com]

Re-scheduling December 10th

class

XI will be away on December 10th

XWe can reschedule the class for December 7th(Mon), or

11th(Fri)

XPart of your assignment: Email me which of these days you would be availablequotesdbs_dbs8.pdfusesText_14