Kerala Plus Two Computer Science (DHSE) cheat sheet
Kerala Plus Two Computer Science (DHSE) · Keep the key ideas within reach.
Structures and Pointers in C++
A structure groups variables of different types under one name; each member is accessed with the dot operator on a variable or the arrow operator (->) on a pointer.
struct members are public by default; class members are private by default. sizeof(struct) may exceed the sum of member sizes because of padding/alignment.
A pointer stores the address of another variable. &x yields the address of x; *p dereferences p. Pointer type determines how many bytes are read on dereference.
Dynamic allocation uses new and delete (new[]/delete[] for arrays). Memory from new is on the heap; failing to delete causes a memory leak; deleting twice causes undefined behaviour.
self-referential structures hold a pointer to their own type (e.g. struct Node { int data; Node *next; }); this is the basis of linked lists and trees.
A structure can be passed to a function by value (a copy is made) or by reference/pointer (the original is modified). Arrays as struct members are copied on assignment.
this is a pointer available inside non-static member functions; it holds the address of the object on which the function was called.
Pointer arithmetic advances by the size of the pointed-to type: p+1 moves sizeof(T) bytes, not one byte.
Data Structures: Arrays, Stacks and Queues
An array stores a fixed number of elements of the same type in contiguous memory; index access a[i] is O(1), and valid indices run 0 to n-1.
In a 1-D array of size n, address of a[i] = base + i * sizeof(element); for a 2-D array in row-major order, address of a[i][j] = base + (i * cols + j) * size.
Stack is LIFO: push adds at the top, pop removes from the top; both are O(1). A stack has a single access point, the top.
Queue is FIFO: enqueue at the rear, dequeue from the front; both O(1) in a circular queue, which reuses freed slots via front = (front+1) % size.
Overflow occurs when pushing/enqueuing into a full structure; underflow occurs when popping/dequeuing from an empty one. Both must be checked before the operation.
Infix to postfix conversion uses a stack for operators; postfix evaluation scans left to right, pushing operands and applying operators to the top two values.
A circular queue is full when (rear+1) % size == front and empty when front == -1 (or front == rear depending on the convention used).
Linear search is O(n); binary search on a sorted array is O(log n) and needs random access, so it suits arrays but not linked lists.
Linked Lists and Memory Management
A linked list stores each element in a node holding data plus a pointer to the next node; nodes are non-contiguous, so no index arithmetic is possible.
Insertion or deletion at a known position is O(1) because only pointers change; finding that position costs O(n) traversal from the head.
A singly linked list node: struct Node { int data; Node *next; }; the last node's next is NULL. A doubly linked list adds a prev pointer.
Deleting a node requires saving its next pointer, linking the predecessor to it, then delete-ing the removed node to avoid a leak.
A stack implemented as a linked list pushes at the head; a queue needs both front and rear pointers to keep enqueue and dequeue O(1).
Circular linked lists have the last node pointing back to the first; traversing must stop on returning to the start rather than on NULL.
new returns NULL (or throws) on failure; delete frees heap memory but leaves the pointer dangling, so set it to NULL after deletion.
Static memory is allocated at compile time on the stack/global area; dynamic memory is allocated at run time on the heap and must be released explicitly.
Object-Oriented Programming Concepts
Four pillars: encapsulation (bundling data with methods and hiding internals), abstraction (exposing only essentials), inheritance (reuse via is-a), polymorphism (one interface, many forms).
Data hiding is achieved with the private access specifier; access goes through public member functions. A class is the blueprint; an object is an instance.
Compile-time polymorphism = function/operator overloading (resolved by signature). Run-time polymorphism = virtual functions resolved through a base-class pointer or reference.
A pure virtual function (= 0) makes a class abstract; abstract classes cannot be instantiated but can be inherited.
A friend function is not a member but can access private members; friendship is granted, not inherited, and is not mutual unless declared both ways.
Message passing means one object invokes a method of another; it is the mechanism by which objects interact at run time.
Overloading differs by parameter list; overriding redefines a base virtual function with the same signature in a derived class.
Classes, Objects, Constructors and Inheritance
A constructor has the same name as the class, no return type, and runs automatically when an object is created; it can be overloaded.
A default constructor takes no arguments; if any constructor is declared, the compiler no longer supplies one. A destructor (~ClassName) runs when an object is destroyed.
A copy constructor (ClassName(const ClassName &)) initialises an object from another of the same class; it is invoked on pass-by-value and on initialisation from an existing object.
Initialiser list syntax ClassName(args) : member(value) {} initialises members before the constructor body runs; order follows declaration order, not list order.
Inheritance syntax: class Derived : access Base. public inheritance keeps public members public and protected members protected in the derived class.
A derived constructor calls the base constructor first (explicitly via Base(args) in the initialiser list, otherwise the base default constructor), then its own members, then its body.
Destructors run in reverse order: derived destructor first, then base. A virtual destructor in the base ensures correct cleanup through a base pointer.
Multiple inheritance allows a class to inherit from more than one base; ambiguity from duplicate member names is resolved with the scope-resolution operator.
Database Concepts and SQL
A relation is a table; a tuple is a row; an attribute is a column. A primary key uniquely identifies rows and cannot be NULL; a foreign key references a primary key in another table.
Candidate keys are all minimal unique identifiers; one is chosen as the primary key. Alternate keys are the remaining candidates.
DDL: CREATE, ALTER, DROP. DML: SELECT, INSERT, UPDATE, DELETE. DCL: GRANT, REVOKE. TCL: COMMIT, ROLLBACK.
SELECT columns FROM table WHERE condition GROUP BY col HAVING condition ORDER BY col [ASC|DESC]; WHERE filters rows, HAVING filters groups after aggregation.
Aggregate functions: COUNT, SUM, AVG, MIN, MAX. COUNT(*) counts rows including NULLs; COUNT(col) ignores NULLs.
Joins: INNER returns matching rows; LEFT/RIGHT outer joins keep unmatched rows from one side with NULLs; a Cartesian product results from a join with no condition.
Constraints: PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL, CHECK, DEFAULT. Referential integrity forbids a foreign key pointing to a nonexistent parent row.
Web Technology: HTML, CSS and JavaScript
HTML gives structure (elements and attributes), CSS gives presentation (selectors, box model: content, padding, border, margin), JavaScript gives behaviour in the browser.
Core HTML tags: , , , <body>, <h1>-<h6>, <p>, <a href>, <img src alt>, <ul>/<ol>/<li>, <table>/<tr>/<td>, <form>.</p>
CSS can be inline (style attribute), internal (
Selector specificity order: inline style > id (#) > class (.) > element tag; later rules win among equal specificity.
JavaScript is case-sensitive and dynamically typed; var is function-scoped while let and const are block-scoped. Functions are first-class values.
DOM access: document.getElementById, querySelector, addEventListener. Form validation can run client-side in JavaScript, but server-side validation is still required.
The box model total width = content width + left/right padding + left/right border + left/right margin (with box-sizing: border-box, padding and border are inside the declared width).
PHP and Server-Side Scripting
PHP is a server-side, embedded scripting language: code between executes on the server and only its output reaches the browser.
Variables start with $ and are loosely typed; strings concatenate with . and arrays are associative or indexed, e.g. $a = array("k" => 1).
Superglobals: $_GET and $_POST carry form data, $_REQUEST combines them, $_SESSION stores per-user state, $_COOKIE reads cookies, $_SERVER holds request/server details.
session_start() must be called before output; session data lives on the server, whereas a cookie is stored on the client and can be tampered with.
Database access with mysqli/PDO: connect, prepare a statement, bind parameters, execute, fetch. Prepared statements with bound parameters prevent SQL injection.
Form input must be validated and sanitised server-side; htmlspecialchars() escapes output to prevent cross-site scripting (XSS).
PHP is embedded in HTML and runs on the server; JavaScript runs on the client. A PHP page can generate HTML, JSON or any other output the client requests.
Computer Networks and Internet Basics
OSI layers (1-7): Physical, Data Link, Network, Transport, Session, Presentation, Application. TCP/IP maps to four layers: Network Access, Internet, Transport, Application.
IP provides addressing and routing (connectionless); TCP adds reliable, ordered, connection-oriented delivery with flow control; UDP is connectionless and unreliable but low-latency.
IPv4 addresses are 32 bits, written as four dotted decimal octets; IPv6 is 128 bits. A subnet mask separates network and host bits.
Common ports: HTTP 80, HTTPS 443, FTP 21, SMTP 25, POP3 110, SSH 22, DNS 53, Telnet 23.
DNS resolves domain names to IP addresses; DHCP assigns IP addresses dynamically; ARP maps an IP address to a MAC address on a local network.
Topologies: star (central hub/switch, single point of failure), bus (shared backbone), ring, mesh (redundant but costly). LAN is local; WAN spans large distances.
Devices: hub broadcasts to all ports (Layer 1), switch forwards by MAC address (Layer 2), router forwards by IP address between networks (Layer 3).
ICT, IT Applications and Emerging Trends
e-Governance delivers government services online; e-Learning uses digital platforms; e-Business/e-Commerce covers online buying, selling and transactions.
Cloud computing delivers computing as a service: IaaS (infrastructure), PaaS (platform), SaaS (software). Public, private and hybrid are deployment models.
IoT connects physical devices with sensors and network connectivity to collect and exchange data; edge and fog computing process data near the source.
Artificial intelligence and machine learning build systems that learn from data; big data is characterised by volume, velocity, variety, veracity and value.
Blockchain is a distributed, append-only ledger of cryptographically linked blocks; it gives tamper-evident records without a central authority.
Licensing: proprietary software restricts use, modification and redistribution; free and open-source software (FOSS) grants those freedoms under licences such as GPL.
Digital signatures use asymmetric keys (private key to sign, public key to verify) and provide authentication, integrity and non-repudiation, not confidentiality.