Font size
WorksheetsSegundo Parcial EDL
Total questions: 93
Worksheet time: 2hrs 32mins
Only top element can be accessed in stack
TRUE
FALSE
Stacks have LIFO ordering
TRUE
FALSE
The postfix form of the expression (A+ B)*(C*D- E)*F / G is?
AB + CDE * - * F *G /
AB+ CD*E - FG /**
AB + CD* E - F **G /
AB + CD* E - *F *G /
LIFO stands for
List of Outputs
Last in First Out
First in Last Out
None of them
Act of adding values into a stack is called
Popping
Polling
Pushing
None
The postfix form of A*B+C/D is?
*AB/CD+
AB*CD/+
A*BC+/D
ABCD+/*
Which of the following statement(s) about stack data structure is/are NOT correct?
Stack data structure can be implemented using linked list
New node can only be added at the top of the stack
Stack is the FIFO data structure
The last node at the bottom of the stack has a NULL link
If the elements “A”, “B”, “C” and “D” are placed in a stack and are deleted one at a time, in what order will they be removed?
ABCD
DCBA
DCAB
ABDC
Which of the following application generally use a stack?
Parenthesis balancing program
Syntax analyzer in compiler
Keeping track of local variables at run time
All of the above
Consider the following operation performed on a stack of size 5.
Push(1);
Pop();
Push(2);
Push(3);
Pop();
Push(4);
Pop();
Pop();
Push(5);
After the completion of all operation, the no of element present on stack are
1
2
3
4
In the stack, If user try to remove element from the empty stack then it called as ___________.
Overflow of Stack
Empty Collection
Underflow of Stack
Garbage Collection
Process of Removing element from the stack is called as __________.
Pop
Push
Create
Postfix
User push 1 element in the stack having already five elements and having stack size as 5 then stack becomes ___________.
Overflow
User Flow
Underflow
Crash
In order to keep track of current topmost element of the stack we need to maintain one variable.
Yes
No
Both Yes and No
None of the answer
Select a real life situation implement stack
All of the answers
The cars a garage the first car in will be the last car out of the garage
The batteries in a flashlight
The person wear bangles
What is the value of the postfix expression 6 3 2 4 + – *
1
40
74
-18
Which one of the following is an application of Stack Data Structure?
Managing function calls
The stock span problem
Arithmetic expression evaluation
All of the above
List of data in which element can be inserted and removed at the same end is called as __________.
array
stack
linked list
queue
Which of them is an abstract data structure (ADT)?
Stacks
Functions
Queues
Both A and C
If the elements “A”, “B”, “C” and “D” are placed in a queue and are deleted one at a time, in what order will they be removed?
ABCD
DCBA
DCAB
ABDC
a QUEUE in a computer acts just like people queuing for a bus - the first person in queue is going to be the first to get on the bus.
True
False
A Queue uses a front and rear pointer?
True
False
The type of expression in which operator succeeds its operands is?
a) Infix Expression
b) Prefix Expression
c) Postfix Expression
d) Both Prefix and Postfix Expressions
What is the infix equivalent for the following postfix expression?
3 5 6 + *
5 + 6 * 3
5 + (3 * 6)
(5 + 6) * 3
5 (+ 6 * 3)
A FIFO structure implemented as a ring where the front and rear pointers can wrap around the end of the start of the array.
Linear Queue
Circular Queue
Priority Queue
In linked list implementation of a queue, from where is the item deleted?
At the head of link list
At the centre position in the link list
At the tail of the link list
None of the mentioned
In a circular queue, how do you increment the rear end of the queue?
rear++
(rear+1) % Number of Item
(rear % Number of Item)+1
rear–
What is the term for inserting into a full queue known as?
overflow
underflow
null pointer exception
all of the mentioned
Let the following circular queue can accommodate maximum six elements with the following data
front = 2 rear = 4
queue = _______; L, M, N, ___, ___
What will happen after ADD O operation takes place?
front = 2 rear = 5
queue = ______; L, M, N, O, ___
front = 3 rear = 5
queue = L, M, N, O, ___
front = 3 rear = 4
queue = ______; L, M, N, O, ___
front = 2 rear = 4
queue = L, M, N, O, ___
A circular queue is implemented using an array of size 10. The array index starts with 0, front is 6, and rear is 9. The insertion of next element takes place at the array index.
0
7
9
10
What is the reason for using a "circular queue" instead of a regular one?
running time of enqueue() is improved
reuse empty spaces
you can traverse all the elements more efficiently
none of the above
In Queue Insertion & Deletion take place at ________________.
same end
first end
different end
last end
One difference between a queue and a stack is:
Queues require dynamic memory, but stacks do not
Stacks require dynamic memory, but queues do not.
Queues use two ends of the structure; stacks use only one.
Stacks use two ends of the structure, queues use only one.
If the numbers 5, 10, 3, 42 are enqueued onto a queue in that order, what does dequeue return?
5
10
3
42
Queue can be implemented using a list?
True
False
A queue of characters currently contained a,b,c,d. What would be the contents of queue after the following operationDELETE, ADD W, ADD X, DELETE, ADD Y.
A,B,C,W,Y
A,B,C,D,W
C,D,W,X,Y
W,Y,X,C,D
If front=rear ,then the queue is?
full
undeflow
overflow
empty
Which the following is not true about queue?
An ordered collection of items where the addition of new items happens at one end
The simplest example of a queue is the typical line that we all participate in from time to time.
As an element enters the queue it starts at the rear and makes its way toward the front, waiting until that time when it is the next element to be removed.
An ordered collection of items where the addition of new items and the removal of existing items always takes place at the same end
Suppose you have the following series of queue operations.
q = Queue();
q.enqueue('hello');
q.enqueue('dog');
q.enqueue(3);
q.dequeue();
What items are left on the queue?
'hello', 'dog'
'dog', 3
'hello', 3
'hello', 'dog', 3
Suppose you have the following series of queue operations.
q = Queue();
q.enqueue('hello');
q.enqueue('dog');
q.dequeue();
q.enqueue('3');
q.dequeue();
What items are the output?
hellodog
hello
doghello
hellodog3
3
Suppose you have the following series of queue operations.
q = Queue();
q.enqueue(1);
q.enqueue(10);
q.enqueue(100);
q.dequeue();
q.dequeue();
What items are the output?
10010
101
110
10010
A Queue can only store 6 data items. The Queue is sent 4 data items: Bert, Cynthia, Cedric and Albert. Where does the "Front" pointer point?
Bert
Cynthia
Cedric
Albert
In a Queue Data Structure...
New elements may only be added to the end of the queue
Elements may only be retrieved from the front of the queue.
Elements may only be retrieved from the end of the queue.
New elements may only be added to the front of the queue
Select ALL the situations that a Queue data structure would be used?
Printer in a room full of computers
Characters typed on a keyboard
Back Button
Undo Button
Which is the correct operation for:
"Add a item to the rear of the queue."
enQueue(item)
Append.Queue(item)
enQueue()
AddItem(EnQueue())
Which is the correct operation for:
"Remove the rear item from the queue and return it"
dQueue()
de.Queue(Item)
deQueue()
item.remove()
Cant be performed on a Queue Data Structure.
Which is the correct operation for:
"Add a item to the front of the queue."
enQueue(item)
Append.Queue(item)
enQueue()
AddItem(EnQueue())
Cant be performed on a Queue.
Select operations that can be performed on a Queue Data Structure...
isEmpty()
pop()
push()
isFull()
Append(Item)
Where would pointers be pointing if...
- Eli leaves the Queue
- Adam joins the Queue
front = 0 rear = 3
front = 1 rear = 4
front = 2 rear = 3
front = 0 rear = 4
front = 0 rear = 4
Where would pointers be pointing if...
- Eli leaves the Queue.
- Hanna joins the Queue.
- Adam joins the Queue.
- Jason leaves the Queue.
front = 0 rear = 5
front = 1 rear = 4
front = 2 rear = 4
front = 0 rear = 4
front = 2 rear = 5
What would happen if...
deQueue()
enQueue(Hanna)
enQueue(Steve)
enQueue(Jack)
front = 1 rear = 0
*and Steve would be unable to be added to position 0.
front = 1 rear = 5
*and Jack would be unable to be added to position 0
front = 0 rear = 5
front = 0 rear = 4
front = 1 rear = 4
COMPSC
COMPS
COMP
COM
CO
C
OMPSCI
MPSCI
PSCI
SCI
CI
I
COM
COMP
COMPS
COMPSC
COMPSCI
CO
COM
COMP
COMPS
COMPSC
COMPSCI
Recursion is:
is a computer programming technique involving the use of a procedure, subroutine, function, or algorithm that calls itself in a step having a termination condition.
is a computer programming technique involving the use of a procedure, subroutine, function, or algorithm that calls other function in a step.
is a computer programming technique involving the use of a procedure, subroutine, function, or algorithm that calls itself in a step having no termination condition.
None of the above
In recursion a base case is:
The most simplistic code of a program
is a non-recursive function
Is a problem that we know the answer to
What stops the recursion from continuing on forever
In recursion the sequence of smaller problems must eventually converge on?.
an even smaller problem
sorting algorithm
the base case
the main function of your program
Which one is not a reason to use recursion?.
One of the sub-tasks to be solved is nothing more than a simpler version of the same problem you are trying to solve in first place
Code is generally shorter and easier to write than iterative code.
Recursion is most useful for tasks that can be defined in terms of similar sub-tasks
Low computational complexity
Recursion is very efficient
True
False
There is not overhead in the use of recursion
True
False
The data structure used to implement recursive function calls _____________
Stack
Linked list
Queue
Array
We are sorting the following list in ascending order:
5 4 2 9 3 1 8
What does the list look like after ONE pass of the selection sort algorithm?
1 2 4 3 8 5 9
1 4 2 9 3 5 8
1 5 4 2 9 3 8
4 5 2 9 3 1 8
The Selection Sort algorithm repeatedly finds the smallest value in the list, then swaps it into its sorted position.
True
False
Why might a sorting algorithm be needed before a search?
Data is less when sorted
Data cannot be searched if it not sorted
Data can be retrieved faster and easier when sorted
Data must always be sorted before it is searched
What sorting algorithm is this?
Merge Sort
Heap Sort
Quicksort
Bubble Sort
What sorting algorithm is this?
Insertion Sort
Sort of lame
Selection Sort
Bubble Sort
What sorting algorithm is this?
Insertion Sort
Selection Sort
Quicksort
Bubble Sort
Merge sort and Quicksort are [blank] sorting algorithms. (Hint: Three words)
(a)
Which sorting algorithm is this?
Quicksort
Divide Sort
Merge Sort
Match Sort
Quicksort uses a [blank] to help partition the array into two.
(a)
What sorting algorithm is this?
Bubble Sort
Insertion Sort
Selection Sort
None of the above
Which sorting algorithm is efficient when it comes to using less space?
Merge Sort
Quicksort
In which of the following cases, binary search algorithm is used?
To search an element in an unordered list.
To search an element in a list of few elements.
To search an element in any ordered list with large number of elements.
How does a binary search algorithm works?
Dividing the list into halves until the item is matched with one in the list.
Starts with the first element and checks the next element consecutively until a match is found.
None of the above
An array with 32 elements is input to a binary search algorithm. How many maximum number of comparisons are performed?
32
16
8
5
An array with 32 elements is input to a linear search algorithm. How many maximum number of comparisons are performed?
32
16
8
5
Under which of the following conditions, binary search algorithm terminates?
Item_found=true
lower_bound <= upper_bound
lower_bound > upper_bound
A or C
What is the disadvantage of binary search algorithm?
It takes longer time when compared to linear search algorithm
It works only on sorted lists
It is very complex to understand
In a binary search the statement
int middle = (left + right) / 2;
calculates
the element in the remaining list that has a greater value than the value being sought
the element in the remaining list that has a smaller value than the value being sought
the element in the remaining list to be checked for the value being sought
None of the above
