2. a. Using C/C++, define a node structure of the linked list (e.g. value is an...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
2. a. Using C/C++, define a node structure of the linked list (e.g. value is an integer, next is a node type pointer), construct a linked list of 10 nodes and assign random numbers as the nodes' values. Use loop to track and print from the first node to the last and output all nodes' values. Finally, free all memories of the linked list. b. Based on 2.a, (1) define a function which takes the header as parameter, the function will create a new node and assign its value 100; then insert this node at the sixth position of the list; (2) define another function which recursively print the list forwards to verify the result; (3) define the 3rd function which takes the header as parameter, the function will delete the eighth node of the list to keep the linked list having 10 nodes, and (4) define the 4th function which recursively to print the linked list backwards. After creating the four functions, revise your program 2.a, before delete all memories of the list, call the four functions in order to verify the results. 2. a. Using C/C++, define a node structure of the linked list (e.g. value is an integer, next is a node type pointer), construct a linked list of 10 nodes and assign random numbers as the nodes' values. Use loop to track and print from the first node to the last and output all nodes' values. Finally, free all memories of the linked list. b. Based on 2.a, (1) define a function which takes the header as parameter, the function will create a new node and assign its value 100; then insert this node at the sixth position of the list; (2) define another function which recursively print the list forwards to verify the result; (3) define the 3rd function which takes the header as parameter, the function will delete the eighth node of the list to keep the linked list having 10 nodes, and (4) define the 4th function which recursively to print the linked list backwards. After creating the four functions, revise your program 2.a, before delete all memories of the list, call the four functions in order to verify the results.
Expert Answer:
Answer rating: 100% (QA)
2a Using CC define a node structure of the linked list e9 value is an integer next is a node type p... View the full answer
Related Book For
Data Structures and Algorithm Analysis in Java
ISBN: 978-0132576277
3rd edition
Authors: Mark A. Weiss
Posted Date:
Students also viewed these programming questions
-
Assets Cash 2004 $31.000 18,000 27,000 80,000 (30,000) $126,000 2003 $ 20,000 14,000 20,000 78,000 (24,000) $108,000 Accounts receivable Merchandise inventory Property, plant, and equipment...
-
Directions Complete the following homework assignment using the description given in each section. Purpose Use a structure to build linked list. Perform search and delete operations on the built...
-
A linked list is a collection of nodes, where each node containssome data and a reference (or link) to the next node. Unlikearrays, linked lists can easily grow and shrink by simply addingand...
-
Water flowing in a positive x-direction passes through a 90 elbow in a 6-inch-diameter pipeline and heads in a positive y-direction with a flow rate of 3.05 ft3/sec. Compute the magnitude and...
-
Go-Ahead Limited began the year with common shares of $100,000 and retained earnings of $350,000. During the year, it issued an additional $25,000 of common shares, reported a profit of $75,000, and...
-
For y = 2x 3 3x 2 36x + 4 a. Find dy/dx and the values of x when dy/dx = 0. b. Find the value of d 2 y/dx 2 at each stationary point and hence determine its nature. c. Find the value of y at each...
-
Refer to the data for Inland Equipment in P5-40A. However, assume Inland Equipment uses the average cost method. Requirements 1. Prepare a perpetual inventory record using average cost. Round the...
-
Buster Cogdill, a real estate developer, made an offer to the Bank of Benton to have the bank provide construction financing for the development of an outlet mall, with funds to be provided at prime...
-
Divergent Thinking Process: Apply divergent thinking to determine as many possible solutions to surface coal mine safety as possible. What is a divergent Thinking Process when it comes to surface...
-
On December 31, the trial balance indicates that the supplies account has a balance, prior to the adjusting entry, of $320. A physical count of the supplies inventory shows that $90 of supplies...
-
Solve for maturity value, discount period, bank discount, and proceeds. Assume a bank discount rate of 9%. Use the ordinary interest method. (Use table value.) (Use 360 days a year. Do not round...
-
What interest rate must your bank offer if you want your $1,500 invested today to grow to $2,500 in 10 years? (Round to the nearest whole number; remember to enter present value as a negative number...
-
The three domains of life are Bacteria, Archaea, and Eukarya.This activity asks you to match the description of each group orexamples from a group with the appropriate location in the imagedepicting...
-
Supply chains often comprise thousands of vendors, many of which might be vulnerable to cyber attacks. Hackers often target such vendors as a means of gaining access into a larger company - the...
-
Watch the video bellow and answer the 3 questions! Alice Dreger: Is anatomy destiny? | TED Talk Link to the video bellow...
-
Blue Ridge Marketing Inc. manufactures two products, A and B. Presently, the company uses a single plantwide factory overhead rate for allocating overhead to products. However, management is...
-
38 Illustration 17 From the following extracts of Receipts and Payment A/c and additional information you are required to calculate the income from subscription for the year ending December 31, 2017...
-
On January 1, 2017, McIlroy, Inc., acquired a 60 percent interest in the common stock of Stinson, Inc., for $340,200. Stinson's book value on that date consisted of common stock of $100,000 and...
-
Suppose that a singly linked list is implemented with both a header and a tail node. Describe constant-time algorithms to a. Insert item x before position p (given by an iterator). b. Remove the item...
-
The longest common subsequence problem is as follows: Given two sequences A = a1, a2, . . . , aM, and B = b1, b2, . . . , bN, find the length, k, of the longest sequence C = c1, c2, . . . , ck such...
-
Add support for a ListIterator to the MyArrayList class. The ListIterator interface in java.util has more methods than are shown in Section 3.3.5. Notice that you will write a listIterator method to...
-
The partnership of King. Queen, \&- Page has experienced operating losses for three consecutive years. The partners-who have shared profits and losses in the ratio of King, \(15 \%\) : Queen, \(60...
-
ABACUS is a partnership owned by Allen, Bacon, and Cush, who share profits and losses in the ratio of \(1: 3: 4\). The account balances of the partnership at June 30 follow. Requirements 1. Prepare...
-
On June 30, Allie Hayes and Mandy McKay formed a partnership. The women agree to invest equal amounts of capital. Hayes invests her proprietorship's assets and liabilities (credit balances in...
Study smarter with the SolutionInn App