1. If the depth of a tree is 3 levels, then what is the size of the Tree? 1. 2 2. 4 3. 6 4. 8 Answer: 4 Explanation: Formula is 2n 2. What is the time
... [Show More] complexity of adding three matrices of siz e NXN cell-by-cell? 1. O (N) 2. O (N^2) 3. O (N^3) 4. None of these Answer: 2 Explanation: Time Complexity of Adding Three Matrices because there is only two loop are needed for adding the matrix so complexity will be o(n^2), there is no effect for increase the number of matrix. 3. Vijay wants to print the Following pattern on the screen: 2 2 4 2 4 6 2 4 6 8 He writes the following program: integer i = 1, j=2 // statement 1 while ( i <= 4 ) // statement 2 { j = 2; while ( j <= ? ) // Statement 3 { print j print blank space j = j + 2 } print end-of-line \takes the cursor to the next line i = i + 1 } What is the value of ? in statement 3 :: 1. 8 2. i 3. 2*i 4. 4 Answer: 3 Explanation: n first line we want to print only 0.j=2 then the line should be equal to 2 to print only 0 in first line. So answer is 2*i. 4. Himanshu wants to write a program to print the larger of the two inputted number. He writes the following code: int number1, number 2 input number1, number 2 if ("??") // Statement 1 print number1 else print number2 end if Fill in the ?? in statement 1. 1. number1>number22. number2>number1 3. number2 equals number1 4. number1 <= number2 Answer: 1 Explanation: number 1>number 2 5. Shalini wants to programme to print the largest number out of 3 inputted numbers. She writes the following programme Int number 1, number 2, number 3, temp; Input number 1, number 2, number 3; If ( number 1 > number 2) Temp = number 1 Else Temp= number 2 End if If ( ??) // statement 1 Temp = number 3 End if Print temp Fill in the ?? in statement 1 ? Choose the correct answer? 1. Number 3> number 2 2. Number 3> temp 3. Number 3< temp 4. Number 3> number 1 Answer: 2 Explanation: number 3>temp ,after first condition checking, temp will hold the largest value, so in stmt 1 third no. will be compared with temp and if it is greater than temp will hold the largest no. 6. Rohit writes the following program which inputs a number and prints "Double digit" if the number is composed of two digits and "Not a double digit" if it is not. int number; if (number>10 AND number < 100) print "Double digit" else print "Not a double digit" end if Rohit tries the following inputs: 5 and 66. The program works fine. He asks his brother Ravi to try the program. When Ravi enters a number, the program doesn't work correctly. What did Ravi enter? 1. 8 2. 100 3. 99 4. 10 Answer: 4 Explanation: smallest two digit no. is 10.if we enter 10, condition will become false in first expression. compiler will not evaluate second expressions because in AND operation if one of the condition is false, else part will execute. 7. Rohan writes the following program which inputs a number and prints "Triple digit" if the number is composed of three digits and "Not triple digit" if it is not. int number; if (number>99) print "Triple digit" elseprint "Not triple digit" end if Rohan tries the following inputs: 25 and 566. The program works fine. He asks his brother Ravi to try the program. When Ravi enters a number, the program doesn't work correctly. What did Ravi enter? 1. 99 2. 100 3. 0 4. 1000 Answer: 4 Explanation: Because 1000 is not a triple digit number but by the following code it give 1000 as triple digit the code should be (number>99 AND number <1000) 8. In a sequential programming language, code statements are executed in which order? 1. All are executed simultaneously 2. From top to bottom 3. From bottom to top 4. None of these Answer: 2 Explanation: It‟s the default working order 9. Stuti is making a questionnaire of True-false questions. She wants to define a data-type which stores the response of the candidate for the question. What is the most-suited data type for this purpose? 1. integer 2. Boolean 3. float 4. character Answer: 2 Explanation: Bool used for true or false 10. A variable cannot be used… 1. Before it is declared 2. After it is declared 3. In the function it is declared in 4. Can always be used Answer: 1 Explanation: it‟s the rule to declare variable before to use this 11. What is implied by the argument of a function? 1. The variables passed to it when it is called 2. The value it returns on execution 3. The execution code inside it 4. Its return type Answer: 1 Explanation: max(2,3) 2 and 3 are the argument of function MAX 12. Zenab and Shashi independently write a program to find the the mass of one mole of water, which includes mass of hydrogen and oxygen. Zenab defines the variables: integer hydrogen, oxygen, water // Code A while Shashi defines the three quantities as: integer a, b, c // Code B Which is a better programming practice and why? 1. Code B is better because variable names are shorter 2. Code A is better because the variable names are understandable and non confusing 3. Code A will run correctly, while Code B will give an error.4. Code B will run correctly, while Code A will give an error. Answer: 2 Explanation: Meaning full name makes sense of understanding 13. Every element of a data structure has an address and a key associated with it. A search mechanism does with two or more values assigned to the same address by using the key. What is this search mechanism? 1. Linear search 2. Binary Search 3. Hash coded search 4. None of the above Answer 3 Explanation: Hash Coded Search uses a hash key and hash address in hash table. 14. A programmer writes a sorting algorithm that takes different amount of time to sort two different lists of equal size. What is the possible difference between the two lists? 1. All numbers in one list are more than 100 while in the other are less than 100. 2. The ordering of numbers with respect to the magnitude in the two lists has different properties. 3. One list has all negative numbers while the other has all positive numbers. 4. One list contains 0 as an element while the other does not. Answer:2 Explanation: Sorting algorithm is always based on the comparisons so the list that requires more comparisons will be slow and number of comparisons will be more for unsorted list and will be minimal for sorted list, that is ordering of numbers in same sized list will make difference 15. A sorting algorithm iteratively traverses through a list to exchange the first element with any element less than it. It then repeats with a new first element. What is this sorting algorithm called? 1. insertion sort 2. selection sort 3. heap sort 4. quick sort Answer: 2 Explanation: Selection sort searches for the minimum element in the list then replaces with the first element. 16. A sorting mechanism uses the binary tree concept such that any number in the tree is larger than all the numbers in the sub tree below it. What is this method called? 1. Selection Sort 2. Insertion Sort 3. Heap sort 4. Quick Sort Answer: 3 Explanation: The heap is often placed in an array with the layout of a complete binary tree 17. How many comparisons are needed to sort an array of length 5 if a straight selection sort is used and array is already in the opposite order? 1. 1 2. 10 3. 50 4. 20 Answer: 2 Ans: n (n-1)/2=10 18. Queues serve a major role in 1. simulation of recursion 2. simulation of arbitrary linked list3. Simulation of limited resource allocation 4. expression evaluation Answer: 3 Explanation: Simulation of limited resource allocation scheduling algorithms. 19. The average search time of hashing with linear probing will be less if the load factor 1. Is far less than one 2. equals one 3. Is far greater than one 4. N 5. one of these Answer: 1 Explanation: A critical statistic for a hash table is the load factor, that is the number of elements divided by size of hash table: Load factor where: n = number of elements k = Size of hash table As the load factor grows larger, the hash table becomes slower, and it may even fail to work (depending on the method used). 20. Number of vertices of odd degree in a graph is 1. is always even 2. always odd 3. either even or odd 4. always zero Answer: 1 Explanation: In graph theory, a branch of mathematics, the handshaking lemma is the statement that every finite undirected graph has an even number of vertices with odd degree (the number of edges touching the vertex) 21. The algorithm design technique used in the quick sort algorithm is 1. Dynamic programming 2. Back tracking 3. Divide and conquer 4. Greedy Search Answer: 3 Explanation: Quick sort is a divide and conquer algorithm. Quick sort first divides a large array into two smaller sub-arrays: the low elements and the high elements. Quick sort can then recursively sort the subarrays 22. Linked lists are not suitable for 1. Insertion sort 2. Binary search 3. Queue implementation 4. None of these Answer: 2 Explanation: For binary search, if we are using array, then we can go to middle of array by just dividing index of array by 2. Since array is stored in contiguous memory. But that is not true in case of linked list.If you want to access middle of list then each time you have to traverse from its head. Hence use of linked list is not good idea for binary search 23. A connected graph is the one which 1. Cannot be partitioned without removing an edge 2. Can be partitioned without removing an edge 3. does not contain a cycle 4. Has even number of vertices Answer: 1 Explanation: A graph is connected when there is a path between every pair of vertices. In a connected graph, there are no unreachable vertices. A graph that is not connected is disconnected. A graph with just one vertex is connected. A graph is said to be connected if there is a path between every pair of vertex 24. Stack is useful for implementing 1. radix search 2. breadth first search 3. recursion 4. none of these Answer: 3 Explanation: Stack is useful for Recursion as well as Depth first Search. 25. Which of the following is useful in traversing a given graph by breadth first search? 1. stack 2. set 3. list 4. queue Asnwer: 4 Explanation: It uses a queue instead of a stack 26. In a circular linked list organization, insertion of a record involves modification of 1. One pointer 2. Two pointers 3. Three pointers 4. No pointer Answer: 2 Explanation: Suppose we want to insert node A to which we have pointer p, after pointer q then we will Have following pointer operations 1. p->next=q->next; 2. q->next = p; So we have to do two pointer modifications 27. Which of the following is useful in implementing quick sort? 1. stack 2. set 3. list 4. queue Answer: 1 Explanation: It uses the concept of Recursion and follows stack. 28. Which of the following abstract data types can be used to represent a many to-many relation? 1. Tree 2. Stack 3. Graph 4. Queue Answer: 3 Explanation: As the following rule:graph...many to many tree.. one to many stack... one to one 29. A programmer writes a code snippet in which a set of 3 lines occurs 10 times in different parts of the program what programming concept should be used to shorten the code length? 1. For loop 2. Functions 3. Arrays 4. Classes Answer: 2 Explanation: Function is a block of code which is defined once and can be called multiple times in the program. The feature of code reusability reduced the size of program. 30. X and Y are asked to write a program to sum the rows of 2*2 matrix stored in an array A X writes the Code (code A) as follows: For n= 0 to 1 Sumrow1[n]= A[n][1]+A[n][2] End Y writes the Code (code B) as follows: Sumrow1[0]=A[0][1]+A[0][2] Sumrow1[1]=A[1][1]+A[1][2] Which of the following statement is correct about these codes if no loop unrolling is done by the compiler? 1. Code A would executes faster than Code B 2. Code B would executes faster than Code A 3. Code A is logically incorrect 4. Code B is logically incorrect Answer: 2 Explanation: First statement will take more time to check the loop condition and then execute the loop body based on that condition. 31. Which of the following is the lowest level format to which the compiler converts a program in a higher language before execution? 1. English Code 2. Machine Code 3. Assembly language 4. System language Answer: 2 Explanation: Machine code is also called the binary code which is directly understood by the compiler. So,it is the lowest level format. 32. In which of the following situations can a constructor be invoked? 1. When an object is created 2. When an object is assigned the value 0 3. Only at the end of the code. 4. When the scope of the object is over Answer: 1 Explanation: A constructor is a special member function which is called automatically when the object of class is created. 33. What is the difference between a function and a method? 1. Function is named code unlike method which is part of an object. 2. Function contained in an object is called a method. 3. Function cannot change variables outside its scope unlike method. 4. There is no difference between the two.Answer: 4 Explanation: Method is another name of function which is mostly used in OOP terminology. 34. What is implied by the argument of a function? 1. The variables passed to the function when it is called. 2. The value that the function returns on execution. 3. The execution code inside the function. 4. Return type of the function. Answer 1. Explanation: Argument specifies the number of inputs you want to pass to function body when it is called. For example, to print table of a number, we will pass one argument only in the function body because there is one input only. The function prototype is given below: void table(int); 35. Which tree(s) from the given figure is/are Heap(s)? 1. Only 1 2. Only 2 3. Only 3 4. Both 1 and 2 5. Both 1 and 3 [Show Less]