Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 30.2, Problem 30.2.1CP
Program Plan Intro
Purpose of given code:
Purpose of given code is to implements the aggregate operations using “Stream” class.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
you will create a spell checker. The program will take three command line arguments: number of words in the dictionary, a dictionary file name, and a text file name. The program will first create a hash table. The number buckets of the hash table should be about twice the number of words in the dictionary. Then, it will read the dictionary from the file, insert the words into the hash table, and report collision statistics. After reading the dictionary, the spelling checker will read a list of words from a text file. Each word will be looked up in the dictionary. If it is incorrect, it will be written to the standard output together with a list of suggested corrections. The algorithm for generating corrections is given below. Hash Table The hash table programs, QuadraticProbing.h and QuadraticProbing.cpp, are posted on Canvas. The programs use quadratic probing to deal with collisions. You should carefully study these programs and make some changes to collect the required statistics.…
you will create a spell checker. The program will take three command line arguments: number of words in the dictionary, a dictionary file name, and a text file name. The program will first create a hash table. The number buckets of the hash table should be about twice the number of words in the dictionary. Then, it will read the dictionary from the file, insert the words into the hash table, and report collision statistics. After reading the dictionary, the spelling checker will read a list of words from a text file. Each word will be looked up in the dictionary. If it is incorrect, it will be written to the standard output together with a list of suggested corrections. The algorithm for generating corrections is given below. Hash Table The hash table programs, QuadraticProbing.h and QuadraticProbing.cpp, are posted on Canvas. The programs use quadratic probing to deal with collisions. You should carefully study these programs and make some changes to collect the required statistics.…
what is the problem in this code ?
def add():id = input("Enter ID:")f = open("data.txt", "r")id_list = []lines = f.readlines()if lines != "":for line in lines:token = line.split(" ")id_list.append(token[0])for i in id_list:if i == id:print("The student record is already in the database!Zero records added")returnf.close()file = open("data.txt", "a")name = input("Enter name: ")course = input("Enter course: ")absences = int(input("Enter absences: "))exam1 = int(input("Enter exam 1 grade: "))exam2 = int(input("Enter exam 2 grade: "))marks = int(input("Enter Total Marks: "))s = id+" "+name+" "+course+" "+str(absences)+" "+str(exam1)+" "+str(exam2)+" "+str(marks)+"\n"file.write(s)file.close()while True:print("1.Add a student")print("Any other numeric to terminate")choice = int(input())if choice == 1:add()else:break
Chapter 30 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 30.1 - Prob. 30.1.1CPCh. 30.2 - Prob. 30.2.1CPCh. 30.2 - Prob. 30.2.2CPCh. 30.2 - Prob. 30.2.3CPCh. 30.2 - Prob. 30.2.4CPCh. 30.3 - Prob. 30.3.1CPCh. 30.3 - Prob. 30.3.2CPCh. 30.3 - Prob. 30.3.3CPCh. 30.3 - Prob. 30.3.4CPCh. 30.3 - Given an array names in Listing 30.1, write the...
Ch. 30.4 - Prob. 30.4.1CPCh. 30.4 - How do you create a parallel stream?Ch. 30.4 - Prob. 30.4.3CPCh. 30.4 - Prob. 30.4.4CPCh. 30.4 - Prob. 30.4.5CPCh. 30.4 - Write a statement to obtain an array of 1000...Ch. 30.5 - Prob. 30.5.1CPCh. 30.5 - Prob. 30.5.2CPCh. 30.5 - Prob. 30.5.3CPCh. 30.5 - Prob. 30.5.4CPCh. 30.6 - Prob. 30.6.1CPCh. 30.7 - Prob. 30.7.1CPCh. 30.8 - Can the following code be used to replace line 19...Ch. 30.8 - Prob. 30.8.2CPCh. 30.8 - Prob. 30.8.3CPCh. 30.8 - Prob. 30.8.4CPCh. 30.8 - Write the code to obtain a one-dimensional array...Ch. 30 - Prob. 30.1PECh. 30 - Prob. 30.2PECh. 30 - Prob. 30.3PECh. 30 - (Print distinct numbers) Rewrite Programming...Ch. 30 - Prob. 30.5PECh. 30 - Prob. 30.6PECh. 30 - Prob. 30.7PECh. 30 - Prob. 30.8PECh. 30 - Prob. 30.9PECh. 30 - Prob. 30.10PECh. 30 - Prob. 30.11PECh. 30 - (Sum the digits in an integer) Rewrite Programming...Ch. 30 - (Count the letters in a string) Rewrite...Ch. 30 - Prob. 30.14PECh. 30 - (Display words in ascending alphabetical order)...Ch. 30 - Prob. 30.16PECh. 30 - Prob. 30.17PECh. 30 - (Count the occurrences of words in a text file)...Ch. 30 - (Summary information) Suppose the file test.txt...
Knowledge Booster
Similar questions
- What is the purpose of data encapsulation? Which is faster, static routes or dynamic routes please elaborate anwerarrow_forwardProblem Given the target file f0 and candidate files f1-f20, there is an identical copy of f0 among the files f1-f20. Write a python program to perform the following tasks: · Read in each file and calculate the hex hash values by using SHA3 function with the length of 512 for all the given files f0, f1-f20. · Save the hex hash values of each file as a new line in a .txt file named hash.txt file. · Read hash values from hash.txt and compare them to find the identical copy of f0 among f1-f20. · Write the finding result (the matched file name) back to hash.txt Submission • Name your project fileHash.py and submit both fileHash.py and hash.txt on Blackboard. • The program should be properly documented. • The program should have user friendly Input/Output design • Duplicate work (or obviously similar one) will result in an F grade in the course. Grading 1. Include comments as specified in the course syllabus. (10%) 2. Source code and results. · Correctness (70%) · User-friendliness…arrow_forwardHello The java function belw is generating a NullPointerException. How can I improve it? public int quadraticProbing(String[] hashArray, int initial_index, int collision) { int index = (initial_index + (collisions * collisions)) % maxSize; System.out.println("Index " + index); if (index == maxSize) { System.out.println("flag 04"); index = 0; // To wrap around the table } if (hashArray[index] == null) { return index; // We can insert at this location } else { // The index isn't empty so we need to insert the value // at the end of the list } collisions = ++collision; return quadraticProbing(hashArray, initial_index, collision); // Recursive call } Thanks in advance. Respectfully, Emmanuelarrow_forward
- JUST ONLY USE <iostream>. Write a program that reads 10 pairs of Cartesian coordinates from a file called "points.txt" and sorts them by increasing x-values, decreasing y-values, and increasing distance from the origin. Use only one sorting routine. Use an enumerated data type to keep track of the field on which the list is being sorted. The number of pairs should be in a global constant c++arrow_forwardJAVA:Use the "natural split" algorithm on the file split.txt and answer the following question: How many elements are in the first list? (Split into two files.) Splt.txt 200494 774 644 345 521 61 27 28 584 569 66 857 210 2 211 675 548 596 188 647 671 517 408 475 615 113 731 522 850 17 640 940 556 517 602 935 76 578 880 428 168 394 381 497 247 368 137 138 619 973 895 106 838 45 921 800 681 660 490 427 937 917 786 959 152 604 837 749 684 963 926 963 988 492 385 458 788 7 62 46 932 996 787 634 34 616 71 128 686 578 923 532 933 545 100 224 895 595 342 933 934 797 120 565 495 884 237 648 843 599 157 843 192 279 301 649 382 881 667 178 126 746 44 601 22 52 769 708 991 83 447 786 525 168 328 922 153 367 22 689 834 774 93 110 547 597 644 726 237 20 370 573 391 225 750 897 956 839 951 455 8 509 746 338 576 276 277 341 274 891 723 53 966 271 50 990 493 823 833 306 619 461 768 832 736 759 920 451 549 833 911 123 907 225 252 179 177 272 747 859arrow_forwardPlease write a program using python that will create a dictionary and keep count of how many words of certain length are seen in a known text file. For example, in text file "example.txt" there are 5 words; chocolate, mild, separate, question, and. This would produce: {8:2, 9:1, 4:1, 3:1}arrow_forward
- Can you please help update this? //A6Utilities.java import java.io.IOException;import java.nio.file.Files;import java.nio.file.Paths;import java.security.SecureRandom;import java.util.List;import java.util.TreeMap;import java.util.function.Function;import java.util.stream.Collectors;public class A6Utilities {/*** Returns the corresponding letter grade. Don't modify this method, simply use it when converting single* grades to their equivalent letter grade** @param grade the integer grade to convert* @return the letter grade equivalent to the integer grade*/private static char letterGrade(final int grade) {if (grade < 0) return '?';else if (grade < 60) return 'F';else if (grade < 70) return 'D';else if (grade < 80) return 'C';else if (grade < 90) return 'B';else if (grade <= 100) return 'A';else return '?';}/*** The method uses Java Streams only. Don't use any looping structures, conditional statements are OK (IF, TERNARY, SWITCH)* <p>* Generates a list of secure…arrow_forwardJAVA: Use the "natural split" algorithm on the file split.txt and answer the following question: How many elements are in the first list? Split.txt file 200494 774 644 345 521 61 27 28 584 569 66 857 210 2 211 675 548 596 188 647 671 517 408 475 615 113 731 522 850 17 640 940 556 517 602 935 76 578 880 428 168 394 381 497 247 368 137 138 619 973 895 106 838 45 921 800 681 660 490 427 937 917 786 959 152 604 837 749 684 963 926 963 988 492 385 458 788 7 62 46 932 996 787 634 34 616 71 128 686 578 923 532 933 545 100 224 895 595 342 933 934 797 120 565 495 884 237 648 843 599 157 843 192 279 301 649 382 881 667 178 126 746 44 601 22 52 769 708 991 83 447 786 525 168 328 922 153 367 22 689 834 774 93 110 547 597 644 726 237 20 370 573 391 225 750 897 956 839 951 455 8 509 746 338 576 276 277 341 274 891 723 53 966 271 50 990 493 823 833 306 619 461 768 832 736 759 920 451 549 833 911 123 907 225 252 179 177 272 747 859arrow_forward#include <stdio.h>#include <stdlib.h>#include <string.h>#define capacity 101 // Size of Hash Table int hash_function(char* str) { int i = 0; for (int j=0; str[j]; j++) i += str[j]; return i % capacity;} struct Ht_item { char* name; int numberCourses;}; // Hash Table Definitionstruct HashTable { struct Ht_item** items; int size; int count;}; struct Ht_item* create_item(char* key, int value) { struct Ht_item* item = (struct Ht_item*) malloc (sizeof(struct Ht_item)); item->name = (char*) malloc (strlen(key) + 1); item->numberCourses = value; strcpy(item->name, key); item->numberCourses = value; return item;} struct HashTable* create_table(int size) { // Creates a New Hash Table struct HashTable* table = (struct HashTable*) malloc (sizeof(struct HashTable)); table->size = size; table->count = 0; table->items = (struct Ht_item**) calloc (table->size, sizeof(struct Ht_item*));…arrow_forward
- Given the following Java functions, transcribe it into a Python 3 program. /*** Add a new entry with the specified key, value and hash code to* the specified bucket. It is the responsibility of this* method to resize the table if appropriate.*/void addEntry(int hash, Object key, Object value, int bucketIndex) {table[bucketIndex] = new Entry(hash, key, value, table[bucketIndex]);if (size++ >= threshold)resize(2 * table.length);}arrow_forwardUse C/C++ Write a program to store n integers in a chained hash table of 9 memory locations. Use h(k) = k mod n. The program can do jobs as follows: a) Add a number to the table. b) Print out the hash table. c) Search for a given value. d) Remove a number from the hash table.arrow_forwardAssume you have a text file containing 10,000 words and you want to count the frequency of each word in the file. What is the time complexity of this operation using a hash table?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
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