You're bulding an app that uses ADT Bag to model a backpack contalning school supples. This code fragment shows how we could create a backpack containing three pens, three pencils, one eraser and one notebook. backpack - Bag() backpack.add('pen') backpack.add ('pencil') backpack.add('pencil') backpack.adkd ('eraser') backpack.add('pen') backpack.add ('notebook') backpack.add ('pen') backpack.add ('pencil') You've been asked to implement class Bag using a hash table that stores key/value pairs. What objects should be used as the keys and the values? Each key is a string that describes one Item in the backpack, and the associated value is 1. For eample, the table will have three entries in which the key is pencil and associated value is 1, because there are three pencils in the backpack. O None of the other answers is correct, because a hash table shouldn't be used to implement ADT Bag. O Each key is an integer count, and the associated value is a list of strings the describe the items that occur that many times in the backpack. For example, one entry in the table will have key 3. The value associated with this key will be the list ['pencil, pen'), because there are three pens and three pencils in the backpack. Each key is a string that describes one item in the backpack, and the associated value is the integer count of the number of occurrences of that item. For example, one entry will contain key 'pencil and associated value will be 3, because there are three pencils in the backpack.
You're bulding an app that uses ADT Bag to model a backpack contalning school supples. This code fragment shows how we could create a backpack containing three pens, three pencils, one eraser and one notebook. backpack - Bag() backpack.add('pen') backpack.add ('pencil') backpack.add('pencil') backpack.adkd ('eraser') backpack.add('pen') backpack.add ('notebook') backpack.add ('pen') backpack.add ('pencil') You've been asked to implement class Bag using a hash table that stores key/value pairs. What objects should be used as the keys and the values? Each key is a string that describes one Item in the backpack, and the associated value is 1. For eample, the table will have three entries in which the key is pencil and associated value is 1, because there are three pencils in the backpack. O None of the other answers is correct, because a hash table shouldn't be used to implement ADT Bag. O Each key is an integer count, and the associated value is a list of strings the describe the items that occur that many times in the backpack. For example, one entry in the table will have key 3. The value associated with this key will be the list ['pencil, pen'), because there are three pens and three pencils in the backpack. Each key is a string that describes one item in the backpack, and the associated value is the integer count of the number of occurrences of that item. For example, one entry will contain key 'pencil and associated value will be 3, because there are three pencils in the backpack.
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...
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
Recommended textbooks for you
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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
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
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY