Inleiding Informatica, 2000-2001 College 4, H 4 – sheet nr. 117 October 2000 - 14:17 Basiscursus Informatica 98/991 Inleiding Informatica College 5 Brookshear.

Slides:



Advertisements
Verwante presentaties
Programmeren met Alice
Advertisements

Basiscursus Informatica SWI Theoriegedeelte Overzicht en H0 Richard Benjamins.
Datastructuren Quicksort
Hoofdstuk 8: Recursie.
Workshop creatief brainstormen
Practica Computerlinguistiek Tekst en uitleg:
Datastructuren Analyse van Algoritmen en O
Datastructuren Analyse van Algoritmen en O
‘Inleiding programmeren in Java’ SWI cursus: ‘Inleiding programmeren in Java’ 4e college Woe 19 januari 2000 drs. F. de Vries.
VBA en VBS Een introductie.
Tel de zwarte stippen!. Tel de zwarte stippen!
Hoofdstuk 6: Controle structuren
1 Datastructuren Sorteren: alleen of niet alleen vergelijkingen College 5.
1 Datastructuren Sorteren: alleen of niet alleen vergelijkingen (II) College 6.
Parallelle Algoritmen String matching. 1 Beter algoritme patroonanalyse Bottleneck in eenvoudig algoritme: WITNESS(j) (j = kandidaat in eerste i-blok)
Tegengestelden / Synoniemen
Stijn Van Wonterghem1 ALICE Een animatie opbouwen.
1 Datastructuren Skiplists. 2 Skiplists  Vrij eenvoudige datastructuur  “Makkelijker” dan gebalanceerde bomen  Kunnen hetzelfde als gebalanceerde bomen.
Tips (beoordelingscriteria finale versie ) Diederik, “Three Sins”: Diederik, “Three Sins”: In introductie er niet veel omheen draaien In introductie er.
Tussentoets Digitale Techniek. 1 november 2001, 11:00 tot 13:00 uur. Opmerkingen: 1. Als u een gemiddeld huiswerkcijfer hebt gehaald van zes (6) of hoger,
Hogeschool HZ Zeeland 19 augustus 2003augustus 2003 Data Structuren & Algoritmen Week 3.
Inleiding Informatica, College 6, H 6 – sheet nr. 117 October :27 Basiscursus Informatica 98/991 Inleiding Informatica College 7, Brookshear.
Inleiding Informatica, College 5, H 5- sheet nr. 117 October :19 Basiscursus Informatica 98/991 Inleiding Informatica College 6, Brookshear.
Basiscursus Informatica, College 8, H 8 1 Basiscursus Informatica 98/991 Basiscursus Informatica College 8, File Structures Brookshear H8 Richard.
Basiscursus Informatica, College 5, H 5 1 Basiscursus Informatica 98/991 Basiscursus Informatica College 5, Programming Languages Brookshear H5 Richard.
Basiscursus Informatica, College 6, H 6 1 Basiscursus Informatica 98/991 Basiscursus Informatica College 6, Software Engineering Brookshear H6 Bob.
Datastructuren Sorteren, zoeken en tijdsanalyse
Sorteeralgoritmen. Sorteren: aanpak 1 Hoe ga je een rij getallen sorteren met PC? Sorteren door selectie (= selection sort): Zoek de kleinste waarde Sorteer.
, 17h30Recursie 1 Inleiding tot recursie Karel Popelier.
Basiscursus Informatica, College 4, H 4 1 Basiscursus Informatica 98/991 Basiscursus Informatica College 4, Algoritmes Brookshear H4 Richard Benjamins.
Tel de zwarte stippen. Tel de zwarte stippen Lopen de horizontale lijnen evenwijdig of niet?
Deltion College Engels B1 Lezen [no. 001] can-do : 2 products compared.
Deltion College Engels B1 Gesprekken voeren [Edu/006] thema: Look, it says ‘No smoking’… can-do : kan minder routinematige zaken regelen © Anne Beeker.
CONTROLESTRUCTUREN (DEEL 1)
Hoofdstuk 3 - Conditionele logica
Nothing Is As It Seems Introduction Lesson. What are we going to do? - We gaan deze periode spreek, luister, lees en schrijflessen in een thema oefenen.
Deltion College Engels C1 Schrijven [Edu/007] thema: Mind twister or how to write an essay… can-do : kan heldere, goed gestructureerde uiteenzetting schrijven.
Nothing Is As It Seems Lesson 7 What’s the Story?.
T U Delft Parallel and Distributed Systems group PGS Fundamentele Informatica in345 Deel 2 College 6 Cees Witteveen.
Deltion College Engels B2 Lezen [Edu/003] thema: Topical News Lessons: The Onestop Magazine can-do: kan artikelen en rapporten begrijpen die gaan over.
Deltion College Engels B2 Spreken [Edu/001] thema: What’s in the news? can-do : kan verslag doen van een gebeurtenis en daarbij meningen met argumenten.
AWK A Pattern scanning and processing language made by Aho Weinberger Kernighan and explained by Albert Montijn.
Deltion College Engels B1 Spreken [Edu/001] thema: song texts can-do : kan een onderwerp dat mij interesseert op een redelijk vlotte manier beschrijven.
Deltion College Engels B2 Lezen[Edu/001] /subvaardigheid schrijven korte samenvattingen thema: Exotic news can-do : lezen om informatie op te doen - kan.
Deltion College Engels B2 Schrijven [Edu/005] thema: Writing a hand-out can-do: kan een begrijpelijke samenvatting schrijven © Anne Beeker Alle rechten.
Deltion College Engels B2 Gesprekken voeren [Edu/007] thema: ‘With this mobile you can…’ can-do : kan op betrouwbare wijze gedetailleerde informatie doorgeven.
Methods of Development #2: Logistiek. Conceptfase Pre-productiefase Productiefase Post-productiefase.
Deltion College Engels B2 (telefoon)gesprekken voeren[Edu/002] /subvaardigheid lezen/schrijven thema: I am so sorry for you… can-do : kan medeleven betuigen.
1 PI1 week 9 Complexiteit Sorteren Zoeken. 2 Complexiteit van algoritmen Hoeveel werk kost het uitvoeren van een algoritme (efficiëntie)? –tel het aantal.
GegevensAnalyse Les 2: Bouwstenen en bouwen. CUSTOMER: The Entity Class and Two Entity Instances.
Hoorcollege 1: efficiëntie en complexiteitsontwikkeling.
Hoorcollege 1: efficiëntie en complexiteitsontwikkeling.
Welkom! maandag 16 November 2015 Les B-2.
Minimum Opspannende Bomen Algoritmiek. 2 Inhoud Het minimum opspannende bomen probleem Een principe om een minimum opspannende boom te laten groeien Twee.
Doorzoeken van grafen Algoritmiek. Algoritmiek: Divide & Conquer2 Vandaag Methoden om door grafen te wandelen –Depth First Search –Breadth First Search.
Divide & Conquer: Verdeel en Heers vervolg Algoritmiek.
The Research Process: the first steps to start your reseach project. Graduation Preparation
Programmeren.
Key Process Indicator Sonja de Bruin
Minimum Opspannende Bomen
Dictionary Skills!?.
Programmeren woensdag 4 oktober 2017.
De taaltaak
Modderdorp UNPLUGGED Bron: csunplugged.org.
Tel de zwarte stippen!. Tel de zwarte stippen!
Modderdorp UNPLUGGED Bron: csunplugged.org.
English 23 April 2018.
Tel de zwarte stippen!. Tel de zwarte stippen!
Software Development fundamentals
Python – For loop + strings
Transcript van de presentatie:

Inleiding Informatica, College 4, H 4 – sheet nr. 117 October :17 Basiscursus Informatica 98/991 Inleiding Informatica College 5 Brookshear hoofdstuk 4: Algoritmes

Inleiding Informatica, College 4, H 4 – sheet nr. 217 October :17 Basiscursus Informatica 98/992 Overzicht college 5 n Notie van algoritme n Representatie van algoritmes n “Ontdekking” van algoritmes n Iteratieve structuren n Recursieve structuren n Efficientie en correctie

Inleiding Informatica, College 4, H 4 – sheet nr. 317 October :17 Basiscursus Informatica 98/993 Algoritme n Informeel ä Verzameling stappen die definieert hoe een taak wordt uitgevoerd n Formeel ä Verzameling geordende, niet-ambigue, uitvoerbare stappen, die een eindig proces definieren ä Is onderstaande een programma? - maak een lijst van alle positieve integers - zet lijst in afnemende volgorde (hoog naar laag) - neem eerste integer van lijst

Inleiding Informatica, College 4, H 4 – sheet nr. 417 October :17 Basiscursus Informatica 98/994 Termen n Er is een verschil tussen: programma, algoritme en proces: ä Programma is de representatie van algoritme ä Proces is de aktiviteit van de executie van een programma

Inleiding Informatica, College 4, H 4 – sheet nr. 517 October :17 Basiscursus Informatica 98/995 Overzicht college 5 n Notie van algoritme n Representatie van algoritmes n “Ontdekking” van algoritmes n Iteratieve structuren n Recursieve structuren n Efficientie en correctie

Inleiding Informatica, College 4, H 4 – sheet nr. 617 October :17 Basiscursus Informatica 98/996 Representatie: de taal n Probleem van natuurlijke taal ä ambiguiteit ä mate van detail is niet uniform ä bv. ‘Visiting grandchildren can be nerve-racking’ ä bv. ‘Ik zag een grote hond en kat’ n Instructies in beeldvorm ä origami: syntax en semantiek ä Lego

Inleiding Informatica, College 4, H 4 – sheet nr. 717 October :17 Basiscursus Informatica 98/997 Programmeertaal n Goed gedefinieerde bouwstenen: primitieven ä syntax (symbool) ä semantiek (wat het betekent) ä formele regels hoe primitieven te combineren n Op het nivo van machine-instructies? n Abstract hulpmiddel ä onafhankelijk van specifieke computer ä denken op hoger nivo (minder detail)

Inleiding Informatica, College 4, H 4 – sheet nr. 817 October :17 Basiscursus Informatica 98/998 Pseudocode n Informele notatie tijdens programma- ontwikkeling, gemakkelijk om te zetten naar de programmeertaal ä programmeertal van belang? (Prolog, Java?) n Terugkerende patronen in primitieven vatten ä If/Then/Else en If/Then ä While/Do ä Assign

Inleiding Informatica, College 4, H 4 – sheet nr. 917 October :17 Basiscursus Informatica 98/999 If/Then/Else n Neem je jas mee als het regent, en anders je zonnebril: If (conditie) dan (actie) ä If (regent) Then (jas mee) Else (zonnebril mee) n Afhankelijk of het een schrikkeljaar is, deel het totaal door 366 of 365, respectievelijk ä If (schrikkeljaar) Then (deel totaal door 366) Else (deel totaal door 365) n Als ik geld heb, ga ik op reis ä If (geld) Then (ik op reis)

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9910 While/Do n Zolang er nog kaartjes zijn, ga door met de verkoop: While (conditie) Do (actie) ä While (er zijn kaartjes) Do (verkoop) Assignment n Assign name the value expression ä assign Prijs the value Kosten + Winstmarge

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9911 Inspringen n If (item is belastbaar) Then [( If (prijs > limiet) Then (betaal x) Else (betaal y)] Else (betaal z)

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9912 Procedures n Aanroepen van programma’s binnen een programma: ä subprogramma, module, functie, procedure n Procedure naam (argumentenlijst) n Procedure groet (Persoon) assign Teller the value 3; while Teller > 0 do (print bericht “hallo Persoon” en assign Teller the value Teller - 1)

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9913 Uniforme taal: OO n UML =Unified Modelling Language n object oriëntatie = zelfde concepten voor traject van analyse, ontwerp en implementatie: ä klassen, objecten, ä methoden, variabelen, ä verzoek, boodschap, ä overerving,

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9914 Overzicht college 5 n Notie van algoritme n Representatie van algoritmes n “Ontdekking” van algoritmes n Iteratieve structuren n Recursieve structuren n Efficientie en correctie

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9915 Programmaontwikkeling n Tot nu toe: representatie van een algoritme n Vraag: waar komt het algoritme vandaan? n Polya: theorie van probleemoplossen: ä begrijpen - ontwerpen - uitvoeren - evalueren n Creatief proces ä soms “weet” je de oplossing opeens als je al niet meer met probleem bezig bent ä “getting a foot in the door”

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9916 Waar beginnen? n Achterwaarts werken vanuit de gevraagde output (Warnier-Orr) n Gebruik eerdere oplossingen voor gelijkende problemen (Design Patterns) n Probeer een paar specifieke voorbeelden, en generaliseer (Case Based) n “Stepwise refinement”: deel probleem op in sub-problemen

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9917 Pas op! n Stepwise refinement lastig toepasbaar bij een sterke samenhang tussen elementen: n As you step from a pier into a boat, your hat falls into the water, unbeknownst to you. The river is flowing at 2.5 mph so your hat begins to float downstream. In the meantime, you begin traveling upstream at about the speed of 4.75 mph relative to the water. After 10 minutes you realize that your hat is missing,turn the boat around, and begin to chase your hat down the river. How long will it take to catch up with your hat?

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9918 Overzicht college 5 n Notie van algoritme n Representatie van algoritmes n “Ontdekking” van algoritmes n Iteratieve structuren n Recursieve structuren n Efficientie en correctie

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9919 Herhalingslussen n Herhaaldelijk uitvoeren van een verzameling instructies ä initialisatie ä test voor terminatie ä modificatie (in richting terminatieconditie) n While (beker niet vol) Do (voeg iets toe) n Soorten: ä While/Do ä Repeat/Until (Do/While, in Java)

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9920 De “While” loop conditie waar conditie onwaar test conditie actie n Data flow diagram n Semantiek van de loop ä actie wordt 0 of meer keren uitgevoerd n while (munt in zak) do (haal ‘m eruit)

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9921 De “Repeat” loop conditie waar conditie onwaar test conditie actie n Semantiek van de loop ä actie wordt 1 of meer keren uitgevoerd n repeat (haal munt uit zak) until (geen munt in zak) n Actie moet tenminste 1x uitgevoerd kunnen worden

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9922 Sequential Search algoritme procedure Search (List, TargetValue) if (List empty) then (Declare search a failure) else [Select the first entry in list as the test entry; while (TargetValue > test entry and there remain entries to be considered) do(Select the next entry in list as the test entry); if (TargetValue = test entry) then (Declare search of success) else (Declare search a failure) ]

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9923 Sorteren door invoegen n Efficiënt met de ruimte omspringen: daarom sorteren binnen de lijst zelf, + 1 hulpplaats n Uitgangspositie: alles ligt door elkaar n Aanpak: ä 1. Sorteer nr. 1 en 2 ä 2. Voeg nr. 3 in de gesorteerde lijst van 1 en 2 ä 3. Voeg nr. 4 in de lijst van 1, 2 en 3 ä 4. Ga zo door tot en met het laatste element

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9924 Pseudo code: Insertion Sort procedure Sorteer (lijst) { assign: N krijgt de waarde 2 while ( N niet groter dan de lengte van de lijst ) do { kies het N-de element als pivot, zet de pivot in het hulpvakje, waarbij een vakje open blijft, na while ( boven het open vakje een naam die na de pivot komt) do { verplaats de naam boven het open vakje 1 plaats naar beneden } Verplaats de pivot naar het open vakje, Hoog N met 1 op, } Figuur 4.11

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9925 Test de pseudo code n Lege lijst n Lijst met 1 element n Lijst met 2 elementen n Volledig gesorteerde lijst n ‘worst case’ scenario (fig 4.18)

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9926 Overzicht college 5 n Notie van algoritme n Representatie van algoritmes n “Ontdekking” van algoritmes n Iteratieve structuren n Recursieve structuren n Efficientie en correctie

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9927 Recursie n Andere manier van probleemopsplitsen ä herhaling van zelfde programma op simpelere input ä bv. Binair zoeken n Stopconditie belangrijk n Geheugenintensief n Equivalente power: iteratief - recursief

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9928 Binary Search Fig Procedure Search (List, TargetValue) if (List empty) then (Declare the search a failure) else [select the "middle" entry in List as the test entry; Execute one of the following blocks of instructions depending on whether TargetValue is equal to, less than, or greater than the test entry TargetValue = test entry; (Declare the search a success) TargetValue < test entry; [Apply the procedure Search to see whether TargetValue is in the portion of List preceding the test entry, and if (that search is successful) then (Declare this search a success) else (Declare this search a failure)] TargetValue > test entry; [Apply the procedure Search to see whether TargetValue is in the portion of List following the test entry, and if (that search is successful) then (Declare this search a success) else (Declare this search a failure)]

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9929 Recursie n Heeft ook ä initialisatie, test voor terminatie, modificatie n Test voor terminatie (base case) Als slaagt, dan is huidige activatie van programma klaar, en Terug naar vorige activatie Anders start nieuwe activatie met simpeler input n Initialisatie=begin input n modificatie=simpelere input ä bv. splits in tweeën, haal 1 element weg

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9930 Overzicht college 5 n Notie van algoritme n Representatie van algoritmes n “Ontdekking” van algoritmes n Iteratieve structuren n Recursieve structuren n Efficiëntie en correctheid

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9931 Efficiëntie n Sommige algoritmes zijn significant sneller of trager dan andere: ä bv. in een gesorteerde lijst: –traag: sequential search –snel: binary search n Lijst met elementen, zoek element ä sequential: gemiddeld vergelijkingen ä binary: 15 vergelijkingen

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9932 Correctheid n Intuïtief correct versus formeel correct A traveler with a gold chain of seven links must stay in an isolated hotel for seven nights. The rent each night consists of one link from the chain. What is the fewest number of links that must be cut so that the traveler can pay the hotel one link of the chain each morning without paying for lodging in advance? Fig 4.21, 4.22

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9933 Oplossing: 1 keer On the first morning, give the hotel the single link. On the second morning, retrieve the single link and give the hotel the two-link piece. On the third morning, give the hotel the single link. On the fourth morning, retrieve the three links held by the hotel and give the hotel the four-link piece. On the fifth morning, give the hotel the single link. On the sixth morning, retrieve the single link and give the hotel the double-link piece. On the seventh morning, give the hotel the single link.

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9934 Formele verificatie n We nemen pré-condities aan n Propageer gevolgen door het programma ä if (conditie) then (instructie 1) else (instructie 2) ä als voor uitvoering if/then een bewering waar is, dan is direct voor uitvoering van instructie 1 deze bewering waar + de conditie waar. In geval instructie 2 uitgevoerd moet worden is vlak daarvoor de bewering waar en de ontkenning van de conditie

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9935 Beweringen in while loop test conditie initialiseerbodyverander Precondities Loop invariant Loop invariant en stopconditie Vind beweringen om te checken en te propageren door het programma false true

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9936 Insertion sort: beweringen n Loop invariant = aanname die waar is bij ingaan van de lus en bij de stop conditie ä voorgaande elementen vormen steeds een gesorteerde lijst n Stop conditie: ä de hele lijst is ontschaduwd n Eindig proces: ä steeds een naam ontschaduwen leidt uiteindelijk tot ‘unshaded list’

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9937 Insertion Sort algoritme procedure Sort (List) if (that are two or more entries in List) then [Shade the portion of List from the 2nd entry through the last entry; repeat (Remove the shading from the first name in the shaded portion of List and identify this name as the pivot entry; Move the pivot entry to a temporary location leaving a hole in List; while (there is a name above the hole and that name is greater than the pivot) do (Move the name above the hole down into the hole leaving the hole above the name) Move the pivot entry into the hole in List) until (entire List is unshaded)] Figuur 4.11

Inleiding Informatica, College 4, H 4 – sheet nr October :17 Basiscursus Informatica 98/9938 Verificatie versus testen n Verificatie is fundamenteel, omslachtig en duur ä wie verifieert de verificatie? n Testen is goedkoper, maar garandeert geen correcte software (alfa en bèta testers) ä populairder in industriële wereld dan verificatie n Consumenten software versus bedrijfskritische applicaties!