0
0
DSA Typescriptprogramming~10 mins

Graph Terminology Vertices Edges Directed Undirected Weighted in DSA Typescript - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
A'E'
B'C'
C'D'
D'F'
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a vertex label not mentioned in the problem.
2fill in blank
medium

Complete 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'
A'C'
B'D'
C'A'
D'B'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same vertex for 'to' as 'from'.
3fill in blank
hard

Fix 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'
A'B'
B'C'
C'A'
D'D'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same vertex twice or wrong vertex label.
4fill in blank
hard

Fill 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'
A'B'
B5
C'C'
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up vertices or using wrong weight values.
5fill in blank
hard

Fill 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'
A'A'
B'C'
C7
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping vertices or using wrong weight.