From b05e956b5a6617807043e429e6bd891b5dbede09 Mon Sep 17 00:00:00 2001 From: Avi Parshan Date: Sun, 17 Mar 2024 19:23:03 +0200 Subject: [PATCH] dsa2 --- _data/navigation.yml | 3 +++ data_struct2/README.md | 60 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 data_struct2/README.md diff --git a/_data/navigation.yml b/_data/navigation.yml index 505482c..d3970d5 100644 --- a/_data/navigation.yml +++ b/_data/navigation.yml @@ -16,6 +16,9 @@ - name: Data Structures link: /data_struct/ +- name: Data Structures2 + link: /data_struct2/ + - name: Digital Systems link: /DigitalSystems/ diff --git a/data_struct2/README.md b/data_struct2/README.md new file mode 100644 index 0000000..9ecb5ec --- /dev/null +++ b/data_struct2/README.md @@ -0,0 +1,60 @@ +--- +layout: page +title: Advanced Data Structures and Algorithms (DSA2) +description: Linked Lists, Trees, Queues, Heaps, Stacks, etc. +date: '2024-03-17 12:24:11 -0400' +permalink: /data_struct2/ +image: /static/post-image/bigo.png +categories: DSA +tags: +- DataStruct +- Algos +- DataStructures2 +--- + +## Advanced Data Structures and Algorithms (DSA2) + +Adjacency representation (for graphs) + +| Representation | Find Edge | Insert Edge | Delete Edge | Memory | +|----------------|-----------|-------------|-------------|----------------| +| List | O(|V|) | O(1) | O(|V|) | Θ(|V|+|E|) | +| Matrix | O(1) | O(1) | O(1) | Θ(|V|^2) | + +### Vertex colors + +- **White:** unprocessed/undiscovered +- **Grey:** processing/not finished +- **Black:** done/finished + +### Edge types + +- **Tree Edge** + - Parent to a child + - Goes to undiscovered vertex + - V finishes before U + +- **Back Edge** + - To an ancestor + - Of a vertex (parent, grandparent, etc.) + - Adding a back edge to tree edge makes a cycle + - To discovered but unfinished vertex + - In DFS, every back edge completes a cycle + - Removing back edges from a graph removes all cycles + - Self-edge = back edge + - V finishes after U + +- **Forward Edge** + - To a non-child descendant + - To a finished vertex discovered after the current vertex + - Indirect descendant (not child) + - V finishes before U + +- **Cross Edge** + - Everything else + - To a vertex finished before the current vertex's discovery + - One branch to another tree, or one tree to another + - V finishes before U + + +[YouTube Playlist](https://www.youtube.com/playlist?list=PL9DdgseuDZgI4iVxPbjXJy4bMG-8DILVq) \ No newline at end of file