CPDS Viva Questions
CPDS Viva Questions
CPDS Viva Questions
com
CDS Questions
1. 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 as boxes 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 program Creating the program Compiling the program Linking the program with functions that are needed from C Library Running 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 programming? Ans: Header files are used to have declarations. It is simple to include a single header file than writing all the needed functions prototypes. 8. What is the Structure of a C Program? Ans: Documentation Section, Linking Section, Definition Section, Global declaration Section, main function, 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 is replaced 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 of
function. The disadvantage of it is here the entire code is substituted so the program becomes lengthy if a macro is called several times.
www.jntuworld.com
www.jntuworld.com
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 Constants 16. 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 enum 20. 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 23. What are Relational Operators? Ans: <, <=, >, >=, ==, != 24. What are Logical Operators? Ans: && meaning (logical AND), || meaning (logical OR) and ! meaning (logical NOT) 25. What are the special operators in C? Ans: comma operator, sizeof operator, pointer operators (& and *) and member selection operators (. and ->) 26. What is sizeof operator? Ans: It returns the number of bytes the operand occupies. 27. What is type casting? Ans: converting a variable of one type to another type. 28. What is the abbreviation of stdio.h? Ans: standard input-output header file. 29. what is the format specifier for integer? Ans: %d
www.jntuworld.com
www.jntuworld.com
30. %x is a format specifier for hexadecimal integer. 31. %o is a format specifier for Octal integer. 32 What are control or decision making statements? Ans: if, switch, conditional operator and goto statements. 33. Syntax of conditional operator? Ans: condition? result1: result2. If the condition is true, result1 is returned else result2 is returned. 34. What is goto statement? Ans: The goto statement is used for unconditional jump from one part of the program to another part of the program. 35. What is the difference between while and do-while? Ans: In case of while loop, the condition is first checked and then the loop is executed. In case of do-while, the loop is first executed and then the condition is checked. Here in do-while the loop is executed atleast once irrespective of the condition. 36. Incase of for() loop, initialization is mandatory. True or false? Ans: False. 37. Incase of for() loop, test-condition is mandatory. True or false? Ans: True. 38. What is an array? Ans: An array is a group of related data items that share a common name. 39: How do you declare an array? Ans: type variable-name[size]; 40. How do you initialize an array? Ans: static type array-name [size]={list of values} 41. How do you declare an array? Ans: type variable-name[row_size][column_size]; 42. What is a string in C? Ans: A string is a collection of character variables. 43. What are the string handling functions in C? Ans: strcat()concatenates two strings, strcmp() compares two strings, strcpy() copies one string over another, strlen() finds the length of the string. 44. What are the examples of library functions in C? Ans: printf() and scanf()
www.jntuworld.com
www.jntuworld.com
45. What is <ctype.h > used for? Ans: Character testing and conversion functions 46. What does <stdio.h> contain? Ans: It contains standard I/O library functions. 47. What does <stdlib.h> contain? Ans: It contains Utility functions such as string conversion routines, memory allocation routines, random number 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 the statement 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 to the beginning of the loop. 58. What is the difference between Break and Continue in C? Ans: break statement is used to break any type of loop such as while, do while and for loop. Break statement terminates the loop body immediately. Continue statement is used to break current iteration. After continue 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.
www.jntuworld.com
www.jntuworld.com
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 to empty 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 of time 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 of the program. 67. What is difference between call by value and call by reference in Ans: In call by value the value to function interchange is passed by value. And in call by
reference 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 variables used by the program / application are auto variables, being the main memory is faster. These variables are stored in the memory runtime stack. 69. List out differences between arrays and linked list Ans: 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 in the 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 for modifying 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 added and deleted from the list.
www.jntuworld.com
www.jntuworld.com
70. Explain the term enumerations in C Ans: A set of named integer constants is known as an enumeration. The enumeration type declaration includes 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 variables 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,not function 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 as dynamic 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 two argument function malloc() 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 always starts 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
www.jntuworld.com
www.jntuworld.com
\0 character. - The length of an array is to specified in [] at the time of declaration (except char[]). The length of the string is the number of characters + one (null character). 80. Difference between array and pointer? Ans: Array 1- Array allocates space automatically 2- It cannot be resized 3- It cannot be reassigned 4- sizeof (arrayname) gives the number of bytes occupied by the array. Pointer 1-Explicitly assigned to point to an allocated space. 2-It can be sized using realloc() 3-pointer can be reassigned. 4-sizeof (p) returns the number of bytes used to store the pointer variable p 81. What will be printed as the result of the operation below: main() { int x=10, y=15; x = x++; y = ++y; printf(%d %d\n,x,y); } Ans: 11, 16 82. What will be the result of the following code? #define TRUE 0 // some code while(TRUE) { // some code } Ans: This will not go into the loop as TRUE is defined as 0 83. What are the uses of a pointer? Ans: Pointer is used in the following cases i) It is used to access array elements ii) It is used for dynamic memory allocation. iii) It is used in Call by reference iv) It is used in data structures like trees, graph, linked list etc. 84. What is a structure? Ans: Structure constitutes a super data type which represents several different data types in a single unit. A structure can be initialized if it is static or global. 85. What is a union? Ans: Union is a collection of heterogeneous data type but it uses efficient memory utilization technique
www.jntuworld.com
www.jntuworld.com
by allocating enough memory to hold the largest member. Here a single area of memory contains values of different types at different time. A union can never be initialized. 86. What are the differences between structures and union? Ans: A structure variable contains each of the named members, and its size is large enough to hold all the members. Structure elements are of same size. A union contains one of the named members at a given time and is large enough to hold the largest member. Union element can be of different sizes. 87. What are the differences between structures and arrays? Ans: Structure is a collection of heterogeneous data type but array is a collection of homogeneous data types. Array 1-It is a collection of data items of same data type. 2-It has declaration only 3-.There is no keyword. 4- array name represent the address of the starting element. Structure 1-It is a collection of data items of different data type. 2- It has declaration and definition 3- keyword struct is used 4-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 is completely 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 of iterations 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 the largest 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 array of 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
www.jntuworld.com
www.jntuworld.com
model all pointers to data are 32bits long. If we use small data model(tiny, small, medium) the above address wont work since in these model each pointer is 16bits long. If we are working in a small data model and want to access the address B0008000 then we use far pointer. Far pointer is always treated as a 32bit pointer and contains a segment address and offset address both of 16bits each. Thus the address is represented using segment: offset format B000h:8000h. For any given 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/code from where segment begins. 94. What is a huge pointer? Ans: Huge pointer is 32bit long containing segment address and offset address. Huge pointers are normalized 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 than any 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 a segment can start every 16bytes so the offset will have a value from 0 to F. for normalization convert the 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 the pointer is pointing to code) or current contents of DS (data segment) register (if the pointer is pointing to data) for the segment part, the offset part is stored in a 16 bit near pointer. Using near pointer limits the 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 back again 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? 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 is invoked with and v in argv(argument vector) is a pointer to an array of character string that contain the arguments.
www.jntuworld.com
www.jntuworld.com
102. Difference between syntax vs logical error? Ans: Syntax Error 1-These involves validation of syntax of language. 2-compiler prints diagnostic message. Logical Error 1-logical error are caused by an incorrect algorithm or by a statement mistyped in such a way that 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 any expression 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 of information .It is not a data type. 105. What are the types of file? Ans: Files are of two types 1-high level files (stream oriented files) :These files are accessed using library functions 2-low level files(system oriented files) :These files are accessed using system calls 106. 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 to the 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 pointers 1- Declaration is: data_type *array_name[size]; 2-Size represents the row size. 3- The space for columns may be dynamically Pointers to an array 1-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.
www.jntuworld.com
www.jntuworld.com
111. What is a Data structure? Ans: Data structure is a collection of organized data that are related to each other. Data structures can be 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. 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 refer to 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 parts 1) Values definition 2) Operation definition Example:-The value definition for the ADT RATIONAL states that RATIONAL value consists of two integers, 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 a Last in First out (LIFO) structure because the data item is inserted into the stack is the first data item to be deleted from the stack. 117. What is the difference between a Stack and an Array? Ans: STACK i) Stack is a ordered collection of items ii) Stack is a dynamic object whose size is constantly changing as items are pushed and popped . iii) Stack may contain different data types iv) Stack is declared as a structure containing an array to hold the element of the stack, and an integer to indicate the current stack top within the array. ARRAY i) Array is an ordered collection of items ii) Array is a static object i.e. no of item is fixed and is assigned by the declaration of the array iii) 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.
www.jntuworld.com
www.jntuworld.com
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 recursive definition. 121. What is sequential search? Ans: In sequential search each item in the array is compared with the item being searched until a match occurs. 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 called i) arguments are passed ii) local variables are allocated and initialized ii) transferring control to the function. 123. What actions are performed when a function returns? Ans: i) Return address is retrieved ii) Functions data area is freed iii) Branch is taken to the return address. 124. What is a linked list? Ans: A linked list is a linear collection of data elements, called nodes, where the linear order is given by pointers. Each node has two parts first part contain the information of the element second part contains the 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 are i) unlike linked list it is expensive to insert and delete elements in the array ii) One cant double or triple the size of array as it occupies block of memory space. In linked list i) each element in list contains a field, called a link or pointer which contains the address of the next element ii) 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 indexing the middle element in the list. This is the drawback in using linked list as a data structure.
www.jntuworld.com
www.jntuworld.com
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 the free 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 time consuming. 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. free storage 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 or alphabetic). Determines the result of its basic operation. It is of two types i) 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 an array. 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 is freed but the value of p(address) remain unchanged .so the object at that address may be used as the value 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. 136. What are the disadvantages of linear list? Ans: i) We cannot reach any of the nodes that precede node (p)
www.jntuworld.com
www.jntuworld.com
ii) If a list is traversed, the external pointer to the list must be persevered in order to reference the list again 137. 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 node contain 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 parts i) An info field that contains the information stored in the node ii) Left field that contain pointer to node on left side iii) 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 to sort the file. Thus it depends on situation. 141. What are the issues that hamper the efficiency in sorting a file? Ans: The issues are i) Length of time required by the programmer in coding a particular sorting program ii) Amount of machine time necessary for running the particular program iii) 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 the table If it appears at first position then one comparison If it appears at last position then n comparisons Average=(n+1)/2 comparisons Unsuccessful search n comparisons Number 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 expressions determines 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.
www.jntuworld.com
www.jntuworld.com
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 Graph Hierarchical data model Trees 146. If you are using C language to implement the heterogeneous linked list, what pointer type will you use? Ans: The heterogeneous linked list contains different data types in its nodes and we need a link, pointer to connect them. It is not possible to use ordinary pointers for this. So we go for void pointer. Void pointer 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 whom to return 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 equivalent iterative 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 Postfix notations. Ans: Prefix Notation: ^ * +ABC DE + FG Postfix Notation: AB + C * DE FG + ^ 151. Sorting is not possible by using which of the following methods? (a) Insertion (b) Selection (c) Exchange (d) Deletion Ans: (d) Deletion. Using insertion we can perform insertion sort, using selection we can perform selection sort, using exchange we can perform the bubble sort (and other similar sorting methods). But no sorting method can 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.
www.jntuworld.com
www.jntuworld.com
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) none Ans: (b) Linked list 155. What is the type of the algorithm used in solving the 8 Queens problem? Ans: Backtracking 156. 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 have formed a full binary tree? Ans: 15 In 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 correct answer is 15. Note: Full and Complete binary trees are different. All full binary trees are complete binary trees but not vice versa. 158. In RDBMS, what is the efficient data structure used in the internal storage representation? 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 shall be 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 tree once. A minimum spanning tree is a spanning tree organized so that the total edge weight between nodes is minimized. 160. Does the minimum spanning tree of a graph give the shortest distance between any 2 specified nodes? 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 to the memory. free: Frees previously allocated space.
www.jntuworld.com
www.jntuworld.com
Realloc: Modifies 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 the next item. 170. What is self referential structure? Ans: A structure which contains a member field that points to the same structure type is called self referential 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 in size 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 list Circular singly linked list Two way or doubly linked list Circular doubly linked list.
www.jntuworld.com
www.jntuworld.com
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 a sequence 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 next item 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 item Deleting an item Displaying all the items in the list Searching for an item in the list 176. 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 would otherwise be null: The last element of the list is made the predecessor of the first element; the first element, the successor of the last. 180. What are the applications of linked list? Ans: 1.Sparse matrix representation 2. Polynomial manipulation 3. Dyanamic memory storage 4. in symbol table 181. What is a tree? Ans: A tree consists of one or more nodes (vertex) which are connected by branches (edges). Each node can 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: Two 184. 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 all the non leaf nodes should have exactly two children.
www.jntuworld.com
www.jntuworld.com
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-1 2. 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 sub tree. 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 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 sort 2. Insertion sort 5. Quick sort 3. 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 is less than the second element, then they are left undisturbed. If the first element is greater than the second element, they are swapped. This procedure continues with the next two elements, goes on and ends 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)
www.jntuworld.com
www.jntuworld.com
197. Briefly explain Selection sort. Ans: In this, the first element in the list is selected. It is compared repeatedly with all the elements. If any element is found to be lesser than the selected element, these two are swapped. This procedure is repeated till the entire array is sorted. 198. What is the best case performance of selection sort? Ans: O(n2) 199. What is merge sort? Ans: The merge sort technique sorts a given set if values by combining two sorted arrays into one larger sorted array. 200. What is binary search? Ans: Search a sorted array by repeatedly dividing the search interval in half. Begin with an interval covering the whole array. If the value of the search key is less than the item in the middle of the interval, narrow the interval to the lower half. Otherwise narrow it to the upper half. Repeatedly check until the value is found or the interval is empty.
www.jntuworld.com