  
            CBSE Guess > Papers > Important Questions > Class XII > 2010 > Computer Science > Computer Science By Ravi Kiran             
            CBSE CLASS XII 
            
                
             
			
			    
			DELHI 2008 
			Q.1 
            Write a  function in C++ to insert an element into a dynamically  allocated Queue where each 
		    node contains a name (of type string) as data. 
		    Assume the following definition of THENODE for the same. 
		    struct  THENODE 
		    { 
		    char  Name[20]; 
		    THENODE  *Link; 
		    }; 
			Solution: 
						  struct THENODE 
			  { 
			  char Name[20]; 
			  THENODE *Link; 
			  }; 
			  class Queue 
			  { 
			  THENODE *front,*rear; 
			  public: 
			  Queue( ) 
			  { front = rear = NULL; } 
			  void Insert( ); 
			  void Delete( ); 
			  void Display( ); 
			  }; 
			  void Queue::Insert( ) 
			  { 
			  THENODE *ptr; 
			  ptr=new THENODE; 
			  if(ptr= = NULL) 
			  { 
			  cout<<”\nNo memory to create a new node….”; 
			  exit(1); 
			  } 
			  cout<<”\nEnter the name….”; 
			  gets(ptrName); 
			  ptrLink=NULL; 
			  if(rear= = NULL) 
			  front=rear=ptr; 
			  else 
			  { 
			  rearLink=ptr; 
			  rear=ptr; 
			  } 
		    } 
			Q.2.  Evaluate  the following postfix notation of expression (Show status of stack after  execution of 
              each operation ). 4,  10, 5, +, *, 15, 3, /, -  
			    
            Paper By Mr. Ravi Kiran 
			Email Id : [email protected] 		   |