
Concept explainers
Write a struct ‘Student’ that has member variables: (string) first name, (int) age and (double) fee. Create a sorted (in ascending order according to the age) linked list of three instances of the struct Student. The age of the students must be 21, 24 and 27. Write a function to insert the new instances (elements of the linked list), and insert three instance whose member variable have age (i) 20, (ii) 23 and (iii) 29. Write a function to remove the instances from the linked list, and remove the instances whose member variables have age (i) 21 and (ii) 29. Write a function to count the elements of the linked list. Write a function to search the elements from the linked list, and implement the function to search an element whose age is 23. Write a function to print the linked list on the console.
Consider the Student struct as defined above. Create a stack of 5
objects of the class. Implement the following (i) push an element to the stack (ii) pop an element from the stack (iii) get the size of the stack (iv) check whether the stack is empty or not (v) print the peek of the stack.

Step by stepSolved in 3 steps with 1 images

- get_top_regions() that takes three input parameters; the 2-D list (similar to the database), the dictionary that stores information of all regions, and a non-zero positive integer x. This function returns a new dictionary that contains the information of top-x regions in terms of the total number of hospitalization cases recorded in these regions. That means these top-x regions have the largest numbers of hospitalization cases. Each {key:value} pair in this resulting dictionary stores the name of a top region as the key and the value is the total number of hospitalization cases reported in this region. The result does not need to be sorted, the regions of the resulting dictionary can appear in any order as long as the top-x regions have been identified correctly. If the value of x is less than 1, or more than the total number of unique regions, your function should print a message informing the user and return an empty dictionary. See sample outputs below. >>> topx_regions…arrow_forwardPyhton code please help, indentation would be greatly appreciatedarrow_forwardWrite a function create_task that creates a dictionary to store the information for a single task. This function takes two parameters: a list with the keys and a list with the corresponding values and returns a dictionary with the provided keys mapping to the corresponding values. In our main program, we will create a list with the keys that allow us to capture: the name of the task (a string) description (a string) due date (a list) priority (an integer) In the main program, create a list called task_fields that stores these keys: task_fields = ["name", "description", "due date", "priority"] Do not hardcode these fields in the function -- they are provided as the argument into the function. Loop over each key to ask the user to input the corresponding information. Assemble it into a new list. Call create_task with these two lists as an input to get the dictionary with the task information. Print the resulting dictionary from the main program. When running the program, you could see…arrow_forward
- Find Country Function Name: findCountry() Parameters: capitalList ( list ) Returns: Dictionary mapping each capital to its country( dict ) Description: Given a list of countries' capital cities, write a function that returns a dictionary that maps a capital to its country's name. Note: Assume that all capital cities provided are valid. example test cases: >>> findCountry(('tokyo', 'delhi', 'stockholm']) {'tokyo': 'Japan', 'delhi": 'India', 'stockholm': 'Sweden'} >>> findCountry(l'paris', 'canberra', 'copenhagen']) {'paris': 'France', 'canberra': 'Australia', 'copenhagen': 'Denmark'} For this assignment, use the REST countries API (https://restcountries.com/#api-endpoints-v2). For all of your requests, make sure you to use version 2 of the REST countries API (V2), not version 3 (V3.1). If you make a request with the URL: https://restcountries.com/v2/alpha/usa, you will receive the following response: { "name": "United States of America", "topLevelDomain": [".us"], "alpha2Code": "US",…arrow_forwardFollowing the Function Design Recipe, create a complete functionnamed get_consonant_cluster that returns a tuple of the consonant phonemes atthe BEGINNING of a word pronunciation. The parameter is of type PHONEMES. Inthe example word pronunciation ('G', 'UW1', 'F', 'IY0') from above, thereturned tuple would be ('G',). If a word pronunciation begins with a vowelphoneme, the empty tuple would be returned. Use the image attached as a helper function."""arrow_forwardq2arrow_forward
- Do this using C++ language using structures and singly linked list.arrow_forwardThe function to be built, amino_acids, must return a list of a tuple and an integer when given a string of mRNA code. The first tuple must contain all the amino acids and the integer must be the number of distinct amino acids. You can use the dictionary below to help with your function. The function must also not include the stop codon codes. NOTE : For this piece of code, we'll assume that there's only one stop codon in the sequence {'CUU': 'Leu', 'UAG': '---', 'ACA': 'Thr', 'AAA': 'Lys', 'AUC': 'Ile', 'AAC': 'Asn','AUA': 'Ile', 'AGG': 'Arg', 'CCU': 'Pro', 'ACU': 'Thr', 'AGC': 'Ser','AAG': 'Lys', 'AGA': 'Arg', 'CAU': 'His', 'AAU': 'Asn', 'AUU': 'Ile','CUG': 'Leu', 'CUA': 'Leu', 'CUC': 'Leu', 'CAC': 'His', 'UGG': 'Trp','CAA': 'Gln', 'AGU': 'Ser', 'CCA': 'Pro', 'CCG': 'Pro', 'CCC': 'Pro', 'UAU': 'Tyr', 'GGU': 'Gly', 'UGU': 'Cys', 'CGA': 'Arg', 'CAG': 'Gln', 'UCU': 'Ser', 'GAU': 'Asp', 'CGG': 'Arg', 'UUU': 'Phe', 'UGC': 'Cys', 'GGG': 'Gly', 'UGA':'---', 'GGA': 'Gly', 'UAA': '---', 'ACG':…arrow_forwardWrite a function called list_to_dict(lst) that takes a 2-D list of sales records of this form.[["customer1", "bread", 5], ["customer2", "bread", 4.5], ["customer1", "egg", 6.75]]Your function will store the sales information in a dictionary, where each {key:value} pair of the dictionary stores {a unique customer: [ a list of all products purchased by this customer, total cost of these products]}, and returns the dictionary. Sample run,sales = [ ["customer1", "bread", 5], ["customer2", "bread", 4.5], ["customer1", "egg", 6.75],["customer2", "milk", 4.35], ["customer3", "egg", 3.6], ["customer4", "bread", 4.5],["customer1", "milk", 4.35], ["customer2", "egg", 3.6], ["customer4", "milk", 4.35] ]>>> record = list_to_dict(sales)>>> display(record)customer1 : [['bread', 'egg', 'milk'], 16.1]customer2 : [['bread', 'milk', 'egg'], 12.45]customer3 : [['egg'], 3.6]customer4 : [['bread', 'milk'], 8.85]arrow_forward
- Exercise 3 Use the function design recipe to develop a function named unique_list. The function takes a list of strings, which may be empty. The function returns a new list that includes the first occurrence of each value in a list and omits later repeats. The returned list should include the first occurrences of values in a list in their original order. For example, if a list contains the following animals ['cat', 'dog', 'cat', 'bug', 'dog', 'ant', 'dog', 'bug'], the unique_list function returns a unique list: ['cat', 'dog', 'bug', 'ant'].arrow_forwardJS Write a function named sum_between_indices whose parameter is a list/array of decimal numbers. Your function must return the sum of the entries at index 4 through index 15. Make certain to include the entries at index 4 and at index 15 in your sum. You SHOULD assume the parameter will have more than 15 entries.arrow_forwardPart 3: Time for a Financial Checkup Complete the function financial_checkup, which takes a dictionary representing your monthly budget for certain categories of expenditures (budget), and a dictionary that represents how much you actually spent in each category (outlays). The function then creates and returns a new dictionary of those categories in which you overspent and the excess amount. Specifically, the returned dictionary maps the category name to the amount of excess spending, given as a negative number. If a category appears in outlays, but not budget, we interpret this to mean that we budgeted $0 for that category, so the entire amount in outlays is considered to be excess spending. Example #1: budget: spent returned: {'food' -95, 'travel': -100} Example #2: budget: spent {'food': 125, 'gas': 75, 'travel': 400} {'food' 220, 'gas': 10, 'travel': 500} Example #3: {'food' 100, 'gas': 30} {'food' 220, 'gas': 10, 'travel': 500} returned: {'food": -120, 'travel': -500} {'drinks'…arrow_forward
- 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





