Python Programming: An Introduction to Computer Science, 3rd Ed.
Python Programming: An Introduction to Computer Science, 3rd Ed.
3rd Edition
ISBN: 9781590282755
Author: John Zelle
Publisher: Franklin, Beedle & Associates
bartleby

Concept explainers

bartleby

Videos

Question
Book Icon
Chapter 11, Problem 19PE
Program Plan Intro

Classical set

Program Plan:

  • Define the “Set” class.
    • Define the “init” method
      • Set an array
      • Iterate “i” until it reaches “elements” value
        • Append the values
    • Define the “addElement ()” method
      • Append the values
    • Define the “deleteElement ()” method
      • Delete the “x” element from the list
    • Define the “member ()” method
      • Check “x” is in the list
        • Return true
      • Otherwise, return false
    • Define “intersection ()” method
      • Set an array
      • Iterate “x” until it reaches “set2”
        • Append the values
      • Return the value
    • Define the “union ()” method
      • Iterate “x” until it reaches “set2”
        • Append the value
    • Define the “subtract ()” method
      • Iterate “x” until it reaches “set2”
        • Check “x” is in the set
          • Remove the “x”
    • Define the “getSet ()” method
      • Return the set
  • Define the main method
    • Set an array “list1”
    • Set the value
    • Call the “addElement ()” and “deleteElement ()” methods
    • Set an array “list2”.
    • Set an array “list3”.
    • Call the methods “intersection ()”, “union ()” and “subtract ()”.
    • Display the outputs
  • Call the main method

Blurred answer
Students have asked these similar questions
Unique Words Summary Specifications:You are tasked to implement an abstract data type class which takes in a given input file called input.txt, and processes, identifies and sorts all unique word instances found in the file. Sample InputHi hello hi good bye goodbye Bye bye good say Sample OutputBye Hi bye hello hi say The input.txt file is found along with the zip folder where this instructions file also came along with. Note: you are not allowed to use pythonic lists, and its methods and functions, and string methods. However the use of the file handling methods (read readlines and readline) are allowed for this project.
addCourse: accepts an object of type Course as the first parameter and the idNum of the Student as the second parameter. The Course can be added only if the Student object with the specified idNum exists in the studentsList, Course does not exist in the coursesRegistered list for the Student, After adding the course, the number of credits, do not exceed 18. If the course is added successfully, return true, else return false.
Concatenate Map This function will be given a single parameter known as the Map List. The Map List is a list of maps. Your job is to combine all the maps found in the map list into a single map and return it. There are two rules for addingvalues to the map. You must add key-value pairs to the map in the same order they are found in the Map List. If the key already exists, it cannot be overwritten. In other words, if two or more maps have the same key, the key to be added cannot be overwritten by the subsequent maps.   Signature:   public static HashMap<String, Integer> concatenateMap(ArrayList<HashMap<String, Integer>> mapList) Example: INPUT: [{b=55, t=20, f=26, n=87, o=93}, {s=95, f=9, n=11, o=71}, {f=89, n=82, o=29}]OUTPUT: {b=55, s=95, t=20, f=26, n=87, o=93} INPUT: [{v=2, f=80, z=43, k=90, n=43}, {d=41, f=98, y=39, n=83}, {d=12, v=61, y=44, n=30}]OUTPUT: {d=41, v=2, f=80, y=39, z=43, k=90, n=43} INPUT: [{p=79, b=10, g=28, h=21, z=62}, {p=5, g=87, h=38}, {p=29,…
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Introduction to Classes and Objects - Part 1 (Data Structures & Algorithms #3); Author: CS Dojo;https://www.youtube.com/watch?v=8yjkWGRlUmY;License: Standard YouTube License, CC-BY