Pearson eText for Concepts of Programming Languages -- Instant Access (Pearson+)
12th Edition
ISBN: 9780135102268
Author: Robert Sebesta
Publisher: PEARSON+
expand_more
expand_more
format_list_bulleted
Question
error_outline
This textbook solution is under construction.
Students have asked these similar questions
Write a Perl program that uses a hash and a large number of operations
on the hash. For example, the hash could store people's names and
their ages. A random-number generator could be used to create three-
character names and ages, which could be added to the hash. When a
duplicate name was generated, it would cause an access to the hash but
not add a new element. Rewrite the same program without using
hashes. Compare the execution efficiency of the two. Compare the
ease of programming and readability of the two.
Implement a city database using ordered lists by using java. Each database record contains the name of the city (a string of arbitrary length) and the coordinates of the city expressed as integer x and y coordinates. Your database should allow records to be inserted, deleted by name, and searched by name. Another operation that should be supported is to print all records within a given distance of a specified point/coordinate. The order of cities should be alphabetically by city name. Implement the database using both: an arraybased list implementation, and a circular single linked list implementation.Use may the following node, SLL implementations to implement an ordered circular single linked list
Implement a city database using ordered lists. Each database record contains the name of the city (a string of arbitrary length) and the coordinates of the city expressed as integer x and y coordinates. Your database should allow records to be inserted, deleted by name, and searched by name. Another operation that should be supported is to print all records within a given distance of a specified point/coordinate. The order of cities should be alphabetically by city name. Implement the database using: an array- based list implementation. By using JAVA.
Knowledge Booster
Similar questions
- Implement c# program to Retrieving a value using its associated key can be accomplished using an indexer, which works just like an indexer for an array. A key is passed in as the index value, and the value associated with the key is returned, unless the key doesn’t exist, in which a null is returned. you can use an indexer along with the Keys method to retrieve all the data stored in a hash tablearrow_forwardWrite a c++ code that compare the times to traverse a list (containing a large number of elements) implemented in an array, in a simple linked list, and in an unrolled linked list. In this experiment, you need to generate a large list, store it in each representation, and then measure the time to traverse the list in each representation. For the array, this is almost straightforward: Fill the array and then do a sequential scan. Here is the thing to watch for: When you fill the array, it all gets read into cache. So, somehow you need to ensure that almost all of the array is NOT in cache before you do your traversal. One thing you can do is make your array big enough that most of it will not fit in cache at once. You need to make sure that the node capacity is not too small, or it will behave too much like a simple linked list.arrow_forwardWrite a test client TestBinarySearch.java for use in testing the implementations of min(), max(), floor(), ceiling(), select(), rank(),deleteMin(), deleteMax(), and keys() that are given in the text. Start with the standard indexing client given on page 370. Add code to take additional command-line arguments, as appropriate.Write a test client TestBinarySearch.java for use in testing the implementations of min(), max(), floor(), ceiling(), select(), rank(),deleteMin(), deleteMax(), and keys() that are given in the text. Start with the standard indexing client given on page 370. Add code to take additional command-line arguments, as appropriate.Write a test client TestBinarySearch.java for use in testing the implementations of min(), max(), floor(), ceiling(), select(), rank(),deleteMin(), deleteMax(), and keys() that are given in the text. Start with the standard indexing client given on page 370. Add code to take additional command-line arguments, as appropriate.Write a test client…arrow_forward
- Suppose we built a hash table for strings where the hash value (number) associated to each string is just the numeric value of its first character. (Lowercase 'a' is 97, 'b' is 98, 'c' is 99, and so on, through 'p' at 112, 's' at 115, z' at 122, and on to a few special characters; numbers and capital letters are earlier in the sequence.) If we used the simplest implementation shown in class, separate chaining, where each bucket points to a possibly-empty list of values, adding the words "apple", "bag", “aardvark", and "badger" to an otherwise empty table with five buckets would give us something like се. this: 3 аpple aardvark bag badger a. If we then added "snake" and "pear" to the hash table (in that order), where would they go? b. If we then increased the table size to have ten buckets, where would each of the six strings end up? c. Comment on the efficacy of just using the first letter of a string to compute its hash value.arrow_forwardUsing the C# indexer mechanism, create a hash table class that can be indexed like an array. (In effect, create a simple version of the System .Collections.Hashtable container class.) Alternatively, use an overloaded version of operator[] to build a similar class in C++.arrow_forwardDevelop a program in C++ that will implement a Josephus Circle using circular linked list. There are n people standing in a circle waiting to be executed. The counting out begins at some point in the circle and proceeds around the circle in a fixed direction. In each step, a certain number of people are skipped and the next person is executed. The elimination proceeds around the circle (which is becoming smaller and smaller as the executed people are removed), until only the last person remains, who is given freedom. Given the total number of persons n and a number m which indicates that m-1 persons are skipped and mth person is killed in circle. The task is to choose the place in the initial circle so that you are the last one remaining and so survive.arrow_forward
- Develop a program in C++ that will implement a Josephus Circle using circular linked list. There are n people standing in a circle waiting to be executed. The counting out begins at some point in the circle and proceeds around the circle in a fixed direction. In each step, a certain number of people are skipped and the next person is executed. The elimination proceeds around the circle (which is becoming smaller and smaller as the executed people are removed), until only the last person remains, who is given freedom. Given the total number of persons n and a number m which indicates that m-1 persons are skipped and mth person is killed in circle. The task is to choose the place in the initial circle so that you are the last one remaining and so survive. ***Using #include <iostream>arrow_forwardWrite a program in c++ and make sure it works, that reads a list of students (first names only) from a file. It is possible for the names to be in unsorted order in the file but they have to be placed in sorted order within the linked list.The program should use a doubly linked list.Each node in the doubly linked list should have the student’s name, a pointer to the next student, and a pointer to the previous student. Here is a sample visual. The head points to the beginning of the list. The tail points to the end of the list. When inserting consider all the following conditions:if(!head){ //no other nodes}else if (strcmp(data, head->name)<0){ //smaller than head}else if (strcmp(data, tail->name)>0){ //larger than tail}else{ //somewhere in the middle} When deleting a student consider all the following conditions:student may be at the head, the tail or in the middleBelow, you will find a sample of what the file looks like. Notice the names are in…arrow_forwarddevelop a java program for :arrow_forward
- During tough times like these, investment becomes more uncertain with more dangers. To solve it, we might try to train a model to decide when to buy or sell. Therefore, to provide it with correct data, we plan to design an algorithm that answers: what is the perfect moment to buy and when to sell to maximize your profit? Assume you must buy Input: changes : array listing changes in the prices, where indices represent days; it has at least two values Output: i : index of the change before which we buy j: index of the change before which we sell maxProfit : the profit of this interval Example: Assume the below table contains the prices of a particular stock over days prices changes Day Value 50 1 63 13 70 7 3 40 -30 55 15 65 10 6 60 -5 7 72 12 8 79 7 9 68 -11 10 74 6 Therefore, the output of maxProfit([13,7,-30,15,10, -5,12,7, -11,6]) should be (3, 7, 39) . This is because our maximum profit would be 39 when we buy the stock at day 4, index of 3, and sell after day 8, index of 7. Then,…arrow_forwardComputer Science Can someone help me create a program that is a library management system? So, the program will manage a library collection of books, allowing the user to add books, check them out, and return them. possibly use data structures such as linked lists or hash tables which will keep track of the availability of the books. demonstrate its function and discuss your experiences in creating it. Topics worthy of discussion include details of the implementation itself (language choice, class design, etc), difficulties that you faced in implementing it (learning new techniques, significant errors encountered, etc), and maybe a project post-mortem discussing whether or not you would do anything differently, knowing what you do about it at the end (e.g. using a linked list instead of an array). c++arrow_forwardImplement a resize function for a hash table. Resizing is the process of increasing a hash table's size when too many items have been added, reducing the hash table's effectiveness. To resize the hash table, increase the size of the table by some small factor (not less than 2x), remove everything from the old table, and insert it into the new larger table. Make sure to free up memory that is no longer used after resizing. Use the following heuristics to resize the table: • When the load factor exceeds .5. If no entry is found within the probe distance. Note, you may need to change insert as well to have a fully working solution.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning