Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hey guys .. the following code is to reverse a list and it works just fine.. #in

ID: 3615966 • Letter: H

Question

Hey guys .. the following code is to reverse a list and it works just fine..

#include

using

struct

{

StackFrame *link;

};

typedef

class

{

public

Stack (): top(NULL)

{

}

~Stack ()

{

next = pop ();

}

{

StackFramePtr temp;

temp =

temp->value = no;

temp->link = top;

top = temp;

}

{

{

cout <<

exit (1);

}

top = top->link;

}

{

}

private

StackFramePtr top;

};

void

{

{

cout <<

<<

exit (1);

}

}

void

{

Stack stack;

StackFramePtr temp;

temp = head;

{

stack.push( temp->value);

temp = temp->link;

}

temp = head;

{

temp->value = stack.pop();

temp = temp->link;

}

}

void

{

cout << to_show->value << endl;

}

void

{

StackFramePtr temp =

temp->value = no;

temp->link = head;

head = temp;

}

int

{

StackFramePtr head =

head = NULL;

cout <<

cin >> number;

{

insert_head (head, number);

cin >> number;

}

checkList (head);

cout<<

showList (head);

cout <<

reverse (head);

showList (head);

}

Explanation / Answer

please rate - thanks technically--now it's a reference parameter (see the red) but it makes no difference, since the value in the parameter isunchanged #include using namespace std; struct StackFrame { int value; StackFrame *link; }; typedef StackFrame* StackFramePtr; class Stack { public: Stack (): top(NULL) { } ~Stack () { int next; while (! empty () ) next = pop (); } void push (int no) { StackFramePtr temp; temp = new StackFrame; temp->value = no; temp->link = top; top = temp; } int pop () { if ( empty () ) { cout value; top = top->link; return result; } bool empty () const { return (top == NULL); } private: StackFramePtr top; }; void checkList (StackFramePtr head) { if (head == NULL) { cout link; } } void showList (StackFramePtr head) { for (StackFramePtr to_show=head; to_show!=NULL;to_show=to_show->link) cout number; while ( number >= 0) { insert_head (head, number); cin >> number; } checkList (head); cout