Informatik D-MATH/D-PHYS Self-Assessment III,

Ähnliche Dokumente
Das folgende Kleingedruckte finden Sie auch auf einer "scharfen" Prüfung. 1. Dauer der Prüfung: 20 Minuten. Exam duration: 20 minutes.

Informatik 1 Kurzprüfung 2 LÖSUNG

Informatik I D-ITET Self-Assessment II,

Informatik D-MATH/D-PHYS Self-Assessment II,

Das folgende Kleingedruckte finden Sie auch auf einer "scharfen" Prüfung. 1. Dauer der Prüfung: 15 Minuten. Exam duration: 15 minutes.

Informatik D-MATH/D-PHYS Self-Assessment IV,

Informatik Prüfung Lösung B. Gärtner

Informatik - Übungsstunde

Informatik I Prüfung B. Gärtner

Informatik I (D-BAUG)

Weather forecast in Accra

Informatik Prüfung Lösung B. Gärtner

Magic Figures. We note that in the example magic square the numbers 1 9 are used. All three rows (columns) have equal sum, called the magic number.

Informatik Prüfung Lösung B. Gärtner

Accelerating Information Technology Innovation

Level 2 German, 2015

Übungsstunde: Informatik 1 D-MAVT

Mock Exam Behavioral Finance

Informatik für Mathematiker und Physiker Woche 7. David Sommer

SAMPLE EXAMINATION BOOKLET

Informatik für Mathematiker und Physiker Woche 2. David Sommer

DIBELS TM. German Translations of Administration Directions

VGM. VGM information. HAMBURG SÜD VGM WEB PORTAL USER GUIDE June 2016

Level 2 German, 2013

Übersetzen des Quelltexts in ausführbaren Maschinen-Code Translation of source code into executable machine code

Level 2 German, 2016

Registration of residence at Citizens Office (Bürgerbüro)

Level 1 German, 2016

a < &a[2] a < &a[2] Wert/Value: true

Level 1 German, 2014

Level 1 German, 2013

Informatik Prüfung B. Gärtner

Paper Reference. Paper Reference(s) 4375/01 London Examinations IGCSE German Paper 1: Listening

Functional Analysis Final Test, Funktionalanalysis Endklausur,

VGM. VGM information. HAMBURG SÜD VGM WEB PORTAL - USER GUIDE June 2016

Paper Reference. Paper Reference(s) 4375/01 London Examinations IGCSE German Paper 1: Listening

D-BAUG Informatik I. Exercise session: week 1 HS 2018

Was heißt Denken?: Vorlesung Wintersemester 1951/52. [Was bedeutet das alles?] (Reclams Universal-Bibliothek) (German Edition)

Cambridge International Examinations Cambridge International Advanced Subsidiary Level

Cambridge International Examinations Cambridge International Advanced Subsidiary Level

Paper Reference. Paper Reference(s) 4375/01 London Examinations IGCSE German Paper 1: Listening

Programmier-Befehle - Woche 08

Cambridge International Examinations Cambridge International Advanced Subsidiary Level

Microcontroller VU Exam 1 (Programming)

Paper Reference. Paper Reference(s) 4375/01 London Examinations IGCSE German Paper 1: Listening

Arbeitsblatt Nein, Mann!

Level 1 German, 2012

Wer bin ich - und wenn ja wie viele?: Eine philosophische Reise. Click here if your download doesn"t start automatically

Paper Reference. German Paper 1F Listening and Responding Foundation Tier Friday 22 May 2009 Morning Time: 30 minutes (+5 minutes reading time)

Übungsstunde: Informatik 1 D-MAVT

Die Bedeutung neurowissenschaftlicher Erkenntnisse für die Werbung (German Edition)

Java Tools JDK. IDEs. Downloads. Eclipse. IntelliJ. NetBeans. Java SE 8 Java SE 8 Documentation

Programmier-Befehle - Woche 10

Brandbook. How to use our logo, our icon and the QR-Codes Wie verwendet Sie unser Logo, Icon und die QR-Codes. Version 1.0.1

Woche 6. Cedric Tompkin. April 11, Cedric Tompkin Woche 6 April 11, / 29

Tote Hose: Worüber Männer schweigen. Ein Tagebuch (German Edition)

Exercise (Part II) Anastasia Mochalova, Lehrstuhl für ABWL und Wirtschaftsinformatik, Kath. Universität Eichstätt-Ingolstadt 1

Paper Reference. Paper Reference(s) 4375/01 London Examinations IGCSE German Paper 1: Listening

*A25321A0116* A25321A W850/T1231/ /6/6/6. Turn over

Word-CRM-Upload-Button. User manual

Informatik Prüfung Lösung B. Gärtner

Paper Reference. Paper Reference(s) 1231/4H Edexcel GCSE German Paper 4H Writing Higher Tier Tuesday 12 June 2007 Afternoon Time: 1 hour

FIRST LANGUAGE GERMAN

*M22525A0116* M22525A W850/T1231/ /4/4/4/4/4/ Turn over

Handbuch der therapeutischen Seelsorge: Die Seelsorge-Praxis / Gesprächsführung in der Seelsorge (German Edition)

Paper Reference. Paper Reference(s) 4375/01 London Examinations IGCSE German Paper 1: Listening

Paper Reference. Paper Reference(s) 4375/01 London Examinations IGCSE German Paper 1: Listening

Level 1 German, 2012

Funktion der Mindestreserve im Bezug auf die Schlüsselzinssätze der EZB (German Edition)

Im Fluss der Zeit: Gedanken beim Älterwerden (HERDER spektrum) (German Edition)

Organische Chemie IV: Organische Photochemie

Wie man heute die Liebe fürs Leben findet

Fachbereich 5 Wirtschaftswissenschaften Univ.-Prof. Dr. Jan Franke-Viebach

p^db=`oj===pìééçêíáåñçêã~íáçå=

Introduction to Python. Introduction. First Steps in Python. pseudo random numbers. May 2016

Hausaufgabe 1-4. Name: If homework late, explanation: Last class homework is being accepted: If correction late, explanation: Student Self-Grading

GERMAN LANGUAGE Tania Hinderberger-Burton, Ph.D American University

Sagen und Geschichten aus dem oberen Flöhatal im Erzgebirge: Pfaffroda - Neuhausen - Olbernhau - Seiffen (German Edition)

Mercedes OM 636: Handbuch und Ersatzteilkatalog (German Edition)

Level 1 German, 2011

Ein Stern in dunkler Nacht Die schoensten Weihnachtsgeschichten. Click here if your download doesn"t start automatically

RECHNUNGSWESEN. KOSTENBEWUßTE UND ERGEBNISORIENTIERTE BETRIEBSFüHRUNG. BY MARTIN GERMROTH

Brand Label. Daimler Brand & Design Navigator

German translation: technology

GR5W. General Certificate of Education June 2007 Advanced Level Examination. Unit 5 The Cultural and Social Landscape in Focus. Time allowed: 2 hours

Data Structures and Algorithm Design

Klimahysterie - was ist dran?: Der neue Nairobi- Report über Klimawandel, Klimaschwindel und Klimawahn (German Edition)

Martin Luther. Click here if your download doesn"t start automatically

MATHEMATIK - MODERNE - IDEOLOGIE. EINE KRITISCHE STUDIE ZUR LEGITIMITAT UND PRAXIS DER MODERNEN MATHEMATIK (THEORIE UND METHODE) FROM UVK

FIRST LANGUAGE GERMAN

Name: Klasse: Standardisierte kompetenzorientierte schriftliche Reifeprüfung AHS. 18. September Englisch. Schreiben

Transkript:

Informatik D-MATH/D-PHYS Self-Assessment III, 28.11.2017 Lösung Name, Vorname:............................................................. Legi-Nummer:............................................................. Diese Selbsteinschätzung dient Ihrer und unserer Orientierung. Sie wird direkt nach der Bearbeitung in der Übungsstunde besprochen und von Ihnen selbst korrigiert. Sie hat keinen Einfluss auf eine spätere Leistungsbewertung. Sie haben 20 Minuten Zeit. Das folgende Kleingedruckte finden Sie auch auf einer "scharfen" Prüfung. Allgemeine Richtlinien: General guidelines: 1. Dauer der Prüfung: 20 Minuten. Eam duration: 20 minutes. 2. Erlaubte Unterlagen: Wörterbuch (für gesprochene Sprachen). Keine eigenen Notizblätter! Bei Bedarf stellen wir Ihnen weitere Blätter zur Verfügung. 3. Benützen Sie einen Kugelschreiber (blau oder schwarz) und keinen Bleistift. Bitte schreiben Sie leserlich. Nur lesbare Resultate werden bewertet. 4. Lösungen sind direkt auf das Aufgabenblatt in die dafür vorgesehenen Boen zu schreiben (und direkt darunter, falls mehr Platz benötigt wird). Ungültige Lösungen sind deutlich durchzustreichen! Korrekturen bei Multiple- Choice Aufgaben bitte unmissverständlich anbringen! Lösungen auf Notizblättern werden nicht berücksichtigt. Permitted eamination aids: dictionary (for spoken languages). No sheets of your own! We will give you etra sheets on demand. Use a pen (black or blue), not a pencil. Please write legibly. We will only consider solutions that we can read. Solutions must be written directly onto the eam sheets in the provided boes (and directly below, if more space is needed). Invalid solutions need to be crossed out clearly. Provide corrections to answers of multiple choice questions without any ambiguity! Solutions on etra sheets will not be considered. 5. Es gibt keine Negativpunkte für falsche Antworten. There are no negative points for false answers. 6. Störungen durch irgendjemanden oder irgendetwas melden Sie bitte sofort der Aufsichtsperson. 7. Wir sammeln die Prüfung zum Schluss ein. Wichtig: stellen Sie unbedingt selbst sicher, dass Ihre Prüfung von einem Assistenten eingezogen wird. Stecken Sie keine Prüfung ein und lassen Sie Ihre Prüfung nicht einfach am Platz liegen. Dasselbe gilt, wenn Sie früher abgeben wollen: bitte melden Sie sich lautlos, und wir holen die Prüfung ab. Vorzeitige Abgaben sind nur bis 15 Minuten vor Prüfungsende möglich. 8. Wenn Sie zur Toilette müssen, melden Sie dies einer Aufsichtsperson durch Handzeichen. 9. Wir beantworten keine inhaltlichen Fragen während der Prüfung. Kommentare zur Aufgabe schreiben Sie bitte auf das Aufgabenblatt. 10. Richtig beantwortete Multiple-Choice Fragen erhalten jeweils 1 Punkt. Es gibt keine negativen Punkte in MC Fragen. If you feel disturbed by anyone or anything, let the supervisor of the eam know immediately. We collect the eams at the end. Important: you must ensure that your eam has been collected by an assistant. Do not take any eam with you and do not leave your eam behind on your desk. The same applies when you want to finish early: please contact us silently and we will collect the eam. Handing in your eam ahead of time is only possible until 15 minutes before the eam ends. If you need to go to the toilet, raise your hand and wait for a supervisor. We will not answer any content-related questions during the eam. Please write comments referring to the tasks on the eam sheets. Correctly answered Multiple-Choice questions receive 1 point each. There are no negative points in MC questions Aufgabe 1 2 3 4 5 6 Punkte Maimum 4 6 6 6 6 8 36

1 Characters (4 Punkte) Betrachten Sie die folgende Schleife und geben Sie ihre Ausgabe direkt in dem dafür vorgesehenen Kästchen an. Nehmen Sie an, dass Buchstaben gemäss dem ASCII-Code sortiert sind! Consider the following loop and write its output directly in the provided bo. Assume that letters are ordered according to the ASCII code! for (char c = F ; c < R ; c += 3) std::cout << c; Ausgabe output: FILO 1 point for each correct letter, or a letter three positions behind the previous. 2 Pointers (6 Punkte) Gegeben sei folgender Code Consider the following code int a = 4; int& b = a; int* c = &a; Kreuzen Sie in der folgenden Tabelle an, welche Ausgabe ein Audruck bewirkt oder ungültig, wenn er ungültig ist. In the following table, mark what kind of output an epression provides or invalid if it is invalid. Resultat / result Ausdruck Ungültig 4 Adresse von a Adresse von c Epression invalid address of a address of c std::cout << b std::cout << *b std::cout << &b std::cout << c std::cout << *c std::cout << &c 1 point for each correct answer. 0 points for missing or wrong answers. Page 2 of 7

3 Referenzen (6 Punkte) Kreuzen Sie an, ob die Aussagen richtig oder falsch sind. Mark if the statements are correct or wrong. Aussage correct wrong Statement richtig falsch Referenzen können benutzt werden, um bei Funktionsaufrufen unnötige Kopien der Argumente zu verhindern. (Correct. This is the reason why we introduced const references.) References can be used to prevent unecessary copies of the arguments of function calls. Eine nicht const-referenz kann nicht verwendet werden, um eine const-variable zu referenzieren. (Correct. therwise, this would compromise const correctness) A non-const reference cannot be used to refer to a const variable. Eine Referenz muss immer mit einem L-Wert initialisiert werden. (Wrong. Const references also allow rvalues of suitable lifetime.) A reference must always be initialized with an L-value. Eine Funktion sollte niemals eine Referenz auf eine lokale Variable zurückgeben. (Correct. The lifetime of the local variable ends with return.) A function should never return a reference to a local variable. Wenn ein Zeiger des Typs const T* auf ein Objekt im Speicher vom Typ T zeigt, kann dieses Objekt seinen Wert nicht ändern. (wrong: const T* only says that the object can t be changed via.) If a pointer of type const T* points to an object of type T in memory, this object cannot change its value. Nachdem eine Referenzvariable initialisiert wurde, kann sie jede andere Variable des gleichen Typs referenzieren. (Wrong. In contrast to pointers, references can t ce changed to refer to something else) Once a reference variable has been initialized, it can refer to any other variable of the same type. 1 point for each correct answer. 0 points for wrong or missing answers Page 3 of 7

4 Iteration (6 Punkte) Gegeben seien die folgenden beiden Funktionen f und g. Consider the following two functions f and g. int f(const int *begin, const int* end) { int val1 = *begin; if (++begin!= end) { const int val2 = f(begin, end); if (val2 > val1) { val1 = val2; return val1; int g(const int *begin, const int* end) { int val= *begin; for (const int* it=++begin; it!= end; ++it) { if (*it > val) { val = *it; return val; Kreuzen Sie an, ob die Aussagen wahr oder falsch sind. Mark if the statements are correct or wrong Aussage richtig falsch Statement correct wrong Die Funktionen f und g haben dieselbe Vorbedingung Functions f and g have the same precondition. Die Funktionen f und g haben dieselbe Nachbedingung Functions f and g have the same postcondition. Page 4 of 7

Betrachten Sie nun folgendes Programmstück Now consider the following program { const int my_size = 7; int my_values[my_size] = { 3, 8, 1, 12, 20, 2, 6 ; int result = f(my_values, my_values+my_size); Beantworten Sie folgende Fragen Answer the following questions: Frage Antwort question answer Was ist der Wert der Variablen result nach dem Aufruf von f? 20 What is the value of variable result after call of f? Wie oft wird f insgesamt aufgerufen 7 How many times will function f be called? 1 point for each correct MC anwer, 2 points for each correct value Page 5 of 7

5 Felder und Arrays I (6 Punkte) Folgender Code bearbeitet den Inhalt eines Arrays a. Geben Sie den Inhalt jedes Elements von a zum jeweiligen Ausführungszeitpunkt in den dafür vorgesehenen Feldern an. The following code manipulates the content of the array a. Provide the content of each element of a at the corresponding point of eecution in the respective fields. int a[8] = {3, 1, -3, -2, 10; 3 1-3 -2 10 0 0 0 a[7] = 5; *(a + 3) = 4; 3 1-3 4 10 0 0 5 int* p = a + 4; *(a + a[3] + *(p - 2)) = *(p + 3) - 9; 3-4 -3 4 10 0 0 5 2 points for each correct line. 2 points also for a line that would be correct given a previous incorrect line (avoid to punish follow-up errors) Page 6 of 7

6 Felder und Zeiger II (8 Punkte) Seien und y zwei Folgen mit Längen n und m, = ( 1, 2,..., n ) und y = (y 1, y 2,..., y m ). Wir definieren den Reissverschluss von und y als Let and y be two sequences of lengths n and m, = ( 1, 2,..., n ) and y = (y 1, y 2,..., y m ). We define the zip of and y as zip(, y) = ( 1, y 1, 2, y 2,..., min(n,m), y min(n,m) ). Gesucht ist eine Funktion, die zwei Folgen ganzer Zahlen und y als Zeigerbereiche erhält und zip(, y) ausgibt. Hier ist ein Beispiel: We are looking for a function that receives two integer sequences and y as ranges and outputs zip(, y). Here is an eample: = (1, 3, 5, 7, 9, 11), y = (2, 4, 6, 8) zip(, y) = (1, 2, 3, 4, 5, 6, 7, 8). Unten finden Sie das Skelett eines Programms, das eine solche Funktion definiert und aufruft. Ihre Aufgabe ist es, die Lücken so zu füllen, dass sich eine korrekte Funktion und ein korrektes Programm ergibt! Above, you find a skeleton of a program that defines and calls such a function. Your task is to fill the gaps in such a way that you get a correct function and a correct program! // POST: writes the zip of [begin, end) and [ybegin, yend) to standard output void zip (const int begin, const int end, const int ybegin, const int yend) { const int p = begin ; const int yp = ybegin ; while ( p!= end && yp!=yend ) { std :: cout << *p << << *yp << ; ++p; ++yp; int main () { int [] = {1, 3, 5, 7, 9, 11; int y [] = {2, 4, 6, 8; zip (, +6, y, y+4 ); // 1 2 3 4 5 6 7 8 return 0; Page 7 of 7 2 points for the while condition, 1 point for each other (correct) field