SmartExpert

(118)

$30/per page/Negotiable

About SmartExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Business & Finance See all
Accounting,Business & Finance,Economics,English,HR Management,Math Hide all
Teaching Since: Apr 2017
Last Sign in: 56 Weeks Ago, 4 Days Ago
Questions Answered: 7570
Tutorials Posted: 7352

Education

  • BS,MBA, PHD
    Adelphi University/Devry
    Apr-2000 - Mar-2005

Experience

  • HOD ,Professor
    Adelphi University
    Sep-2007 - Apr-2017

Category > Information Systems Posted 25 Oct 2017 My Price 8.00

Linked List Build Forward

Linked List Build Forward

Problem: 

Suppose that we read a list of integers ending with -999. The following function, buildListForward, builds a linked list in a forward manner) and returns the pointer of the built list:

Q1: The bulidListForward function to create a linked List structure with the keyboard input( cin >> num). Change this function to receive the values stored in the array from the main function( use int type pointer variable).  eg.  nodeType* buildListForward(int *arrayPrt, int Size)

Q2: Implement main function to call bulidListForward with an array type actual parameter that contains node information 2, 15, 8, 24, 34. 

Q3: Declare a struct named nodeType which contains two members     info and *link;

Q4: Inside of the function buildListForward,    change while loop to for loop to be able to get node information from the array and put this node information to newNode.

Q5: At the main function, print out node information by Traversing the Linked List that we have created at the main function and print out node information as follows:

Input     

 int Size_Array = 5;   

 int ArrayInfo[5] = { 2, 5, 8, 24, 34 };

 Output

& address of curr pointer   0x125cc20                                                                                                                                                                                                           & address of info:  0x125cc20 INFO:  2      LINK 0x125cc40                                                                                                                                                                                       & address of info:  0x125cc40 INFO:  5      LINK 0x125cc60                                                                                                                                                                                       & address of info:  0x125cc60 INFO:  8      LINK 0x125cc80                                                                                                                                                                                       & address of info:  0x125cc80 INFO:  24     LINK 0x125cca0                                                                                                                                                                                      & address of info:  0x125cca0 INFO:  34     LINK 0       

 

 nodeType* buildListForward( )

 {

  nodeType *first, *newNode, *last;

  int num;

 

 cout << "Enter a first of interges." << endl;   

  cin >> num;

   first = NULL;

    while (num != -999) 

 {   

  newNode = new nodeType;    

 newNode->info = num;   

  newNode->link = NULL;

 

     if (first == NULL)   

  {   

   first = newNode;   

   last = newNode;  

   }

else 

    {     

 last->link = newNode;    

  last = newNode;  

   }

  cout << "list of integers ending with -999." << endl;

      cin >> num;

   } //end while

 

        return first;

} //end buildListForward

 

 

Hand in:

1) Source code and :  Lab7.cpp, Lab7.doc ( Capture your screen shot)

 

2) Upload two files to the Black board.

Answers

(118)
Status NEW Posted 25 Oct 2017 06:10 AM My Price 8.00

Lin-----------ked----------- Li-----------st -----------Bui-----------ld -----------For-----------war-----------d ----------- -----------

Attachments

1508912646-lab7 Answer.zip
Not Rated(0)
Relevent Questions