Romania Clasa a XI-a Computer Science (mathematics-informatics)
Chapters: 3
1. Data structures
Two-dimensional arrays · Strings · Records · Lists · Graphs
- 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.
- Strings in Python – A string is an immutable sequence of characters written in single, double or triple quotes. Each character has a positive index (0 from the left) and a negative index (−1 from the right). Operations: + (concatenation), * (repetition), in / not in (membership) and slicing s[start:stop:step], which takes characters from start up to but not including stop. Traversal means visiting each character with a for or while loop. Built-in methods like len(), upper(), lower(), title(), capitalize(), count(), find(), index(), replace(), split(), join(), strip(), startswith(), endswith(), isalpha(), isdigit(), isalnum(), islower(), isupper() and isspace() return new values without changing the original string.
- 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.
- Linked Lists – A linked list stores items in nodes. Each node holds data and a pointer (the address of the next node). A variable called head points to the first node; the last node points to NULL. Nodes can sit anywhere in memory, so adding or removing at the front takes only a pointer change, but finding the k-th item means walking from the head.
- Graph Theory: Dots, Lines and Networks – A graph is a set of vertices (dots) joined by edges (lines). The degree of a vertex is how many edges touch it, and the sum of all degrees is twice the number of edges. An Euler trail uses every edge once and exists only when 0 or 2 vertices have odd degree. A tree is a connected graph with no cycles and n − 1 edges. Weighted graphs model roads and networks; Kruskal’s and Prim’s algorithms find a minimum spanning tree.
2. Programming methods
Divide and conquer · Backtracking
Coming soon
3. Subprograms
Subprograms · Recursion
- 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.
- Recursion: Functions That Call Themselves – Recursion is when a function solves a problem by calling itself on a smaller version of the same problem. Every recursive function needs a base case, where it stops and returns an answer directly, and a recursive case that moves closer to the base case. Each call gets its own stack frame on the call stack; frames are removed as calls return.