- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
C++ Program | Update Edge Weights, Find Shortest Path in Tree | Segment Tree + Heavy Light Decompo.
In this video, we solve a challenging C++ coding problem based on trees and queries.
We are given a weighted tree rooted at node 1 and need to handle two types of queries:
1️⃣ Update Query → Update the weight of an edge between two nodes.
2️⃣ Shortest Path Query → Find the shortest path from the root (node 1) to a given node.
We use Heavy Light Decomposition (HLD) with a Segment Tree to handle updates and queries efficiently in O(log² n).
📚 Concepts Covered
Tree representation in C++
Depth, parent, subtree size computation using DFS
Heavy Light Decomposition (HLD)
Segment Tree for path queries and edge updates
Handling online queries efficiently
🚀 Time Complexity:
Build: O(n)
Each query: O(log² n)
This problem is very useful for competitive programming and coding interviews.
#cplusplus #dsa #competitiveprogramming #codinginterview #segmenttree #heavylightdecomposition #treeproblems #shortestpath #cppcoding #dsaproblems #leetcode #codeforces #codingtheoryguru
Видео C++ Program | Update Edge Weights, Find Shortest Path in Tree | Segment Tree + Heavy Light Decompo. канала Coding theory
We are given a weighted tree rooted at node 1 and need to handle two types of queries:
1️⃣ Update Query → Update the weight of an edge between two nodes.
2️⃣ Shortest Path Query → Find the shortest path from the root (node 1) to a given node.
We use Heavy Light Decomposition (HLD) with a Segment Tree to handle updates and queries efficiently in O(log² n).
📚 Concepts Covered
Tree representation in C++
Depth, parent, subtree size computation using DFS
Heavy Light Decomposition (HLD)
Segment Tree for path queries and edge updates
Handling online queries efficiently
🚀 Time Complexity:
Build: O(n)
Each query: O(log² n)
This problem is very useful for competitive programming and coding interviews.
#cplusplus #dsa #competitiveprogramming #codinginterview #segmenttree #heavylightdecomposition #treeproblems #shortestpath #cppcoding #dsaproblems #leetcode #codeforces #codingtheoryguru
Видео C++ Program | Update Edge Weights, Find Shortest Path in Tree | Segment Tree + Heavy Light Decompo. канала Coding theory
Комментарии отсутствуют
Информация о видео
19 сентября 2025 г. 13:32:58
00:02:10
Другие видео канала













