From 1bc166aa088eda8039ffa0ad5b0449031b95fd0f Mon Sep 17 00:00:00 2001 From: Zaira <33151350+zairahira@users.noreply.github.com> Date: Fri, 13 Mar 2026 14:13:30 +0500 Subject: [PATCH] feat(curriculum): add JS graphs and trees review page (#65818) Co-authored-by: Tom <20648924+moT01@users.noreply.github.com> Co-authored-by: Sem Bauke --- client/i18n/locales/english/intro.json | 7 ++ .../698c302951ac746466349fd9.md | 106 ++++++++++++++++++ .../blocks/review-graphs-and-trees-js.json | 14 +++ .../structure/superblocks/javascript-v9.json | 3 +- 4 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 curriculum/challenges/english/blocks/review-graphs-and-trees-js/698c302951ac746466349fd9.md create mode 100644 curriculum/structure/blocks/review-graphs-and-trees-js.json diff --git a/client/i18n/locales/english/intro.json b/client/i18n/locales/english/intro.json index 05047d1aeef..983bc3998f4 100644 --- a/client/i18n/locales/english/intro.json +++ b/client/i18n/locales/english/intro.json @@ -3700,6 +3700,13 @@ "In this lab, you will implement a solution for the N-Queens problem." ] }, + "review-graphs-and-trees-js": { + "title": "Graphs and Trees Review", + "intro": [ + "Graphs and Trees Review", + "Before you are quizzed on graphs and trees, you should review what you've learned." + ] + }, "lecture-understanding-dynamic-programming-js": { "title": "Understanding Dynamic Programming", "intro": [ diff --git a/curriculum/challenges/english/blocks/review-graphs-and-trees-js/698c302951ac746466349fd9.md b/curriculum/challenges/english/blocks/review-graphs-and-trees-js/698c302951ac746466349fd9.md new file mode 100644 index 00000000000..3fc1e8dca6f --- /dev/null +++ b/curriculum/challenges/english/blocks/review-graphs-and-trees-js/698c302951ac746466349fd9.md @@ -0,0 +1,106 @@ +--- +id: 698c302951ac746466349fd9 +title: Review Graphs and Trees +challengeType: 31 +dashedName: review-graphs-and-trees-js +--- + +# --description-- + +## Graphs Overview + +A graph is a set of nodes (vertices) connected by edges (connections). Each node can connect to multiple other nodes, forming a network. The different types of graphs include: + +- Directed: edges have a direction (from one node to another), often represented with straight lines and arrows. +- Undirected: edges have no direction, represented with simple lines. +- Vertex labeled: each node is associated with a label or identifier. +- Cyclic: contains cycles (a path that starts and ends at the same node). +- Acyclic (DAG): does not contain cycles. +- Edge labeled: each edge has a label usually drawn next to the corresponding edge. +- Weighted: edges have weights (values) associated with them, that can be used to perform arithmetic operations. +- Disconnected: contains two or more nodes that are not connected by any edges. + +Graphs are used in various applications such as maps, networks, recommendation systems, dependency resolution. + +## Graph Traversals + +This involves visiting all the nodes in a graph. The two main algorithms are: + +- **Breadth-First Search (BFS)** + - Uses a queue. + - Explores level by level. + - Finds shortest path in unweighted graphs. + +- **Depth-First Search (DFS)** + - Uses a stack (or recursion). + - Explores a branch fully before backtracking. + - Useful for cycle detection and path finding. + +## Graph Representations + +Graphs can be represented in two main ways: + +- **Adjacency List** + - Each node has a list of its neighbors. + - Space efficient for sparse graphs. + - Easy to iterate over neighbors. + +- **Adjacency Matrix** + - A 2D array where rows and columns represent nodes. + - Space intensive for large graphs. + - Fast to check if an edge exists between two nodes. + +## Trees + +A tree is a special type of graph that is acyclic and connected. Key properties include: + +- They have no loops or cycles (paths where the start and end nodes are the same). +- They must be connected (every node can be reached from every other node). + +### Common types of trees + +The most common types of trees are: + +- Binary Trees + - Each node has at most two children, a left and a right child. + +- Binary Search Trees (BST) + - A binary tree in which every left child is less than its parent, and every right child is greater than its parent. + + +## Tries + +Also known as prefix trees, they are used to store sets of strings, where each node represents a character. + +Shared prefixes are stored only once, making them efficient for tasks like autocomplete and spell checking. + +Search and insertion operations have a time complexity of O(L), where L is the length of the string. + +## Priority Queues + +A priority queue is an abstract data type where each element has a priority. + +Queues and stacks consider only the order of insertion, while priority queues consider the priority of elements. + +Standard queues follow FIFO (First In First Out) and stacks follow LIFO (Last In First Out). However, in a priority queue, elements with higher priority are served before those with lower priority, regardless of their insertion order. + +## Heaps + +It's a specialized tree-based data structure with a very specific property called the heap property. + +The heap property determines the relationship between parent and child nodes. There are two types of heaps: + +- Max-Heap + - The value of each parent node is greater than or equal to the values of its children. + - The largest element is at the root. + +- Min-Heap + - The value of each parent node is less than or equal to the values of its children. + - The smallest element is at the root. + + +JavaScript doesn't have a built-in heap module, but you can implement a min-heap using an array. + +# --assignment-- + +Review the Graphs and Trees topics and concepts. diff --git a/curriculum/structure/blocks/review-graphs-and-trees-js.json b/curriculum/structure/blocks/review-graphs-and-trees-js.json new file mode 100644 index 00000000000..76b25477838 --- /dev/null +++ b/curriculum/structure/blocks/review-graphs-and-trees-js.json @@ -0,0 +1,14 @@ +{ + "name": "Graphs and Trees Review", + "isUpcomingChange": true, + "dashedName": "review-graphs-and-trees-js", + "helpCategory": "JavaScript", + "blockLayout": "link", + "challengeOrder": [ + { + "id": "698c302951ac746466349fd9", + "title": "Graphs and Trees Review" + } + ], + "blockLabel": "review" +} diff --git a/curriculum/structure/superblocks/javascript-v9.json b/curriculum/structure/superblocks/javascript-v9.json index 4a23a9a1f0d..71aa9dcffeb 100644 --- a/curriculum/structure/superblocks/javascript-v9.json +++ b/curriculum/structure/superblocks/javascript-v9.json @@ -325,7 +325,8 @@ "lecture-understanding-graphs-and-trees-js", "lab-adjacency-list-to-matrix-converter-js", "lab-depth-first-search-js", - "lab-n-queens-problem-js" + "lab-n-queens-problem-js", + "review-graphs-and-trees-js" ] }, {