This approach reserves the List's first node (Index Position # zero) as a Sentinel called the 'NIL
Fantastic news! We've Found the answer you've been seeking!
Question:
This approach reserves the List's first node (Index Position # zero) as a Sentinel called the 'NIL node' it does not hold valid key data, it is used for keeping track of the Head pointer value in the Next attribute and the Tail pointer value in the Prev attribute.
For the steps below us a Circular DLL with sentinel node architecture. Upload your work.
- Illustrate an empty list. Show result.
- Insert "M" Show result.
- Insert "E" Show result.
Transcribed Image Text:
Sentinel Node IP # Zero Key data Prev - IP # Next IP# Node Index Position # Prev Key IP# data Next IP# Node Index Position # Prev Key Next IP# data IP# L.nil.next (attribute pointer to first element in list, the head.) L.nil.prev (attribute pointer to last element in list, the tail.) Node Index Position # Prev Key Next data IP# IP# A sentinel is a dummy object that allows us to simplify boundary conditions, head and tail. Presume the pseudo code 'NIL node' index position # = zero is reserved for the sentinel. The list L has an object L.nil that represents node zero and has all the attributes of the other objects in the list (i.e. prev key next). Wherever we have a reference to NIL in a LIST algorithms, we replace it by a reference to the sentinel L.nil node index position # = zero. An empty list consists of just the sentinel, and both L.mil.next and L.nil.prev point to L.nil. The attribute L.nil.next points to the head of the list, and L.nil.prev points to the tail. Similarly, both the next attribute of the tail and the prev attribute of the head point to L.nil. Eliminate Variables Head, and Tail. Since L.nil.next points to the head, we can eliminate the variable attribute L.head altogether, replacing references to it by references to L.nil.next. Likewise eliminate the variable attribute L.tail replacing references to it by references to L.nil.prev. LIST-SEARCH(L, k) 1) x = L.nil.next 2) while (x != L.nil and x.key != k) 3) x = x.next 4) return x LIST-INSERT(L, x) 1) x.next = L.nil.next 2) L.nil.next.prev = x 3) L.nil.next = x 4) x.prev - L.nil LIST-DELETE(L, X) 1) if x.prev != NIL 2) x.prev:next = x.next 3) x.next:prev = x.prev 3) else 4) L.nil.next = x.next 5) if x.next != NIL 6) x.next.prev=x.prev 7) L.remove(x) //attributes = null 8) L. list.trimToSize() // reduces windows LIST-GET_NEXT_AVAIL_NODE(L) Go To Settings to activate 1) return x Sentinel Node IP # Zero Key data Prev - IP # Next IP# Node Index Position # Prev Key IP# data Next IP# Node Index Position # Prev Key Next IP# data IP# L.nil.next (attribute pointer to first element in list, the head.) L.nil.prev (attribute pointer to last element in list, the tail.) Node Index Position # Prev Key Next data IP# IP# A sentinel is a dummy object that allows us to simplify boundary conditions, head and tail. Presume the pseudo code 'NIL node' index position # = zero is reserved for the sentinel. The list L has an object L.nil that represents node zero and has all the attributes of the other objects in the list (i.e. prev key next). Wherever we have a reference to NIL in a LIST algorithms, we replace it by a reference to the sentinel L.nil node index position # = zero. An empty list consists of just the sentinel, and both L.mil.next and L.nil.prev point to L.nil. The attribute L.nil.next points to the head of the list, and L.nil.prev points to the tail. Similarly, both the next attribute of the tail and the prev attribute of the head point to L.nil. Eliminate Variables Head, and Tail. Since L.nil.next points to the head, we can eliminate the variable attribute L.head altogether, replacing references to it by references to L.nil.next. Likewise eliminate the variable attribute L.tail replacing references to it by references to L.nil.prev. LIST-SEARCH(L, k) 1) x = L.nil.next 2) while (x != L.nil and x.key != k) 3) x = x.next 4) return x LIST-INSERT(L, x) 1) x.next = L.nil.next 2) L.nil.next.prev = x 3) L.nil.next = x 4) x.prev - L.nil LIST-DELETE(L, X) 1) if x.prev != NIL 2) x.prev:next = x.next 3) x.next:prev = x.prev 3) else 4) L.nil.next = x.next 5) if x.next != NIL 6) x.next.prev=x.prev 7) L.remove(x) //attributes = null 8) L. list.trimToSize() // reduces windows LIST-GET_NEXT_AVAIL_NODE(L) Go To Settings to activate 1) return x
Expert Answer:
Answer rating: 100% (QA)
a circular doubly linked list CDLL with a sentinel node architecture A sentinel node is a dummy node that simplifies code by handling edge cases specifically those related to the head and tail of the ... View the full answer
Related Book For
Smith and Roberson Business Law
ISBN: 978-0538473637
15th Edition
Authors: Richard A. Mann, Barry S. Roberts
Posted Date:
Students also viewed these programming questions
-
What would be considered "accumulated taxable income" for the year?
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Dollar General Corporation, headquartered in Goodlettsville, Tennessee, is an aggressive competitor in the deep discount retail industry, fighting for position with other stores such as Family...
-
a) Assuming that your capital is constrained, what is the fifth project that you should invest in? Please show work. b) Assuming that your capital is constrained so that you only have $600,000...
-
When high-energy charged particles move through a transparent medium with a speed greater than the speed of light in that medium, a shock wave, or bow wave, of light is produced. This phenomenon is...
-
Explain what the following terms mean in object-oriented database terminology: method, signature, message, collection, extent.
-
A round concrete storm sewer pipe used to carry rainfall runoff from a parking lot is designed to be half full when the rainfall rate is a steady \(1 \mathrm{in}\)./hr. Will this pipe be able to...
-
On November 1, 2009, Olympic Company adopted a share-option plan that granted options to key executives to purchase 40,000 shares of the companys $10 par value ordinary shares. The options were...
-
An ASTM A572 Grade 50 steel bar is attached to a rigid wall at one end and a spring at the other end, with the other end of the spring being attached to a rigid wall, as shown below. The bar is 20 cm...
-
Kate Jackson, a new staff accountant, is confused because of the complexities involving accounting standard setting. Specifically, she is confused by the number of bodies issuing financial reporting...
-
1. An object with a mass of 220kg is held 2.20m above the ground for 10.0s. How much work is being done on the object during this time interval.
-
Credit Card Debt. Repeat the table in Exercise 33, but this time assume that you make monthly payments of $300. Extend the table as long as necessary until your debt is paid off. How long does it...
-
Consider the assembly code addui x6, x5, 8 slli x7, x6, 3 beq x0, x0, Label 1 a) Write the machine language instructions corresponding to the above RISC-V code; b) What number is stored in register...
-
Foreign Investments Use the Internet to find three foreign companies you might want to invest in. What country is the company in? What do they make or own? Why do you think the value of their stock...
-
During Morch, manufacturing company produced 6,000 ott and has the following manufacturing costs: valable costs $31 per unit, find conto $22 per unit. The factory monthly production capacity is...
-
Springfield Limited wishes to raise 300,000 in cash. How many shares will the company have to issue to raise 300,000 if the shares have a par value of 50 cent and the shares are issued at a premium...
-
10 points Save Answer On its most recent financial statements, Gevelyn Inc. reported net sales of $571,000, accounts receivable of $75,000, inventories of $66,000, and accounts payable of $58,000....
-
In the circuit shown in Figure 4, a battery supplies a constant voltage of 40 V, the inductance is 2 H, the resistance is 10, and l(0) = 0. (a) Find l(t). (b) Find the current after 0.1s.
-
Distinguish among the following relationships: (a) agency, (b) employment, and (c) independent contractor.
-
Turman executed a deed of trust note for $107,500.00 payable to Wards Home Improvement, Inc. The note was consideration for a contract by which Ward was to construct a home on property owned by...
-
Civil Code 1719, subdivision (a) provides in part that any person who draws a check that is dishonored due to insufficient funds shall be liable to the payee for the amount owing upon the check and...
-
Understanding the Feds actions that are needed to stabilize the interest rate The diagram below shows three different money demand curves and a target interest rate i*. Fill in the table below using...
-
This section looks at US recessions over the past 60 years. To work out this problem, first obtain quarterly data on US output growth for the period 1960 to the most recent data from www.bea.gov....
-
This question asks you to examine the movements of investment and consumption before, during and after the recession of 2001. It also asks you to consider the response of investment and consumption...
Study smarter with the SolutionInn App