Computer Science – Complete Study Notes
Computer Science is the study of computation, algorithms, data structures, programming languages, and computer
systems. It forms the backbone of modern digital technology and is increasingly important in all fields.
These notes cover computer basics, number systems, data structures, algorithms, programming concepts, operating
systems, networking, and database fundamentals.
Chapter 1: Fundamentals of Computing
A computer is an electronic machine that processes data according to instructions (programs). It accepts input,
processes it, stores results, and produces output. The basic cycle is: Input → Process → Output → Storage.
Hardware refers to the physical components: CPU (Central Processing Unit), RAM (Random Access Memory),
ROM (Read Only Memory), storage devices (HDD, SSD), input devices (keyboard, mouse), output devices
(monitor, printer).
Software is a set of instructions that tells the hardware what to do. System software (OS, device drivers, utilities)
manages hardware resources. Application software (browsers, word processors, games) performs specific user tasks.
CPU is the brain of the computer. It consists of ALU (Arithmetic Logic Unit) for calculations, CU (Control Unit) for
directing operations, and registers for temporary storage. CPU speed is measured in GHz.
Memory hierarchy from fastest/smallest to slowest/largest: Registers → Cache (L1, L2, L3) → RAM → Secondary
Storage (SSD/HDD) → External Storage.
Chapter 2: Number Systems
Computers use different number systems. Decimal (base 10) uses digits 0-9. Binary (base 2) uses only 0 and 1. Octal
(base 8) uses digits 0-7. Hexadecimal (base 16) uses digits 0-9 and A-F.
Binary to Decimal: Multiply each bit by 2 raised to its position. Example: 1011₂ = 1×2³ + 0×2² + 1×2¹ + 1×2 ⁰ =
8+0+2+1 = 11₁₀
Decimal to Binary: Repeatedly divide by 2 and record remainders from bottom to top. Example: 13 ÷ 2 = 6 R1, 6 ÷
2 = 3 R0, 3 ÷ 2 = 1 R1, 1 ÷ 2 = 0 R1 → Binary = 1101
Hexadecimal is used in computing because each hex digit represents exactly 4 binary bits. 0=0000, 1=0001, ...,
9=1001, A=1010, B=1011, C=1100, D=1101, E=1110, F=1111.
Binary Arithmetic: Addition rules: 0+0=0, 0+1=1, 1+0=1, 1+1=10 (carry 1). Two's complement is used to represent
negative binary numbers: flip all bits and add 1.
Memory units: 1 Bit = 0 or 1. 4 Bits = 1 Nibble. 8 Bits = 1 Byte. 1024 Bytes = 1 KB. 1024 KB = 1 MB. 1024 MB =
1 GB. 1024 GB = 1 TB. 1024 TB = 1 PB.
Chapter 3: Data Structures
Data structures are ways of organizing and storing data in a computer to enable efficient access and modification.
Choosing the right data structure is crucial for algorithmic efficiency.
Array: A collection of elements of the same type stored in contiguous memory locations. Access by index is O(1).
Insertion/deletion at middle is O(n). Fixed size in most languages.
Linked List: A sequence of nodes where each node contains data and a pointer to the next node. Dynamic size.
Insertion/deletion at beginning is O(1). Access by index is O(n). Types: singly, doubly, circular.
Stack: Last In First Out (LIFO) data structure. Operations: push (add), pop (remove), peek (view top). Applications:
function call stack, undo operations, expression evaluation, backtracking.
Queue: First In First Out (FIFO) data structure. Operations: enqueue (add at rear), dequeue (remove from front).
Applications: CPU scheduling, print spooling, BFS traversal.
Tree: Hierarchical data structure with a root node and subtrees. Binary tree: each node has at most 2 children. BST
(Binary Search Tree): left < root < right. Height-balanced: AVL tree.
Graph: A collection of nodes (vertices) connected by edges. Directed vs undirected. Weighted vs unweighted.
Representations: adjacency matrix, adjacency list. Traversals: BFS, DFS.
Hash Table: Data structure that maps keys to values using a hash function. Average case O(1) for insert, delete,
search. Collision resolution: chaining or open addressing.
Chapter 4: Algorithms
An algorithm is a step-by-step procedure for solving a problem. Key properties: finiteness, definiteness, input,
output, effectiveness. Algorithm complexity is measured using Big O notation.
Big O Notation describes the worst-case time complexity: O(1) constant, O(log n) logarithmic, O(n) linear, O(n log
n) linearithmic, O(n²) quadratic, O(2ⁿ) exponential.
Sorting algorithms: Bubble Sort O(n²) — repeatedly swap adjacent elements. Selection Sort O(n²) — find minimum
and place in position. Insertion Sort O(n²) — insert elements into sorted portion.
Merge Sort O(n log n) — divide array, sort halves, merge. Quick Sort O(n log n) average — partition around pivot.
Heap Sort O(n log n) — use max-heap. Counting Sort O(n+k) — non-comparison sort.
Searching algorithms: Linear Search O(n) — check each element. Binary Search O(log n) — requires sorted array,
compare with middle and eliminate half.
Dynamic Programming solves complex problems by breaking them into overlapping subproblems and storing
results (memoization). Examples: Fibonacci, Knapsack, Longest Common Subsequence.
Greedy algorithms make locally optimal choices hoping for a global optimum. Examples: Activity Selection,
Huffman Coding, Prim's MST, Dijkstra's Shortest Path.
Chapter 5: Operating Systems
An Operating System (OS) is system software that manages hardware resources and provides services to application
programs. Examples: Windows, Linux, macOS, Android, iOS.
Functions of OS: Process management (CPU scheduling), Memory management (allocation/deallocation), File
system management, Device management (I/O), Security and protection, User interface.
Process vs Thread: A process is an executing program with its own memory space. A thread is a lightweight unit of
execution within a process, sharing memory with other threads.
CPU Scheduling algorithms: FCFS (First Come First Serve), SJF (Shortest Job First), Priority Scheduling, Round
Robin (time quantum), Multilevel Queue Scheduling.
Memory management techniques: Contiguous allocation, Paging (fixed-size frames), Segmentation (variable-size
segments), Virtual memory (allows programs larger than RAM using paging/demand paging).
Deadlock: A situation where two or more processes are waiting for each other indefinitely. Four conditions: Mutual
exclusion, Hold and wait, No preemption, Circular wait. Prevention, avoidance (Banker's algorithm), detection, and
recovery.
Chapter 6: Computer Networks
A computer network is a collection of interconnected computers that can share resources and information. Networks
are classified by size: PAN, LAN, MAN, WAN.
Network topologies: Bus (single cable), Star (central hub/switch), Ring (circular), Mesh (every device connected to
every other), Tree (hierarchical), Hybrid.
OSI Model has 7 layers: Physical, Data Link, Network, Transport, Session, Presentation, Application. TCP/IP model
has 4 layers: Network Interface, Internet, Transport, Application.
IP addresses identify devices on a network. IPv4: 32-bit address (e.g., [Link]). IPv6: 128-bit address.
Subnetting divides a network into smaller subnetworks.
TCP (Transmission Control Protocol) is connection-oriented and reliable. UDP (User Datagram Protocol) is
connectionless and faster but unreliable. Common protocols: HTTP/HTTPS, FTP, SMTP, DNS, DHCP.
Cybersecurity threats: Malware (viruses, worms, trojans, ransomware), Phishing, SQL injection, DDoS attacks,
Man-in-the-middle attacks. Security measures: Firewalls, Encryption (SSL/TLS), Authentication, VPN.