Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Collections / Reference Semantics - Debugging Download starter code: File Debugging.zip One of the TAs has been programming in Python for too long, and forgot

Collections
/
Reference Semantics
-
Debugging
Download starter code:
File
Debugging.zip
One of the TAs has been programming in Python for too long, and forgot how to code in Java! They wrote a solution to the following problem, but accidentally included some bugs:
Write a method called deepCopy that takes as a parameter map whose keys are strings and whose values are lists of integers and that creates and returns a new map that is a copy of the map parameter. For example, given a variable called map that stores the following information:
{
"
cse
1
2
1
"
=
[
4
2
,
1
7
,
4
2
,
4
2
]
,
"cse
1
2
2
"
=
[
1
0
,
1
2
,
1
4
]
,
"cse
1
2
3
"
=
[
1
0
0
,
9
9
,
9
8
,
-
9
7
]
}
The call deepCopy
(
map
)
should return a new map whose structure and content are identical to map. Any later modifications to map or the lists in map following this call should not be reflected in the copy. The map you construct should store keys in alphabetical order. Your method should not modify the contents of the map passed as a parameter.
There are
5
bugs in the following program. Find and fix them all!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started