# Write a C++ function to add a node to the beginning of a linked list. Your...

###### Question:

Write a C++ function to add a node to the beginning of a linked list.

Note that the list may be empty!

Your function should modify the head of the linked list to point to the new node, and set the new node to point to the rest of the list (if not empty).

Example:

Initial Array: 4->2->3, key = 5

Array After Function Call: 5->4->2->3

$void AddNode(node** head, int num);$

$struct node { int key; node *next; };$

The objective is to understand how to make use of a pointer-to-a-pointer, and why it is important.

For example:

Test Result
$// head = 4 // AddNode(head, 2) // AddNode(head, 3) // AddNode(head, 5)$
$5->3->2->4$

#### Similar Solved Questions

##### HiTiak Cond For the circuit in Fig. 5 (0)-12 V and (0) 30 mA. nd 2....
hiTiak Cond For the circuit in Fig. 5 (0)-12 V and (0) 30 mA. nd 2. Fig S 2X10 a) Find the initial energy stored in the inductor at t-0 b) Find the initial energy stored in the capacitor at to c) Find the type of damping...
##### B) Assuming the following. P(S)-0.3 P(BIS) 0.75 P(BIS) 0.20 P(HS'B)-0.15 P(H S'nB') 0.9 P(HİSnB)-0.20 Write out...
b) Assuming the following. P(S)-0.3 P(BIS) 0.75 P(BIS) 0.20 P(HS'B)-0.15 P(H S'nB') 0.9 P(HİSnB)-0.20 Write out the equations and compute: PSPCS) 0.320.1 c) Now eompute the probabilities pertaining to each section in the Venn diagram B2 BnsnH 5 2 3...
##### After several profitable years running her business, BLANK decided to acquire the assets of a small...
After several profitable years running her business, BLANK decided to acquire the assets of a small competing business. On May 1 of year 1, BLANK acquired the competing business for $372,000. BLANK allocated$62,000 of the purchase price to goodwill. BLANK’s business reports its taxable income...
##### Please let it be legible, thanks in advance! Review constants I Porodic Table The elastic energy...
Please let it be legible, thanks in advance! Review constants I Porodic Table The elastic energy stored in your tendons can contribute up to 35 % of your energy needs when running. Sports scientists have studied the change in length of the knee extensor tendon in sprinters and nonathletes. They ...
##### Question 1 n= c/v where vis the [x]of light in the medium. Question 2 [x] is...
Question 1 n= c/v where vis the [x]of light in the medium. Question 2 [x] is a great circle that passes through both poles, and it forms a right angle with equator....
##### Lambeth, Inc. produces the basic fillings used in many popular frozen desserts and treats-vanilla and chocolate...
Lambeth, Inc. produces the basic fillings used in many popular frozen desserts and treats-vanilla and chocolate ice creams, puddings, meringues, and fudge. Lambeth uses standard costing and carries over no inventory from one month to the next. The ice-cream product group's results for June 2017 ...
##### Cle Tutorial Step 7: Prepare the Adjusted Trial Balance ding balances after adjustments rify ending balances...
cle Tutorial Step 7: Prepare the Adjusted Trial Balance ding balances after adjustments rify ending balances after adjustments e adjusted balance after adjustments have been posted to the T-Accounts. Accounts Receivable Accumulated Depreciation- Furniture Office Supplies Nov. 10 2.500 140 Dec. 31 No...
##### Demand and Supply in Labor Markets As the text suggests, the demand and supply model predicts...
Demand and Supply in Labor Markets As the text suggests, the demand and supply model predicts that the new computer and communications technologies will raise the pay of high-skill labor but reduce the pay of low-skill labor. Explain how this works using the four-step process....
##### Why is chlorination less selective than bromination?
Why is chlorination less selective than bromination?...
##### Question 8 (10 points) Use Boolean algebra to simplify the following expression X = ABC +...
Question 8 (10 points) Use Boolean algebra to simplify the following expression X = ABC + ĀBC + ĀBC + ABC + ABC (2.5 points) Sketch the simplified circuit...
##### Infants weighing less than 1,500 grams at birth are classed as "very low birth weight." Low...
Infants weighing less than 1,500 grams at birth are classed as "very low birth weight." Low birth weight carries many risks. IQ tests are designed to produce IQ scores varying Normally with standard deviation ?=15 . They are also scaled so that the mean score in a large population should be ...
##### Quick Cleaners, Inc. (QCI), has been in business for several years. It specializes in cleaning houses...
Quick Cleaners, Inc. (QCI), has been in business for several years. It specializes in cleaning houses but has some small business clients as well. a. Issued $23,000 of QCI stock for cash. b. Incurred$660 of utilities costs this month and will pay them next month. c Incurred and paid wages for the c...