ata Structures Using C Viva Questions
Answer the follo
9
1] The postfix expression for the infix expression A+8%(C+D)/F+D"E is ABCD+*F/DE*++
2) Which data structure is needed to convert infix notations to postfix notations? Stack
3) The infix expression A+((B-C)*D) is correctly represented in prefix notation as + A* -
BCD
4) A list of data items usually words or bytes, with the accessing restriction that elements
can be added or removed at one end of the list only, is known as Stack
5] In what order the elements of 2 push down stack are accessed Last In First Out (LIFO)
6) The following sequence of operations performed on a stack push (1), push (2), pop, push
(), push (2), pop, Pop, pop, push (2), pop. The sequence of popped oUt values are 2, 2, 1,
7) The postfix form of ASE ~ C-D + E/F/(G+H] is AB $ C*D ~ EF/GH+/+
8) The postfix form of A-8/(C*DSE) is ABCDES*/-
9) The prefix form of A-B/(C*DSE] is ~A/B*C$DE
10) The prefix of (A+B)*(C-D) is *+AB-CD
11) What is @ Base case? It is a nonrecursive exit from the recursive routine
/e calll to the rout
12) What is 2 Recursive case? It is a path that includes a recut
to solve a smaller version of the original problem
13) What will be the value returned by the following function when it is called with 11,
recur (int num) {
if((nurn/2}!=0)
retum(recur(num/2)*10+num%2);
else
return
+
1011
14) A linear list in which elements can be added or removed at either end but not in the
middle is enown as : dqueue
15) The initial configuration of queue is 4, b, c d ('a" is at the front). To get the
configuration d, c, b, 2 one needs a minimum of : 3 deletions and 3 additions
16) Queues serve a major role in : simulation of limited resource allocation
17) Queu
items.
an be Created by setting up an ordinary contiguous array to hold the
18) Let P be the queue of integers defined as follows-
Mr. Shylesh BC Page 1 of 8ata Structures Using C Viva Questions
‘define MAXQ 500
struct queue {
int items [MAXQ];
int front, rear;
3a;
To insert an elements in the queue we can use
ems[++9.rear]=x
19) Implementation of list in a dynamit
and free storage ora set of nodes
fashion is : to call upon the system to
not reserved in advance for use
20) Because of linear structure of linked list having natural linear ordering, there is
similarity between linked list end array in : traversal of elements of list
21) Header of a linked list is a special node at the : Beginning of the list
22)struct address {char name [40]; struct address “next }info;
func(struct adéress *j) {
static struct address. *i
if ) 13;
else i ->next = js
j-> next
ink
+
builds the linked list by placing each element : On the end
23) struct address { char name [40]; struct address “next }info;
Tune (struct address ~head) {
wnile (head) {
printf (head ->name);
head = head -> next;}
+
prnts the: Name in all elements of linked
t starting from the elements
alent to the
24) In linked list the logical order of elements : Is not necessai
physical arrangement.
eq
25) The nth node in singly linked list is accessed via (wheren> 1): (m-1) node
26) In linked list the successive elements : need not occupy contiguous space in
memory but should be linked to one another.
27) Linear order in linked list is provided through : Pointer.
28) NULL pointer is used to tell : End of linked list., Empty pointer field of a structure.
Linked list is empty.
29) List pointer variable in linked list contains address of the : First node in the list.
30) Underfiow condition in linked list may occur when attempting to : Delete a node in an
empty list.
Mr. Shylesh BC Page 2of 8ata Structures Using C Viva Questions
31) Deletion of a node in linked list involves keeping track of the address of the node
Which immediately follows the node that has to be deleted
32) Having address of the node to be deleted in double linked list, the node can be delata
Without traversing the list
33) Appropriate data structure in C to represent linked listis : Array and Struct
34) Link ef linked list in Cis of type : Pointer to struct
35) malloc function returns NULL value when :
argument size is 0
ff enough memory is not there or
36) Previously allocated memory can be returned to the system by using: free()
37) Function /s associated with dynamic memory allocation is : malloc(), calloc(), free()
38) How many ancestors does a node in the N® level (root level
have? N
) of a binary search tree
39) A binary search tree is generated by inserting in order the following integers : 50, 15,
62, 5, 20, 58, 91, 3, 8, 37, 60, 24. The number of nodes in the left subtree and right
subtree of the root respectively is (7,4)
40) Which process is faster for threaded trees compared with their unthreaded counterparts
: Traversal
41) If'a binary tree is threaded for an in order traversal order, NULL left link of any node is
replaced by the address of its : Predecessor
42) The inorder traversal of some binary tree procuced the sequence DBEAFC, and the
postorder traversal of the same tree produced the sequence DEBFCA. What is the preorder
traversal sequence? ABDECF
43) A balanced binary tree is 2 binary tree in which the heights of the two subtrees of every
node never differ by more than : 1
44) The postorder traversal of some binary tree produced the sequence CDBFEA, and the
inorder traversal of the same tree produced the sequence CBDAFE. What will be the total
number of nodes in its right sub tree : 2
45) The postorder traversal of some binary tree produced the sequence CDBFEA, and the
inorder traversal of the same tree produced the sequence CBDAFE. What will be the total
number of nodes in its left sub tree : 3
46) The inorder traversal of some binary tree produced the sequence CBDA, and the
postorder traversal of the same tree produced the sequence CDBA. Then Right subtree is
empty, and the left subtree contains 3 nodes.
47) In view of a complete binary tree what is the value of the outdegree - The outdegree
of every node is exactly equal to 2 or 0.
48) Balance of the node : Height of its left subtree minus height of its right subtree.
Mr. Shylesh BC Page 3 of &ata Structures Using C Viva Questions
49) Level of any node of z tree is: Its distance from the root.
50) The element at the root of the heap is depending on type of heap it may be
smallest or largest
51) Bubble sort does not use divide and conquer methodology
52) Name the sort in which array to be sorted is partitioned again and again in such a way
that all elements less than or equal to partition element appear before it and those which
are greater appear after it. quick sort
52) This sort inserts each elements A(k) into its proper position in the previously sorted
subarray A(2), ... A(k-1). insertion sort
53) In this sort file is divided into subfiles which are to be independently sorted and then
merged : shell Sort
54) Average case time complexity of the cuick sort algorithm is more than: O(N log2 N)
55) For scrting contiguous list of records cuicksort may be preferred over merge sort
because : it does not require extra space for an auxilliary storage
56) In quicksort desirable choice for the partitioning element will be : met
57) The techniques used in creating hash keys are - Divided
58) In this search keys must be ordered : binary search
59) The searching method requires that all keys must reside in internal memory
search
inary
60) The element being searched for is not in an array of 100 elements. What is the average
number of comparisons needed in a sequential search to determine that the element is not
there if the elements are completely unordered. 100
61) The element being searched for is not in an array of 100 elements. What is the average
number of comparisons needed in a sequential search to determine that the element is not
there if the elements are ordered from smallest to largest. 50
62) The element being searched for is not in an array of 100 elements. What is the average
number of comparisons needed in a sequential search to determine that the element is not
there if the elements are ordered from largest to smallest. 50
63) The element being searched for is not in an array of 100 elements. What is the average
number of comparisons needed in 3 sequential search to determine the positicn of the if the
elements are completely unordered. 75
State whether the follo
1g statements are TRUE or FALSE :
1] A stack may be represented by a linear linked list - True
2] Push operation in stack is performed at the rear end - False
Mr. Shylesh BC Page 4 of 8ata Structures Using C Viva Questions
3) Only the most recently inserted element can be accessed through POP operation in stack
~ True
4) POP operation in stack may result in overflow - False
5] PUSH operation in stack may result in underflow - False
6) Stack is an example of linear list - True
7) Recursive function must be called directly - True
8) In many cases we observe that, a recursive solution is the most natural and logical way
of solving problem. - True
9) The problem cf Tower of Hanoi is very difficult to solve using non recursive process. -
True
10) Recursive functions and iterative functions using stacks can accomplish exactly the
seme tasks, - True
11) The number of total elements in a queue is fixed. - False
12) The number of elements in 3 queue, at any time is : g.rear ~ g.front - 1. - False
13) The operation of removing an element from a queue logically, involves manipulation of
only one element. - True
14) The term head of the queue is same as the term front of the queue. - True
15) Queue can be created by setting up am ordinary contiguous array to hold the items. -
True
16) The concept of circular array is very difficult to implement. - False
17) For stack or queue,a arbitrary amount of memory can be allocated. - False
18) FRONT = REAR pcinter means queue is empty. - True
19) A Queue can be implemented using 2 circular array with front and rear indices and one
position left vacant. - True
20) Queue is an useful data structure for eny simulation applications. - True
21) A Priority queue is implemented using an array of stacks. - False
22) List NULL can be used to initialize list as empty list - True
23)_In linked list the logical order of elements is same as their physical arrangement -
False
24) Random access of elements in linked list is possible - False
Mr. Shylesh BC Page Sof &ata Structures Using C Viva Questions
25) In linked list each node must have atleast two fields - True
26) In linked list successive elements need not occupy adjacent space in memory. - True
27) Searching the linked list requires the list must be in sorted order - False
28) Every tree can be uniquely represented by a binary tree. True
20) Tree traversal is 2 procedure by which, each node in the tree is processed exactly twice
in 8 systematic manner False
30) In preorder traversal of a binzry tree the left subtree is traversed after processing the
root node, True
31) In preorder traversal of a binzry tree the root node is processed first. True
32) For inorder traversal of a binary tree the inorder traversal of its left subtree should be
performe¢ first. True
33) Abinary tree is threaded according to a particular traversal order. False
34) For inorder threading of a binary tree if the left link of some node is NULL it is replaced
by the address of its successor. True
35) The height of a binary tree is the maximum level of its leaves. False
36) In a tree a node with no sub trees is called a leaf node. True
37) The level of any node of a tree is the length of its path from the root. True
38) The level of the root node of any tree is 1. False
39) In internal sorting methods it is necessary for all data to reside in internal memory True
40) Insertion sort is also called bubble sort False
41) In merge sort, files to be merged must be sorted True
42) Quick sort and merge sort are example of divide and conquer algorithms True
43) Insertion sort is O(N) False
44) Average case time for quick sort is O(log n ) False
45) Bubble sort algorithm requires O(N) comparisons for sorting ¢ sorted list True
46) Quick sort algorithm requires O(N log N) comparisons for sorting @ sorted list False
47) A Heap need not be a binary tree False
48) Merge sort is a stable sorting algorithm True
Mr. Shylesh BC Page 6 of 8ata Structures Using C Viva Questions
49) For sorting elements of an array, where each elementis a large record, itis always
desirable to use an index array for reducing overhead of comparison. False
50) Radix search algorithms work with bits or components of the keys instead of the
complete keys. True
51) A binary search of an ordered set of elements in an array is always faster than a
Sequential search of the elements :False
52) A binary search is an O(N log N) algorithm : False
53) A binary search of elements in an array requires that the elements be sorted from
smallest to largest True
54) When a hash function is used to determine the placement of elements in an array, the
order in which the elements are added will not affect the resulting array : False
55) When hashing is used, increasing the size of the array will always reduce the rumber of
collisions. False
56) No. of elements in the linear Queue with pointers REAR & FRONT at any given instant
can be given by formula - REAR - FRONT +1
57) Ifn is the size of array, maximum no. of elements that can be stored in the circular
queue isn-1
58) The property of which data structure matches with that of Priority queue? Heap
59) If a doubly linked list is I/? restricted as well as O/P restricted, the queue become
circular queue
60) The use of free() function in C requires the header file declaration malloc.h, alloc.h
61) malloc(sizeof(int[10])) The pointer that can point to the above defined m/y area is void
62)Minimum no of pointer adjustment for deletion of any node from the circular doubly
linked listis 4
63) sizeof () is an identifier
64) The overfiow condition in the array implementation of linked list may occur while calling
to getnode
65) Struct book
t
int acc_no;
char tifle[20];
Float price;
hi
Struct book ~s;
sizeof (*s) will give 2
Mr. Shylesh BC Page 7of &