## All Weeks Advanced Data Structures in Java Coursera Quiz Answers

How does Google Maps plan the best route for getting around town given current traffic conditions? How does an internet router forward packets of network traffic to minimize delay? How does an aid group allocate resources to its affiliated local partners?

To solve such problems, we first represent the key pieces of data in a complex data structure. In this course, you’ll learn about data structures, like graphs, that are fundamental for working with structured real world data. You will develop, implement, and analyze algorithms for working with this data to solve real world problems. In addition, as the programs you develop in this course become more complex, we’ll examine what makes for good code and class hierarchy design so that you can not only write correct code, but also share it with other people and maintain it in the future.

### Advanced Data Structures in Java Coursera Quiz Answers

### Week 1

#### Quiz 1: Pre-course quiz

Q1. If you took the second course in the specialization (Data Structures: Measuring and Optimizing Performance), feel free to skip this quiz! If not, continue on….

Hold on, isn’t it a bit too early for a quiz?

Because this isn’t an introductory programming course and is, in fact, the third course in an intermediate programming specialization, one of the most common questions we’ve gotten is “Am I ready for this course?” To help you answer this question, we encourage you to work through this quiz. About two-thirds of these questions ask about your experience, while the other third are technical questions that involve programming in Java.

If you score 60% or greater, you’re in the right place.

If you score between 35 and 60%, we recommend you look into either the first course in our specialization “Object Oriented Programming in Java” or the second course in our specialization “Data Structures: Measuring and Optimizing Performance” or both and come back to this course after you finish the first.

If you score less than 35%, we recommend you start with this Coursera Introduction Java Programming Specialization and come back to our specialization when you complete those courses.

However, you are very welcome to stick with this course instead if you prefer, and if you don’t mind brushing up on your Java programming as needed along the way.

So let’s begin:

Have you written code in Java?

**Yes**- No

Q2. Have you written code that uses conditional statement (if-statements), including using compound boolean expressions (e.g. x < 5 && x > 0) and multiple if-else clauses (e.g. if… else if… else), to solve problems?

**Yes**- No, or I’m not sure

Q3. Have you implemented code that uses for-loops and while-loops, including nested for-loops?

**Yes**- No or I’m not sure

Q4. Have you written methods that take parameters, both with and without return values?

**Yes**- No, or I’m not sure

Q5. Have you authored classes (or methods in classes) which were part of a specific inheritance hierarchy? In other words, have you worked with classes which “extend” other classes or classes which “implement” an interface?

**Yes**- No, or I’m not sure

Q6. Have you written code that manipulates (i.e. accesses and/or changes the values in) arrays in Java? E.g.

```
// Assume arr is an array of ints
int sum = 0;
for (int i = 0; i < arr.length; i++) {
sum += arr[i];
arr[i] += 1;
}
```

**Yes**- No

Q7. Have you analyzed the running time of code or algorithms using Big-O (asymptotic) notation?

**Yes**- I think so, but I can’t really remember how
- No

Q8. Have you authored a linked data structure (e.g. a Linked List or a Tree) in Java or another language?

**Yes**- No, but I am comfortable with how they are implemented
- No

Q9. What is the output of the following Java code (assume the code is in main)?

```
int x = 7;
int y = x;
x = 2;
System.out.println(x + ", " + y);
```

**2, 7**- 2, 2

Q10. Consider the following code:

```
public class MyClass
{
private int a;
public double b;
public MyClass(int first, double second)
{
this.a = first;
this.b = second;
}
```

What would this code print? Hint – draw a memory model!

Note that this might seem like a compiler error to be accessing c1.a and c1.b from main, but because the method main is defined in the class “MyClass”, it will compile just fine (feel free to check it for yourself).

**2**- 10

Q11.

```
public class Question11 {
public static void main(String[] args) {
int[] array = {20, -10, 15, -7, -8, 45};
int sum = 0;
for(int i = 0; i<array.length;i++) {
// MISSING IF STATEMENT //
sum+=array[i];
}
}
System.out.println(sum);
}
}
```

In the code above, which if statement below would make it so only the positive values in the array are summed? In other words, once the missing if statement is included, the program will print the value 80.

if( i>= 0) {if(array[i] > 0) {if( i > 0) { if(array[i] < 0) {

Q12. What is the big-O class of the number of operations executed when running the method below, where n is the size of arr? Remember, when we’re talking about Big-O analysis, we only care what happens when n is very large, so don’t worry that this method might have problems on small array sizes.

```
int sumTheMiddle(int[] arr) {
int range = 100;
int start = arr.length/2 - range/2;
int sum = 0;
for (int i=start; i< start+range; i++)
{
sum += arr[i];
}
return sum;
} O(2^n2
n
) O(n^2n
2
) O(nn) O(11)
```

- O(2^n2
*n*) - O(n^2
*n*2) - O(n
*n*) **O(11)**

Q13. Based on your score of this quiz, what do we recommend you do?

**If you score 60% or greater, go on to the next video.****If you score between 35 and 60%, we recommend you look into our first course in this specialization: Object Oriented Programming in Java.****If you score less than 35%, we recommend you start with this Coursera Introduction Java Programming Specialization and come back to our specialization when you complete those courses.**

- Regardless of my score, just go onto the next video.

#### Quiz 2: Survey: Your goals for the course

Q1. What is/are your reasons for taking this course? We recognize that

you probably don’t know exactly what this course is about, specifically,

but take your best guess. Please select all that apply.

**To brush up on material I already learned****To learn this material for the first time****To earn the course certificate****To complete the specialization****To learn Java****I’m not sure. I’m just browsing.****Some other reason (please let us know in the last question)**

Q2. How much of the course do you intend to complete?

**The videos and readings, and all of the required assessments, including the programming assignments.**- Most of the videos, some of the quizzes, and I might try some of the programming assignments.
- Some of the videos and readings, probably no assessments.
- I might watch a few more videos. I’m still figuring out what this course is about.
- I probably won’t continue after this survey.

Q3. How did you discover this course? Please select all that apply.

**A general internet search (please tell us your search terms in the last question)****A search on Coursera (please tell us your search terms in the last question)****Browsing Coursera’s catalog****I’m continuing from Course 2 in the specialization****An email from Coursera****A personal contact (e.g., friend, teacher, parent**, etc.)- Other (please tell us in the last question)

Q4. If applicable, please provide more information about any of the

questions above. Specifically, what search terms did you use to find

this course, or what other reasons do you have for taking this course?

What do you think?

Your answer cannot be more than 10000 characters.

#### Quiz 3: Course Structure and Starter Code Quiz (make sure you can run the starter code first)

Q1. Which of the following are among the things that you will learn in this course? Select all that apply.

- How to implement the Graph data structure
- The basics of creating classes in Java
- Algorithms for searching a graph.
- How to build a Web crawler

Q2. Which video series in this course will present the fundamental concepts and skills you need to complete the assignments?

- The Core series
- The Support series
- The Concept Challenges
- The “In the Real World” series

Q3. Next week you will be working with the files in the basicgraph package. Open this package in the Eclipse Package Explorer. Then select all of the files from the list below that are included in that package.

- BasicGraph.java
- Graph.java
- GraphAdjList.java
- GraphAdjMatrix.java
- MapGraph.java

Q4. Which of the following is a correct statement about the classes in the basicgraph package.

- Graph is an abstract class and its subclasses are GraphAdjList and GraphAdjMatrix
- GraphAdjList is an abstract class and its subclass is Graph
- Graph, GraphAdjList and GraphAdjMatrix are all abstract classes.

Q5. Run the main method in the class Graph. You will see the following information printed out:

Loading graphs based on real data…

Goal: use degree sequence to analyse graphs.

Roads / intersections:

Graph with ** _ vertices and _** edges.

…

We have replaced the numbers in the statement above with blanks. What is the actual statement that is printed?

- Graph with 5 vertices and 14 edges.
- Graph with 8 vertices and 20 edges
- Graph with 10 vertices and 35 edges
- Graph with 9 vertices and 22 edges

Q6. Which data folder contains the street data in a format suitable for loading into roadgraph.MapGraph objects?

- mazes
- intersections
- maps

### Week 2

#### Quiz 1: Graphs

Q1. What’s the maximum number of edges in a directed graph with n vertices?

- Assume there are no self-loops (i.e. edges from a node back to itself).
- Assume there there is at most one edge from a given start vertex to a given end vertex.

NOTE: you might wonder why we’re asking you a math question. It turns out that the relationship between the number of vertices and the number of edges in our graph data structure will have a huge impact on the performance of our code. In order to analyze our algorithms and predict which problems we’ll be able to feasibly solve, we need to get through some calculations.

Even though we haven’t done the calculation in the slides, try it out yourself. If you don’t get it right the first time, we have some hints to help you out.

One more note: the answer to this question is a math expression. Use the input tool to make sure your syntax matches up with the expected format. The syntax checker treats ‘n’ differently from ‘N’. Also, please simplify your formula.

Preview will appear here…

Enter math expression here

Q2. What’s the maximum number of edges in an undirected graph with n vertices?

- Assume there are no self-loops.
- Assume there there is at most one edge from a given start vertex to a given end vertex.

Again, please simplify your formula.

Preview will appear here…

Enter math expression here

#### Quiz 2: Where to next?

Q1. Now that you’ve seen the basics of graph representation, what do you want to do next?

**Learn how these ideas are used in the real world and get more practice**- Learn a little more about ideas that will help me with the project in the next Core video
- I’m ready to get started. Take me to the project!

#### Quiz 3: Graph definitions and implementation

Q1. Consider the following adjacency matrix representation of a directed graph (represented as code for nicer formatting):

1 0 0 1

0 1 0 1

0 0 1 0

0 1 1 1

How many edges are in this graph? Hint: Self-loops should be counted as edges.

Enter answer here

Q2. Consider the same adjacency matrix representation of a directed graph (represented as code for nicer formatting):

1 0 0 1

0 1 0 1

0 0 1 0

0 1 1 1

How many vertices in this graph have a self-loop, i.e. an edge that starts in a vertex and ends at the same vertex it started at?

Enter answer here

Q3. If you have a graph with 5 vertices and 2 edges, how many total entries (not just non-zero entries) are there in the matrix with an adjacency matrix representation of this graph?

Enter answer here

Q4. Consider the following adjacency list representation of a directed graph:

0 -> {}

1 -> {2, 3}

2 -> {1}

3 -> {0, 2, 3}

4 -> {0, 1, 3, 4}

How many edges does this graph have?

Enter answer here

Q5. Consider the following adjacency list representation of a directed graph:

0 -> {} 1 -> {2, 3} 2 -> {1} 3 -> {0, 2, 3} 4 -> {0, 1, 3, 4} Which vertex in this graph has the highest in-degree?

Enter answer here

Q6. Consider the following adjacency list representation of a directed graph (note: this graph is slightly different from the graph in the previous two questions):

0 -> {} 1 -> {2, 3} 2 -> {1, 3} 3 -> {0, 2, 3} 4 -> {0, 1, 3, 4}

What is the degree sequence for this graph? Make sure you put a single space between each number in the sequence. There should be no commas or additional spaces in the sequence.

Note: make sure you list the degrees in the correct order.

Enter answer here

Q7. Consider the following adjacency list representation of a directed graph:

0 -> {} 1 -> {2, 3} 2 -> {1} 3 -> {0, 2, 3} 4 -> {0, 1, 3, 4}

Which of the following pairs of vertices have paths from the first vertex to the second. Select all that apply.

- From 4 to 0
- From 3 to 4
- From 1 to 4
- From 1 to 0
- From 0 to 1

Q8. How many hours did you spend on the programming assignment this week?

- Less than 1
- 1-2
- 2-3
- 3-4
- 4-5
- More than 5

Q9. How difficult did you find the programming assignment?

- Very easy
- Pretty easy
- Neither easy nor difficult
- Pretty difficult
- Very difficult

Q10. How much did you enjoy the programming assignment?

- I really enjoyed it!
- I enjoyed it.
- I’m neutral about my enjoyment
- I did not enjoy it.
- I really did not enjoy it!

### Week 3

#### Quiz 1: Where to next?

Q1. Now that you’ve seen basic graph search, where do you want to go next?

**More practice with these search algorithms, please (note that you’ll be asked to analyze the running time of these algorithms on the end of week quiz).**- Take me to the next core videos on class design and refactoring.

#### Quiz 2: End of Week Quiz (complete project and peer review first)

Q1. What is the running time of the breadth first search (BFS) algorithm in the worst case?

- O(V^2)
- O(V)
- O(E + V)

Q2. Which of the following is true about code refactoring? Select all that apply.

- It is common during code development
- It should be avoided unless absolutely necessary
- It refers to the process of changing the structure of the code without changing its functionality
- It generally changes the code’s public interface.

Q3. Which of the following is/are true about Depth First Search (DFS)?

- In the worst case, depth first search is more efficient than breadth first search.
- DFS usually finds a shorter path (in terms of number of nodes) than BFS.
- DFS uses a Stack to hold the list of unexplored nodes.
- DFS has a straightforward recursive solution.
- DFS will always find a path from Start to Goal if there is one.

Q4. Which of the following is the better representation for the MapGraph graph that you implemented in the programming project this week?

- Adjacency List
- Adjacency Matrix

Q5. How many hours did you spend on the programming assignment this week?

- Less than 1 hour
- 1-2 hours
- 2-3 hours
- 3-4 hours
- 4-5 hours
- More than 5 hours

Q6. How difficult did you find the programming assignment?

- Very easy
- Pretty easy
- Neither easy nor difficult
- Pretty difficult
- Very difficult

Q7. How much did you enjoy the programming assignment?

- I really enjoyed it!
- I enjoyed it
- I’m neutral about my enjoyment
- I did not enjoy it
- I really did not enjoy it

Q8. How difficult did you find it to provide a review of your peers’ designs in the peer review assignment?

- Very easy
- Pretty easy
- Neither easy nor difficult
- Pretty difficult
- Very difficult

Q9. How much time did completing one peer review take, on average?

- Less than 15 minutes
- 15-30 minutes
- 30-60 minutes
- More than 60 minutes

### Week 4

#### Quiz 1: End of Week Quiz (very short, do programming assignment first)

Q1. Dijkstra and AStarSearch only differ substantially in the number of nodes they explore in the process of finding a route. As you’ve already completed those methods, let’s look at this in more detail.

For this question, uncomment (or add) the following code to the main method in MapGraph.java. If you don’t already count the number of items removed from the queue, you should add that to your code now. (Whenever an element is removed from the priority queue, you increment the count, then print out the count before the method returns. Elements are only added to the queue only when you find a “lower-cost” path to that element.)

MapGraph theMap = new MapGraph();

System.out.print(“DONE. \nLoading the map…”);

GraphLoader.loadRoadMap(“data/maps/utc.map”, theMap);

System.out.println(“DONE.”);

GeographicPoint start = new GeographicPoint(32.8648772, -117.2254046);

GeographicPoint end = new GeographicPoint(32.8660691, -117.217393);

List route = theMap.dijkstra(start,end);

List route2 = theMap.aStarSearch(start,end);

How many nodes were visited by Dijkstra and AStarSearch (if you are close but not exact to one of the results below, chose the one closest to your result)?

- Dijkstra: 97, AStarSearch: 13
- Dijkstra: 82, AStarSearch: 25
- Dijkstra: 82, AStarSearch: 19
- Dijkstra: 65, AStarSearch: 13
- Dijkstra: 97, AStarSearch: 19
- Dijkstra: 65, AStarSearch: 19
- Dijkstra: 97, AStarSearch: 25
- Dijkstra: 65, AStarSearch: 25
- Dijkstra: 82, AStarSearch: 13

Q2. How many hours did you spend on this week’s programming assignment?

- Less than 1 hour
- 1-2 hours
- 2-3 hours
- 3-4 hours
- 4-5 hours

More than 5 hours

Q3. How difficult did you find this week’s programming assignment

- Very easy
- Somewhat easy
- Neither easy nor difficult
- Somewhat difficult
- Very difficult

Q4. How much did you enjoy the programming assignment?

- I really enjoyed it!
- I enjoyed it.
- I’m neutral about my enjoyment
- I did not enjoy it
- I really did not enjoy it

### Week 5

#### Quiz 1: End of Week Quiz

Q1. What is the tightest bound Big-O running time of the brute force solution to the traveling salesperson problem (TSP), where nn is the number of nodes in the graph?

- O(2^n)O(2

n

) - O(n^k)O(n

k

) - O(n!)O(n!)
- O(n^2)O(n

2

)

Q2. If you know that a problem is considered NP Hard, that means:

- You can be sure there is a polynomial time – O(n^k)O(n

k

) – solution. - You can be sure there is no polynomial time – O(n^k)O(n

k

) – solution. - You can be sure that the problem is at least as hard as a set of problems where there is no known polynomial – O(n^k)O(n

k

) – solution.

Q3. For which of the graphs below would the greedy algorithm (nearest neighbor) NOT find the best solution to the Travelling Salesperson Problem assuming A is the start vertex. Again, each node must be visited once and you must return back to A.

Q4. Which of the following is true about the 2-opt heuristic as explained this week?

- 2-opt is an approach which may improve a non-optimal solution to the TSP problem but may end up producing a solution worse than the original non-optimal solution
- 2-opt is an approach which may improve a non-optimal solution to the TSP problem and is guaranteed to do no worse than the original non-optimal solution
- 2-opt is an approach which is guaranteed to improve a non-optimal solution to the TSP problem to create an optimal solution for the TSP problem

Q5. A Hamiltonian graph is one where there’s some path through the graph which visits every vertex exactly once. An Eulerian graph is one where there’s some path through the graph which traverses every edge exactly once.

Which of the following is true about Hamiltonian and Eulerian graphs?

(Select all that apply.)

- Every Hamiltonian graph is Eulerian, because every Hamiltonian path uses each edge at most once.
- Each graph is either Hamiltonian or Eulerian.
- There can be a graph that is Hamiltonian but not Eulerian.

### Week 6: Project Quiz (Complete your project extension first)

Q10. Did you add an extension to your project?

- Yes
- No

Q2. In one paragraph, describe what you did with your extension to someone who will just be using your application and doesn’t know anything about programming. (Keep this answer, copy-paste to another document- if you want to submit it for the optional peer review.)

Your answer cannot be more than 10000 characters.

Q3. In one-two paragraphs, describe what you did with your extension to someone else on the same project team. What problems did you encounter and how did you fix them? (Keep this answer, copy-paste to another document- if you want to submit it for the optional peer review.)

Your answer cannot be more than 10000 characters.

##### Mastering the Software Engineering Interview Course Review:

In our experience, we suggest you enroll in Mastering the Software Engineering Interview courses and gain some new skills from Professionals completely free and we assure you will be worth it.

Mastering the Software Engineering Interview course is available on Coursera for free, if you are stuck anywhere between a quiz or a graded assessment quiz, just visit Networking Funda to get Mastering the Software Engineering Interview Quiz Answers.

##### Conclusion:

I hope this Mastering the Software Engineering Interview Quiz Answers would be useful for you to learn something new from this Course. If it helped you then don’t forget to bookmark our site for more Quiz Answers.

This course is intended for audiences of all experiences who are interested in learning about new skills in a business context; there are no prerequisite courses.

Keep Learning!

##### Get All Course Quiz Answers of Object Oriented Java Programming: Data Structures and Beyond Specialization

Object Oriented Programming in Java Coursera Quiz Answers

Data Structures and Performance Coursera Quiz Answers

Advanced Data Structures in Java Coursera Quiz Answers

Mastering the Software Engineering Interview Coursera Quiz Answers