Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

CGC COLLEGE OF ENGINEERING, LANDRAN, MOHALI

Viva Voce Sheet

DEPTT. : COMPUTER SCIENCE & ENGINEERING LABORATORY: Data Structures LAB SEMESTER: III

Q1. What is a data structure?


Ans: Data Structure is a logical and mathematical modal of a particular organization of data.

Q2. What is a pointer?


Ans: A pointer is a variable that contains the address of a variable.

Q3. What is sorting?


Ans: Sorting is arranging elements in increasing or decreasing order.

Q4. What is searching?


Ans: Searching is finding whether a Key element is present in the list or not.

Q5. What is a stack?


Ans: A stack is an ordered list in which all insertions and deletions are made at one end, called top.

Q6. What is a queue?


Ans: A queue is an ordered list in which all insertions take place at the rear end and all deletions take
place at the front.

Q7. Which are non-linear data structures?


Ans: Trees and graphs.

Q8. Which are linear data structures?


Ans: Stacks, queues, linear linked list.

Q9. Which is the indirection operator?


Ans: “*”--- it stands for value at address.

Q10. What is an array?


Ans: an array is a collection of data elements of same type that are stored consecutively in memory.

Q11. What is a structure?


Ans: A structure is a collection of data elements which may or may not be of the same type.

Q12. What is a homogenous data structure?


Ans: A homogeneous data structure is one in which all data elements are of the same type. E.g. an
array.

Q13. What is a heterogeneous data structure?


Ans: A heterogeneous data structure is one in which all data elements are of different types.

Q14. What is the difference between int (*p)[10] and int *p[10] ?
Ans: int (*p)[10] means that p is a pointer pointing to an array of size 10 whereas int *p[10] means
that p is an array of pointers of size 10. all containing integer type values.

Q15. What does int (*p[10])[5] means?


Ans: it means that p ia an array of pointers of size 10, whose each element contains the base address
of an array of size 5.all containing integer type values.

PREPARED BY : Prof. S. K. Chawla APPROVED BY : Dr. Anuj K. Gupta


CGC COLLEGE OF ENGINEERING, LANDRAN, MOHALI

Viva Voce Sheet

DEPTT. : COMPUTER SCIENCE & ENGINEERING LABORATORY: Data Structures LAB SEMESTER: III

Q16.what does &a means?


Ans: it means address of variable “a”.

Q17. What does *p means?


Ans: it means that p is a pointer which stores some address and we want the value stored at address
that p points to.

Q18.what are the functions used for dynamic memory allocation?


Ans: malloc and calloc are the functions used for dynamic memory allocation.

Q19. what is the difference between calloc and malloc functions?


Ans: 1. Calloc( ) function requires two arguments whereas Malloc( ) requires one parameter.
2. calloc( ) function initilises memory elements to 0 whereas a malloc( ) function does not
initilises to 0. garbage values are present in the memory locations initially.

Q20. what is the header file for “exit( )” function?


Ans: process.h

Q21.what is the header file for “malloc( )” function?


Ans: alloc.h

Q22.what is the what is the header file for “exit( )” function?


Ans: process.h

Q23.header file for “clrscr()” function?


Ans: conio.h

Q24. what does FILE *ptr stands for?


Ans: FILE allocates a buffer for the file and ptr is the pointer that will be used in the file and it will
initially points to the beginning of the buffer area.

Q25. where is a file stored?


Ans: on hard disk.

Q26: how many bytes does an integer takes?


Ans: 2 bytes.

Q27: how many bytes does a character takes?


Ans: 1 bytes.

Q28: how many bytes does a float takes?


Ans: 4 bytes.

Q29: how many bytes does a double takes?


Ans: 8 bytes.

Q30. what is the policy followed by a stack?


Ans: Last In First Out(LIFO)

PREPARED BY : Prof. S. K. Chawla APPROVED BY : Dr. Anuj K. Gupta


CGC COLLEGE OF ENGINEERING, LANDRAN, MOHALI

Viva Voce Sheet

DEPTT. : COMPUTER SCIENCE & ENGINEERING LABORATORY: Data Structures LAB SEMESTER: III

Q31. what is the policy followed by a queue?


Ans: First In First Out(FIFO)

Q32. what is a sparse matrix?


Ans: A sparse matrix is one in which maximum entries are 0.

Q33. what is an algorithm?


Ans: an algorithm is a well defined list of steps for solving a particular problem.

Q34. how is efficency of algorithm found?


Ans: By the time and space that the algorithm requires for execution.

Q35. what is the complexity of an algorithm?


Ans: it is a function f(n) which gives the running time and/or storage space requirement of an
algorithm in terms of size n of the input data.

Q36. what is the time complexity of linear search?


Ans: O(n)

Q37. what is the time complexity of binary search?


Ans: O(log n)

Q38. what is the time complexity of selection sort?


Ans: O(n2)

Q39. what is the time complexity of exchange selection sort?


Ans: O(n2)

Q40. what is the time complexity of insertion sort?


Ans: O(n2)

Q41. what is the time complexity of bubble sort?


Ans: O(n2)

Q42. what is the time complexity of quick sort in average case?


Ans: O(n log n)

Q43. what is the time complexity of quick sort in worst case?


Ans: O(n2)

Q44. what is the time complexity of heap sort in average and worst case?
Ans: O(n log n)

Q45. what is the worst case for quick sort?


Ans: the worst case is that the list on which we are applying quick sort is already sorted.

Q46: what is the compulsion for binary search?


Ans: the compulsion is that the elements should be sorted.

PREPARED BY : Prof. S. K. Chawla APPROVED BY : Dr. Anuj K. Gupta


CGC COLLEGE OF ENGINEERING, LANDRAN, MOHALI

Viva Voce Sheet

DEPTT. : COMPUTER SCIENCE & ENGINEERING LABORATORY: Data Structures LAB SEMESTER: III

Q47: which sorting technique is the best one?


Ans: quick sort is the best technique if the worst case is avoided.

Q48: what is the drawback of heap sort?


Ans: the problem is that it is difficult to program heap sort.

Q49. what is a b-tree?


Ans: it is a finite set of nodes which is either empty or consists of a root and two disjoint b-trees called
left and right subtrees.

Q50. what is the depth of a b-tree?


Ans: depth is the maximum number of nodes along a path in the b-tree.

Q51.what are terminal nodes?


Ans: nodes with no successor are called terminal nodes.

Q52. what is a complete b-tree?


Ans: a tree T is complete if all levels, except the last have maximum number of possible nodes and if all
nodes at last level appear as far left as possible.

Q53.what is the maximum number of nodes on level “i” in a b-tree?


Ans: 2 i-1

Q54. what is the maximum number of nodes of b-tree of depth k?


Ans: 2 k –1.

Q55. what is the relation between the branches and nodes in a b-tree?
Ans: n=B+1
Where n is the number of nodes
and B is the number of branches.

Q56. what is an extended b-tree?


Ans: An extended B-tree is one in which each node has 0 or 2 children. In such a case nodes with two
children are called internal nodes and the nodes with 0 children are called external nodes.

Q57. how are b-trees represented in memory?


Ans: it is represented in memory usingd linked representation, using 3 arrays- info, left, right
Info—contains the data of the node
Left—contains the address of left child.
Right—contains the address of right child.

Q58. how many subtrees can a b-tree have?


Ans: two.

Q59. what are the operations that can be performed on data structure?
Ans: traversing, searching,inserting,deleting

Q60. what is a linked list?

PREPARED BY : Prof. S. K. Chawla APPROVED BY : Dr. Anuj K. Gupta


CGC COLLEGE OF ENGINEERING, LANDRAN, MOHALI

Viva Voce Sheet

DEPTT. : COMPUTER SCIENCE & ENGINEERING LABORATORY: Data Structures LAB SEMESTER: III

Ans: a linked list is a linear collection of data elements called nodes where the linear order is given by
means of pointers.

Q61.how is a list represented in memory?


Ans: list requires two linear arrays- one for the data part and the other for the pointer that would
contain the address of the next element in the list.

Q62. what are the ways of traversing a b-tree?


Ans: postorder, inorder, preorder.

Q63. what is postorder?


Ans: LRD

Q64. what is preorder?


Ans: DLR

Q65. what is inorder?


Ans: LDR

Q66. is a linked list stored in consecutive memory locations?


Ans: no

Q67. what is free pool?


Ans: Free pool is a way of maintaining a special list of unused memory cells. this list has its own
pointer and is called the list of available space.

Q68. what is garbage collection?


Ans: Operating system collects all the deleted space to the free-storage list. Any technique which does
this collection is called garbage collection.

Q69. how is garbage collection done?


Ans: it is done in two steps:
1. computer runs through all lists and marks those cells which are in use.
2. it then collects all the unmarked cells onto the free-storage list.

Q70. how is insertion done in linked list?


Ans: to insert elements in linked list the address of the element is changed to that of the element to be
added and the element to be added is assigned the address of the element before which this element
is to be inserted.

Q71. how are stacks implemented?


Ans: 1. one way is to use an array and a variable called TOP to store the address of the element at the
top in the stack.
2.second way is to use linked list.

Q72. what are the ways for expression evaluation?


Ans: Infix, postfix, prefix.

Q73. what is polish notation?


PREPARED BY : Prof. S. K. Chawla APPROVED BY : Dr. Anuj K. Gupta
CGC COLLEGE OF ENGINEERING, LANDRAN, MOHALI

Viva Voce Sheet

DEPTT. : COMPUTER SCIENCE & ENGINEERING LABORATORY: Data Structures LAB SEMESTER: III

Ans: it is a notation in which operator is placed before 2 operands eg. +AB. It is also called prefix
notation.

Q74. what is reverse polish notation?


Ans: it is a notation in which operator is placed after 2 operands eg. AB+. It is also called postfix
notation

Q75. what is infix notation?


Ans: it is a notation in which operator is placed between 2 operands eg. A+B.

Q76. how is postfix implemented?


Ans: it is implemented using stacks.

Q77. how does computer evaluates arithmetic expression which is in infix notation?
Ans: 1. first it is converted to postfix notation.
2.then postfix expression is evaluated using stacks.

Q78. which data structure is used to convert infix to postfix notation?


Ans: stacks.

Q79. give an example of application of stack?


Ans: quick sort

Q80: what is divide and conquer strategy?


Ans: in this the problem is divided into smaller parts and these parts further into smaller parts till the
sub problem can be solved easily.

Q81: quick sort is an algorithm of divide and conquer? Explain how?


Ans: in this problem of sorting a set is divided into 2 smaller sets which are then sorted separately.

Q82. what is recursion?


Ans: when one function calls itself, it is known as recursion.

Q83. what are the properties of recursion?


Ans: 1. there must be a certain criteria called the base criteria for which procedure does not call itself.
2. each time the procedure calls itself it must be closer to its base criteria.

Q84. how is recursion implemented?


Ans: using stacks.

Q85. what is a priority queue?


Ans: it is a queue which is a collection of elements such that each element is assigned a priority and
such that the order in which the elements are deleted and processed follows the rule:
1. elements of higher priority are processed first.
2. elements of same priority are processed in the order in which they were added to the queue.

PREPARED BY : Prof. S. K. Chawla APPROVED BY : Dr. Anuj K. Gupta

You might also like