Romania Clasa a IX-a Computer Science (intensive)
Chapters: 3
1. Conceptual organisation of data
Linear conceptual model: the list
- Data Structures: Arrays, Lists, Stacks, Queues and Trees – A data structure is a way of organising data in memory so a program can use it well. Arrays keep items in numbered boxes for instant access by index. Linked lists chain nodes with pointers, so inserting is easy. Stacks work last-in-first-out, queues first-in-first-out. Dictionaries find values by key, and trees store data in levels so searching is fast. Choosing the right structure makes programs faster and simpler.
2. Problem-solving strategies
Principles of writing a program · Processing numbers · Systematic generation of list items · Sorting a list
- Number Algorithms – A number algorithm is a short list of steps a computer repeats to work with numbers. Use n % 10 and n ÷ 10 to take digits one by one. Find divisors in pairs, split a number into primes, find the HCF with Euclid's method (replace (a, b) by (b, a mod b)), and change base by dividing again and again.
- Sequences and Progressions – A sequence is a list of numbers in a fixed order. We can describe it with a recursive rule (how to get the next term from the last one) or an explicit rule (a formula for term n). In an arithmetic progression (AP) we add the same number every time. In a geometric progression (GP) we multiply by the same number every time. Fractals and the Tower of Hanoi are fun patterns that hide these rules.
- Sorting Algorithms – A sorting algorithm puts a list in order. Bubble sort swaps neighbours, insertion sort slides each item into a sorted part, selection sort picks the smallest each time, and merge sort splits the list and merges sorted halves. Merge sort needs far fewer comparisons on long lists (about n log₂ n instead of about n²/2).
3. Storing data and organising code in a programming language
Subprograms · Introduction to object-oriented programming · Text files · Graphical interfaces with Tkinter · Python list class · One-dimensional arrays in C++
- Functions in Python: Build Your Own Machines – A function is a named block of code that does one job. Python has built-in functions (print, len), functions inside modules (math.sqrt, random.randint) and user-defined functions you write with def. Values sent in a call are arguments; the names that receive them are parameters. Arguments can be positional, keyword or use default values. return sends a value back. Python runs code top to bottom, jumps into a function when it is called and comes back after it. Names made inside a function are local; names made outside are global.
- Object-Oriented Programming (OOP) – Object-oriented programming builds a program out of objects. A class is a blueprint that lists the data (attributes) and actions (methods) its objects will have. Each object is made from a class and keeps its own data. The four big ideas are encapsulation (hide data behind methods), inheritance (a new class reuses an old one), polymorphism (the same method call behaves in the right way for each object) and abstraction (show only what is needed).
- File Handling in Python: Save Data That Lasts – Variables vanish when a program ends; files keep data on the disk. A text file stores characters in lines, a binary file stores raw bytes (such as pickled Python objects), and a CSV file stores table rows with commas. You open a file with open(path, mode), using an absolute or relative path and a mode such as r, w, a, r+, rb or wb. The with statement closes the file for you. Text files use write, writelines, read, readline and readlines. seek moves the file pointer and tell reports where it is. pickle.dump and pickle.load save and load objects in binary files, letting you search, append and update records. The csv module's writer (writerow, writerows) and reader handle CSV files.
- GUI Programming with Tkinter: Windows, Widgets and Events – A GUI (graphical user interface) lets people use a program with windows, buttons and boxes instead of typing commands. In Python the built-in Tkinter library makes this easy: create a window with Tk(), add widgets such as Label, Entry and Button, arrange them with pack, grid or place, and connect each button to a function. The program then waits in mainloop() and runs your functions when events like clicks and key presses happen.
- Lists in Python: Create, Traverse, Change and List Methods – A list is an ordered, changeable collection written in square brackets, like [10, 20, 30]. Items are reached by index (from 0, or negative from the end) and slices. We traverse a list with a for loop, change items in place because lists are mutable, and use functions (len, max, min, sum, sorted, list) and methods (append, insert, extend, remove, pop, sort, reverse, count, index, clear) to work with it.
- Arrays and Lists: Storing Many Values in One Name – An array is a row of numbered boxes that share one name. Each box holds one value and has an index that starts at 0. We read or change a box with its index, visit every box with a loop (traversal), and use that loop for standard algorithms: sum, average, largest, count and linear search. A 2D array is a grid of rows and columns, read with two indexes and two nested loops. A fixed array has a set length; a list (Python list, Java ArrayList) can grow and shrink.