{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Samplefinalexam

# Samplefinalexam - ECE242 Data Structures and Algorithms...

This preview shows pages 1–5. Sign up to view the full content.

ECE242 Data Structures and Algorithms Fall 2008 Final Examination (120 Minutes, closed book) Name: ______________________ Student ID: ______________________ NOTE: Any questions on writing code must be answered in Java using Data Structures topics covered in the lectures. Question Score 1 (20) 2 (20) 3 (08) 4 (11) 5 (15) 6 (11) 7 (05) 8 (10)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
1. [20 pts] The goal of this question is to write a code to convert a given adjacency list to an adjacency matrix for a graph as illustrated in the following figure. Consider an undirected graph consisting of N vertices that are named 0, 1, 2,…, (N-1) a) [7 pts] Create a class, AdjList . Write a method called populateAdjList() that reads in information from the keyboard using Scanner for each vertex and the vertices which are linked to the vertex. The information appears in the following input format vertex neighbor1 neighbor2 … (e.g. “0 1 2”, for vertex 0). One line is input per vertex. Before the vertex information is input, the user indicates the total number of vertices. This information is stored in an adjacency list. Hint: You could use an array of ArrayList’s to store the adjacency list. 1 2 0 0 1 2 1 3 3 3 3 1 1 2 2 2 0 0 A[i][j] 0 1 2 3 0 0 1 1 0 1 1 0 1 1 2 1 1 0 1 3 0 1 1 0 Graph Adjacency List Adjacency Matrix

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
b) [10 pts] Create a class, List2MatrixC , and write a method, list2matrix,
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 20

Samplefinalexam - ECE242 Data Structures and Algorithms...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online