CAPE Computer Science Unit 2 - Detailed Study Notes
CAPE Computer Science Unit 2 - Detailed Study Notes
General Objective 1: Appreciate the use of abstract data types (ADTs) in the efficient
manipulation of data
An Abstract Data Type is a mathematical model for data types where the data type is defined
by its behaviour from the perspective of the user, not its implementation. ADTs separate the
interface (what operations can be performed) from the implementation (how those
operations are carried out), allowing programmers to focus on what the data structure does
rather than how it works internally.
This abstraction enables modular programming, code reusability, and the ability to change
implementation details without affecting the rest of the program. For example, a stack ADT
specifies operations like push and pop, but whether it is implemented using arrays or linked
lists is irrelevant to the user of the stack.
Stack (LIFO - Last In, First Out): Elements are added and removed from the same end (top).
The last element inserted is the first element removed. Real-world analogy: a stack of plates
where you add and remove plates from the top only.
Queue (FIFO - First In, First Out): Elements are added at the rear and removed from the
front. The first element inserted is the first element removed. Real-world analogy: a line of
customers at a bank where the first person in line is served first.
Singly Linked List: A linear collection of nodes where each node contains data and a pointer
to the next node. Unlike arrays, linked lists are dynamic and can grow or shrink during
runtime. Insertion and deletion operations are efficient (O(1) at known positions) but
accessing elements requires sequential traversal (O(n)).
3. Perform basic operations on standard ADTs using diagrams and algorithms
Stack Operations:
- Push: Add an element to the top of the stack
```
if top < maxSize - 1
top = top + 1
stack[top] = value
else
stack is full (overflow)
```
Queue Operations:
- Enqueue: Add an element to the rear of the queue
```
if rear < maxSize - 1
rear = rear + 1
queue[rear] = value
if front == -1
front = 0
else
queue is full
```
int pop() {
if (top >= 0) {
return stack[top--];
}
return -1; // error value
}
int isEmpty() {
return top == -1;
}
```
int dequeue() {
if (front != -1) {
int value = queue[front];
if (front == rear) {
front = rear = -1;
} else {
front = (front + 1) % MAX;
}
return value;
}
return -1;
}
```
Circular queues prevent the "false overflow" problem where a linear queue appears full even
though positions at the beginning become available after dequeuing. The modulo operator
(%) wraps indices around to reuse vacated spaces.
General Objective 2: Understand basic algorithms for sorting and searching
Linear Search: Sequentially checks each element in the array until the target is found or the
end is reached. Works on both sorted and unsorted arrays. Time complexity: O(n) worst
case, O(1) best case. Simple to implement but inefficient for large datasets.
Binary Search: Repeatedly divides the search interval in half. Requires a sorted array.
Compares target with middle element; if equal, search is successful; if target is less, search
left half; if greater, search right half. Time complexity: O(log n). Much more efficient than
linear search for large sorted datasets.
Bubble Sort: Repeatedly steps through the array, compares adjacent elements, and swaps
them if they are in the wrong order. Each pass "bubbles" the largest element to its correct
position at the end. Time complexity: O(n²) worst and average case, O(n) best case when
array is already sorted. Simple but inefficient for large datasets.
Selection Sort: Divides array into sorted and unsorted regions. Repeatedly selects the
smallest (or largest) element from the unsorted region and swaps it with the first element of
the unsorted region. Time complexity: O(n²) in all cases. Makes fewer swaps than bubble
sort but same number of comparisons.
---
if (arr[mid] == target) {
return mid;
} else if (arr[mid] < target) {
return binarySearchRecursive(arr, mid + 1, right, target);
} else {
return binarySearchRecursive(arr, left, mid - 1, target);
}
}
return -1;
}
```
Complexity Analysis:
- Time Complexity: Measures how execution time grows as input size increases
- Space Complexity: Measures how memory usage grows as input size increases
- Big O notation describes upper bound (worst case), Omega describes lower bound (best
case), Theta describes tight bound
ADT Comparison Table:
General Objective 1: Understand the phases of the software development life cycle
1. Explain the reasons for a structured approach to the software development process
Structured methodologies provide visibility into the development process, enabling better
management control, risk assessment, and resource allocation. They establish clear
milestones, deliverables, and quality checkpoints while ensuring appropriate documentation
is created. Furthermore, structured approaches facilitate standardisation across projects,
improve communication among team members, and formally incorporate end-users and
management throughout the development lifecycle to ensure the final product truly
addresses business requirements.
Maintainability: Software should be written in a way that makes it easy to modify, correct
defects, adapt to new requirements, and change environments. This requires clear
documentation, consistent coding standards, modular design, and meaningful variable
names. Maintainable software reduces long-term costs and extends the useful life of the
system.
Dependability: The software must be reliable, available, and secure. It should perform its
required functions under stated conditions for a specified period, remain accessible when
needed, and protect against unauthorized access or data corruption. Dependability inspires
user confidence and prevents business disruptions.
Usability: The software must be intuitive, easy to learn, and efficient to use for its intended
audience. This includes appropriate user interface design, clear error messages, consistent
navigation, and accessibility features. High usability reduces training costs and user errors.
3. Identify different generic software process models and examine their strengths and
weaknesses
Waterfall Model: A linear sequential approach where each phase must be completed before
the next begins: requirements, design, implementation, testing, deployment, maintenance.
Strengths include simple management, clear milestones, and thorough documentation.
Weaknesses include inflexibility, late detection of errors, and difficulty accommodating
changing requirements. Best suited for projects with stable, well-understood requirements.
Fountain Model: An object-oriented variant where phases overlap and iteration occurs within
and between phases. Objects and classes are developed incrementally. Strengths include
support for reuse, flexibility, and object-oriented paradigm alignment. Weaknesses include
complex project tracking and management difficulty.
4. Outline the main activities, tools, techniques, and deliverables of the analysis phase
Activities:
- Feasibility Study: Determines whether the proposed system is technically feasible,
economically viable, and operationally acceptable. Assesses costs, benefits, risks, and
alignment with organisational strategy.
- Requirements Analysis: Elicits, documents, validates, and manages stakeholder
requirements. Identifies what the system must do, constraints it must operate under, and
quality attributes it must exhibit.
Tools and Techniques:
- Data Gathering: Interviews (structured/unstructured), questionnaires, direct observation,
document analysis, and joint application development (JAD) sessions
- Data Flow Diagrams (DFD): Graphical representation showing how data moves through the
system using symbols for external entities, processes, data stores, and data flows
- Entity-Relationship Diagrams (ERD): Illustrates data entities, their attributes, and
relationships between entities
- Object Models: UML diagrams (class diagrams, use case diagrams) showing system
objects and their interactions
- Data Dictionary: Central repository containing definitions, structures, and relationships of all
data elements
- CASE Tools: Computer-Aided Software Engineering tools that automate diagramming,
consistency checking, and documentation generation
- Prototyping: Building working models to clarify requirements and validate understanding
with users
Deliverables:
- Feasibility Report: Document presenting findings and recommendations regarding project
viability
- Requirements Specification: Comprehensive document detailing functional requirements
(what the system does) and non-functional requirements (performance, security, usability,
reliability constraints)
- Validated Requirements: Requirements that have been reviewed and approved by
stakeholders
5. Outline the main activities, tools, techniques, and deliverables of the design phase
Activities:
- Architectural Design: Identifies overall system structure, components, their relationships,
and allocation to hardware/software platforms
- Interface Design: Specifies how users interact with the system, including screens, reports,
input forms, and navigation
- Data Structure Design: Defines database schemas, file structures, and data organisation
- Algorithm Design: Develops detailed logic for each program module
Design Guidelines:
- Screen design should maintain consistency, use appropriate fonts and colours, provide
clear labels and instructions, group related items logically
- Report design should consider audience needs, include appropriate headers/footers, use
meaningful column headings, provide summary information
- User interfaces should be intuitive, minimise user memory load, provide feedback, support
error prevention and recovery
Deliverables:
- System Architecture: Documentation of overall system structure, hardware/software
platform decisions, and component allocation
- Design Specification: Detailed description of modules, interfaces, data structures, and
algorithms sufficient for implementation
6. Outline the main activities, tools, techniques, and deliverables of the implementation
phase
Activities:
- Coding: Translating design specifications into executable programs using appropriate
programming languages
- Unit Development: Creating individual program modules according to design specifications
- Code Reviews: Systematic examination of source code by peers to identify defects and
ensure adherence to standards
- Documentation: Producing technical documentation and user manuals
Deliverables:
- Source Code: Complete program code written in the specified programming language
- Executable Program: Compiled/interpreted software ready for testing
- Technical Documentation: Comments, module descriptions, and programmer guides
- User Documentation: Manuals, help systems, and training materials
7. Outline the main activities, tools, techniques, and deliverables of the validation phase
Activities:
- Test Planning: Developing comprehensive test strategies, test cases, and test data
- Software Inspection: Formal, systematic review of requirements, design, or code without
executing the program
- Testing: Executing the program with various inputs to discover defects
- Defect Tracking: Recording, managing, and monitoring resolution of identified defects
Deliverables:
- Test Plan Document: Comprehensive testing strategy and schedule
- Test Reports: Documentation of test results, defects found, and resolution status
- Verified Software: Software that has been tested and confirmed to meet requirements
- Defect Log: Complete record of identified defects and their resolution
8. Outline the main activities, tools, techniques, and deliverables of the evolution phase
Activities:
- Maintenance: Correcting defects discovered after deployment
- Adaptation: Modifying software to operate in changed environments (new hardware,
operating systems, regulations)
- Enhancement: Adding new features or improving existing functionality
- Re-engineering: Restructuring or rewriting parts of the system to improve quality while
preserving functionality
- Retirement: Planned removal of the system from operation
General Objective 2: Appreciation for methods, processes, tools and techniques in software
engineering
Risk Management:
- Risk Identification: Determining potential project, product, and business risks
- Risk Analysis: Assessing probability and potential impact of each risk
- Risk Planning: Developing strategies to avoid, mitigate, transfer, or accept risks
- Risk Monitoring: Continuously tracking risks and effectiveness of mitigation strategies
UNIT 2 MODULE 3: OPERATING SYSTEMS AND COMPUTER NETWORKS
An operating system is system software that manages computer hardware and software
resources and provides common services for computer programs. As a resource manager,
the OS allocates CPU time, memory space, storage capacity, and input/output devices
among competing programs, ensuring efficient and fair utilisation while preventing conflicts.
It keeps track of which resources are in use, by whom, and for how long.
As an interface, the OS hides the complexity of hardware from users and applications,
providing a clean, abstract interface to access system resources. This abstraction allows
programmers to write applications without needing detailed knowledge of underlying
hardware specifics. The OS presents this interface through system calls, which are
programmatic requests for services, and through user interfaces (command-line, graphical,
or touch) that allow humans to interact with the computer.
Second Generation (1950s-1960s): Batch processing systems emerged. Jobs with similar
requirements were grouped together, and a monitor program controlled job sequencing.
Punched cards and magnetic tapes were primary input/output media. When one job finished,
the monitor automatically loaded the next, reducing transition time. However, CPU often
remained idle during slow I/O operations.
Fifth Generation (2000s-Present): Mobile operating systems (iOS, Android), cloud computing
platforms, and virtualisation have become dominant. Modern OSes support multi-core
processors, sophisticated security features, power management for portable devices, and
distributed computing paradigms. Containerisation and microkernel architectures represent
ongoing evolution trends.
Bootstrap Process:
When power is applied, the CPU executes code from ROM (typically the BIOS or UEFI).
This code performs Power-On Self-Test (POST), initialises hardware, and locates the
bootloader from the boot device. The bootloader loads the operating system kernel into
memory, transfers control to it, and the kernel then initialises its data structures, device
drivers, and system services before presenting the user interface.
Process Management:
- Definition: A process is a program in execution, including program code, current activity,
stack, data section, and heap
- Process States: New (being created), Ready (waiting for CPU), Running (instructions being
executed), Blocked/Waiting (waiting for I/O or event), Terminated (finished execution)
- Process Control Block (PCB): Kernel data structure containing process ID, program
counter, registers, memory limits, open files, and scheduling information
- Context Switching: Saving current process state and loading another process's saved state
Interrupt Mechanism:
Interrupts are signals that temporarily suspend normal program execution to handle urgent
events. When an interrupt occurs, hardware saves the current instruction pointer, jumps to
the interrupt handler address in the interrupt vector table, executes the handler, then
restores the saved state. Types include:
- Internal Interrupts (Traps/Exceptions): Generated by running process (division by zero,
system calls)
- I/O Interrupts: Hardware signals completion of input/output operations
- External Interrupts: Timer interrupts, power failure alerts
- Restart Interrupt: Reinitialises the system
Deadlock:
A permanent blocking state where two or more processes are each waiting for resources
held by the others, none can proceed. Four necessary conditions: mutual exclusion, hold
and wait, no preemption, circular wait. Prevention strategies include breaking any of these
conditions through resource allocation policies.
Scheduling Algorithms:
- Non-preemptive: Process runs until it voluntarily relinquishes CPU or terminates
- First-Come-First-Served (FCFS): Simplest algorithm; processes execute in order of arrival
- Shortest-Job-First (SJF): Selects process with smallest expected CPU burst time
File Management:
- Directories/Folders: Hierarchical organisation structures for grouping files
- Files: Named collections of related information stored on secondary storage
- Operations: Create, delete, open, close, read, write, seek
Security:
- User IDs/Passwords: Authentication mechanisms to verify identity
- Lockwords: Additional authentication for specific resources
- Access Control Lists (ACL): Specify which users/groups have what permissions for each
object
- File Encryption: Transforming data to prevent unauthorised access
- File Compression: Reducing storage space requirements
- Activity Logs: Recording system events for audit and forensic purposes
Interface (User):
- Command-Line Interface (CLI): Text-based interaction using commands
- Menu Interface: Selection from displayed options
- Graphical User Interface (GUI): Visual interaction using windows, icons, menus, pointer
Device Management:
- Device Drivers: Kernel modules that understand device specifics and provide uniform
interface
- Interrupt Handling: Processing device-generated interrupts through PCB management
- I/O Control: Sending commands to devices
- Peripheral Control: Managing attached devices
- Polling: Periodically checking device status (alternative to interrupts)
- Buffering: Temporary storage area to smooth data transfer between devices with different
speeds
- Spooling: Simultaneous Peripheral Operations On-Line; queue for devices that cannot
interleave data (printers)
General Objective 2: Develop an appreciation for networking technology and applications
Network Architecture:
- Ethernet: Most widely used LAN technology; uses CSMA/CD (Carrier Sense Multiple
Access with Collision Detection); speeds from 10 Mbps to 100 Gbps
- FDDI (Fiber Distributed Data Interface): 100 Mbps token-passing ring network using fiber
optic cable; provides redundancy through dual counter-rotating rings
Network Topology:
- Star: All devices connect to central hub/switch; easy installation and troubleshooting;
central point of failure
- Ring: Devices connected in circular path; data travels in one direction; deterministic
access; single break disrupts entire network
- Bus: All devices share common backbone cable; economical for small networks; difficult
troubleshooting; limited length
- Hybrid: Combination of topologies (star-bus, star-ring)
Network Devices:
- Modem: Modulates/demodulates signals for transmission over analog lines
- Switch: Connects devices within LAN; uses MAC addresses to forward frames only to
intended recipient
- Router: Connects different networks; uses IP addresses to determine optimal path;
maintains routing tables
- Bridge: Connects two network segments; filters traffic based on MAC addresses
- Network Interface Card (NIC): Provides physical connection to network media; has unique
MAC address
- Hub: Simple repeater; broadcasts all traffic to all ports; inefficient use of bandwidth
Transmission Media:
- Wired:
- Twisted Pair: UTP (unshielded) and STP (shielded); RJ45 connectors; Categories 5e, 6,
6a; up to 10 Gbps; 100m maximum distance
- Coaxial: Copper core with insulation, braided shield; BNC connectors; used in cable TV,
older Ethernet
- Fiber Optic: Glass/plastic strands carrying light pulses; SC, ST, LC connectors; immune to
electromagnetic interference; high bandwidth; long distances
- Wireless:
- Satellite: Geostationary or low-earth orbit; wide coverage; high latency
- Microwave: Terrestrial line-of-sight; point-to-point; affected by weather
- Infrared: Short-range; line-of-sight; remote controls, some LANs
- IEEE1394 (Firewire): High-speed serial bus; hot-swappable; daisy-chaining; video
cameras, external drives
Protocols:
- TCP/IP (Transmission Control Protocol/Internet Protocol): Core Internet protocol suite; TCP
provides reliable, connection-oriented delivery; IP provides addressing and routing
- FTP (File Transfer Protocol): Transfers files between client and server; separate control
and data connections
- HTTP (Hypertext Transfer Protocol): Web page retrieval; request-response; stateless
- HTTPS: HTTP over SSL/TLS; encrypted communication
- IEEE 802.11a/b/g/n/ac/ax: Wireless LAN standards; varying frequencies, speeds, ranges
- IEEE 802.16g (WiMAX): Wireless metropolitan area network; broadband access
- VoIP (Voice over Internet Protocol): Transmitting voice over IP networks; protocols include
SIP, H.323, RTP
- OSI Model: Seven-layer conceptual framework (Physical, Data Link, Network, Transport,
Session, Presentation, Application)
Networking Considerations:
- Cost: Hardware, software, installation, training, maintenance, upgrades
- Security: Firewalls, encryption, authentication, intrusion detection, VPNs
- Management: Monitoring, configuration, fault detection, performance tuning
- Expandability: Ability to add users, devices, applications without major redesign
- Interconnectivity: Compatibility with existing and future systems
- Wired vs Wireless: Bandwidth, security, mobility, installation cost, reliability trade-offs
Network Configuration Types:
- Multiuser: Multiple terminals connected to single host computer; terminals perform no
processing
- Client Server: As previously described
- Centralised vs Distributed: Centralised places control and resources in single location;
distributed spreads across multiple locations
- Peer-to-Peer: All computers equal; each can act as client or server; no central control
Network Security:
- Firewalls: Hardware or software filtering traffic based on rules; packet filtering, stateful
inspection, application gateway, next-generation