Implement the dictionary ADT of Figure 4.27 using an unsorted linked list as defined by class LList
Question:
Implement the dictionary ADT of Figure 4.27 using an unsorted linked list as defined by class LList in Figure 4.8.
Make the implementation as efficient as you can, given the restriction that your implementation must use the unsorted linked list and its access operations to implement the dictionary.
State the asymptotic time requirements for each function member of the dictionary ADT under your implementation.
Transcribed Image Text:
// Linked list implementation class LList implements List { private Link head; private Link tail; protected Link curr; int cnt; //Constructors LList (int size) { this(); } LList() { // Constructor -- Ignore size curr = tail = head = new Link (null); // Create header cnt = 0; } public void clear() { // Remove all elements. // Drop access to links. head.setNext (null); curr = tail = head = new Link (null); // Create header cnt = 0; // Pointer to list header // Pointer to last element // Access to current element // Size of list. } // Insert "it" at current position public void insert (E it) ( curr.setNext (new Link (it, curr.next())); if (tail == curr) tail = curr.next(); // New tail cnt++; } public void append (E it) { // Append "it" to list tail = tail.setNext (new Link (it, null)); cnt++; } public void moveToStart() {curr = head; } } // Set curr at list start // Remove and return current element public E remove() { if (curr.next() == null) return null; E it = curr.next().element (); if (tail == curr.next()) tail = curr; curr.setNext (curr.next() .next()); cnt--; return it; // Nothing to remove // Remember value // Removed last // Remove from list // Decrement count // Return value. Figure 4.8 A linked list implementation.
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 100% (QA)
Part 1 Part 2 Part 3 java public interface Dictionary void clear boolean containsK key voi...View the full answer
Answered By
Jayshree Rathi
Hello Students!
This is Jayshree Rathi. I work on a number of renowned student-centric channels such as Chegg, coursehero, as a certified private tutor.
If you are looking for relevant and original content to complete your assignments, essays, and homework, then contact me and within the promised time, I will deliver you your personalized academic work and help you score the best.
4.80+
1+ Reviews
10+ Question Solved
Related Book For
Practical Introduction To Data Structures And Algorithm Analysis Java Edition
ISBN: 9780136609117
1st Edition
Authors: Clifford A. Shaffer
Question Posted:
Students also viewed these Computer science questions
-
Define an ADT for a bag (see Section 2.1 ) and create an array-based implementation for bags. Be sure that your bag ADT does not rely in any way on knowing or controlling the position of an element....
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
List three specific parts of the Case Guide, Objectives and Strategy Section (See below) that you had the most difficulty understanding. Describe your current understanding of these parts. Provide...
-
Capital Inc. has prepared the operating budget for the first quarter of 2015. They forecast sales of $50,000 in January, $60,000 in February, and $70,000 in March. Variable and fixed expenses are as...
-
Helium gas enters a steady-flow expander at 800 kPa, 300C, and exits at 120 kPa. The mass flow rate is 0.2 kg/s, and the expansion process can be considered as a reversible polytropic process...
-
What is the average zenith angle given the following direct and reversed readings? Direct: 94o 23' 48'', 94 o 23' 42'', 94 o 23' 44'' Reversed: 265 o 36' 20'', 265 o 36' 24'', 265 o 36' 22'' In...
-
1 To what extent are people in your organisation aware of the limitations of financial measures of performance? Have they acted to take account of this by, for example, considering some kind of...
-
Dingel Corporation has contracted with you to prepare a statement of cash flows. The controller has provided the following information. Additional data related to 2010 are as follows. 1. Equipment...
-
There is an editorial on page 198 of the 12/1/2002 with a quote by a well-known humorist. Who is the humorist?
-
Implement the dictionary ADT of Figure 4.27 based on stacks. Your implementation should declare and use two stacks. /** The Dictionary abstract class. */ public interface Dictionary { }; /**...
-
Implement a collection of freelists for variable-length strings, as described at the end of Section 4.1.2. For each such freelist, you will need an access function to get it if it exists, and...
-
Show, without amounts, the form of the closing entries for a retail store using a perpetual inventory system.
-
Caching. CPUs. Hard disk drives. Parallelism. Pipelining. RAM. Registers. Solid-state drives. Dinkleberg 1. (3 points) You know that neighbor who always one-ups you? Apparently, he just bought a...
-
Information for Question 1 and 2: The National Health Interview Survey is an annual national health survey of people living in about 35,000 randomly selected households in the United States. On the...
-
Q1. There is trampoline on the ground, and connected to spring of spring constant, k, on the bottom. You are holding a child of mass, M on a H tall building top (H is measured from the trampoline to...
-
SPSS for intermediate statistics extra problems solutions d. Approximately how much variance in consumers' tendency to purchase the product could be predicted from these variables? If you owned the...
-
A finance company uses the discount method of calculating interest. The loan principal is $5,000, the interest rate is 10%, and repayment is expected in two years. You will receive 4196.25 X from the...
-
Reconsider Prob. 8-51. Using EES (or other) software, solve the problem and in addition determine the actual heat transfer, if any, and its direction, the minimum power input (the reversible power),...
-
Suppose the index goes to 18 percent in year 5. What is the effective cost of the unrestricted ARM?
-
Ten sources, six with a bit rate of 200 kbps and four with a bit rate of 400 kbps, are to be combined using multilevel TDM with no synchronizing bits. Answer the following questions about the final...
-
Which of the three multiplexing techniques is common for fiber-optic links? Explain the reason.
-
We have 14 sources, each creating 500 8-bit characters per second. Since only some of these sources are active at any moment, we use statistical TDM to combine these sources using character...
-
Q2R. on account for each depreciable asset. During 2024, Jane VIIS nsactions.) i More Info Apr. 1 Purchased office equipment. 5111,000. Paid 581,000 cash and financed the remainder Jan. 1 with a note...
-
The rate of return on Cherry Jalopies, Inc., stock over the last five years was 14 percent, 11 percent, 4 percent, 3 percent, and 7 percent. What is the geometric return for Cherry Jalopies, Inc.?
-
U.S. GAAP specifies all of the following characteristics of variable interest entities except: A. Equity holders hold less than 5% of the entitys voting stock. B. Equity holders do not have voting...
Study smarter with the SolutionInn App