. assume the node is in the usual info-link form with info

Assignment Help Basic Computer Science
Reference no: EM13163467

Show what is produced by the following C++ code. Assume the node is in the usual info-link

form with the info of the type int. (list, trail, and current are pointers of type nodeType.)

 

list = new nodeType;

list -> info = 28;

trail = new nodeType;

trail -> info = 33;

trail -> link = list;

list -> link = NULL;

current = new nodeType;

current -> info = 62;

trail -> link = current;

current ->link = list;

list= trail;

current = list ->link;

trail = current -> link

cout << list -> info<<" "<<current -> info << '' " <<trail -> info<<endl;

 

 

 

3. Assume that the node of a linked list is in the usual info-link form with the info of type int. The

following data, as described in parts (a) to (d), is to be inserted into an initially linked list: 72, 43,

8, 12. Suppose that head is a pointer of type nodeType. After the linked list is created, head

should point to the first node of the list. Declare additional variables as you need them. Write

the C++ code to create the linked list. After the linked list is created, write a code to print the

list. What is the output of your code?

a. Insert 72 into an empty linked list.

b. Insert 43 before 72.

c. Insert 8 at the end of the list.

d. Insert 12 after 43.

 

 

4. Assume that the node of a linked list is in the usual info-link form with the info of type int. (list

and ptr are pointers of type nodeType.) The following code creates a linked list:

 

ptr = new nodeType;

ptr -> info = 16;

list = new nodeType;

list - > info = 25;

list -> link = ptr;

ptr = new nodeType;

ptr -> info = 12;

ptr -> link = NULL;

list ->link -> link = ptr;

Use the linked list created by this code to answer the following questions. (These questions are

independent of each other.) Declare additional pointers if you need them.

 

a. Which pointer points to the first node of the linked list?

b. Determine the order of the nodes of the linked list.

c. Write a C++ code that creates and inserts a node with info 45 after the node with info 16.

d. Write a C++ code that creates and inserts a node with info 58 before the node with info 25.

Does this require you to the change the value of the pointer that was pointing to the first node

of the linked list?

e. Write a C++ code that deletes the node with info 25. Does this require you to the change the

value of the pointer that was pointing to the first node of the linked list?

 

 

 

 

 

6. What is the output of the following C++ code? (The class unorderedLinkedList is as defined in

this chapter.) Assume input is:

45 35 12 83 40 23 11 98 64 120 16 -999

 

 

unorderedLinkedList <int> list;

unorderedLinkedList <int> copyList;

int num;

cin>>num;

while (num != -999)

{ if (num % 4 == 0 | | num% 3 == 0)

list.insertFirst (num);

else

list.insertLast (num);

cin>>nume;

}

cout<<"copyList = ";

list.print();

cout<<endl;

copyList = list;

copyList.deleteNode(33);

copyList.deleteNode(58);

cout<<"copyList = ";

copyList.print()

 

Reference no: EM13163467

Questions Cloud

Simple java application that uses the string : Create a simple Java application that uses the String class and/or the StringBuffer class and at least 4 of the class methods. Show the code, demonstrate it works properly and describe what it is doing.
Using unix extract the various ethnic populations in file : Using Unix extract the various ethnic populations in your file.
Using array subscript notation : Using array subscript notation, base/offset notation with the array name as the pointer, array notation with  vPtr , and pointer/offset notation with  vPtr , add 3 to the value in the 3 rd element and display that number. (Do not modify the value in ..
Implement a function to recursively : Implement a function to recursively determine if a word is a palindrome. A palindrome is a word, phrase, number, or other sequence of symbols or elements, whose meaning may be interpreted the same way in either forward or reverse direction.
. assume the node is in the usual info-link form with info : Show what is produced by the following C++ code. Assume the node is in the usual info-link form with the info of the type int. (list, trail, and current are pointers of type nodeType.)
Prepare the journal entry to record depreciation expense : Irons Delivery, Inc., purchased a new delivery truck for $42,000 on January 1, 2009. The truck is expected to have a $2,000 residual value at the end of its five-year useful life. Irons uses the straight-line method of depreciation.
Compute price and usage variances for direct materials : Compute price and usage variances for direct materials and compute the direct labor rate and labor efficiency variances.
Find all irreducible polynomials : Find all irreducible polynomials1. of degree 3 over GF(2),2. of degree 4 over GF(2).
State responsibility and environmental regulation : What are three jurisdiction -what can they make a state do? Do they have any power over a company?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Compare performance-one-level split-two-level unified cache

Compare the performance (using AMAT) of a one-level split cache and a two-level unified cache system. For the one-level split cache, suppose a hit takes 2 clock cycles.

  Create a driver class to instantiates-updates several object

Create a driver class called FlightTest whose main method instantiates and updates several Flight objects. Two classes are required for this project: Flight and FlightTest.

  Policies and provisions to unbundled network elements

What are some of the major policies and provisions under the 1996 Act in regards to unbundled network elements (UNEs).

  create a version of a carnival game

assignment, your job is to create a version of a carnival game in which mechanical dogs race along a track. The racing game is called DogTrack. DogTrack is also the name of the java source file you must submit to complete the assignment. The DogTrack..

  Explaining responsibility ofconfidentiality to employer

Describe what you must do in such a situation. You know that cost to your present employer will increase if ambiguities are not resolved. Though, you also have a responsibility of confidentiality to previous employer.

  Explain performance which is boost by new version of chip

Let the following hypothetical news release: "Company will unveil industry's first 5 GHz version of chip, which presents 25% performance boost over company's former speed champ. Explain the definition (or definitions) of performance.

  Develop a technique for machines

For artificial intelligence systems to adapt to new conditions, the 1st task is to construct a technique for machines to resolve problems 'on their own'. To do this, one requires to develop a generic method to resolve generic troubles

  Windows active directory

A research paper on Windows Active Directory and User Access Controls with some additional info about Group Policy Objects and Microsoft Baseline Security Analyzer.

  How spki be augmented to support policy

Consider a policy that, for reasons of separation of duties, does not allow an entity to exercise the rights it may grant (delegate) to others. How could SPKI be augmented to support such a policy?

  Explain how versatility of excel affect application support

How does versatility of Excel affect application support? As its versatility, what assumptions should be made when diagnosing and troubleshooting Excel-based problems?

  Determine the maximum period obtainable from lcg

Determine the maximum period obtainable from following LCG? Xn+1 = aXn (mod 24). What must be the value of a?

  Describe happening of water lubrication film under ice skate

Similar reasoning is utilized to describe occurrence of water lubrication film beneath ice skates. Describe your opinion of this explanation?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd