Sie sind auf Seite 1von 26

Institut für rechnergestützte

Modellierung im Bauingenieurwesen

Platzhalter für Bild, Bild auf Titelfolie hinter das Logo einsetzen

Algorithms & Programming


(Exam Preparation)
0. General Informations
When? February 19, 2024, 12:00 - 14:00
Where? ZI 24.3 – Zimmerstraße 24c – 24d
What? Theoretical and practical parts
How? Written - with pen and paper, no colors needed

Algorithms & Programming | Page 2 Institut für rechnergestützte


Modellierung im Bauingenieurwesen
1. Programming Basics

Assign a reasonable basic built-in data type to the following variables.

IBAN –

last_name –

prime_number –

temperature –

letter –

is_clicked –
Algorithms & Programming | Page 3 Institut für rechnergestützte
Modellierung im Bauingenieurwesen
1. Programming Basics

Between which three types of errors does a programmer distinguish?

Algorithms & Programming | Page 4 Institut für rechnergestützte


Modellierung im Bauingenieurwesen
1. Programming Basics

Which errors are in the following source code? To which type of errors do they
belong?

Algorithms & Programming | Page 5 Institut für rechnergestützte


Modellierung im Bauingenieurwesen
1. Programming Basics

Describe the different parts of a method:

Algorithms & Programming | Page 6 Institut für rechnergestützte


Modellierung im Bauingenieurwesen
1. Programming Basics
The following methods are part of a single class. Why is the IDE showing an
error?

Algorithms & Programming | Page 7 Institut für rechnergestützte


Modellierung im Bauingenieurwesen
1. Programming Basics
Which output in the command line results from the following source code?
Does the method call behave like call-by-object-reference or call-by-value?

Algorithms & Programming | Page 8 Institut für rechnergestützte


Modellierung im Bauingenieurwesen
1. Programming Basics
Which output in the command line results from the following source code?
Does the method call behave like call-by-object-reference or call-by-value?

Algorithms & Programming | Page 9 Institut für rechnergestützte


Modellierung im Bauingenieurwesen
2. Object Oriented Programming
Write the source code for the following UML diagram.

Algorithms & Programming | Page 10 Institut für rechnergestützte


Modellierung im Bauingenieurwesen
2. Object Oriented Programming

What is the meaning of data encapsulation with regard to the class Circle?
How would you improve it?

Algorithms & Programming | Page 11 Institut für rechnergestützte


Modellierung im Bauingenieurwesen
2. Object Oriented Programming

What are the three main principles of OOP?

For what reasons inheritance is used in programming?

How is inheritance implemented in source code (in Python)?

Algorithms & Programming | Page 12 Institut für rechnergestützte


Modellierung im Bauingenieurwesen
2. Object Oriented Programming
The classes WorkerAnt and
SoldierAnt use the protocal Ant. Each
of these three classes contains a method
do_your_job()

Complete the give_commands()


method in order that for all objects in the
passed list ants the method
do_your_job()will be invoked.

Algorithms & Programming | Page 13 Institut für rechnergestützte


Modellierung im Bauingenieurwesen
2. Object Oriented Programming

Which principle of Object Oriented Programming enables the method


give_commands() to invoke the do_your_job() method of the respective
subclasses of the class Ant?

Algorithms & Programming | Page 14 Institut für rechnergestützte


Modellierung im Bauingenieurwesen
2. Object Oriented Programming

Which line of code do you have to add in the following example in order that the
code will be compiled without errors?

Algorithms & Programming | Page 15 Institut für rechnergestützte


Modellierung im Bauingenieurwesen
2. Object Oriented Programming

You are provided with the following code snippet. What values do the attributes of
the circle object c1 have?

Algorithms & Programming | Page 16 Institut für rechnergestützte


Modellierung im Bauingenieurwesen
3. Data Structures

The classes List and Node are given as below.


Add the method remove()to the class List. This method will delete the first item
following the head, if this item is existing.

Algorithms & Programming | Page 17 Institut für rechnergestützte


Modellierung im Bauingenieurwesen
3. Data Structures

Algorithms & Programming | Page 18 Institut für rechnergestützte


Modellierung im Bauingenieurwesen
4. Algorithms

What is Recursion and why is it used?

Which is the most common error with recursive functions?

Algorithms & Programming | Page 19 Institut für rechnergestützte


Modellierung im Bauingenieurwesen
4. Algorithms

Which output in the console line is generated by the following recursive method ?

Algorithms & Programming | Page 20 Institut für rechnergestützte


Modellierung im Bauingenieurwesen
4. Algorithms

Which complexity in Big O-Notation is assigned to a triple nested loop?

Which complexity in Big O-Notation has the insertion of a value in an array?

Algorithms & Programming | Page 21 Institut für rechnergestützte


Modellierung im Bauingenieurwesen
4. Algorithms

Which condition has to be fulfilled by the structure of your data to use the Binary
Search Algorithm?

Algorithms & Programming | Page 22 Institut für rechnergestützte


Modellierung im Bauingenieurwesen
4. Algorithms

Describe and/or sketch the process of finding the value 23 in the array below with
the Binary Search Algorithm.

2 5 20 23 123 155 221 323 756

Algorithms & Programming | Page 23 Institut für rechnergestützte


Modellierung im Bauingenieurwesen
4. Algorithms

Describe or sketch the process of sorting the array below by using the Insertion
Sort Algorithm.
6 2 3 1

6 2 3 1

2 6 3 1

2 3 6 1

1 2 3 6

Algorithms & Programming | Page 24 Institut für rechnergestützte


Modellierung im Bauingenieurwesen
4. Algorithms

Describe or sketch the process of sorting the array below by using the Insertion
Sort Algorithm.
6 2 3 1

6 2 3 1

2 6 3 1

2 3 6 1

1 2 3 6

Algorithms & Programming | Page 25 Institut für rechnergestützte


Modellierung im Bauingenieurwesen
4. Algorithms

For what reasons the Insertion Sort Algorithm is faster than the Bubble Sort and
the Selection Sort Algorithm?

Algorithms & Programming | Page 26 Institut für rechnergestützte


Modellierung im Bauingenieurwesen

Das könnte Ihnen auch gefallen