This page is located in archive.

Timetable at FEE Students of PGE Upload system BRUTE Discussion board PRG


Download the examples and run them in your python environment.
Follow the assignments at the end of the code and calculate results or modify the code accordingly.

1. Asymptotic complexity of Python code and code fragments

Maximum sum of a contiguous subsequence
Hi-Lo game and 1D battleships game, with variants (kind of programming warm-up)

2. 1D array and list processing, Python built-in functions
1D array problems, solve them all

3. 2D arrays training problems
If the problems are too trivial for you, prove it by solving the last one in the problem list and show your solution to the teacher. After that you will be not obliged to solve the other problems. Otherwise, work through the problems one by one according to your capacity.

2D array problems, again, solve them all.

First homework Bounding Boxes

See solution hints if you do not know how to start solving the homework.

4. Text files processing, text search

The list of exercises is available at exercises page.

 −1. Read all input lines using, for example,:
        import sys
        for myLine in sys.stdin:
           # do your stuff with the text line (string) stored in myLine
        # the loop automatically recognizes the end of the input
    Be careful, some IDEs do not recognize the end of input. 
    In PyCharm, after inserting the last line in the console, 
    press CTRL+D, this is a end-of-file symbol.     
 0. NEVER use windows "notepad" application to view/process text files. 
    It does not display/process the text correctly and it is completely unreliable.
    Use either editor in your Python IDE or any *programmer's* text editor 
    many of which are available for free on the web.   
 1. The data files are big. Create a smaller copy of a data file using your text editor, 
    just by copying first 20-40 lines into a new text file. You can easily check 
    the behaviour of your code and debug it when processing the small file.
    When the programs seems to be working correctly on the small file 
    try to process the original big one.
 2. Proceed in small steps when writing your code. 
    First just read the file and copy its contents to the screen. 
    Next, copy to the screen those text lines which satisfy some condition 
    (even partially) specified in the problem. 
    Also, print with each text line some additional information regarding that line 
    like e.g.  length, number of words in it, number of specific characters etc.
    This helps you to get confidence that the program logic is correct. 
    It also helps in debugging when the program is failing.

5. Recursive functions and procedures. Recursive generation of data/objects

The list of exercises is available at exercises page.

6. Effectivity of search and sort methods on various datasets

7. Homework problems comments and consultations

8. Tree processing, In-, Pre and Post-order, recursion tree of a function call

9. Comparing effectivity of graph representations (skipped)

10. BFS and DFS implementations
The list of exercises is available at exercises page.

11. Scientific and math computations with Numpy and Scipy

12. Data processing visualisation with Python libraries

13. Repetitions, exam preparations

courses/be5b33pge/practices.txt · Last modified: 2019/04/24 11:33 by berezovs