vault backup: 2024-10-16 09:12:37
This commit is contained in:
86
Data Structures/Week 1/Lecture 1 - Module Intro.md
Normal file
86
Data Structures/Week 1/Lecture 1 - Module Intro.md
Normal file
@@ -0,0 +1,86 @@
|
||||
# Module Support and Assessment
|
||||
|
||||
- Assessed Via:
|
||||
- Written Exam (100%)
|
||||
|
||||
# Specific Objective
|
||||
|
||||
- Data Structures - How data organised.
|
||||
- Algorithms - Unambiguous sequence of events / steps to compute.
|
||||
|
||||
# Why Data #Structures Are Useful
|
||||
|
||||
- DSA demonstrates:
|
||||
- Problem-solving ability
|
||||
- Analytical Skills
|
||||
- Which algo, data type would be best to efficiently solve problems
|
||||
- Fundamentals of Software Dev
|
||||
- Remain constant no matter the technology or language
|
||||
- Programs solve problems, and process information
|
||||
- Information needs to be organised in certain ways, and must be correct and efficient.
|
||||
- We organise data to attain faster access to data, using both the correct data structure, and correct algorithm.
|
||||
- Examples of data types / structures on the module:
|
||||
- Arrays
|
||||
- Linked Lists
|
||||
- Stacks
|
||||
- Queues
|
||||
- Trees
|
||||
- Hash Tables
|
||||
- Graphs
|
||||
|
||||
## Examples
|
||||
|
||||
- 
|
||||
- 
|
||||
- 
|
||||
- N is linear, log2(n) is logarithmic.
|
||||
|
||||
# Why #Algorithms Are Useful
|
||||
|
||||
- Important for all branches of CS
|
||||
- Plays a role in modern innovation
|
||||
- ex. Search Engines (Page Rank)
|
||||
- Give estimates for running time (using Big O notation)
|
||||
- Help to decide hardware requirements
|
||||
|
||||
# Module Objectives
|
||||
|
||||
- Necessary to understand most important data structures used when designing / implementing software
|
||||
- Allows discussion and comparison of data structures and assessment of usage circumstances.
|
||||
- Concept of algorithms is fundamental
|
||||
- Variety of possible approaches can lead to competing algorithms
|
||||
- Each algorithm is likely to have different resource requirements, time usage or use case.
|
||||
- Analyse requirements and provide understanding for usage of choices.
|
||||
|
||||
# Module Aims
|
||||
|
||||
- Introduce important data structures
|
||||
- Understand abstract data types
|
||||
- Show variety of implementations of ADTs
|
||||
- Introduce detailed appreciation of data structures, including:
|
||||
- Linear Lists
|
||||
- Stacks
|
||||
- Queues
|
||||
- Trees
|
||||
- Graphs
|
||||
- Appreciate relationship between ADTs and Data Structures
|
||||
- Develop Skills required to express methods for solving problems precisely
|
||||
- Analyse complexity of implementation
|
||||
- Develop deeper understanding of recursion
|
||||
|
||||
## End Goals
|
||||
|
||||
- Describe and contrast algorithmic strategy
|
||||
- Demonstrate understanding of recursion
|
||||
- Utilise standard notation for computational complexity
|
||||
- Demonstrate precise and formal understanding of resource requirements of algorithms, and their inner workings.
|
||||
|
||||
# Mathematical Requirements
|
||||
|
||||
- Basic Algebra
|
||||
- Indices
|
||||
- Log
|
||||
- Graphs
|
||||
- Limits and Asymptotic Notations (Big O)
|
||||
- Summations of series, including arithmetic and geometric series
|
||||
- Recurrence relations
|
94
Data Structures/Week 1/Lecture 2 - Data Structures & ADTs.md
Normal file
94
Data Structures/Week 1/Lecture 2 - Data Structures & ADTs.md
Normal file
@@ -0,0 +1,94 @@
|
||||
- "Software engineering is the application of a systematic, disciplined, quantifiable approach to the development, operation, and maintenance of software, and the study of these approaches."
|
||||
- Software Development Lifecycles allow creation or modification of computer systems. One phase is the **implementation** stage.
|
||||
|
||||
# Data #Structures
|
||||
|
||||
- Arrangement of data in computer memory
|
||||
- Makes data quickly available to the processor
|
||||
- A sort of software allowing data to be stored, organised and accessed.
|
||||
|
||||
# Abstract Data Types ( #ADT )
|
||||
|
||||
- ADT is used to define high level features and operations for data structures.
|
||||
- Required before exploration of implementation of data structures.
|
||||
- Before implementing a linked list for example, it would be good to understand what we want to do with said defined linked list.
|
||||
- Should be able to insert, delete, search, and see if it is populated.
|
||||
- ADT is a model of data structure that specifies characteristics of the collection, and the operations performed on it.
|
||||
- Abstract, since it does not specify how the ADT will be implemented
|
||||
- Just need to know type of data required, and allowed operations.
|
||||
- Any given ADT can have multiple implementations.
|
||||
|
||||
# Types of Data Structures
|
||||
|
||||
| Data Type | Description |
|
||||
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Integer | Represents number with no decimal point |
|
||||
| Float | Represents number with decimal point |
|
||||
| Character | Represents single char |
|
||||
| Boolean | Represents logical values |
|
||||
| Tree | Flexible, versatile and powerful. Non-linear. Used to represent data items processing hierarchical relationships between the grandfather and his children and grandchildren. Ideal data structure for representing hierarchical data. |
|
||||
| Graph | Non-Linear. Consists of a finite set of ordered pairs called edges. Set of elements connected by edges. Each element called vertex and node. |
|
||||
| Arrays | Collection of elements. Used in mathematical processes like matrices, algebra, etc. Each element of an array is referenced by subscripted variables or values, called subscript or index, enclosed in parethesis. |
|
||||
| Linked List | Collection of data elements. Consists of 2 parts, Info and Link. Info gives information, and Link is address of next node. Linked List can be implemented by using pointers. |
|
||||
| Stack | List of data elements. In a stack, elements may be inserted or deleted at one end, known as the top of the stack. Performs Push and Pop operations. The former meaning adding to the top of the stack, the latter meaning removing from the top of the stack. Also called Last-in-First-Out (LIFO) |
|
||||
| Queue | Linear list of elements. In a queue, elements are added at one end, the rear, and existing elements are removed from the other end, at the front. Also called First-in-First-out (FIFO) |
|
||||
|
||||
# #ADTs And Data Structures
|
||||
|
||||
- Common ADTs:
|
||||
- Stack
|
||||
- Queue
|
||||
- Priority Queue
|
||||
- Dictionary
|
||||
- Sequence
|
||||
- Set
|
||||
- Common Implementations used to Implement
|
||||
- Array
|
||||
- Linked List
|
||||
- Hash Table
|
||||
- Trees
|
||||
- Binary Search, Heaps
|
||||
- Data structure is a **concrete** implementation of an ADT, helps you store and organise data in memory.
|
||||
|
||||
## Implementation
|
||||
|
||||
- OOP concerned with interacting objects, however, objects do not need to know the implementation. Rather, it juts needs to know the interface, public fields and methods of the class, from which the object was created.
|
||||
- Specifically, does not need to know how the object stores it data, or how the operations are performed.
|
||||
- An ADT is a collection of data, and set of operations on the data.
|
||||
- In Java, for example, we do this using interface types.
|
||||
- A Java interface cannot contain an implementation of methods, only the signature (name, parameters, and exceptions)
|
||||
|
||||
### Example
|
||||
|
||||

|
||||
|
||||
- Using interface types allow for the possibility of several different implementations, but with a guarantee of consistent sets.
|
||||
- Data structures can then be defined as a concrete implementations within a language.
|
||||
- For example, in Java, the ArrayList data type provides a collection of information and operations for storage and access of information. It implements the `List<E>` interface, and this ADT is based on Array. Implementation is hidden, but we may understand the cost of operations.
|
||||
|
||||
# Abstraction, Modularisation, Encapsulation
|
||||
|
||||
- Abstraction is the ability to consider only relevant features of problems, and not get involved with finer details
|
||||
- Separation of purpose from implementation. Specifying *what* something does, rather than how.
|
||||
- Modularisation is breaking down problems into smaller sub-problems
|
||||
- 
|
||||
- Encapsulation is the process of binding an object's state and behaviors. A method of wrapping data and code acting on data into a single unit (ex. Classes).
|
||||
- We may want to keep classes separated and prevent them from being tightly coupled with each other.
|
||||
- With encapsulation, variables of data of a given class is hidden from other classes, and can only be accessed through methods of it's own class.
|
||||
- Also known as **Information Hiding**, which is the process of hiding details of an object or function.
|
||||
|
||||
## Summary
|
||||
|
||||
- #Abstraction removes unnecessary complexity
|
||||
- #Modularisation helps us to more easily manage large problems
|
||||
- #Encapsulation "protects" the user from unnecessary implementation details
|
||||
|
||||
# Algorithm
|
||||
|
||||
- Starting point to any solution is the specification. A step-by-step sequence of instructions leading to said solution.
|
||||
- The steps are modularised, to introduce finer detail later on as the process continues to clarity. At this point, the algorithm can be implemented as code.
|
||||
- As this process continues, the programmer gains insight into which data structures would be more appropriate, however details are left until implementation as code.
|
||||
|
||||
### Example
|
||||
|
||||

|
@@ -0,0 +1,66 @@
|
||||
# Lists
|
||||
|
||||
- Ordered
|
||||
- Denoted by (a1, a2, … an) or {a1, a2, …an}
|
||||
|
||||
# Strings and Queues
|
||||
|
||||
## Strings
|
||||
|
||||
- Ordered list
|
||||
- (1,2,3,4) or {1,2,3,4}
|
||||
|
||||
## Queue
|
||||
|
||||
- Special list, where elements are removed from the bottom, and added to the top.
|
||||
|
||||
# Sets, Elements
|
||||
|
||||
- Any collection of objects is a set
|
||||
- Objects contained in a set are elements, or members
|
||||
- Set defined with braces.
|
||||
- Conventional to use singular capital letters for names of sets.
|
||||
- Commonly denoted a `a ∈ S`, where `a` is an element of the set `S`.
|
||||
- Elements that are not contained are denoted as `d ∉ S`, where `d` is not an element of the set `S`.
|
||||
|
||||
## #Cardinality
|
||||
|
||||
- Cardinality of a set is the number of elements contained in the set.
|
||||
- For example, let S = {a,b,c}, the cardinality of S is 3.
|
||||
- These facts are denoted symbolically
|
||||
- n(S) = 3.
|
||||
|
||||
## Set Equality
|
||||
|
||||
- Two sets are equal if they contain exactly the same elements.
|
||||
|
||||
## #Subsets
|
||||
|
||||
- Suppose V is a set, and W is a set formed using only elements of V.
|
||||
- W would be a **subset** of V
|
||||
- Denoted as `W ⊆ V`, where W is the subset of V
|
||||
- Every set is a subset of itself.
|
||||
- {Moe, Larry} $\subseteq$ {Moe, Larry}
|
||||
- The empty set is a subset of every set .
|
||||
- {} $\subseteq$ {Moe, Larry}
|
||||
|
||||
### Example
|
||||
|
||||
Let T = {Moe, Larry, Curly}
|
||||
|
||||
List all subsets of T.
|
||||
|
||||
{Moe}
|
||||
{Larry}
|
||||
{Curly}
|
||||
{Moe, Larry}
|
||||
{Moe, Curly}
|
||||
{Larry, Curly}
|
||||
{Moe, Larry, Curly}
|
||||
|
||||
{} <- Empty Set
|
||||
|
||||
## True or False
|
||||
|
||||
1. {b, h, r, q} $\subseteq$ {h, r} - True
|
||||
2. {a, 13, d, 2} $\subseteq$ {13, 2, d, a} - True
|
4
Data Structures/Week 3/Lecture 5 - Linear List.md
Normal file
4
Data Structures/Week 3/Lecture 5 - Linear List.md
Normal file
@@ -0,0 +1,4 @@
|
||||
y++, use then increment (post)
|
||||
++y, increment then use (pre)
|
||||
y--, use then decrement (post)
|
||||
--y, decrement then use (pre)
|
17
Data Structures/Week 3/Workshop 3 - ADTs.md
Normal file
17
Data Structures/Week 3/Workshop 3 - ADTs.md
Normal file
@@ -0,0 +1,17 @@
|
||||
1. Define the concept of abstraction as it is related to programming.
|
||||
Abstraction is the process of removing detail to simplify a problem.
|
||||
|
||||
2. In general programming terms, explain briefly what an interface is.
|
||||
An interface is information which allows re-use of a class or method. Includes information such as methods, parameters and return types, but no implementation.
|
||||
|
||||
3. In java, we implement Abstract Data Types using Java interface types. What would be contained such interface types?
|
||||
Method headers for public use.
|
||||
|
||||
4. Name two classes that implement the LinearList interface.
|
||||
LinkedList ArrayList
|
||||
|
||||
5. The specification of ADTs depend on the used programming language. True or False, explain your answer.
|
||||
False, ADTs are a concept, non-specific to language.
|
||||
|
||||
6. What does it means when we say that one class implements a particular interface?
|
||||
Source code defines class.
|
10
Data Structures/Week 4/Week 4 - Exceptions.md
Normal file
10
Data Structures/Week 4/Week 4 - Exceptions.md
Normal file
@@ -0,0 +1,10 @@
|
||||
```mermaid
|
||||
flowchart BT
|
||||
ex[Exception] --> th[Throwable]
|
||||
re[RuntimeException] --> ex
|
||||
ae[ArithmeticException] --> re
|
||||
ioob[IndexOutOfBoundsException] --> re
|
||||
iae[IllegalArgumentException] --> re
|
||||
npe[NullPointerException] --> re
|
||||
```
|
||||
|
Reference in New Issue
Block a user