12
Department of Electrical Engineering University of Engineering & Technology Peshawar, Mardan Campus Reg. No: _______MDELE _____________ Name: _____________________________ OOP and Data Structures (EE-271) – Final Term Examination Fall (2016) Time Allowed: 2hrs Max Marks: 100 DIRECTIONS : 1. Be clear and precise in your answers. Do NOT include unnecessary details. 2. Calculators and mobile phones are not allowed in the examination hall. 3. Attempt all questions on the question paper. Q: No. 1: Encircle the best possible answer. (20) 1. Vector is a header file that can be used for implementing? a. Linked List b. Stack c. Queue d. Array e. All of the above 2. The output of the expression (1 && 1) || 1 || (1 && 1) && 0 is a. true b. false 3. Structure of file systems on hard drive follows __________, we see it on our desktop as ___________ a. Tree, tree b. Linked list, tree c. Tree, linked list d. Queue, stack e. Stack, queue 4. “Virtual” keyword is used for ______ a. Prototyping Function b. Redefining Function c. Making it visible to derived classes d. None of the above 5. Queue calls the ______ element stored while stack calls the _______. a. Last, first b. First last c. None of the above d. Depends upon the algorithm 6. Which of the following is not a keyword? a. this b. false c. List d. vector Page 1 of 12

Subject: › ... › 9 › 96692532 › final_ter… · Web viewOOP and Data Structures (EE-271) – Final Term Examination Fall (2016) Time Allowed: 2hrs Max Marks: 10 0 DIRECTIONS:

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Subject: › ... › 9 › 96692532 › final_ter… · Web viewOOP and Data Structures (EE-271) – Final Term Examination Fall (2016) Time Allowed: 2hrs Max Marks: 10 0 DIRECTIONS:

Department of Electrical EngineeringUniversity of Engineering & Technology

Peshawar, Mardan Campus

Reg. No: _______MDELE_____________ Name: _____________________________

OOP and Data Structures (EE-271) – Final Term ExaminationFall (2016)

Time Allowed: 2hrs Max Marks: 100DIRECTIONS :

1. Be clear and precise in your answers. Do NOT include unnecessary details.2. Calculators and mobile phones are not allowed in the examination hall.3. Attempt all questions on the question paper.

Q: No. 1: Encircle the best possible answer. (20)1. Vector is a header file that can be

used for implementing?a. Linked Listb. Stackc. Queued. Arraye. All of the above

2. The output of the expression(1 && 1) || 1 || (1 && 1) && 0 is

a. trueb. false

3. Structure of file systems on hard drive follows __________, we see it on our desktop as ___________

a. Tree, treeb. Linked list, treec. Tree, linked listd. Queue, stacke. Stack, queue

4. “Virtual” keyword is used for ______

a. Prototyping Functionb. Redefining Functionc. Making it visible to derived

classesd. None of the above

5. Queue calls the ______ element stored while stack calls the _______.

a. Last, firstb. First lastc. None of the aboved. Depends upon the algorithm

6. Which of the following is not a keyword?

a. thisb. falsec. Listd. vector

7. Which of the following section, once inherited, can’t be inherited from derived class?

a. Publicb. Protectedc. Privated. None of the above

8. Inheriting two class from one another will lead a(n) ___________

a. Memory dump errorb. Non-assigned RAM location

errorc. Fills up the designated space

for applicationd. Both (b) and (c)

9. For swapping 2 variables, one can use;

a. Stackb. Queuec. Both (a) and (b)

10.To prevent a variable of base class from any further change, which of the following types of inheritance is used?

a. Publicb. Protectedc. Privated. All of the above

Page 1 of 8

Page 2: Subject: › ... › 9 › 96692532 › final_ter… · Web viewOOP and Data Structures (EE-271) – Final Term Examination Fall (2016) Time Allowed: 2hrs Max Marks: 10 0 DIRECTIONS:

Department of Electrical EngineeringUniversity of Engineering & Technology

Peshawar, Mardan Campus

Reg. No: _______MDELE_____________ Name: _____________________________

Q: No. 2: Write the outputs of the following sequence when entered to a stack and when entered to a queue. Write “no output/empty” where applicable. (12)

Instruction Stack (Output) Queue (Output)SET_SIZE(10)PUSH(12)PUSH(23)PUSH(34)PUSH(45)POP( )POP( )SIZE( )SIZE( )PUSH(Y)POP( )POP( )SIZE( )POP( )POP( )

SET_SIZE(n):Initializes the size of stack and queue to ‘n’SIZE( ): Shows the size of stack/queuePUSH(n): Places element ‘n’ in stack/queuePOP( ): Pops back and shows element from stack/queue

Page 2 of 8

Page 3: Subject: › ... › 9 › 96692532 › final_ter… · Web viewOOP and Data Structures (EE-271) – Final Term Examination Fall (2016) Time Allowed: 2hrs Max Marks: 10 0 DIRECTIONS:

Department of Electrical EngineeringUniversity of Engineering & Technology

Peshawar, Mardan Campus

Reg. No: _______MDELE_____________ Name: _____________________________

Q: No. 3: Write down the console output of the following error free c++ Program. (10)

#include <iostream>#include <conio.h>using namespace std;

class baseclass{float x, y;public:

baseclass(){x=5;y=5;

}float multiply(int p){

return x*p;}

};class inh_class:public baseclass{

int x=2;int y=24;

public:int add(void){

return x+y;}

};main (){

inh_class var1, var2;cout<<var1.add()<<endl;cout<<var2.multiply(7);}

Page 3 of 8

Page 4: Subject: › ... › 9 › 96692532 › final_ter… · Web viewOOP and Data Structures (EE-271) – Final Term Examination Fall (2016) Time Allowed: 2hrs Max Marks: 10 0 DIRECTIONS:

Department of Electrical EngineeringUniversity of Engineering & Technology

Peshawar, Mardan Campus

Reg. No: _______MDELE_____________ Name: _____________________________

Q: No. 4: (4+4+4)a. Why is it necessary to overload an operator for class object?b. When can we convert an object of linked list to form a binary tree?c. What is the role of pointer object in connecting two class object?

Page 4 of 8

Page 5: Subject: › ... › 9 › 96692532 › final_ter… · Web viewOOP and Data Structures (EE-271) – Final Term Examination Fall (2016) Time Allowed: 2hrs Max Marks: 10 0 DIRECTIONS:

Department of Electrical EngineeringUniversity of Engineering & Technology

Peshawar, Mardan Campus

Reg. No: _______MDELE_____________ Name: _____________________________

Q: No. 5: Draw block diagram of an object P that is structured by the following class; (8)

class List{int data;public:

List(List *Link, int setData){data = setData;prev=Link;

}List(int setData){

data = setData;prev=NULL;

}List *next=NULL;List *prev;void showConnection(void){

cout<<this->prev<<endl;cout<<this->next<<endl;

}void showData(void){

cout<<"Contains :"<<data<<endl;}int getData(void){

return data;}void showData (List x){

cout<<"Contains :"<<x.data<<endl;}void NodeStatus(List x){

cout<<"Connected to: "<<x.prev<<endl<<"Contains :"<<x.data<<endl;}

}P;

Page 5 of 8

Page 6: Subject: › ... › 9 › 96692532 › final_ter… · Web viewOOP and Data Structures (EE-271) – Final Term Examination Fall (2016) Time Allowed: 2hrs Max Marks: 10 0 DIRECTIONS:

Department of Electrical EngineeringUniversity of Engineering & Technology

Peshawar, Mardan Campus

Reg. No: _______MDELE_____________ Name: _____________________________

Q: No. 6: Write C++ code for swapping two int a and int b variables using stack or queue; (10)

Note: Assume that you have an already defined header file “stack/queue” having functions;

void SET_SIZE(int n): Initializes the size of stack and queue to ‘n’void SIZE(void): Shows the size of stack/queuevoid PUSH(int n): Places element ‘n’ in stack/queueint POP(void): Pops back and saves element from stack/queue

Page 6 of 8

Page 7: Subject: › ... › 9 › 96692532 › final_ter… · Web viewOOP and Data Structures (EE-271) – Final Term Examination Fall (2016) Time Allowed: 2hrs Max Marks: 10 0 DIRECTIONS:

Department of Electrical EngineeringUniversity of Engineering & Technology

Peshawar, Mardan Campus

Reg. No: _______MDELE_____________ Name: _____________________________

Q: No. 7: Write a program that uses goto label and label for counting numbers from 1 up to 10. (8)Hint: Sample syntax for using go to functionality;

[some code here]label:[your desired instructions]goto label;[rest of code]

Page 7 of 8

Page 8: Subject: › ... › 9 › 96692532 › final_ter… · Web viewOOP and Data Structures (EE-271) – Final Term Examination Fall (2016) Time Allowed: 2hrs Max Marks: 10 0 DIRECTIONS:

Department of Electrical EngineeringUniversity of Engineering & Technology

Peshawar, Mardan Campus

Reg. No: _______MDELE_____________ Name: _____________________________

Q: No. 8: What is complexity analysis? What is the relation between process time and complexity of algorithm? (10)

Q: No. 9: Complete the table with the Big-O notation for the cases given (10)

S. No. Case Big-O Notation1 for loop2 Nested for loop3 Assigning number to a variable4 Checking a condition using if statement5 while (if (condition))

*****

Page 8 of 8