CS301 Quiz-2 Solution Fall 2022 (32 to 41)

5

Vu All Subjects Assignment Quiz GDB Handouts Available here

 Aslam U Alaikum!

Dear Students,

In this post we are providing you CS301 Quiz-2 Solution Fall 2022 (32 to 41) 100% correct or right solution. You'll Download assignment Solution File From below download (Click Here For Download File) link interface.

Be prepared for quiz no. 2 of CS301 that will open on Monday, March 07, 2022. The quiz will remain open for 3 days (72 hours) only and cover the lectures from 32 to 41. Retake of the quiz will not be given in any case. Do not wait for the last hour and attempt the quiz on the first day. 

Quiz No 2 will be opened from


A binary relation R over S is called an equivalence relation if it has following property(s)

All of the given options

 

If there are N elements in an array then the number of maximum steps needed to find an element using Binary Search is .

log2N

 

Use of binary tree in compression of data is known as .

 Huffman encoding

 

While building Huffman encoding tree the new node that is the result of joining two nodes has the frequency.

Equal to the sum of the two frequencies

 

 

Which of the following statement is correct?

A Threaded Binary Tree is a binary tree in which every node that does not have a right child has a THREAD (in actual sense, a link) to its INORDER successor.

 

 

A Threaded Binary Tree is a binary tree in which every node that does not have a right child has a THREAD (in actual sense, a link) to its successor.

Inorder

 

 

Which of the following statement is true about dummy node of threaded binary tree?

This dummy node has either no value or some dummy value.

 

A complete binary tree is a tree that is filled, with the possible exception of the bottom level.

completely

A complete binary tree of height 3 has between _ nodes.

8 to 15

We can build a heap in _ time.

Linear

 

Suppose that a selection sort of 100 items has completed 42 iterations of the main loop. How many items are now guaranteed to be in their final spot (never to be moved again)?

 42

Which of the following statement is NOT correct about find operation:

One idea might be to use a tree to represent each set, since each element in a tree has the same root, thus the root can be used to name the set.

(Consider the following infix )expression:

x – y a + b / c

Which of the following is a correct equivalent expression(s) for the above?

 x y a * - b c / +

A complete binary tree of height has nodes between 16 to 31 .

 4

What requirement is placed on an array, so that binary search may be used to locate an entry?

The array must have at least 2 entries

 

A solution is said to be efficient if it solves the problem within its resource constraints i.e. hardware and time.

False

If there are 100 elements in a heap and 100 delete Min operation are performed, will get_____list

 Sorted

Sorting procedure normally takes ____times

 NLogN

The expression if(!heap-> is empty ())Checks

Heap is not empty

If the height of a perfect binary tree is 4.What will be the total number of nodes in it?

31

A binary relation R over S is called an equivalence relation if it has following property(S)?

All of the given

If a tree has 20 edges/links, then the total number of nodes in the tree will be:

21

For a perfect binary tree of height 4, what will be the sum of highest of node

26

If Ahmed is cousin of Ali and Ali is cousin of Asad then Ahmed is also cousin of Asad.This statement has the following property

Transitivity

Which property of equivalence relation is satisfied if we say: Ahmad is cousin of Ali and Ali is also cousin of Ahmed

Symmetry

Which one of the following is NOT the property of equivalence relation?

Associative

The main reason of using heap in priority queue is

Improve performance

 

The total number of nodes on 10th level of perfect binary tree are

 1024

Suppose there are 100 elements in an equivalence class, so initially there will be 100 trees,the collection of these trees is called ___________.

Forest

The percolate Down procedure will move the smaller value ____ and bigger value ____.

 Up, down

For a perfect binary tree of height h, having N nodes, the Sum of height of nodes is _____

N - h -1

Which of the following method is helpful in creating the heap at once?

percolateDown

If ahmad is boss of Ahsan and ehsan is boss of umer then ahmad is also boss of umer,the above mentioned relation is _______.

Transitive

If we want to find 3rd minimum element from an array of element, then after applying build heap method. How many times deleteMin method will be called?

3

If we want to find median of 50 elements, then after applying builtHeap method, how many

time deleteMin method will be called?

25

Which of the following properties are satisfied by equivalence relationship?

Reflexive, symmetric and transitive

The Expressionif ( ! heap->isFull() ) Check

Heap is not full

Given the values are the array representation of heap: 12 23 26 31 34 44 56 64 78 100 If we perform 4 deleteMin operation, the last element deleted is _______.

31

Which of the following heap method increase the value if key at position ‘p’ by the amount ‘delta’?

increaseKey(p, delta)

 Which property of equivalence relation is satisfied if we say: Ahmad R(is related to)Ahmad

Reflexivity

The total number of nodes on 5th level of perfect binary tree are:

 32

Which property of equivalence relation is satisfied if we say: Ahmad is cousin of Ali and Ali is also Cousin of Ahmad

Symmetry

If a tree has 50 nodes , then the total edges/links in the tree will be

 49

If the height of perfect binary tree is 4, what will be the total number of nodes in it?

31

Suppose there are set of fruits and the set of vegetables, both sets are _______ sets.

 Disjoint

A binary relation R over S is called an equivalence relation if it has following property(s)

All of Above

Heap can be used to implement

Priority queue

If a tree has 20 edges/links, then the total number of nodes in the tree will be:

 21

If there are 100 elements in an equivalence class, then we will have _______ sets initially.

100

Given the values are the array representation of heap; 12 23 26 31 34 44 56 64 78 100 What is the 5th smallest element in the given heap?

34

A solution is said to be efficient if it solves the problem within its resource constraints i.e. hardware and time.

True

Which one of the following is known as "Last-In, First-Out" or LIFO Data Structure?

Stack

What will be postfix expression of the following infix expression? infix Expression: a+b*c-d

abc*+d-

For compiler a postfix expression is easier to evaluate than infix expression?

True

Consider the following pseudo code declare a stack of characters while ( there are more characters in the word to read )

{

read a character

push the character on the stack

}

while ( the stack is not empty )

{

pop a character off the stack

write the character to the screen

}

What is written to the screen for the input "apples"?

selppa

A binary tree of N nodes has .

Log2 N levels

 

The easiest case of deleting a node from BST is the case in which the node to be deleted .

Is a leaf node

If there are N elements in an array then the number of maximum steps needed to find an element using Binary Search is .

 log2N

Merge sort and quick sort both fall into the same category of sorting algorithms. What is this category?

None of the given options.

If one pointer of the node in a binary tree is NULL then it will be a/an .

External node

We convert the _ pointers of binary to threads in threaded binary tree.

NULL

If the bottom level of a binary tree is NOT completely filled, depicts that the tree is NOT

complete Binary tree

What is the best definition of a collision in a hash table?

Two entries with different keys have the same exact hash value.

Suppose that a selection sort of 100 items has completed 42 iterations of the main loop. How many items are now guaranteed to be in their final spot (never to be moved again )

 42

Suppose you implement a Min heap (with the smallest element on top) in an array. Consider the different arrays below; determine the one that cannot possibly be a heap:

16, 24, 20, 30, 28, 18, 22

Do you see any problem in the code of nextInOrder

below: TreeNode * nextInorder(TreeNode * p)

{

if(p->RTH == thread)

return( p->R );

else {

p = p->R;

while(p->LTH == child)

p = p->R;

return p;

}

}

The function has logical problem, therefore, it will not work properly.

Here is an array of ten integers: 5 3 8 9 1 7 0 2 6 4 The array after the FIRST iteration of the large loop in a selection sort (sorting from smallest to largest).

 0 3 8 9 1 7 5 2 6 4

Which one of the following operations returns top value of the stack?

Top

Which one of the following is NOT true regarding the skip list?

List Sh contains only the n special keys.

By using we avoid the recursive method of traversing a Tree, which makes use of stacks and consumes a lot of memory and time.

Threaded binary tree

 What is the best definition of a collision in a hash table?

Two entries with different keys have the same exact hash value.

 Which formula is the best approximation for the depth of a heap with n nodes?

log (base 2) of n

which of the following is not true regarding the maze generation?

Remove a randomly chosen wall if the cells it separates are already in the same set.

 

Which of the given option is NOT a factor in Union by Size:

 Make the larger tree, the subtree of the smaller one.

when we have declared the size of the array, it is not possible to increase or decrease it during the of the program.

 Execution

it will be efficient to place stack elements at the start of the list because insertion and removal take time.

Constant

is the stack characteristic but was implemented because of the size limitation of the array.

isEmpty() , isFull()

 What kind of list is best to answer questions such as "What is the item at position n?"

 Lists implemented with an array.

 Each node in doubly link list has,

 2 pointers

If there are 56 internal nodes in a binary tree then how many external nodes this binary tree will have?

 57

A simple sorting algorithm like selection sort or bubble sort has a worst-case of O(n2) time because sorting 1 element takes O(n) time - After 1 pass through the list, either of these

algorithms can guarantee that 1 element is sorted.

Merge sort and quick sort both fall into the same category of sorting algorithms. What is this category?

None of the given options.

Huffman encoding uses tree to develop codes of varying lengths for the letters used in the original message.

 Binary tree

Consider a min heap, represented by the following array: 10,30,20,70,40,50,80,60 Afer inserting a node with value 31.Which of the following is the updated min heap?

 10,30,20,31,40,50,80,60,70

 Consider a min heap, represented by the following array: 11,22,33,44,55 After inserting a node with value 66.Which of the following is the updated min heap?

11,22,33,44,55,66

Suppose that a selection sort of 100 items has completed 42 iterations of the main loop. How many items are now guaranteed to be in their final spot (never to be moved again)?

 42

Is a data structure that can grow easily dynamically at run time without having to copy existing elements.

Both of these

A complete binary tree of height has nodes between 16 to 31 .

4

Which of the given option is NOT a factor in Union by Size:

Make the larger tree, the subtree of the smaller one.

Here is an array of ten integers:

5 3 8 9 1 7 0 2 6 4

The array after the FIRST iteration of the large loop in a selection sort (sorting from smallest to largest).

 0 3 8 9 1 7 5 2 6 4

Suppose A is an array containing numbers in increasing order, but some numbers occur more than once when using a binary search for a value, the binary search always finds

the first occurrence of a value.

A binary tree with 24 internal nodes has external nodes. 22

 25

77.it will be efficient to place stack elements at the start of the list because insertion and removal take time.

Constant

 “+” is a operator.

Binary

A kind of expressions where the operator is present between two operands called expressions.

Infix

Here is a small function definition:

void f(int i, int &k)

{

i = 1;

k = 2;

}

Suppose that a main program has two integer variables x and y, which are given the value 0. Then the main program calls f(x,y); What are the values of x and y after the function f finishes?

x is still 0, but y is now 2.

A binary tree with N internal nodes has links, links to internal nodes and links to external nodes

2N, N-1, N+1

Each node in doubly link list has,

2 pointers

If you know the size of the data structure in advance, i.e., at compile time, which one of the following is a good data structure to use.

Both of these

Which one is a self-referential data type?

Link list

There is/are case/s for rotation in an AVL tree,

 4

 Which of the following can be the inclusion criteria for pixels in image segmentation.

All of the given options

 In a perfectly balanced tree the insertion of a node needs .

One rotation

 If there are N elements in an array then the number of maximum steps needed to find an element using Binary Search is .

 log2N

Which of the following is NOT a correct statement about Table ADT?

A table consists of several columns, known as entities.

Suppose we are sorting an array of eight integers using quick sort, and we have just finished the first partitioning with the array looking like this:

2 5 1 7 9 12 11 10

Which statement is correct?

The pivot could be either the 7 or the 9

What is the best definition of a collision in a hash table?

Two entries with different keys have the same exact hash value.

For a perfect binary tree of height h, having N nodes, the sum of heights of nodes is

N – (h + 1)

A binary tree with 33 internal nodes has links to internal nodes.

32

Suppose you implement a Min heap (with the smallest element on top) in an array. Consider the different arrays below; determine the one that cannot possibly be a heap:

16, 24, 20, 30, 28, 18, 22

Which of the following is not true regarding the maze generation?

Remove a randomly chosen wall if the cells it separates are already in the same set. (Page 424)

Which formula is the best approximation for the depth of a heap with n nodes?

log (base 2) of n

 Mergesort makes two recursive calls. Which statement is true after these recursive calls finish, but before the merge step?

Elements in the second half of the array are less than or equal to elements in the first half of the array.

The arguments passed to a function should match in number, type and order with the parameters in the function definition.

 True

If numbers 5, 222, 4, 48 are inserted in a queue, which one will be removed first?

5

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;

A Compound Data Structure is the data structure which can have multiple data items of same type or of different types. Which of the following can be considered compound data structure?

 All of the given options

Here is a small function definition:

void f(int i, int &k)

{

i = 1;

k = 2;

}

Suppose that a main program has two integer variables x and y, which are given the value 0. Then the main program calls f(x,y); What are the values of x and y after the function f finishes?

x is still 0, but y is now 2.

The difference between a binary tree and a binary search tree is that ,

a binary search tree has two children per node whereas a binary tree can have none, one, or two Children per node

If there are 56 internal nodes in a binary tree then how many external nodes this binary tree will have?

 57

If there are 23 external nodes in a binary tree then what will be the no. of internal nodes in this binary tree?

 22 (n-1)

Which of the following method is helpful in creating the heap at once?

 preculateDown

If both pointers of the node in a binary tree are NULL then it will be a/an .

Leaf node 

By using we avoid the recursive method of traversing a Tree, which makes use of stacks and consumes a lot of memory and time.

Threaded binary tree

 A complete binary tree of height 3 has between _ nodes.

 8 to 15

Consider a min heap, represented by the following array:

3,4,6,7,5,10

After inserting a node with value 1.Which of the following is the updated min heap?

 1,4,3,5,7,10,6 close to correct but correct ans is 1,4,3,7,5,10,6

Consider a min heap, represented by the following array:

10,30,20,70,40,50,80,60

After inserting a node with value 31.Which of the following is the updated min heap?

10,30,20,31,40,50,80,60,70

Which one of the following algorithms is most widely used due to its good average time,

 Quick Sort

The following are statements related to queues. The last item to be added to a queue is the first item to be removed A queue is a structure in which both ends are not used The last element hasn‟t to wait until all elements preceding it on the queue are removed queue is said to be a last-in-first-out list or LIFO data structure. Which of the above is/are related to normal queues?

queue is said to be a last-in-first-out list or LIFO data structure.

Which of the above is/are related to normal queues?

 None of the given options

In complete binary tree the bottom level is filled from

Left to right

We are given N items to build a heap, this can be done with successive inserts.

N

Suppose we had a hash table whose hash function is “n % 12”, if the number 35 is already in the hash table, which of the following numbers would cause a collision?

143

Here is an array of ten integers:

5 3 8 9 1 7 0 2 6 4

The array after the FIRST iteration of the large loop in a selection sort (sorting from smallest to largest).

 0 3 8 9 1 7 5 2 6 4  

What requirement is placed on an array, so that binary search may be used to locate an entry?

The array must be sorted.

 

In case of deleting a node from AVL tree, rotation could be prolong to the root node.

Yes

only removes items in reverse order as they were entered.

Stack

Here is a small function definition:

void f(int i, int &k)

{

i = 1;

k = 2;

}

Suppose that a main program has two integer variables x and y, which are given the value 0. Then the main program calls f(x,y); What are the values of x and y after the function f finishes?

 x is still 0, but y is now 2.

Select the one FALSE statement about binary trees:

Every binary tree has at least one node.

Searching an element in an AVL tree take maximum time (where n is no. of nodes in AVL tree),

 1.44 Log2n 

Suppose that we have implemented a priority queue by storing the items in a heap. We are now executing a reheapification downward and the out-of-place node has priority of 42. The node‟s parent has a priority of 72, the left child has priority 52 and the node‟s right child has priority 62. Which statement best describes the status of the reheapification.

The next step will swap the out-of-place node with its left child.

Suppose you implement a heap (with the largest element on top) in an array. Consider the different arrays below, determine the one that cannot possibly be a heap:

 7 3 6 4 2 5 1

Which one of the following is NOT the property of equivalence relation:

Associative

The definition of Transitivity property is

For all elements x, y and z, if x R y and y R z then x R z

Union is a time operation.

 Constant

Which of the following is NOT a correct statement about Table ADT.

 A table consists of several columns, known as entities.

In the worst case of deletion in AVL tree requires .

 Rotations equal to log2 N

By using we avoid the recursive method of traversing a Tree, which makes use of stacks and consumes a lot of memory and time.

Threaded binary tree 

Consider a min heap, represented by the following array:

11,22,33,44,55

After inserting a node with value 66.Which of the following is the updated min heap?

11,22,33,44,55,66

Consider a min heap, represented by the following array:

3,4,6,7,5

After calling the function deleteMin().Which of the following is the updated min heap?

4,5,6,7

We can build a heap in _ time.

Linear

Suppose we are sorting an array of eight integers using quick sort, and we have just finished the first partitioning with the array looking like this:?

2 5 1 7 9 12 11 10

Which statement is correct?

The pivot could be either the 7 or the 9.

Which formula is the best approximation for the depth of a heap with n nodes?

log (base 2) of n

Suppose you implement a Min heap (with the smallest element on top) in an array. Consider the different arrays below; determine the one that cannot possibly be a heap:

 16, 24, 20, 30, 28, 18, 22

While joining nodes in the building of Huffman encoding tree if there are more nodes with same frequency, we choose the nodes _.

Randomly 

Consider the following paragraph with blanks.

A …….…….. is a linear list where …………… and ................. take place at the

same end . This end is called the …….……….

What would be the correct filling the above blank positions?

 (i) stack (ii) insertion (iii) removals (iv) top

A binary tree with 33 internal nodes has links to internal nodes.

32

Which traversal gives a decreasing order of elements in a heap where the max element is stored at the top?

 None of the given options

 What requirement is placed on an array, so that binary search may be used to locate an entry

The array must be sorted

Which of the following is a non linear data structure?

 Tree

The data of the problem is of 2GB and the hard disk is of 1GB capacity, to solve this problem we should

Increase the hard disk space


In an array list the current element is

The middle element

Which one of the following is a valid postfix expression?

 abc*+d-

In sequential access data structure, accessing any element in the data structure takes different amount of time.Tell which one of the following is sequential access data structure,

 Lists

I have implemented the queue with a circular array. If data is a circular array of CAPACITY elements, and last

is an index into that array, what is the formula for the index after last?

 (last + 1) % CAPACITY

Which one of the following is TRUE about recursion?

 Recursion extensively uses stack memory.

Which one of the following is TRUE about iteration?

Recursion is more efficient than iteration.

If a max heap is implemented using a partially filled array called data, and the array contains n elements (n >0), where is the entry with the greatest value?

Data[0]

If there are 56 internal nodes in a binary tree then how many external nodes this binary tree will have?

57

Which of the following heap method increase the value of key at position „p" by the amount „delta"??

increaseKey(p,delta)

If we have 1000 sets each containing a single different person. Which of the following relation will be true on each set:

Reflexive

Which one of the following is not an example of equivalence relation?

<= relation

A binary tree of nodes has .

Log2 N levels

Binary Search is an algorithm of searching, used with the data.

Sorted

Consider te following array

23 15 5 12 40 10 7

After the first pass of a particular algorithm, the array looks like

15 5 12 23 10 7 40

Name the algorithm used

Bubble sort

Which of the following statements is correct property of binary trees?

A binary tree with N internal nodes has N+1 external nodes.

If the bottom level of a binary tree is NOT completely filled, depicts that the tree is NOT a

complete Binary tree

In a selection sort of n elements, how many times the swap function is called to complete the execution of the algorithm?

 n-1

Which of the following statement is correct about find(x) operation?

A find(x) on element x is performed by returning the root of the tree containing x.

Which of the following statement is NOT correct about find operation?

One idea might be to use a tree to represent each set, since each element in a tree has the same root, thus the root can be used to name the set.

Consider the following postfix expression S and the initial values of the variables.

S = A B - C + D E F - + ^ Assume that A=3, B=2, C=1, D=1, E=2, F=3 What would be the final output of the stack?

1

The maximum number of external nodes (leaves) for a binary tree of height H is

 2H+1

In threaded binary tree the NULL pointers are replaced by ,

 inorder successor or predecessor

In a min heap , preculateDown procedure will move smaller value and bigger value .

up,down

Which of the following statement is correct about union:

To perform Union of two sets, we merge the two trees by making the root of one tree point to the root 

of the other. 

Suppose A is an array containing numbers in increasing order, but some numbers occur more than once when using a binary search for a value, the binary search always finds

the first occurrence of a value.

Let heap stored in an array as H = [50, 40, 37, 32, 28, 22, 36, 13]. In other words, the root of the heap contains the maximum element. What is the result of deleting 40 from this heap

[50,32, 37,13, 28, 22, 36]

In an array we can store data elements of different types.

False

Which one of the following statement is NOT correct?

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

Doubly Linked List always has one NULL pointer.

False

A queue is a data structure where elements are,

 inserted at the front and removed from the back.

Each node in doubly link list has,

2 pointers 

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?

Both change

Compiler uses which one of the following to evaluate a mathematical equation,

Parse Tree

If a complete binary tree has n number of nodes then its height will be,

Log2 (n+1) -1

If a complete binary tree has height h then its no. of nodes will be,

2h+1- 1

 


If you appreciate our work, please share our website vuonlinehelp.blogspot.com with your friends.

We are here to provide Latest Virtual University Assignment Solutions, GDB Solutions, Quiz  Solution, Midterm Past Papers, and Final term Past Papers in this website.

Post a Comment

5Comments

Thanks everone

Post a Comment