Sunday, November 13, 2011

CS301 Midterm Past Solved Paper (1)


MIDTERM  EXAMINATION
Spring 2010
CS301- Data Structures


Question No: 1      ( Marks: 1 ) - Please choose one
 

Which one of the following statement is NOT correct .


       ►  In linked list the elements are necessarily to be contiguous

       ►  In linked list the elements may locate at far positions in the memory 

       ► In linked list each element also has the   next to it 

       ► In an array the elements are contiguous 



Question No: 2      ( Marks: 1 ) - Please choose one
 

Each operator in a postfix expression refers to the previous ________ operand(s).


       ► One

       ► Two

       ► Three

       ► Four

p67

Question No: 3      ( Marks: 1 ) - Please choose one
 

Which one of the following calling methods does not change the original value of the argument in the calling function? 

       ► None of the given options

       ► Call by passing the value of the argument

       ► Call by passing reference of the argument

       ► Call by passing the address of the argument



Question No: 4      ( Marks: 1 ) - Please choose one
 
  A tree is an AVL tree if 


       ► Any one node fulfills the AVL condition 

       ► At least half of the nodes fulfill the AVL condition
       ► All the nodes fulfill the AVL condition 

       ► None of the given options



Question No: 5      ( Marks: 1 ) - Please choose one
 

Suppose currentNode refers to a node in a linked list (using the Node class with member variables called data and nextNode). What statement changes currentNode so that it refers to the next node?


       ► currentNode ++;

       ► currentNode = nextNode;

       ► currentNode += nextNode;

       ► currentNode = currentNode->nextNode;



Question No: 6      ( Marks: 1 ) - Please choose one
 

A queue where the de-queue operation depends not on FIFO, is called a priority queue 

       ► False

       ► True

p101

Question No: 7      ( Marks: 1 ) - Please choose one
 

Which one is a self- referential data type?                                                                    

       ► Stack

       ► Queue


       ► Link list


       ► All of these



Question No: 8      ( Marks: 1 ) - Please choose one
 

Each node in doubly link list has,


       ► 1 pointer


       ► 2 pointers



       ► 3 pointers


       ► 4 pointers


p39

Question No: 9      ( Marks: 1 ) - Please choose one
 

I have implemented the queue with a linked list, keeping track of a front pointer and a rear pointer. Which of these pointers will change during an insertion into an EMPTY queue?


       ► Neither changes


       ► Only front pointer changes.


       ► Only rear pointer changes.


       ► Both change.

Question No: 10      ( Marks: 1 ) - Please choose one
 

Consider the following tree.

How many of the nodes have at least one sibling?

       ► 8

       ► 7

       ► 5

       ► 6



Question No: 11      ( Marks: 1 ) - Please choose one
 

The nodes with no successor are called _________

       ► Root Nodes

       ► Leaf Nodes  

       ► Both of these

       ► None of these



Question No: 12      ( Marks: 1 ) - Please choose one
 

AVL Tree is,


       ► Non Linear data structure


       ► Linear data structure


       ► Hybrid data structure (Mixture of Linear and Non Linear)


       ► None of the given options.





Question No: 13      ( Marks: 1 ) - Please choose one
 

We access elements in AVL Tree in,


       ► Linear way only


       ► Non Linear way only


       ► Both linear and non linear ways


       ► None of the given options.




Question No: 14      ( Marks: 1 ) - Please choose one
 

A binary search tree should have minimum of one ________ node/s at each level,


       ► One  ( not sure )


       ► Two


       ► Three


       ► Four




Question No: 15      ( Marks: 1 ) - Please choose one
 

Consider the following statements.

(i)       A binary tree can contain at least 2L Nodes at level L.
(ii)     A complete binary tree of depth d is a binary tree that contains 2L Nodes at each level L between 0 and d, both inclusive.
(iii)   The total number of nodes (Tn ) in a complete binary tree of depth d is 2 d+1 - 1 .
(iv)   The height of the complete binary tree can be written as h = log 2 (Tn+1)-1 where Tn is Total number of Nodes.

Which one of the following is correct in respect of the above statements regarding the Binary trees?


       ► (i) and (iii) only

       ► (i), (ii) and (iii) only

       ► (ii) and (iii) only

       ► (ii), (iii) and (iv) only



Question No: 16      ( Marks: 1 ) - Please choose one
 

“+” is a _________operator.

       ► Unary




       ► Binary

       ► Ternary


       ► None of the above



Question No: 17      ( Marks: 2 )
 

What would the state of a stack be after the following operations?

create stack
push A onto stack
push F onto stack
push X onto stack
pop item from stack
push B onto stack
pop item from stack
pop item from stack

                  A Remening On The Stack          

Question No: 18      ( Marks: 2 )
 

What are the applications of Binary Tree.



Question No: 19      ( Marks: 2 )
 

 What is difference between call by reference and call by value?

One application is to find duplicates in a list of numbers.
Let a given list be" 12 34 56 89 33 11 89
the first number in the list is placed in a node that is established as the root of a binary tree. Each number is compared with the node in the root, if the number is larger, we search the right sub-tree else we search the left sub-tree. If the sub-tree is empty, the number is not a duplicate and this will be added as a new node.
2. Binary trees can be used for sorting a given list such that, if we take the first number as root, the numbers less than that number will be transfered to left sub-tree and the greater numbers to right sub-tree.
3. Binary trees are also used for developing the huffman codes.


Question No: 20      ( Marks: 3 )
 

What is the functionality of the following method of BST class

TreeNode<int>* function(TreeNode<int>* tree)
{
    if( tree == NULL )
        return NULL;
    if( tree->getLeft() == NULL )
        return tree; // this is it.
    return function( tree->getLeft() );
}



Question No: 21      ( Marks: 3 )
 

a) Write a C++  statement that declares a valid reference of int i;
b) What is the benefit of reference and where can we use it?

In the last lecture we were discussing about reference variables, we saw three examples; call by value, call by reference and call by pointer. We saw the use of stack when a function is called by value, by reference or by pointer. The arguments passed to the function and local variables are pushed on to the stack. There is one important point to note that in this course, we are using C/C++ but the usage of stack is similar in most of the computer languages like FORTRAN and Java . The syntax we are using here is C++ specific, like we are sending a parameter by pointer using & sign. In Java, the native data types like int, float are passed by value and the objects are passed by reference. In FORTRAN, every parameter is passed by reference. In PASCAL, you can pass a parameter by value or by reference like C++. You might have heard of ALGOL, this language had provided another way of passing parameter ca
lled call by name. These kinds of topics are covered in subjects like


Question No: 22      ( Marks: 5 )
 

Determine what the following recursive “mystery” function computes when given a pointer to the root node of a binary tree.

struct bt_s { int key; struct bt_s *left, *right; } bt_t;
int MFunc (bt_t *T) {
int N1, N2;
if (T == NULL) return -1;
N1 = MFunc(T->left);
N2 = MFunc(T->right);
return (N1 > N2 ? N1 : N2) + 1;
}



Question No: 23      ( Marks: 5 )
 

Is the given tree is an AVL tree? If Not then redraw is so that it becomes AVL

Wednesday, November 2, 2011

CS201 Assignment(1) Solution

CS201 Assignment(1) Solution

#include <iostream>
using namespace std;
main()
{ 
      int customer_nos,Grand_total;
      char choice;
      customer_nos=0;
      Grand_total=0;
          
do{
int meal,sale_tax;
cout<<"Virtual Resutrant\n";
 cout<<"\nenter the price of meal: " ;
cin>>meal;
//sale tex caluculate

 if (meal < 1000)
    {
         sale_tax=0 ;
          cout<< "Sale Tax = "<<sale_tax<<endl;

          }
else if (meal > 1000 && meal <=2000)
    {
        sale_tax= (meal/100)*1;
          cout<< "Sale Tax = " <<sale_tax<<endl;
         
          }
else
    {
        sale_tax= (meal/100)*2;
          cout<< "Sale Tax = " <<sale_tax<<endl;
         
          }

//total amount calc

int total_amount;
total_amount=meal+sale_tax;
cout<<"---------------------------------------";
cout<<"\ntotal amount is "<<total_amount<<endl;

//swet dish

if (total_amount <1000)
{
             cout<<"\nCustomer deserve Candies";   
                
                 }
else if (total_amount >=1000 && total_amount <2000)
{
             cout<<"\nCustomer deserve Sweet bread";   
                
                 }
                
else if (total_amount >=2000 && total_amount <3000)
{
             cout<<"\nCustomer deserve pudding";   
                
                 }                
                

else if (total_amount >=3000 && total_amount <4000)
{
             cout<<"\nCustomer deserve cake";   
                
                 }                            
else
{
             cout<<"\nCustomer deserve trifle";   
                
                 }                     
                
cout<< "\nDo you want to proces another coustomer ";

cin>>choice;
customer_nos++;
Grand_total=Grand_total+total_amount;
}while (choice=='Y' || choice=='y');


cout<<"\n\nNumber of Customer is "<<customer_nos;
cout<<"\nGradn Total is "<<Grand_total<<endl;

system("pause");
}

Sunday, October 23, 2011

CS101 Mid Term Past Paper 2


MIDTERM  EXAMINATION
Spring 2010
CS101- Introduction to Computing (Session - 2)
Ref No: 
Time: 60 min
Marks: 38
Student Info
 StudentID:

 Center:
 
 ExamDate:
  5/27/2010 12:00:00 AM

For Teacher's Use Only
    Q No.
1
2
3
4
5
6
7
8
Total
Marks









Q No.
9
10
11
12
13
14
15
16

Marks









Q No.
17
18
19
20
21
22
23


Marks













    
Question No: 1    ( Marks: 1 )    - Please choose one
 Detailed plan, specifying the required resources and expected deliverables, is done in ________ phase.

       ► Planning
       ► User Requirements
       ► Design
       ► Developer Specification
   
Question No: 2    ( Marks: 1 )    - Please choose one
 A combination of word processing and graphic design is

       ► Corel Draw

       ► Desktop Publishing

       ► Paint

       ► WordPad

   
Question No: 3    ( Marks: 1 )    - Please choose one
 ------------- is an electronic path within a Computer System along which bits are transmitted.

       ► Port
       ► Slots
       ► Bus
       ► Modem
   
Question No: 4    ( Marks: 1 )    - Please choose one
 The key strengths of computers are
       ► Speed
       ► Storage
       ► Do not get bored
       ► All of the given choices
   
Question No: 5    ( Marks: 1 )    - Please choose one
 We can change the background color in HTML, using ___ attribute of <body>

       ► background

       ► bgcolor

       ► backcolor

       ► backgroundcolor

   
Question No: 6    ( Marks: 1 )    - Please choose one
 ASCII WHITE is the fastest Super computer which can perform __________ calculations in one second.
       ► 1.3 billion
       ► 1.3 trillion
       ► 1.3 miillion
       ► 1.3 thousand
   
Question No: 7    ( Marks: 1 )    - Please choose one
 _____ is the example of server-side scripts on Unix servers.
       ► ASP
       ► CGI
       ► VBScript
       ► JavaScript
   
Question No: 8    ( Marks: 1 )    - Please choose one
 We need _____________ for memory management in computer
       ► Software
       ► Hardware
       ► Operating System
       ► Application Software
   
Question No: 9    ( Marks: 1 )    - Please choose one
 Data was stored and counted mechanically using ----------- decimal storage wheels, --------------------- rotary dial switches.

       ► 300,400

       ► 1300,1400

       ► 30100,14100

       ► 3000 , 1400

   
Question No: 10    ( Marks: 1 )    - Please choose one
 The first spread sheet program was invented by
       ► Charles Babbage
       ► Dan Bricklin
       ► Paul Graham
       ► John von Neumann
   
Question No: 11    ( Marks: 1 )    - Please choose one
 In x = x + 20, x is called a __________.

       ► Constant
       ► String
       ► Variable
       ► Number
   
Question No: 12    ( Marks: 1 )    - Please choose one
 The transistor is a solid state semiconductor device used for amplification and switching, and has __________ terminals.
       ► one
       ► two
       ► three
       ► four
   
Question No: 13    ( Marks: 1 )    - Please choose one
 A diode functions as the electronic version of a __________-way valve.
       ► one
       ► two
       ► three
       ► four
   
Question No: 14    ( Marks: 1 )    - Please choose one
 
This element of Flow Chart is called_____________.
       ► Process
       ► Off page connector
       ► Decision
       ► Connector
   
Question No: 15    ( Marks: 1 )    - Please choose one
 Choose the correct html format to create a checkbox.



       ► <checkbox>

       ► <input type=”checkbox”>

       ► <check>          
       ► <input type=”check”>

   
Question No: 16    ( Marks: 1 )    - Please choose one
 ---------------is the process of starting or restarting a computer.

►BIOS

►Refreshing

►Booting
►None of given
   
Question No: 17    ( Marks: 2 )
 What is the Title of the web page for following code segment?
<Head>
<TITLE> VU Web <\TITLE>
<TITLE> Page </TITLE>
</Head>
   
Question No: 18    ( Marks: 2 )
 What do you mean by Comments?


    
Question No: 19    ( Marks: 2 )
 How can an operating system be viewed as a resource allocator?
   
Question No: 20    ( Marks: 3 )
 What is the role of application software in Education?      
   
Question No: 21    ( Marks: 3 )
 Give four  properties  and  two methods of window object ?
   
Question No: 22    ( Marks: 5 )
 What is the difference between High-level and Low-level programming languages?
   
Question No: 23    ( Marks: 5 )
 Elaborate greedy algorithm definition with solid example in favour and one counter example?

Contact Form

Name

Email *

Message *