Growth Mindset: Algorithmic Thinking and Coding (code 27233B)

Lecturer: Dr. Paolo Coletti Paolo.Colettiunibz.it . Office E203 - Office hours: www.paolocoletti.it/timetable
Website: www.paolocoletti.it/algorithmicthinking

NEWS

For the 7 February OPTIONAL
ATC18, as usual here. If you do it all and correct you get +1.5 on the final grade (your grade in 30s of the entire module). If you commit mistakes or do just a part of it, you get a proportionate part of the bonus.
Video and file are finally updated 22/01/2020 17:50 Video is here: https://youtu.be/zQPFl7NN994

Second midterm on 13 January 16:00 or 5th February 14:00
You cannot try both! Prototype is here and suggestions for the solution are here .
Topics are:
11 Search algorithms
12 Hash functions
14 Sorting algorithms
15 Timetable problem
16 Knapsack problem
17 Backtracking algorithm

FOR the 10th January
1. Exercises ATC17exe, as usual here The backtracking code is mandatory, the optimisations are optional.

The ones who want to submit by Friday 10 as planned can do it. In case I have to interrogate one of them, I shall do it at the end of the lesson. In case I need to show their code, I would have to ask the other ones to leave.
The ones who want to submit by Tuesday 14 can do it and same rule as above with interrogation on Tuesday.
The other ones will submit not later than 29 January, but I hope you do it earlier. For these ones I may need to interrogate some of them and therefore they must come if called.
I think that in this way we can accommodate any need: the ones who want to do the assignment and totally forget about it and the ones who need time. Obviously not doing the assignments and taking the midterm on Monday might not be a good idea, as the assignments are on the midterm's topic and help understanding the algorithms.
You may also submit the code before and the optional optimisations by the 29 January if you want.

 

FOR the 7th January
1. Exercises ATC16exe, as usual here

NOTE: if for any reason you need to copy a list, beware that a=b is not a duplication of the list but only of the pointer. To copy a list duplicating it, first

import copy

and then use the function copy.deepcopy( )

a=copy.deepcopy(b)

In this way a and b will be two completely different objects using two different spaces in the memory

FOR the 27th December
1. Exercise ATC15exe, as usual here . It might happen that your program, in particular the first and the fuzzy non-optimized, require hours to complete. Obviously it is not necessary to have them burn your notebook! Just run them a little and then stop it. After having stopped it, you can print TT to see at which timetable attempt was it arrived.
Yes, the TT I write in the file is not correct, because while produceing the video before my lesson I had different constraints. A correct TT for your constraints is TT=[[0,0,0,1,2],[2,3,4,0,0],[1,2,3,4,0],[3,4,0,0,0],[1,0,0,0,0]]

 

1. Some of you probably have a hard time understanding this kind of subject. For these people, my suggestions are:
(a) watch the video of the lesson BEFORE it. It helps you really a lot, you will undersdtanda better what you have understood first time and you will grasp a lot of other details that you usually miss.
(b) repeat the lesson before start doing the exercises. This applies to everybody. Make sure you have understood everything. Well, this should be done also by people who understand this subject perfectly...
(c) Do alternative exercises on your own twisting the ones I did in class. This does not mean to simply change the variables' values, but to actually try to slightly change the code and see what happens or trying to do something slightly different. This is the way I learnt to write programs!

2. People absent on last lesson can be called next time and asked also about things from this time. Video of lessons that you skip will be available (only for a some days) on my YouTube channel in the course's playlist: https://www.youtube.com/playlist?list=PLfuzpc-H8qce-Yc8XpUw34y5ncOLhpOPN

3. I put a new short bizarre video here https://youtu.be/2DEBfyM69lk trying to teach you how to deal with a computer problem.

4. If you need unibz software for free, here is the link: http://knowledge.scientificnet.org/software

5. If you need unibz virtual machines, here is the link: http://desktop.scientificnet.org (it works even from outside Scientific Network)

Course

Scope of this course

  1. Give you a highly requested skill which can enlight your résumé in case you decide (or are forced to) not to become an entrepreneur and apply for a job.
  2. Open your mind towards a problem solving attitude together with the other module Design Thinking. Clearly each module will show you a completely different aspect of problem solving.
  3. Give you a strong background knowledge over programming techniques and strategy, obviously not to become a programmer yourself but to be able to talk with your developers and arrange with them precise plans without accepting passively developers' decisions.

Prerequisites

In order to correctly follow this course each student is required previous knowledge on these topics:

Course content

How to study for this course

This course is different from the majority of courses you are used to. This course is much more technical than theoretical and it is strictly sequential. This means that you have to adapt your study strategy. First of all, you either attend all the lessons (or compensate for missing lessons watching immediately the corresponding videos or reading the book) or it is really not worth coming to the next one, since you will have a hard life understanding the next topic. Moreover, after each lesson you must repeat slowly on your own everything done in class in order to be sure to have fully grasped the explained concepts before the next lesson. And, needless to say it, do the exercise without copying them from your colleagues.

For the exam the main difference with respect to other courses is that you have to train much more than studying. The content of this course is easy and does not need extensive study, however it is only with practice that you become skilled enough and know immediately what to do without wasting time.

Exam

Exam is split in three parts. The grade is the weighted average of the three parts, based on how many lessons were dedicated to each of them.

  1. Theoretical questions on cryptocurrencies and blockchain technology (on paper closed books, no material), worth 2/36
  2. Questions and exercises on computational complexity (on paper closed books, no material), worth 17/36
  3. Practical exercises on Python (on computer, fully open book), worth 17/36

Coursework

Attending students have the opportunity to skip part 2 and 3 of the exam and replace them with a constant coursework. The coursework consists in
(a) home exercises which will be assigned after each lesson and which must be returned to dr. Coletti via email not later than 24 hours before the next lesson (0 hours before the next lesson in case it is the day after). You can make these exercises with a partner, but this partner must be different from the partner of your previous home exercise;
(b) oral presentation of exercises and similar tasks at the beginning of each lesson. Attendance is mandatory to all Python lessons, as you must be available for being called. In case of problems, you can be available via Skype or Google Hangouts or FaceTime, but set up everything in advance as all the technical problems are your responsability (it is a good idea to do a test with me some days before). You may skip maximum 5 times the oral presentation, but the next time you come you might be asked to present the exercises of the time you were absent. And please, do not stay home both the last two lessons!
(c) practical mid-terms which will be organized periodically during the course. In case you skip one, we can try to arrange to do it later, but I do not guarantee.
In order for the coursework to be considered sufficient, you must have fulfilled all three points and with a weighted average grade of at least 60%. If the grade you receive is sufficient but too low for you, please write an email to dr. Coletti at least 7 days before the exam telling him that you will do the full exam.
Note that the only required attendance is when you might be called for the oral presentations or at the mid-terms, for the rest of the lesson you stay only if you think it may be useful for you, there are videos covering all my lessons.

Study resources

Topic
Lessons' slides
Videos as replacement of attendance
Written material as support
Precourse No slides anymore in 2019 Go down here

No books in 2019!

Python No slides anymore in 2019 Go down here No books in 2019!
Algorithms and complexity No slides anymore in 2019 Go down here No books in 2019!
Cryptocurrences Slides in PDF and in PPTX Go down here No books in 2019!

 

Files and programs used in class
Go to this directory here

Python 3 versus Python 2

Issue Python 2 Python 3
print it is a command:
print <string>
it is a function, therefore it needs parentheses:
print(<strin>g)
print with trailing comma a trailing comma after print suppresses new line:
print <string>,
to suppress new line use:
print(<string>, end="")
integer division 5/2 gives 2. To get the float result:
either 5.0/2 or float(5)/2 or 5/2.0 or 5/float(2); float(5/2) still returns 2.0

5/2 gives 2.5
If you want the integer division, use 5//2

dict order is decided by the computer memory, so do not rely on it order is exactly the insertion order
range function range function returns a list range function returns a range object. To get a list:
list(range(<arguments>))
xrange function xrange function returns a range object, like range in Python 3  
sha256 sha256(<string>).hexdigest() sha256(<string>.encode('utf-8')).hexdigest()

Videos of lessons

course brief presentation
YouTube Brief course presentation
precourse 01
YouTube Precourse for Windows 10 on unibz network and file handling, first part.
precourse 02
YouTube Precourse for Windows 10 on unibz network and file handling, second part.
precourse Mac 01
YouTube Precourse for Mac on unibz network and file handling, first part.
precourse Mac 02
YouTube Precourse for Mac on unibz network and file handling, second part.
01 installing Anaconda
YouTube For Python we will use Anaconda with Jupyter and Python 2.7 (but 3.7 is fine)
01bis refusing to install Anaconda
YouTube For those who do not have a notebook (and borrow one from the library) or refuse to install Anaconda
02 basic Python
YouTube Basic Python programming, Bakus-Naur form, integer and float variables, string variables, find method.
How to solve problems
YouTube

How to solve computer problems explained with a carpentry example

03 procedures and decisions
YouTube Procedures, tab, logical expressions, and, or, not, If, else, elif.
04 flowcharts
YouTube Flowcharts
05 while and complexity
YouTube While loops, break, multiple assignment, computational complexity
06 Search engine
YouTube Building a search engine: retrieve the links
07 Solving problems
YouTube How to tackle a computational problem
08 Lists
YouTube Lists and strings, loops, objects and their differences towards variables.
09 Search engine
YouTube Building a search engine: crawling
10 Dictionaries
YouTube Flags, dictionaries, tuples.
11 Search engine
YouTube Finishing our search engine. Indexing the words
     
11 Search algorithms
YouTube Majority problem, Sequential search, Binary search, recursion
12 Hash functions
YouTube Using hashes for fingerprints, for existence proof, for hiding PIN or passwords, for mining bitcoins
14 Sorting algorithms
YouTube Bubble Sort and Merge Sort
15 Timetable problem
YouTube Brute-force algorithm
16 Knapsack problem
YouTube Knapsack problem with branch and bound algorithm
17 Backtracking algorithm
YouTube Backtracking algorithm applied to timetable problem
18 Graphs and paths
YouTube Finding all paths in a graph. Edmonds–Karp algorithm
cryptocurrencies and blockchain technology
YouTube A decentralised currency, basic cryptography, Bitcoin history and technology, blockchain technology, advantages and criticisms
YouTube

This short video illustrates how to reach unibz network folder \\ubz01fst (which contains course_coletti and your own personal stuff) using VPN when you are connected from outside university or when you are connected using wifi.
This procedure is not part of exam's stuff.

Exam

Before the exam:

  1. if you do not use your own notebook, borrow a computer from the library well before the exam and configure it before the exam
  2. make sure that Anaconda is installed and that you can use Jupyter for Python;
  3. check that you are able to locate \\ubz01fst.unibz.it\Courses directory;
  4. just in case your notebook crashes the night before, some days before the exam borrow a computer from the library and check that you are able to log in on your unibz account and that you have, or are able to install, everything you need

Frequently Asked Questions

Q: Which software do I need for Python on my notebook?
A:
Anaconda is available for Windows and for Mac. Take care to install Python 2. Watch the video 01 or 01bis for details.

Q: I have no notebook. What do I need for the course and for the exam?
A:
You can borrow a notebook from the library. Watch the video 01bis to know how can you use Jupyter, you have several possibilities.

Q: How can I reach network folder \\ubz01fst from outside unibz or connected via wifi?
A: For Windows users: if you are connected to wifi ScientificNetwork try to digit in any explorer address bar \\ubz01fst.unibz.it and see whether you reach it. You need to provide your login and password, but you need to tell to your computer that you are using a different domain and then you have to type unibz\loginname instead of simply loginname. If this fails or if you are no connected to ScientificNetwork, then you need to install VPN. There is a specific video up here.
For Mac users: if you are connected to wifi ScientificNetwork, Finder -> Go -> Connect to server -> smb://ubz01fst.unibz.it . You need to provide your login and password, but you need to tell to your computer that you are using a different domain and then you have to type unibz\loginname instead of simply loginname.

Q: May I fix an appointment to talk with you?
A: I live in the XXI century, the age of asynchronous communication. Try to send an email to me clearly stating the course you are talking about (I have several ones) and the problem you have. You will be surprised by how fast I react, and without having the notifications on my smartphone.

Q: When will the next exam be? Can you give me a hint on the exam's date because I have to catch a plane? Can you move the exam's date? Can you fix the exam's date on the week I suggest?
A: Please stop writing me emails on this topic. Exam's date appears on your timetable as soon as it is official. If you have something to say about it, contact your students' speaker who is the only one who can submit requests on students' behalf.

Q: I may not enrol online for technical or administrative reasons or I forgot to enrol or it is my third attempt and I cannot enrol. Can I do the exam anyway?
A: No, I may not let non-enrolled students take part of the exam. Do not ask me to do illegal things! Ask the secretary whether there is something they can do.

Q: May I do the exam with my computer?
A: Sure. But beware: (1) you must be able to navigate the Internet and to enter directory \\ubz01fst.unibz.it\Courses\Course_Coletti. Do not wait for the day before the exam to check it. (2) You are responsible for your different programs' versions and configurations and for the absence on your computer of specific programs.
In any case you will have a unibz desktop computer in front of you.

Q: May I use the operating system in a different language?
A: Yes, sure. Your business.

Q: Will the exam be similar to the other exams on this website?
A: Sure. For the first year (2018/19) I shall put a couple of exam's prototypes.

Q: I lost a file during the practical exam because I did not save it correctly. What may you do?
A: Absolutely nothing. With time spent on exercises you should know the unreliability level of your programs, and how often you have to save.

Q: My files were not copied correctly at the end of the practical exam. What may I do?
A: Checking that the copy is correct, and practicing file copy even during the exam, is your task and is official prerequisite for this course.

Q: Hey, exam's time is not enough! I could not even finish it. If I only had other 5 minutes I would have done it much better!
A: Sorry but you are wrong, as I calculate more than twice the needed time. Look at the important warning after exam's explanation: the fact that for you exam's time was not enough is instead an indication that you must do many more exercises to be efficient and fast enough. On the other hand, if you have documented medical problems that slow your operations, write an email to me to have more time.

Previous exams

ID
Session
Notes
Exam and solution link
02
prototype for A.Y. 2019/20
exam and solution
01
prototype for A.Y. 2019/20

exam and solution

Just to give you some examples of questions on cryptocurrencies given in the past years:

This page is maintained by Paolo Coletti.

Marisa Crucitti il teatro per ringiovanire Paolo Coletti personal page La stanza dell'arte Paolo Coletti Paolo Associazione culturale e ricreativa Kender Trento Bolzano La stanza dell'arte Marzia Centro Felix Trento Aarghen Thael Il Vecchio Continente GURPS Marisa Crucitti il teatro per ringiovanire Laboratorio d'arte Gabbana cornici Rovereto Nursing Up sindacato infermieri Bolzano ASL Italia Advanced Squad Leader Club scherma Bolzano Bozen Fecht club spada fioretto sciabola