cds & oop viva

Upload: uday-desiraj

Post on 02-Jun-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 CDS & OOP Viva

    1/16

    CDS Questions1. What is an algorithm?Ans: An algorithm is a step-by-step method of performing any task.2. What is a flow chart?Ans: A flowchart is a type of diagram that represents an algorithm or process, showing the steps asboxes of various kinds, and their order by connecting these with arrows.3. The C compiler translates source to assembly code in C Programming.4. The assembler creates object code.

    5. What are the stages of developing your C program?Ans: There are four stages of developing C programCreating the programCompiling the programLinking the program with functions that are needed from C LibraryRunning the program.6. What is a C Preprocessor?Ans: C Preprocessor is a program that processes our source program before it is passed to the compiler.7. What is the use of header files as used in C programmin g?Ans: Header files are used to have declarations. It is simple to include a single header file than writing allthe needed functions prototypes.8. What is the Structure of a C Program?

    Ans: Documentation Section, Linking Section, Definition Section, Global declaration Section, mainfunction, subprogram section.9. Every Program statement in a C program must end with a Semicolon.10. What is the use of main() function?Ans: main() is the starting point of program execution.11. How many main() functions can there be in a C Program?Ans: Only one.12. What are Macros?Ans: A macro is a fragment of code which has been given a name. Whenever the name is used, it isreplaced by the contents of the macro. Example: #define UPPER 25.13. What are its advantages and disadvantages?Ans: The advantage of macro is that it reduces the time taken for control transfer as in case

    offunction.The disadvantage of it is here the entire code is substituted so the program becomeslengthy if a macro is called several times.

    14. What are C Tokens?Ans: Keywords, Identifiers, Constants, Strings, Special symbols and Operators.15. What is a constant? What are types of Constants?Ans: There are two types of constants: Numeric and Character Constants16. What is a variable?Ans: A variable is a data name that may be used to store data value.

    17. Main () function is a pre defined function. True or False?Ans: False.18. what are the fundamental/Primary Datatypes in C?Ans: integer (int), character (char), floating point (float) and double-precision floating point (double).19: What are user defined datatypes?Ans: typedef and enum20. What are the storage classes in C?Ans: auto, static, extern and register.21. What are the compile time operators?Ans: only sizeof is a compile time operator.22. What are the operators in C?Ans: Arithmetic, Relational, Logical, Assignment, Increment and Decrement, Conditional, Bitwise, Special

  • 8/10/2019 CDS & OOP Viva

    2/16

  • 8/10/2019 CDS & OOP Viva

    3/16

    Ans: It contains Utility functions such as string conversion routines, memory allocation routines, randomnumber generator etc..48. A main program can contain how many functions?Ans: It can contain any number of functions.49. What is a pointer?Ans: A pointer is a variable, which contains the address of another variable.50. What is NULL pointer?Ans: A null pointer does not point to any object.51. Explain the scope of static variables.Ans: The scope of a static variable is local to the block in which the variable is defined.52. C is High level Language or Low level language?Ans: High-Level Language.53. Who invented C?Ans: Dennis Ritchie.54. C follows Top down Approach.55. C programming language is case sensitive?Ans: Yes.56. What is Break Statement in C?Ans: The break statement terminates the execution of the current loop and the Control passes to thestatement that follows the terminated statement.57. What is Continue Statement in C?Ans: Whenever a keyword continue is encountered inside a loop, the control automatically passes tothe beginning of the loop.58. What is the difference between Break and Continue in C?Ans: b r e a k statement is used to break any type of loop such as while , do while and for loop. B r e a kstatement terminates the loop body immediately. C o n t i n u e statement is used to break current iteration.After c o n t i n u e statement the control returns to the top of the loop test conditions.59. What is a function?Ans: A function is a self contained block of statements that perform a coherent task of some kind.

    60. Why use functions?Ans: It increases the performance of the system.61. Explain the use of fflush() function.Ans: fflush() [returns 0 if buffer successfully deleted / returns EOF on an error] causes the system toempty the buffer associated with the specified output stream.62. Explain the difference between strcpy() and memcpy() function.Ans: strcpy() copies a string until it comes across the termination character \ 0. With memcopy(), the programmer needs to specify the size of data to be copied.63. Explain the difference between exit() and _exit() function.Ans: exit() does cleanup work like closing file descriptor, file stream and so on, while _exit() does not.64. What are volatile variables?Volatile variables are like other variables except that the values might be changed at any given point oftime only by some external resources. 65. Define recursion in C.Ans: A programming technique in which a function may call itself.66. What does static variable mean in C?Ans: static is an access qualifier that limits the scope but causes the variable to exist for the lifetime ofthe program.67. What is difference between call by value and call by reference inAns: In call by value the value to function interchange is passed by value. And in call byreference the address is passed by using symbol & and the value is accessed by using symbol *. 68. What are the auto variables? Where are they stored?Ans: The auto variables are stored in the memory of the system. The keyword auto is optional. Many of the var iables used by the program / application are auto variables, being the main memory is faster. These variables are stored in the memory runtime stack.

  • 8/10/2019 CDS & OOP Viva

    4/16

    69. List out differences between arrays and linked listAns: The difference between arrays and linked lists are:- Arrays are linear data structures. Linked lists are linear and non-linear data structures.- Linked lists are linear for accessing, and non-linear for storing in memory- Array has homogenous values. And each element is independent of each other positions. Each node inthe linked list is connected with its previous node which is a pointer to the node.- Array elements can be modified easily by identifying the index value. It is a complex process formodifying the node in a linked list.

    - Array elements can not be added, deleted once it is declared. The nodes in the linked list can be addedand deleted from the list.

    70. Explain the term enumerations in CAns: A set of named integer constants is known as an enumeration. The enumeration type declarationincludes the name of the enumeration tag and the definition of a set of named integers.Ex: enum CITY {Mumbai, Bangalore, Chennai, New Delhi} metros;71. Define register variables. What are the advantages of using register variables?Ans: The va riables of register type modifier will inform the compiler for storing the variables in a register of CPU.The advantage of this type modifier is the access optimization and speed of program execution. The

    operations of these variables are faster by orders of magnitude.72. What is the use of typedef?Ans: The keyword typedef is used for defining user defined data types.73. How to create user defined datatypes?Ans: by using the keyword typedef Syntax: typedef type identifier;Example: typedef int units;74. In header files whether functions are declared or defined?Ans: Functions are declared within header file. That is function prototypes exist in a header file,notfunction bodies. They are defined in library (lib).75. What is static memory allocation?Ans: Static Memory Allocation : Memory is allocated for the declared variable by the compiler.

    76. What is dynamic memory allocation?Ans: Dynamic Memory Allocation : Allocation of memory at the time of execution (run time) is known asdynamic memory allocation.76.What functions are used to create dynamic memory allocation?Ans: calloc() and malloc()77. What is the difference between malloc() and calloc()?Ans: malloc() is a one argument function while calloc() is twoargument functionmalloc() take garbage value at initial time while calloc()take null values at initial time.78. What is the purpose of main( ) function?Ans: The function main() calls / invokes other functions within it. The execution of the program alwaysstarts with main() function.79. What is the difference between a string and an array?The following are the differences:- String can hold only char data. Where as an array can hold any data type.- An array size can not be changed. Where as a string size can be changed if it is a char pointer- The last element of an array is an element of the specific type. The last character of a string is a null

    \ 0 character. - The length of an array is to specified in [] at the time of declaration (except char[]). The length of thestring is the number of characters + one (null character).80. Difference between array and pointer?

  • 8/10/2019 CDS & OOP Viva

    5/16

  • 8/10/2019 CDS & OOP Viva

    6/16

    1-It is a collection of data items of different data type.2- It has declaration and definition3- keyword struct is used4-Structure name is known as tag it is the short hand notation of the declaration.88. What are enumerations?Ans: They are a list of named integer-valued constants. Example:enum color { black , orange=4,yellow, green, blue, violet };This declaration defines the symbols black, orange, yellow, etc. to have the values 1, 4, 5, etc. The difference between an enumeration and a macro is that the

    enum actually declares a type, and therefore can be type checked.89. Out of fgets() and gets() which function is safe to use and why?Ans: fgets() is safer than gets(), because we can specify a maximum input length. Neither one iscompletely safe , because the compiler cant prove that programmer wont overflow the buffer he pass to fgets ().90. Differentiate between for loop and a while loop? What are it uses?Ans: For executing a set of statements fixed number of times we use for loop while when the number ofiterations to be performed is not known in advance we use while loop.91. What the advantages of using Unions?Ans: When the C compiler is allocating memory for unions it will always reserve enough room for thelargest member.92. What is the difference between Strings and Arrays?Ans: String is a sequence of characters ending with NULL .it can be treated as a one dimensional arrayof characters terminated by a NULL character.93. What is a far pointer? Where we use it?Ans: In large data model (compact, large, huge) the address B0008000 is acceptable because in these

    model all pointers to data are 32bits long. If we use small data model(tiny, small, medium) the aboveaddress wont work since in these model each pointer is 16bits long. If we are working in a small datamodel and want to access the address B0008000 then we use far pointer. Far pointer is always treatedas a 32bit pointer and contains a segment address and offset address both of 16bits each. Thus theaddress is represented using segment: offset format B000h:8000h. For anygiven memory address there are many possible far address segment: offset pair. The segment register

    contains the address where the segment begins and offset register contains the offset of data/codefrom where segment begins.94. What is a huge pointer?Ans: Huge pointer is 32bit long containing segment address and offset address. Huge pointers arenormalized pointers so for any given memory address there is only one possible huge address segment:offset pair. Huge pointer arithmetic is doe with calls to special subroutines so its arithmetic slower thanany other pointers.95. What is a normalized pointer, how do we normalize a pointer?Ans: It is a 32bit pointer, which has as much of its value in the segment register as possible. Since asegment can start every 16bytes so the offset will have a value from 0 to F. for normalization convertthe address into 20bit address then use the 16bit for segment address and 4bit for the offset address.Given a pointer 500D: 9407,we convert it to a 20bitabsolute address 549D7,Which then normalized to

    549D:0007.96. What is near pointer?Ans: A near pointer is 16 bits long. It uses the current content of the CS (code segment) register (if thepointer is pointing to code) or current contents of DS (data segment) register (if the pointer is pointingto data) for the segment part, the offset part is stored in a 16 bit near pointer. Using near pointer limitsthe data/code to 64kb segment.97. In C, why is the void pointer useful? When would you use it?Ans: The void pointer is useful because it is a generic pointer that any pointer can be cast into and backagain without loss of information.98. What is a NULL Pointer? Whether it is same as an uninitialized pointer?Ans: Null pointer is a pointer which points to nothing but uninitialized pointer may point to anywhere.99. Are pointers integer?

  • 8/10/2019 CDS & OOP Viva

    7/16

    Ans: No, pointers are not integers. A pointer is an address. It is a positive number.100. Can a Structure contain a Pointer to itself?Ans: Yes such structures are called self-referential structures.101. . What do the c and v in argc and argv stand for? Ans: The c in argc(argument count) stands for the number of command line argument the program isinvoked with and v in argv(argument vector) is a pointer to an array of character string that contain thearguments.

    102. Difference between syntax vs logical error?Ans:Syntax Error1-These involves validation of syntax of language.2-compiler prints diagnostic message.Logical Error1-logical error are caused by an incorrect algorithm or by a statement mistyped in such a waythat it doesnt violet syntax of language. 2-difficult to find.103. What is pre-increment and post-increment?Ans: ++n (pre increment) increments n before its value is used in an assignment operation or anyexpression containing it. n++ (post increment) does increment after the value of n is used.104. What is a file?Ans: A file is a region of storage in hard disks or in auxiliary storage devices.It contains bytes ofinformation .It is not a data type.105. What are the types of file?Ans: Files are of two types1-high level files (stream oriented files) :These files are accessed using library functions2-low level files(system oriented files) :These files are accessed using system calls106. What is FILE?Ans: FILE is a predefined data type. It is defined in stdio.h file.107. What is a file pointer?Ans: The pointer to a FILE data type is called as a stream pointer or a file pointer. A file pointer points tothe block of information of the stream that had just been opened.108. Difference between an array of pointers and a pointer to an array?Ans:Array of pointers1- Declaration is: data_type *array_name[size];2-Size represents the row size.3- The space for columns may be dynamicallyPointers to an array1-Declaration is data_type ( *array_name)[size];2-Size represents the column size.109. Are the variables argc and argv are always local to main?Ans: Yes they are local to main.110. Can main () be called recursively?Ans: Yes any function including main () can be called recursively.

    111. What is a Data structure?Ans: Data structure is a collection of organized data that are related to each other. Data structures canbe classified into two types:1. Linear data structure.2. Non linear data structure.112. What are the goals of Data Structure?Ans: It must rich be enough in structure to reflect the actual relationship of data in real world.The structure should be simple enough for efficient processing of data.

  • 8/10/2019 CDS & OOP Viva

    8/16

    113. What are linear data structures?Ans: Arrays and Linked lists.114. What are non linear data structures?Ans: Trees and Graphs.115. What does abstract Data Type Mean?Ans: Data type is a collection of values and a set of operations on these values. Abstract data type referto the mathematical concept that define the data type.It is a useful tool for specifying the logical properties of a data type.ADT consists of two parts1) Values definition2) Operation definitionExample:- The value definition for the ADT RATIONAL states that RATIONAL value consists of twointegers, second doesnt equal to zero. The operator definition for ADT RATIONAL includes the operation of creation (make rational) addition,multiplication and test for equality.116. What is a stack?Ans: A stack is a linear data structure in which item is inserted and deleted at one end. A stack is called aLast in First out (LIFO) structure because the data item is inserted into the stack is the first data item tobe deleted from the stack.117. What is the difference between a Stack and an Array?Ans: STACKi) Stack is a ordered collection of itemsii) Stack is a dynamic object whose size is constantly changing as items are pushed and popped .iii) Stack may contain different data typesiv) Stack is declared as a structure containing an array to hold the element of the stack, and an integer toindicate the current stack top within the array.ARRAYi) Array is an ordered collection of itemsii) Array is a static object i.e. no of item is fixed and is assigned by the declaration of the arrayiii) It contains same data types.iv) Array can be home of a stack i.e. array can be declared large enough for maximum size of the stack.118. What are the operations of stack?Ans: Push and Pop.

    119. What is a Queue?Ans: A queue is an ordered collection of items from which items may be deleted at one end (front end)and items inserted at the other end (rear end).It obeys FIFO rule there is no limit to the number of elements a queue contains.120. What do you mean by recursive definition?Ans: The definition which defines an object in terms of simpler cases of itself is called recursivedefinition.121. What is sequential search?Ans: In sequential search each item in the array is compared with the item being searched until a matchoccurs. It is applicable to a table organized either as an array or as a linked list.122 . What actions are performed when a function is called?Ans: When a function is calledi) arguments are passedii) local variables are allocated and initializedii) transferring control to the function.123. What actions are performed when a function returns?Ans:i) Return address is retrievedii) Functions data area is freed iii) Branch is taken to the return address.124. What is a linked list?

  • 8/10/2019 CDS & OOP Viva

    9/16

    Ans: A linked list is a linear collection of data elements, called nodes, where the linear order is given bypointers. Each node has two parts first part contain the information of the element second part containsthe address of the next node in the list.125. What are the advantages of linked list over array (static data structure)?Ans:The disadvantages of array arei) unlike linked list it is expensive to insert and delete elements in the arrayii) One cant double or triple the size of array as it occupies block of memory space.

    In linked listi) each element in list contains a field, called a link or pointer which contains the address of the nextelementii) Successive elements need not occupy adjacent space in memory. 126. What is the pre-requisite of binary search?Ans: The elements should be in sorted order.127. Can we apply binary search algorithm to a sorted linked list, why?Ans: No we cannot apply binary search algorithm to a sorted linked list, since there is no way of indexingthe middle element in the list. This is the drawback in using linked list as a data structure.

    128. What do you mean by free pool?

    Ans: Pool is a list consisting of unused memory cells which has its own pointer.129. What do you mean by garbage collection?Ans: It is a technique in which the operating system periodically collects all the deleted space onto thefree storage list.It takes place when there is minimum amount of space left in storage list or when CPU is ideal.The alternate method to this is to immediately reinsert the space into free storage list which is timeconsuming.130. What do you mean by overflow and underflow?Ans: When new data is to be inserted into the data structure but there is no available space i.e. freestorage list is empty this situation is called overflow.When we want to delete data from a data structure that is empty this situation is called underflow.131. What are the disadvantages array implementations of linked list?Ans:i) The no of nodes needed cant be predicted when the program is written. ii) The no of nodes declared must remain allocated throughout its execution.132. What is a priority queue?Ans: The priority queue is a data structure in which the intrinsic ordering of the elements (numeric oralphabetic).Determines the result of its basic operation. It is of two typesi) Ascending priority queue- Here smallest item can be removed (insertion is arbitrary)ii) Descending priority queue- Here largest item can be removed (insertion is arbitrary)133. What are the disadvantages of sequential storage?Ans:i) Fixed amount of storage remains allocated to the data structure even if it contains less element.ii) No more than fixed amount of storage is allocated causing overflow.134 . What are the disadvantages of representing a stack or queue by a linked list?Ans:i) A node in a linked list (info and next field) occupies more storage than a corresponding element in anarray.ii) Additional time spent in managing the available list .135. What is dangling pointer and how to avoid it?Ans: After a call to free(p) makes a subsequent reference to *p illegal, i.e. though the storage to p isfreed but the value of p(address) remain unchanged .so the object at that address may be used as thevalue of *p (i.e. there is no way to detect the illegality).Here p is called dangling pointer.To avoid this it is better to set p to NULL after executing free(p).The null pointer value doesnt reference a storage location it is a pointer that doesnt point to anything.

  • 8/10/2019 CDS & OOP Viva

    10/16

    136. What are the disadvantages of linear list?Ans:i) We cannot reach any of the nodes that precede node (p)

    ii) If a list is traversed, the external pointer to the list must be persevered in order to reference the listagain137. Define circular list?

    Ans: In linear list the next field of the last node contain a null pointer, when a next field in the last nodecontain a pointer back to the first node it is called circular list.Advantages From any point in the list it is possible to reach at any other point.138. What are the disadvantages of circular list?Ans:i) We cant traverse the list backward ii) If a pointer to a node is given we cannot delete the node.139. Define double linked list?Ans: It is a collection of data elements called nodes, where each node is divided into three partsi) An info field that contains the information stored in the nodeii) Left field that contain pointer to node on left sideiii) Right field that contain pointer to node on right side.

    140. Is it necessary to sort a file before searching a particular item ?Ans:If less work is involved in searching a element than to sort and then extract, then we dont go for sort If frequent use of the file is required for the purpose of retrieving specific element, it is more efficient tosort the file.Thus it depends on situation .141. What are the issues that hamper the efficiency in sorting a file?Ans: The issues arei) Length of time required by the programmer in coding a particular sorting programii) Amount of machine time necessary for running the particular programiii) the amount of space necessary for the particular program.142. Calculate the efficiency of sequential search?

    Ans: The number of comparisons depends on where the record with the argument key appears in thetableIf it appears at first position then one comparisonIf it appears at last position then n comparisonsAverage=(n+1)/2 comparisonsUnsuccessful search n comparisonsNumber of comparisons in any case is O (n).143. Parenthesis is never required in Postfix or Prefix expressions, why?Ans: Parenthesis is not required because the order of the operators in the postfix /prefix expressionsdetermines the actual order of operations in evaluating the expression.144. List out the areas in which data structures are applied extensively?Ans: Compiler Design, Operating System, Database Management System, Statistical analysis package,

    Numerical Analysis, Graphics, Artificial Intelligence, Simulation .

    145. What are the major data structures used in the following areas: network data model &Hierarchical data model.Ans:RDBMS Array (i.e. Array of structures)Network data model GraphHierarchical data model Trees146. If you are using C language to implement the heterogeneous linked list, what pointertype willyou use?

  • 8/10/2019 CDS & OOP Viva

    11/16

    Ans: The heterogeneous linked list contains different data types in its nodes and we need a link, pointerto connect them. It is not possible to use ordinary pointers for this. So we go for void pointer. Voidpointer is capable of storing pointer to any type as it is a generic pointer type.147. Minimum number of queues needed to implement the priority queue?Ans: Two. One queue is used for actual storing of data and another for storing priorities.148. What is the data structures used to perform recursion?Ans: Stack. Because of its LIFO (Last In First Out) property it remembers its caller so knows wh om toreturn when the function has to return. Recursion makes use of system stack for storing the return

    addresses of the function calls.Every recursive function has its equivalent iterative (non-recursive) function. Even when such equivalentiterative procedures are written, explicit stack is to be used.149 . What are the notations used in Evaluation of Arithmetic Expressions using prefix and postfix forms?Ans: Polish and Reverse Polish notations.150. Convert the expression ((A + B) * C (D E) ^ (F + G)) to equivalent Prefix and Postfixnotations.Ans: Prefix Notation:^ * +ABC DE + FGPostfix Notation:AB + C * DE FG + ^151. Sorting is not possible by using which of the following methods?(a) Insertion(b) Selection(c) Exchange(d) DeletionAns: (d) Deletion .Using insertion we can perform insertion sort, using selection we can perform selection sort, usingexchange we can perform the bubble sort (and other similar sorting methods). But no sorting methodcan be done just using deletion.152. List out few of the Application of tree data-structure?Ans:The manipulation of Arithmetic expression,Symbol Table construction,Syntax analysis.

    153. List out few of the applications that make use of Multilinked Structures?Ans: Sparse matrix, Index generation.154 . in tree construction which is the suitable efficient data structure?(A) Array (b) Linked list (c) Stack (d) Queue (e) noneAns: (b) Linked list155. What is the type of the algorithm used in solving the 8 Queens problem?Ans: Backtracking156. In an AVL tree, at what condition the balancing is to be done?Ans: If the pivotal value (or the Height factor) is greater than 1 or less than 1.157. There are 8, 15, 13, 14 nodes were there in 4 different trees. Which of them could haveformed afull binary tree?Ans: 15In general:There are 2n-1 nodes in a full binary tree.By the method of elimination:Full binary trees contain odd number of nodes. So there cannot be full binary trees with 8 or 14 nodes,so rejected. With 13 nodes you can form a complete binary tree but not a full binary tree. So the correctanswer is 15.Note: Full and Complete binary trees are different. All full binary trees are complete binary trees but notvice versa.

  • 8/10/2019 CDS & OOP Viva

    12/16

    158. In RDBMS, what is the efficient data structure used in the internal storagerepresentation?Ans: B+ tree. Because in B+ tree, all the data is stored only in leaf nodes, that makes searching easier.This corresponds to the records that shallbe stored in leaf nodes.159. What is a spanning Tree?Ans: A spanning tree is a tree associated with a network. All the nodes of the graph appear on the treeonce. A minimum spanning tree is a spanning tree organized so that the total edge weight betweennodes is minimized.160. Does the minimum spanning tree of a graph give the shortest distance between any 2specifiednodes?Ans: No.Minimal spanning tree assures that the total weight of the tree is kept at its minimum. But it doesnt mean that the distance between any two nodes involved in the minimum-spanning tree is minimum.161. What are the memory allocation functions in C?Ans:Malloc: Allocates required size of bytes and returns a pointer to the first byte of the allocated space.Calloc: Allocates space for an array of elements, initializes them to zero and then returns a pointer tothe memory.free: Frees previously allocated space.

    Realloc: M odifies the size of previously allocated space.162. Local variables are stored in Stack area.163. The free memory region is called the HEAP.164. Malloc() returns a pointer.165. What is the general form/syntax of malloc?Ans: ptr=(cast-type*)malloc(byte-size);166. What is the general form/syntax of calloc?Ans: ptr=(cast-type*)malloc(n, elem-size);167. What is the use of free() function?Ans: It is used to release a block of memory which was earlier used to store some data.168. What is a node?Ans: A node is an abstract basic unit used to build linked data structures such as trees, linked lists.169. What does a node contain?Ans: A node contains two fields, one containing the item and the other containing the address of thenext item.170. What is self referential structure?Ans: A structure which contains a member field that points to the same structure type is called selfreferential structure.Ex: struct node{Int item;Struct node *next;};171. What are the advantages of Linked List?Ans: A linked list is a dynamic data structure and therefore the size of the linked list can grow or shrink insize during execution of the program.A linked list does not require any extra space therefore it does not waste extra memory.It provides flexibility in rearranging the items efficiently.172. What are the types of Linked Lists?Ans: There are different kinds of linked lists they are:Linear singly linked listCircular singly linked listTwo way or doubly linked list

  • 8/10/2019 CDS & OOP Viva

    13/16

    Circular doubly linked list.

    173. What is singly linked list?Ans: The singly-linked list is the most basic of all the linked data structures. A singly-linked list is simply asequence of dynamically allocated objects, each of which refers to its successor in the list.174. What is doubly linked list?Ans: A doubly linked list, also known as two-way linked list, consists of data as well as links to the next

    item, as well as the previous item. In DLL each item has two links or pointers: one link points to the nextitem in the list, whereas the second link points back to the previous item in the list.175. What are the operations of double linked list?Ans:Inserting an itemDeleting an itemDisplaying all the items in the listSearching for an item in the list176. What does the right link of the last node in a doubly linked list point to?Ans: It points to a null value.177. A linked list is a dynamic data structure. True or false?178. What does the left link of the first node in a doubly linked list point to?

    Ans:It points to a null value.

    179. What is circular double linked list?Ans: A circular, doubly-linked list is a circular list is formed by making use of variables which wouldotherwise be null: The last element of the list is made the predecessor of the first element; the firstelement, the successor of the last.180. What are the applications of linked list?Ans: 1.Sparse matrix representation2. Polynomial manipulation3. Dyanamic memory storage4. in symbol table181. What is a tree?Ans: A tree consists of one or more nodes (vertex) which are connected by branches (edges). Each nodecan have key and associated information.182. What is Binary tree?Ans: A Binary tree is a tree in which each node can have atmost two children, left and right child.183. What is the order of binary tree?Ans: Two184. What is Full Binary tree?Ans: A full Binary tree is a Binary tree in which all the leaf nodes are terminated at the same level and allthe non leaf nodes should have exactly two children.

    185. What is complete Binary tree?Ans:1. A complete Binary tree is a binary tree in which all the leaf nodes be on level n or n-12. Every node on level 1 to n-1 should have exactly two children.3. A right child should not be added before adding left child.186. What are the different Binary tree traversal methods?Ans: In-order tree traversal, Pre-order tree traversal and post order tree traversal.187. What is In-order tree traversal?Ans: In this type, the left sub-tree is traversed first, followed by the root, and finally by the right subtree.188. What is Pre-order tree traversal?Ans: In this traversal, the root is visited first, followed by the left sub-tree, followed by the right subtree.189. What is Post-order tree traversal?Ans: In this traversal, the left sub-tree is traversed first, followed by the right sub-tree, followed by the

  • 8/10/2019 CDS & OOP Viva

    14/16

    node.190. What is a graph?Ans: A graph is a set of nodes (also known as vertices ) and a set of arcs (also known as edges ).191. What is sorting?Ans: Sorting means rearranging a given list of elements in an orderly manner.192. Mention the different types of sorting techniques.Ans:1. Bubble sort 4. Merge sort2. Insertion sort 5. Quick sort3. Selection sort 6. Heap sort etc..193. Quick sort employees Divide and conquer technique.194. Briefly explain Bubble sort.Ans: This method takes two elements at a time. It compares these two elements. If the first element isless than the second element, then they are left undisturbed. If the first element is greater than thesecond element, they are swapped. This procedure continues with the next two elements, goes on andends when all the elements are sorted.195. What is the order of bubble sort?Ans: O (n2)196. What is the average case of quick sort is?Ans: O (nlogn)

    197. Briefly explain Selection sort.Ans: In this, the first element in the list is selected. It is compared repeatedly with all the elements. Ifany element is found to be lesser than the selected element, these two are swapped. This procedure isrepeated till the entire array is sorted.198. What is the best case performance of selection sort?Ans: O(n 2)199. What is merge sort?Ans: The merge sort technique sorts a given set if values by combining two sorted arrays into one largersorted array.200. What is binary search?Ans: Search a sorted array by repeatedly dividing the search interval in half. Begin with an intervalcovering the whole array. If the value of the search key is less than the item in the middle of theinterval, narrow the interval to the lower half. Otherwise narrow it to the upper half. Repeatedly checkuntil the value is found or the interval is empty.

    Java

    Class : A template for an object, which contains variables and methods

    representing behavior and attributes. Classes can inherit variables and methodsfrom other classes.

    Object : A concrete instance of some class. Multiple objects that are instances ofthe same class have access to the same methods, but often have different values fortheir instance variables.

    I nstance : The same thing as an object; each object is an instance of some class.

  • 8/10/2019 CDS & OOP Viva

    15/16

    Superclass : A class further up in the inheritance hierarchy than its child, thesubclass.

    Subclass : A class lower in the inheritance hierarchy than its parent, the superclass.When you create a new class, thats often called subclassing .

    I nstance method : A method defined in a class, which operates on an instance ofthat class. Instance methods are usually called just methods .

    Class method : A method defined in a class, which can operate on the class itself oron any object.

    I nstance var iable : A variable that is owned by an individual instance and whosevalue is stored in the instance.

    Class vari able : A variable that is owned by the class and all its instances as awhole, and is stored in the class.

    Interface : A collection of abstract behavior specifications that individual classescan then implement.

    Package : A collection of classes and interfaces. Classes from packages other than java.lang must be explicitly imported or referred to by full package name.

    How can u difference between Process and Thread??

    For an instance let us consider a word documentation, here typing something inworkspace is a process where Spell check is runs background, the spell check atbackground is the Thread.

    # A PROCESS can have multiple Threads in it.

    # When main() method is called a thread known as main thread is created toexecute program.

    # Processor is like KING. OS is minister i.e it is the OS which schedules thethreads to be processed by the Processor. So the scheduling behavior isdependent on the OS.

  • 8/10/2019 CDS & OOP Viva

    16/16

    # JVM contain Thread Scheduler