Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a graph with 3 vertices labeled 'A', 'B', and 'C'.
DSA Typescript
const vertices = ['A', 'B', [1]];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a vertex label not mentioned in the problem.
✗ Incorrect
The third vertex label is 'C' to match the problem statement.
2fill in blank
mediumComplete the code to add an edge from vertex 'A' to vertex 'B' in a directed graph.
DSA Typescript
const edge = { from: 'A', to: [1] }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same vertex for 'to' as 'from'.
✗ Incorrect
The edge goes from 'A' to 'B', so 'to' must be 'B'.
3fill in blank
hardFix the error in the code to correctly represent an undirected edge between 'A' and 'B'.
DSA Typescript
const edge = { vertices: ['A', [1]] }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same vertex twice or wrong vertex label.
✗ Incorrect
Undirected edge connects 'A' and 'B', so the second vertex is 'B'.
4fill in blank
hardFill both blanks to create a weighted directed edge from 'A' to 'B' with weight 5.
DSA Typescript
const edge = { from: 'A', to: [1], weight: [2] }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up vertices or using wrong weight values.
✗ Incorrect
The edge goes from 'A' to 'B' with weight 5.
5fill in blank
hardFill all three blanks to create a weighted undirected edge between 'A' and 'C' with weight 7.
DSA Typescript
const edge = { vertices: [[1], [2]], weight: [3] }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping vertices or using wrong weight.
✗ Incorrect
The undirected edge connects 'A' and 'C' with weight 7.