COMPUTER SCIENCE LINKED LISTS , STACKS AND QUEUES

3.d) Write a function in C++ to perform a PUSH operation on a dynamically llocated stack containing real number.

struct Node
{ float Number ;
Node *Link ;
} ;
class STACK
{ Node *Top ;
public :
STACK( ) {Top = NULL ;}
void PUSH( ) ;
void POP( ) ;
~STACK( ) ;
} ;

Solution:

struct Node
{ float Number ;
Node *Link ;
} ;
class STACK
{ Node *Top ;
public :
STACK( ) {Top = NULL ;}
void PUSH( ) ;
void POP( ) ;
~STACK( ) ;
} ;
void STACK::PUSH( )
{ Node *Temp;
Temp=new Node;
if(Temp= =NULL)
{
cout<<”\nNo memory to create the node…”;
exit(1);
}
cout<<”\nEnter the Number to be inserted: “;
cin>>Temp→ Number;
Temp→ Link=Top;
Top=Temp;
}

3.e) Write the equivalent infix expression for a, b, AND, a, c, AND, OR.

Ans) a, b, AND, a, c, AND, OR (a AND b), (a AND c), OR (a AND b) OR (a AND c)

OUTSIDE DELHI : 2006

3.c) Introduction

class stack
{ int data[10] :
int top ;
public :
stack( )
{ top = - 1; }
void push( ) ;
//to push an element into the stack
void pop( ) ;
//to pop an element from the stack
void Delete(int ITEM) ;
//To delete all elements which are equal to ITEM.
} ;

Complete the class with all function definitions. Use another stack to transfer data temporarily.

Solution:

void stack::push( )
{ if(top>=9)cout<<”Stack Overflow…”;
else
{ top++;
cout<<”\nEnter the element to be inserted…”;
cin>>data[top];
}
}
void stack::pop( )
{ if(top= =-1)
cout<<”\nStack Underflow”;
else
{ cout<<”\nThe element to be deleted = “<<data[top];
top--;
}
}
void stack::Delete(int ITEM)
{ //Dear children, try to complete this function.
}

 

CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( mrkdata@yahoo.com )


Warning: include_once(../../ebooks-footer19.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/coumputer-science/linklist_stack4.php on line 167

Warning: include_once(): Failed opening '../../ebooks-footer19.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/coumputer-science/linklist_stack4.php on line 167

Warning: include_once(../../../footer19.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/coumputer-science/linklist_stack4.php on line 169

Warning: include_once(): Failed opening '../../../footer19.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/coumputer-science/linklist_stack4.php on line 169