Giter VIP home page Giter VIP logo

2018-2019's Introduction

Computational Thinking and Programming

This space contains all the material related to the Computational Thinking and Programming course of the Digital Humanities and Digital Knowledge degree at the University of Bologna.

Academic year 2018/2019

Table of content

  1. Material
  2. Schedule
  3. Links

Material

Keys:

  • the = theoretical lecture
  • lab = laboratory session
  • exa = partial examination
  • add = additional material
  1. [12/11/18, the] Introduction to the course


  2. [12/11/18, the] Introduction to Computational Thinking


  3. [14/11/18, the] Algorithms


  4. [16/11/18, the] Computability


  5. [19/11/18, the] Programming languages


  6. [22/11/18, lab] 1st Lesson


  7. [23/11/18, the] Organising information: ordered structures


  8. [26/11/18, the] Brute-force algorithms


  9. [27/11/18, lab] 2nd Lesson


  10. [28/11/18, exa] First partial examination

    • content: test 1, test 2
    • solutions:
      • exercise 1:
        • solution to "Describe the main five widgets of the flowchart diagram model": Flowline = the arrow is used to define the order in which the operations are executed; Terminal = it indicates the beginning and ending of an algorithm; Process = used for expressing an instruction or operation; Decision = it depicts a conditional operation; Input / Output = allows the specification of an input or an output.
        • solution to "List the three main characteristics that the data structure list has": order, repeatability of its elements, countability of its elements.
      • exercise 2:
        • solution to "Describe what is a low-level programming language": languages that provide one abstraction level on top of the machine language, and thus it allows one to write programs in a way that is more intelligible to humans.
        • solution to "Describe what is a high-level programming language": languages which are characterised by a strong abstraction from the specifiability of the machine language. In particular, it may use natural language words for specific construct, so as to be easy to use for and to understand by humans.
      • exercise 3: Python script to calculate the output of the Turing machine provided - run with python turing_machine_1st_partial_ex3.py and follow the instructions
      • exercise 4: Python script to calculate the output of the function f - run with python f_1st_partial_ex4.py and follow the instructions
      • exercise 5: implementation of the function do_it

  11. [28/11/18, the] Organising information: unordered structures


  12. [29/11/18, lab] 3rd Lesson (included in the material of the 2nd lesson above)


  13. [30/11/18, the] Recursion


  14. [03/12/18, the] Divide and conquer algorithms


  15. [04/12/18, lab] 4th Lesson


  16. [05/12/18, the] Dynamic programming algorithms


  17. [06/12/18, lab] 5th Lesson


  18. [10/12/18, the] Organising information: trees


  19. [11/12/18, lab] 6th Lesson (included in the material of the 5th lesson above)


  20. [12/12/18, the] Organising information: graph


  21. [13/12/18, lab] 7th Lesson


  22. [14/12/18, the] Backtracking algorithms


  23. [28/11/18, exa] Second partial examination

    • content: test 1, test 2
    • solutions:
      • exercise 1:
        • solution to "Describe the steps chatacterising the dynamic programming algorithmic approach": [base case: solution exists] return the solution calculated previously, otherwise; [base case: address directly] address directly if it is an easy-to-solve problem, otherwise; [divide] split the input material into two or more balanced parts, each depicting a sub-problem of the original one; [conquer] run the same algorithm recursively for every balanced parts obtained in the previous step; [combine] reconstruct the final solution of the problem by means of the partial solutions; [memorize] store the solution to the problem for reusing it.
        • solution to "Describe the steps characterising the backtracking algorithmic approach": [leaf-win] if current node is a leaf and it is a solution then return it, otherwise; [leaf-lose] if current node is a leaf but it is not a solution, then return no solution back the parent node, otherwise; [recursive-step] apply recursively the whole approach for each child of the current node, until one of these recursive executions returns a solution - if no solution, back the parent node of the current one.
      • exercise 2:
        • solution to "Describe the main characteristics that the data structure dictionary has": A dictionary is a countable collection of unordered key-value pairs, where the key is non-repeatable in the dictionary
        • solution to "Considering a particular central node of a tree as focus, introduce the nomenclature used to refer to all the other nodes": the parent node of a given one is a node directly connected to another one when moving close to the root node; a child node of a given one is a node directly connected to another one when moving away from the root node; a sibling node of a given one is a node that shares the same parent node; an ancestor node of a given one is a node that is reachable by following the child-parent path repeatedly; a descendant node of a given one is a node that is reachable by following the parent-child path repeatedly.
      • exercise 3:
        • solution to "Write does the Python function def merge_sort(input_list) implementing the merge sort (the function merge can be used without providing an implementation)": Python implementation.
        • solution to "Write does the Python function def merge(left_list, right_list) used in the combine step of the merge sort": Python implementation.
      • exercise 4: Python script to calculate the output of the function f - run with python f_2nd_partial_ex4.py and follow the instructions.
      • exercise 5: implementation of the function pal.

  24. [17/12/18, the] Project


  25. [18/12/18, lab] 8th Lesson (included in the material of the 7th lesson above)


  26. [19/12/18, the] Greedy algorithms


  27. [19/12/18, add] Ask a thesis


  28. [19/12/18, the] Exercises on algorithms


Schedule

DateTitle
12/11/18Introduction to Computational Thinking
14/11/18Algorithms
16/11/18Computability
19/11/18Programming Languages
22/11/18Laboratory
23/11/18Organising information: ordered structures
26/11/18Brute-force algorithms
27/11/18Laboratory
28/11/18Organising information: unordered structures
29/11/18Laboratory
30/11/18Recursion
03/12/18Divide and conquer algorithms
04/12/18Laboratory
05/12/18Dynamic programming algorithms
06/12/18Laboratory
10/12/18Organising information: trees
11/12/18Laboratory
12/12/18Organising information: graphs (+ evaluation questionnaire)
13/12/18Laboratory
14/12/18Backtracking algorithms
17/12/18Project presentation (time change: 11:30-13:30)
18/12/18Laboratory
19/12/18Greedy algorithms

Links

It is possible to find all the 2018/2019 texts of the written examination in the folder docs/exams.

2018-2019's People

Contributors

essepuntato avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

2018-2019's Issues

Lecture "Divide and conquer algorithm", exercise 2

Develop the divide and conquer algorithm def quicksort(input_list, start, end)​ that takes a list and the positions of the first and last elements in the list to consider as inputs, and that calls partition(input_list, start, end, start) (defined in the previous exercise) to partition the input list into two slices, and then applies itself recursively on the two partitions (neither of which includes the pivot value since it has been already correctly positioned by means of the execution of partition). In addition, define appropriately the base case of the algorithm so as to stop if needed before to run the partition algorithm.

Accompany the implementation of the function with the appropriate test cases.

Lecture "Organising information: trees", exercise 1

Write in Python a recursive function def breadth_first_visit(root_node) that takes the root node of a tree and returns a list containing all the nodes of the tree according to a breadth first order, which first consider all the nodes of the first level, then those ones of the second level, and so forth. For instance, considering the nodes created in Listing 2, the function called on the node book should return the following list: [book, chapter_1, chapter_2, text_8, paragraph_1, paragraph_2, paragraph_3, text_7, text_1, quotation_1, text_3, quotation_2, text_5, text_6, text_2, text_4]. Accompany the implementation of the function with the appropriate test cases.

Lecture "Brute-force algorithms", exercise 5

Write in Python the function def my_reversed(input_list) which behave like the built-in function reversed() introduced in Section "Insertion sort" and returns a proper list, and accompany the function with the related test case. It is not possible to use the built-in function reversed() in the implementation.

Lecture "Computability", exercise 2

Consider an algorithm that takes as input a 0-1 sequence of exactly five symbols, and returns 1 if such sequence contains at least three consecutive 1s, and returns 0 otherwise. Implement such algorithm with a Turing machine, where the cell correspondent to the starting position of the head is where the final result must be stored, while the following five cells are initialised with the 0-1 sequence of five symbols used as input of the algorithm.

Lecture "Organising information: ordered structures", exercise 2

Consider to have a stack obtained by processing, one by one, the elements included in the list of the first exercise, i.e. my_stack = deque(["Draco", "Harry", "Hermione", "Ron", "Severus"]). Describe the status of my_stack after the execution of each of the following operations: my_stack.pop(), my_stack.pop(), my_stack.append("Voldemort").

Question about an exercise from last year

Hi all, I have a question about an exercise in one of last year test.
We have to make the idf using only the document "d" (and in consequence of this fact we have to do the tf only on d) or we have to do the idf using all documents that contain a term?
image

Lecture "Dynamic programming algorithms", exercise 1

Write an extension of the multiplication function introduced in the lecture "Recursion", i.e. def multiplication(int_1, int_2, solution_dict), by using a dynamic programming approach. This new function takes in input two integer numbers to multiply and a dictionary with solutions of multiplications between numbers, which can be used to retrieve directly the result of such multiplication if already present in it. The function returns the result of the multiplication and, at the same time, modifies the solution dictionary adding additional solutions when found.

Accompany the implementation of the function with the appropriate test cases.

Lecture "Recursion", exercise 2

Define a recursive function def fib(n) that implements the algorithm to find the nth Fibonacci number – where if n is less than or equal to 0, then 0 is returned as result; if n is equal to 1, then 1 is returned; otherwise, return the sum of the same function called with n-1 and n-2 as input. Please accompany the function with the related test case.

Lecture "Algorithms", exercise 2

Write the flowchart of an algorithm that takes in input two objects and returns “yes” whether the two objects are the same, otherwise it returns “no”.

Lecture "Brute-force algorithms", exercise 3

Write in Python the function def my_enumerate(input_list) which behave like the built-in function enumerate() introduced in Section "Linear search" and returns a proper list, and accompany the function with the related test case. It is not possible to use the built-in function enumerate() in the implementation.

Lecture "Organising information: ordered structures", exercise 3

Consider to have a queue obtained by processing, one by one, the elements included in the list of the first exercise, i.e. my_queue = deque(["Draco", "Harry", "Hermione", "Ron", "Severus"]). Describe the status of my_queue after the execution of each of the following operations: my_queue.popleft(), my_queue.append("Voldemort"), my_queue.popleft().

Lecture "Organising information: graphs", exercise 2

Create a directed graph which relates the actors Brad Pitt, Eva Green, George Clooney, Catherine Zeta-Jones, Johnny Depp, and Helena Bonham Carter to the following movies: Ocean's Twelve, Fight Club, Dark Shadows.

Lecture "Organising information: graphs", exercise 1

Consider the list of co-authors of Tim Berners-Lee as illustrated in the write box at http://dblp.uni-trier.de/pers/hd/b/Berners=Lee:Tim. Build an undirected graph that contains Tim Berners Lee as the central node and that is linked to other five nodes representing his top-five co-authors. In addition, specify the weight of each edge as an attribute, where the value of the weight is the number of bibliographic resources (articles, proceedings, etc.) Tim Berners-Lee has co-authored with the person linked by that edge.

Lecture "Computability", exercise 1

Write the table of instructions of a Turing machine with four states – A (initial state), B, C, and D (final state) – such that, once reached the final state, only the cells immediately on the left and on the right of the initial position of the head of the machine will have the value 1 specified. The final state must not have any instruction specified in the table.

Lecture "Algorithms", exercise 1

What is the result of the execution of the algorithm in Figure 4 using "Peroni", "HTML", and "Peroni, S., Osborne, F., Di Iorio, A., Nuzzolese, A. G., Poggi, F., Vitali, F., Motta, E. (2017). Research Articles in Simplified HTML: a Web-first format for HTML-based scholarly articles. PeerJ Computer Science 3: e132. e2513. DOI: https://doi.org/10.7717/peerj-cs.132" as input values?

Lecture "Recursion", exercise 1

Define a recursive function def exponentiation(base_number, exponent) for implementing the exponentiation operation, and test (by implementing the related test case) it on the following inputs: 34, 171, and 20.

Lecture "Organising information: unordered structures", exercise 3

Suppose that all the elements in the set returned by the second exercise have been organised in two different sets, i.e. set_hobbit that refers to the set set({"Frodo", "Sam", "Pippin", "Merry"}), and set_magician defined as set({"Saruman", "Gandalf"}). Create a dictionary containing two pairs: one that associate the set of hobbits with the key "hobbit", and the other that associates the set of magicians with the key "magician".

Lecture "Brute-force algorithms", exercise 4

Write in Python the function def my_range(stop_number) which behave like the built-in function range() introduced in Section "Insertion sort" and returns a proper list, and accompany the function with the related test case. It is not possible to use the built-in function range() in the implementation.

Lecture "Divide and conquer algorithm", exercise 1

Implement in Python the partition algorithm – i.e. def partition(input_list, start, end, pivot_position) – that takes a list and the positions of the first and last elements in the list to consider as inputs, and redistributes all the elements of a list having position included between ​start and ​end on the right of the pivot value input_list[pivot_position] if they are greater than it, and on its left otherwise. In addition, the new position where the pivot value is now stored will be returned by the algorithm. For instance, considering ​​my_list = list(["The Graveyard Book", "Coraline", "Neverwhere", "Good Omens", "American Gods"]), the execution of partition(my_list, 1, 4, 1) changes ​my_list as follows: ​list(["The Graveyard Book", "American Gods", "Coraline", "Neverwhere", "Good Omens"]) and 2 will be returned (i.e. the new position of "Coraline"). Note that "The Graveyard Book" has not changed its position in the previous execution since it was not included between the specified start and end positions (i.e. 1 and 4 respectively).

Accompany the implementation of the function with the appropriate test cases.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.