
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
How do you do this? Java

Transcribed Image Text:smallestSection
Write a method smallestSection that accepts a map of student names (strings) to section names
(strings) as a parameter, and returns the name of the section with the smallest number of students.
Consider, for example, a variable called map that contains the following elements:
{ying-AC, will=AA, natalie=AA}
A call to your method should return the following string:
AC
If there are no students in the passed in map then your method should return null. If two sections
have the smallest number of students return the name of the one that comes first alphabetically.
You may assume that the map passed is not null and that none of its elements are null or empty
strings.
For full credit, obey the following restrictions in your solution. A solution that disobeys them can get
partial credit.
• You may create only up to one (1) new data structure of your choice (list, stack, queue, set,
map, etc.) as auxiliary storage. (You can have as many simple variables as you like.)
• You may not call any Collections methods.
• You should not modify the contents of the map passed to your method.
![1 import java.util.*;
2
3 public class SmallestSection {
4
public static String smallestSection (Map<String, String> sections) {
5
6
7
8
9
10
11
12 }
13}
public static void main(String[] args) {
Map<String, String> sections = new HashMap<String, String>();
sections.put("ying", "AC");
sections.put("will", "AA");
sections.put("natalie", "AA");
System.out.println(smallestSection(sections));](https://content.bartleby.com/qna-images/question/13b99b83-b236-48b9-b053-48e3ee2a9fbe/b7c4726c-5bbd-460c-859b-61fcd87ac836/2fjjtwp_thumbnail.png)
Transcribed Image Text:1 import java.util.*;
2
3 public class SmallestSection {
4
public static String smallestSection (Map<String, String> sections) {
5
6
7
8
9
10
11
12 }
13}
public static void main(String[] args) {
Map<String, String> sections = new HashMap<String, String>();
sections.put("ying", "AC");
sections.put("will", "AA");
sections.put("natalie", "AA");
System.out.println(smallestSection(sections));
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 2 images

Knowledge Booster
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
- This is not a java code. Please, I need an expert to solve the problem using java coding and show step-by-step stages.arrow_forwardJava requires its method arguments to be sent in as values, not references. And what, precisely, does it entail?arrow_forwardGive two computer benefits.Programmers analyze computer structure.arrow_forward
- How to count the number of digits in a number in java?arrow_forwardJava Language I want to round up the answer. How to use it in java? public static double calculateBMI(double height, double weight) {return 703 * weight / (height * height);}arrow_forwardUse Java to program a MetroCard Vending Machine.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education