SlideShare a Scribd company logo
Page | 1
PART 1 – Multiple Choice Questions
1. Which of the following is FALSE about linked lists
A. The data structure includes the link to another object of the same type
B. The data set are stored in contiguous order in memory
C. The size is dynamic during run-time
D. Memory is allocated at run-time
2. The advantage of arrays over linked lists is
A. Direct access
B. Less memory usage
C. Easier to implement
D. Dynamic memory allocation
3. Which of the following structures is suitable to keep track of a sequence printing jobs
sent to a network printer?
A. Trees
B. Stack
C. Queues
D. Lists
4. The following problems best solved using stack structures, EXCEPT
A. Balancing of parenthesis
B. Evaluation of postfix expressions
C. Removal of items in random order
D. Evaluation of functions containing recursive calls
5. Given the following sequence of operations performed on a stack:
push (5.0), push (9.5), pop, push (27.5), push (12.7), push (0), pop, pop, push
(31.2)
What will be the sequence of items in the stack as a result?
A. 31.2 0.0 12.7 27.5 9.5 5.0
B. 27.5 9.5 5.0
C. 3.12 27.5 5.0
D. Stack is empty
Page | 2
6. Suppose myList is an object of List data structure, and myList.displayList() produces the
following output:
28 7 76 48 70
What would be the output when the following statements are executed?
myList.InsertNode(2, 10);
myList.DisplayList();
A. 10 28 7 76 48 70
B. 28 7 76 10 48 70
C. 28 7 76 48 70 10
D. 28 7 10 76 48 70
7. Suppose an array myArr contains the following sequences of integers:
28 7 76 48 70
What would be resulting sequence of MyArr when the following statement is executed?
myArr [2] = 10;
A. 10 28 7 76 48
B. 28 7 76 10 48
C. 28 7 10 48 70
D. 7 10 76 48 70
8. Which of the following is FALSE when using recursion
A. The recursions must be assumed to work all the time
B. You must have a base case which can be solved without recursion
C. The recursive call must always make progress towards the base case
D. The recursive calls must always be compounded in multiple recursive calls
9. How many times will the symbol ‘#’ be printed by the call foo (4)?
void foo (int i) {
if (i > 1) {
foo (i/2);
foo (i/2);
}
cout << "#";
}
A. 6
B. 7
C. 8
D. 9
Page | 3
10. Which of the following statements about QUEUES is FALSE ?
A. New items can only be inserted at the end position
B. The items are processed in a queue on a First in First out basis
C. The main operations of a queue is enqueueing and dequeueing
D. Items cannot be removed from a queue at the beginning of queue
11. In linked lists, there are no NULL links in
A. linear doubly linked list
B. circular linked list
C. single linked list
D. All of the above
12. The range of 4-bits unsigned integer is between:
A. 0 to 15
B. 1 to 16
C. -7 to 8
D. -15 to 14
13. When a new node is inserted in between a linked list, which of these is TRUE:
A. nodes appearing after the new node needs to be moved
B. nodes appearing before the new node needs to be moved
C. nodes appearing before and after the new node need to be moved
D. None of the above
14. One DIFFERENCE between a queue and a stack is:
A. Queues require linked lists, but stacks require array
B. Stacks require linked lists, but queues require array
C. Queues use two ends of the structure; stacks use only one.
D. Stacks use two ends of the structure; queues use only one.
15. The address of an element [i, j] in a m × n matrix based on the column-wise order can be ______
A. m * ( i – 2 ) + j
B. m * ( j – 2 ) + i
C. n* ( i – 1 ) + j
D. n* ( i – 1) + (j – 1)
Page | 4
PART 2 – Short Answer Questions
1. Given the following code:
#include <iostream>
using namespace std;
int myfunction(int);
int main () {
int input, answer;
cout <<"Enter an integer: ";
cin >> input;
answer = myfunction(input);
cout << endl<<"The answer "<<input<< "! is " << answer;
return 0;
}
int myfunction (int num) {
cout <<"Fib " << num<< " is " ;
if (num == 0)
return 0;
else (num == 1)
return 1;
else
return myfunction (num-1) + myfunction (num-2);
}
Write the output of the program if the user types 4 as input?
2. Discuss the pros and cons of choosing linked list implementation for lists, stacks
and queues.
3. Suppose a queue called myQueue is implemented using a circular array of
MAXSIZE = 7. Illustrate to show the step-by-step effects in myQueue if the following
sequence of statements is executed:
myQueue.enqueue (‘F’)
myQueue.enqueue (‘C’)
myQueue.enqueue (‘Q’)
myQueue.dequeue
myQueue.enqueue (‘X’)
myQueue.enqueue (‘Z’)
myQueue.dequeue
myQueue.enqueue (‘L’)
myQueue.enqueue (‘S’)
myQueue.enqueue (‘W’)
myQueue.enqueue (‘C’)
myQueue.dequeue
Page | 5
4. In C++, a variable that stores integer values can be declared as short (2 bytes or
16 bits) or int (bytes or 32 bits). Furthermore, floating-point numbers can be
declared as float (4 bytes or 32 bits) or double (8 bytes or 64 bits) based on the
IEEE Standard for Floating Point Arithmetic (IEEE-754).
Determine the corresponding binary values that are stored in the computer for the
following variable declarations:
a. unsigned short a = 15;
b. short b = -15;
c. float c = -52.25
5. Use stacks to show the step-by-step evaluation of the post-fix expression given
below:
5.2 2.0 1.5 * + 4.0 2.0 2.0 ^ * -
6. Given below is a recursive method of function f for the value x. Write an equivalent
program segment using iterative method.
int f (int x){
if (x == 0)
return 0;
else
return 2 * f (x – 1) + x * x;
}
7. The elements in an array may be stored based on a row-wise or column-wise
arrangement depending on the programming language used.
Suppose the dimensions of an array myGoodArray are 7X9X8.
Given the address of myGoodArray [4, z, 3] based on the column-wise method is
438, when the base address (B) is 10, with size of each element (W) is 2, and lowest
index of each dimension is 0,
a. Find z.
b. Determine the address of the same element if it is implemented in row-wise
method.
8. Write an algorithm which checks if the brackets in an expression are balanced and
reports an error if the matching brackets is missing.

More Related Content

PDF
Sample Paper 2 Class XI (Computer Science)
PDF
Sample Paper Class XI (Informatics Practices)
PDF
IP Sample paper 2 Class XI
PDF
Computer Science Sample Paper 2015
PDF
Doc 20180130-wa0004
PDF
Doc 20180130-wa0006
PDF
CBSE Sample Paper IP
PDF
Sample presentation slides template
Sample Paper 2 Class XI (Computer Science)
Sample Paper Class XI (Informatics Practices)
IP Sample paper 2 Class XI
Computer Science Sample Paper 2015
Doc 20180130-wa0004
Doc 20180130-wa0006
CBSE Sample Paper IP
Sample presentation slides template

What's hot (19)

PDF
Class xi sample paper (Computer Science)
PDF
Cplus plus abd datastructure
PPTX
Directed Acyclic Graph Representation of basic blocks
PDF
important C questions and_answers praveensomesh
PDF
Assignment
PDF
Core java
PDF
Ec2203 digital electronics questions anna university by www.annaunivedu.org
PDF
Aloha paper for cdac ccpp
PDF
CDAC CCAT examination important question
PDF
Assignment week0 c++
PDF
Computer science ms
PDF
6th Semester (Dec-2015; Jan-2016) Computer Science and Information Science En...
DOCX
Comp 328 final guide
PDF
Oops Paper
PDF
5th Semester (June; July-2015) Computer Science and Information Science Engin...
PDF
C and data structure
PDF
FP305 data structure PAPER FINAL SEM 3
DOCX
CLASS XII COMPUTER SCIENCE MONTHLY TEST PAPER
DOCX
Sample paper i.p
Class xi sample paper (Computer Science)
Cplus plus abd datastructure
Directed Acyclic Graph Representation of basic blocks
important C questions and_answers praveensomesh
Assignment
Core java
Ec2203 digital electronics questions anna university by www.annaunivedu.org
Aloha paper for cdac ccpp
CDAC CCAT examination important question
Assignment week0 c++
Computer science ms
6th Semester (Dec-2015; Jan-2016) Computer Science and Information Science En...
Comp 328 final guide
Oops Paper
5th Semester (June; July-2015) Computer Science and Information Science Engin...
C and data structure
FP305 data structure PAPER FINAL SEM 3
CLASS XII COMPUTER SCIENCE MONTHLY TEST PAPER
Sample paper i.p
Ad

Similar to Redo midterm (20)

DOCX
Consider this code using the ArrayBag of Section 5.2 and the Locat.docx
PPTX
UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2
PDF
Computer science sqp
PDF
Ds qb 2021 rma
PDF
MATLAB Questions and Answers.pdf
PDF
Cs101 endsem 2014
PDF
CBSE XI COMPUTER SCIENCE
PDF
Doc 20180130-wa0005
PDF
Doc 20180130-wa0004-1
PDF
C Language MCQ Programming Theory Questions
PDF
Gate Previous Years Papers
PPTX
Topic 2_revised.pptx
PDF
Fffgggggfffffffggggggggggggggggggile.pdf
PDF
Sample Questions for XII Computer Science (2).pdf
PDF
Data structure using c bcse 3102 pcs 1002
DOC
Dat 305 dat305 dat 305 education for service uopstudy.com
PDF
Cbse marking scheme 2006 2011
PDF
selfstudys_com_file (4).pdfjsjdcjjsjxjdnxjj
PDF
1z0 851 exam-java standard edition 6 programmer certified professional
Consider this code using the ArrayBag of Section 5.2 and the Locat.docx
UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2
Computer science sqp
Ds qb 2021 rma
MATLAB Questions and Answers.pdf
Cs101 endsem 2014
CBSE XI COMPUTER SCIENCE
Doc 20180130-wa0005
Doc 20180130-wa0004-1
C Language MCQ Programming Theory Questions
Gate Previous Years Papers
Topic 2_revised.pptx
Fffgggggfffffffggggggggggggggggggile.pdf
Sample Questions for XII Computer Science (2).pdf
Data structure using c bcse 3102 pcs 1002
Dat 305 dat305 dat 305 education for service uopstudy.com
Cbse marking scheme 2006 2011
selfstudys_com_file (4).pdfjsjdcjjsjxjdnxjj
1z0 851 exam-java standard edition 6 programmer certified professional
Ad

More from IIUM (20)

PDF
How to use_000webhost
PDF
Chapter 2
PDF
Chapter 1
PDF
Kreydle internship-multimedia
PDF
03phpbldgblock
PDF
Chap2 practice key
PDF
Group p1
PDF
Tutorial import n auto pilot blogspot friendly seo
PDF
Visual sceneperception encycloperception-sage-oliva2009
PDF
03 the htm_lforms
PDF
Exercise on algo analysis answer
PDF
Heaps
PDF
Report format
PDF
Edpuzzle guidelines
PDF
Final Exam Paper
PDF
Final Exam Paper
PDF
Group assignment 1 s21516
PDF
Avl tree-rotations
PDF
Week12 graph
PDF
Vpn
How to use_000webhost
Chapter 2
Chapter 1
Kreydle internship-multimedia
03phpbldgblock
Chap2 practice key
Group p1
Tutorial import n auto pilot blogspot friendly seo
Visual sceneperception encycloperception-sage-oliva2009
03 the htm_lforms
Exercise on algo analysis answer
Heaps
Report format
Edpuzzle guidelines
Final Exam Paper
Final Exam Paper
Group assignment 1 s21516
Avl tree-rotations
Week12 graph
Vpn

Recently uploaded (20)

PDF
Basic Mud Logging Guide for educational purpose
PPTX
master seminar digital applications in india
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Cell Structure & Organelles in detailed.
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Business Ethics Teaching Materials for college
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PDF
Insiders guide to clinical Medicine.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
VCE English Exam - Section C Student Revision Booklet
Basic Mud Logging Guide for educational purpose
master seminar digital applications in india
O5-L3 Freight Transport Ops (International) V1.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Microbial disease of the cardiovascular and lymphatic systems
O7-L3 Supply Chain Operations - ICLT Program
Cell Structure & Organelles in detailed.
102 student loan defaulters named and shamed – Is someone you know on the list?
Business Ethics Teaching Materials for college
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
Insiders guide to clinical Medicine.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Anesthesia in Laparoscopic Surgery in India
Final Presentation General Medicine 03-08-2024.pptx
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
VCE English Exam - Section C Student Revision Booklet

Redo midterm

  • 1. Page | 1 PART 1 – Multiple Choice Questions 1. Which of the following is FALSE about linked lists A. The data structure includes the link to another object of the same type B. The data set are stored in contiguous order in memory C. The size is dynamic during run-time D. Memory is allocated at run-time 2. The advantage of arrays over linked lists is A. Direct access B. Less memory usage C. Easier to implement D. Dynamic memory allocation 3. Which of the following structures is suitable to keep track of a sequence printing jobs sent to a network printer? A. Trees B. Stack C. Queues D. Lists 4. The following problems best solved using stack structures, EXCEPT A. Balancing of parenthesis B. Evaluation of postfix expressions C. Removal of items in random order D. Evaluation of functions containing recursive calls 5. Given the following sequence of operations performed on a stack: push (5.0), push (9.5), pop, push (27.5), push (12.7), push (0), pop, pop, push (31.2) What will be the sequence of items in the stack as a result? A. 31.2 0.0 12.7 27.5 9.5 5.0 B. 27.5 9.5 5.0 C. 3.12 27.5 5.0 D. Stack is empty
  • 2. Page | 2 6. Suppose myList is an object of List data structure, and myList.displayList() produces the following output: 28 7 76 48 70 What would be the output when the following statements are executed? myList.InsertNode(2, 10); myList.DisplayList(); A. 10 28 7 76 48 70 B. 28 7 76 10 48 70 C. 28 7 76 48 70 10 D. 28 7 10 76 48 70 7. Suppose an array myArr contains the following sequences of integers: 28 7 76 48 70 What would be resulting sequence of MyArr when the following statement is executed? myArr [2] = 10; A. 10 28 7 76 48 B. 28 7 76 10 48 C. 28 7 10 48 70 D. 7 10 76 48 70 8. Which of the following is FALSE when using recursion A. The recursions must be assumed to work all the time B. You must have a base case which can be solved without recursion C. The recursive call must always make progress towards the base case D. The recursive calls must always be compounded in multiple recursive calls 9. How many times will the symbol ‘#’ be printed by the call foo (4)? void foo (int i) { if (i > 1) { foo (i/2); foo (i/2); } cout << "#"; } A. 6 B. 7 C. 8 D. 9
  • 3. Page | 3 10. Which of the following statements about QUEUES is FALSE ? A. New items can only be inserted at the end position B. The items are processed in a queue on a First in First out basis C. The main operations of a queue is enqueueing and dequeueing D. Items cannot be removed from a queue at the beginning of queue 11. In linked lists, there are no NULL links in A. linear doubly linked list B. circular linked list C. single linked list D. All of the above 12. The range of 4-bits unsigned integer is between: A. 0 to 15 B. 1 to 16 C. -7 to 8 D. -15 to 14 13. When a new node is inserted in between a linked list, which of these is TRUE: A. nodes appearing after the new node needs to be moved B. nodes appearing before the new node needs to be moved C. nodes appearing before and after the new node need to be moved D. None of the above 14. One DIFFERENCE between a queue and a stack is: A. Queues require linked lists, but stacks require array B. Stacks require linked lists, but queues require array C. Queues use two ends of the structure; stacks use only one. D. Stacks use two ends of the structure; queues use only one. 15. The address of an element [i, j] in a m × n matrix based on the column-wise order can be ______ A. m * ( i – 2 ) + j B. m * ( j – 2 ) + i C. n* ( i – 1 ) + j D. n* ( i – 1) + (j – 1)
  • 4. Page | 4 PART 2 – Short Answer Questions 1. Given the following code: #include <iostream> using namespace std; int myfunction(int); int main () { int input, answer; cout <<"Enter an integer: "; cin >> input; answer = myfunction(input); cout << endl<<"The answer "<<input<< "! is " << answer; return 0; } int myfunction (int num) { cout <<"Fib " << num<< " is " ; if (num == 0) return 0; else (num == 1) return 1; else return myfunction (num-1) + myfunction (num-2); } Write the output of the program if the user types 4 as input? 2. Discuss the pros and cons of choosing linked list implementation for lists, stacks and queues. 3. Suppose a queue called myQueue is implemented using a circular array of MAXSIZE = 7. Illustrate to show the step-by-step effects in myQueue if the following sequence of statements is executed: myQueue.enqueue (‘F’) myQueue.enqueue (‘C’) myQueue.enqueue (‘Q’) myQueue.dequeue myQueue.enqueue (‘X’) myQueue.enqueue (‘Z’) myQueue.dequeue myQueue.enqueue (‘L’) myQueue.enqueue (‘S’) myQueue.enqueue (‘W’) myQueue.enqueue (‘C’) myQueue.dequeue
  • 5. Page | 5 4. In C++, a variable that stores integer values can be declared as short (2 bytes or 16 bits) or int (bytes or 32 bits). Furthermore, floating-point numbers can be declared as float (4 bytes or 32 bits) or double (8 bytes or 64 bits) based on the IEEE Standard for Floating Point Arithmetic (IEEE-754). Determine the corresponding binary values that are stored in the computer for the following variable declarations: a. unsigned short a = 15; b. short b = -15; c. float c = -52.25 5. Use stacks to show the step-by-step evaluation of the post-fix expression given below: 5.2 2.0 1.5 * + 4.0 2.0 2.0 ^ * - 6. Given below is a recursive method of function f for the value x. Write an equivalent program segment using iterative method. int f (int x){ if (x == 0) return 0; else return 2 * f (x – 1) + x * x; } 7. The elements in an array may be stored based on a row-wise or column-wise arrangement depending on the programming language used. Suppose the dimensions of an array myGoodArray are 7X9X8. Given the address of myGoodArray [4, z, 3] based on the column-wise method is 438, when the base address (B) is 10, with size of each element (W) is 2, and lowest index of each dimension is 0, a. Find z. b. Determine the address of the same element if it is implemented in row-wise method. 8. Write an algorithm which checks if the brackets in an expression are balanced and reports an error if the matching brackets is missing.