iExamWorld
Notes

Computer Science and Engineering: Key Topics and Formulas

English · Free on iExamWorld

Overview

Computer Science papers in ISRO, BIS, DRDO and PSU recruitment tests sample every core subject of the B.Tech curriculum. Most questions are short: trace a data structure, count states or page faults, apply a formula for subnets or cache performance, or identify a normal form. This note collects those standard results.

Data Structures

  • Stack: last in, first out. Used for function calls, expression evaluation and conversion between infix and postfix.
  • Queue: first in, first out. A circular queue reuses freed slots; a deque allows insertion and deletion at both ends.
  • Binary tree: with height h (root at height 0) it holds at most 2^(h+1) − 1 nodes. In any binary tree, leaves = nodes of degree two + 1.
  • Binary search tree: in-order traversal yields sorted keys. Search is O(log n) when balanced but O(n) when skewed; AVL and red-black trees keep height O(log n).
  • Heap: a complete binary tree with the heap property; building a heap takes O(n) and each insert or delete-max takes O(log n).
  • Hashing: average O(1) lookup; collisions are resolved by chaining or open addressing (linear probing, quadratic probing, double hashing).

Algorithms and Complexity

The master theorem solves T(n) = aT(n/b) + f(n). Compare f(n) with n^(log_b a): if f is polynomially smaller, T = Θ(n^(log_b a)); if equal, T = Θ(n^(log_b a) log n); if polynomially larger (with the regularity condition), T = Θ(f(n)). Binary search on n sorted elements needs at most ⌊log₂ n⌋ + 1 comparisons.

AlgorithmBestAverageWorst
Bubble / insertion sortO(n)O(n²)O(n²)
Selection sortO(n²)O(n²)O(n²)
Merge sortO(n log n)O(n log n)O(n log n)
Quick sortO(n log n)O(n log n)O(n²)
Heap sortO(n log n)O(n log n)O(n log n)

Merge sort is stable but needs O(n) extra space; heap sort is in place but not stable. Graph algorithms to remember: BFS and DFS run in O(V + E) with adjacency lists; Dijkstra's algorithm finds single-source shortest paths with non-negative weights; Bellman–Ford handles negative edges and detects negative cycles; Kruskal and Prim build minimum spanning trees. Problems in P are solvable in polynomial time; NP-complete problems such as SAT and the decision version of the travelling salesman problem have no known polynomial algorithm.

Discrete Mathematics

  • A set with n elements has 2ⁿ subsets and 2^(n²) binary relations; the number of reflexive relations is 2^(n² − n).
  • A relation is an equivalence relation if reflexive, symmetric and transitive; it is a partial order if reflexive, antisymmetric and transitive.
  • The complete graph Kn has n(n − 1)/2 edges. In any graph the sum of degrees equals twice the number of edges, so the number of odd-degree vertices is even.
  • A tree with n vertices has n − 1 edges. A connected graph has an Euler circuit if and only if every vertex has even degree.
  • Pigeonhole principle: placing n + 1 objects in n boxes forces at least one box to hold two objects.

Theory of Computation

Regular languages are accepted by finite automata and described by regular expressions; they are closed under union, concatenation, Kleene star, complement and intersection. The pumping lemma shows that languages such as {aⁿbⁿ} are not regular because a finite automaton cannot count without bound. Context-free languages are accepted by pushdown automata; {aⁿbⁿ} is context-free while {aⁿbⁿcⁿ} is not. Turing machines accept recursively enumerable languages, and the halting problem is undecidable. A minimum DFA counting a quantity modulo k needs k states.

Compiler Basics

PhaseMain job
Lexical analysisGroups characters into tokens using regular expressions
Syntax analysisBuilds a parse tree using a context-free grammar
Semantic analysisType checking and declaration checks using the symbol table
Intermediate codeMachine-independent form such as three-address code
OptimisationConstant folding, dead-code elimination, loop optimisation
Code generationTarget machine instructions and register allocation

Top-down LL(1) parsers cannot handle left-recursive or ambiguous grammars; left recursion must be removed and common prefixes left-factored. Bottom-up LR parsers are more powerful, in the order LR(0) < SLR < LALR < canonical LR(1).

Operating Systems

CPU scheduling

Turnaround time = completion − arrival; waiting time = turnaround − burst. Non-preemptive SJF gives the minimum average waiting time when all jobs are available together. FCFS suffers from the convoy effect, Round Robin gives good response time depending on the time quantum, and priority scheduling can starve low-priority processes unless ageing is used.

Deadlock

Deadlock requires four conditions together: mutual exclusion, hold and wait, no preemption and circular wait. Banker's algorithm avoids deadlock by granting requests only when the system stays in a safe state. If n processes each need at most k units of one resource type, n(k − 1) + 1 units guarantee that deadlock cannot occur.

Memory management

With paging, a logical address splits into page number and offset. For page size 2^d bytes and an m-bit logical address, the page table has 2^(m − d) entries. A TLB caches recent translations. Page replacement policies include FIFO, LRU and Optimal; FIFO can show Belady's anomaly, where adding frames increases faults, but LRU and Optimal cannot. Thrashing occurs when processes spend more time paging than executing.

Database Management Systems

  • 1NF: atomic attribute values.
  • 2NF: 1NF and no partial dependency of a non-prime attribute on part of a candidate key.
  • 3NF: 2NF and no transitive dependency of a non-prime attribute on a key; equivalently, for every X → A, X is a superkey or A is prime.
  • BCNF: for every non-trivial X → A, X is a superkey.

In SQL, COUNT(*) counts all rows while COUNT(column) skips NULLs; WHERE filters rows before grouping and HAVING filters groups after GROUP BY. Transactions follow ACID: atomicity (all or nothing, supported by undo logging), consistency, isolation (enforced by concurrency control such as two-phase locking) and durability (supported by redo logs). A schedule is conflict serialisable if its precedence graph has no cycle.

Computer Networks

The OSI model has seven layers: physical, data link, network, transport, session, presentation and application. TCP/IP merges them into four or five. Switches work at the data link layer, routers at the network layer. TCP is connection-oriented and reliable, setting up connections with a three-way handshake; UDP is connectionless.

For subnetting, a prefix /p leaves 32 − p host bits, giving 2^(32 − p) − 2 usable hosts. The block size in the interesting octet is 256 minus the mask value in that octet; the network address is the largest multiple of the block size not exceeding the host's value, and the broadcast address is one less than the next block. For example, /27 has mask 255.255.255.224 and block size 32.

Computer Organisation

Average memory access time is AMAT = hit time + miss rate × miss penalty. Caches can be direct-mapped, fully associative or set-associative; the address is split into tag, index and block offset. A k-stage pipeline executing n instructions without stalls needs k + n − 1 cycles, and its ideal speedup over a non-pipelined design approaches k for large n. Structural, data and control hazards cause stalls, reduced by forwarding, branch prediction and duplicated resources.

Quick revision points

  • Binary search worst case: ⌊log₂ n⌋ + 1 comparisons.
  • T(n) = 2T(n/2) + n gives Θ(n log n).
  • Quick sort worst case is O(n²); merge and heap sort stay O(n log n).
  • Kn has n(n − 1)/2 edges; relations on n elements number 2^(n²).
  • {aⁿbⁿ} is context-free but not regular.
  • Undeclared variables and type errors are caught in semantic analysis.
  • Non-preemptive SJF minimises average waiting time for simultaneous arrivals.
  • Deadlock-free resource count: n(k − 1) + 1.
  • Page table entries = 2^(address bits − offset bits).
  • FIFO replacement can show Belady's anomaly.
  • A → B, B → C with key A is in 2NF but not 3NF.
  • COUNT(column) ignores NULLs.
  • Usable hosts in /p subnet: 2^(32 − p) − 2.
  • AMAT = hit time + miss rate × miss penalty; pipeline cycles = k + n − 1.

These notes were written with AI assistance for iExamWorld, based on the official syllabus. Spotted a mistake? Tell us.