Using the two properties below, implement the Dictionary interface using Array in PYTHON • array → Array object, initialized capacity • size → int, keep track of dictionary size Do not add / use other properties other than the two above. • Implement the insert (), find (), remove () methods and the iterators find_all () and entries (). In insert (key, value): • If key doesn't exist yet, add the new Entry to the back of the array • If key already exists, insert the new Entry after the last entry with the same key. But you have to move the succeeding Entry objects backward before inserting, to make room for the new entry • Update the size property, and return the newly added Entry object

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Using the two properties below, implement the Dictionary interface using Array in PYTHON
• array → Array object, initialized capacity
• size → int, keep track of dictionary size
Do not add / use other properties other than the two above.
• Implement the insert (), find (), remove () methods and the iterators find_all () and
entries ().
In insert (key, value):
•
•
If key doesn't exist yet, add the new Entry to the back of the array
If key already exists, insert the new Entry after the last entry with the same key.
But you have to move the succeeding Entry objects backward before inserting, to
make room for the new entry
• Update the size property, and return the newly added Entry object
In remove (entry):
•
•
Traverse the array to look for the given entry
If entry is found, remove it from the array, and move succeeding items forward to
avoid making a "hole" in the array. Update the size property, too.
In find (key):
• Traverse the array to look for the given key, and return the first entry that matches
the given key
If key is not found, return None
Implement the iterators: find_all (key) and entries ():
• find_all → traverse the array and yield entry if its key matches the given key
• entries → traverse the array and yield each entry
Transcribed Image Text:Using the two properties below, implement the Dictionary interface using Array in PYTHON • array → Array object, initialized capacity • size → int, keep track of dictionary size Do not add / use other properties other than the two above. • Implement the insert (), find (), remove () methods and the iterators find_all () and entries (). In insert (key, value): • • If key doesn't exist yet, add the new Entry to the back of the array If key already exists, insert the new Entry after the last entry with the same key. But you have to move the succeeding Entry objects backward before inserting, to make room for the new entry • Update the size property, and return the newly added Entry object In remove (entry): • • Traverse the array to look for the given entry If entry is found, remove it from the array, and move succeeding items forward to avoid making a "hole" in the array. Update the size property, too. In find (key): • Traverse the array to look for the given key, and return the first entry that matches the given key If key is not found, return None Implement the iterators: find_all (key) and entries (): • find_all → traverse the array and yield entry if its key matches the given key • entries → traverse the array and yield each entry
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY