Data Structure

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

Shriram Mantri Vidyanidhi Info Tech Academy

Data structure Question Bank


1. In recursion which data structure is used:
a. Stack b. Linked List c. Tree d. Array

2. A binary tree whose every node has either zero or two children is called:
a. Extended Binary Tree b. Binary Search Tree
c. None of the Above d. Complete Binary Tree

3. Which one is the simplest data structure:


a. Linked List b. Array c. Tree d. Strut

4. Linked lists are not used in:


a. Linker b. OS c. None of these d. Compiler

5. The inorder and preorder traversal of a binary tree are a b c a f c e g and a b d e c f g,Respectively.The postorder
traversal of the binary tree is :
a. e d b g f c a b. e d b f c a
c. d e b f g c a d. d e f b c a

6. What is the output of the following?


#include<iostream>
using namespace std;
int main ()
{
int i;
char*art [] = {“C”,”C++”,”JAVA”,”VBA”};
char *(*ptr)[4] = &arr;
char<<++ (*ptr) [2];
return 0;
}
a. C++ b. ava c. compile time error d. java

7. The initial configuration of the queue is a, b, c, d (a is the front end).To get the configuration d, c, b, a one needs a
minimum of?
a. 2 deletions and 3 additions
b. 3 deletions and 4 additions
c. 3 deletions and 3 additions
d. 3 deletions and 2 additions

8. What is the running time of the following code fragment?


for (int i=0; i<10; i++)
for (int j=0; j<N; J++)
for (int k=N-2; k<N+2; K++)
cout<<in<<” ”<<j<<end
a. O (N^2) b. O (N) c. O (N log N) d. O (log N)

9. The way a card game player arranges his cards as he picks them up one by one, is an example of
a. bubble sort b. merge sort c. insertion sort d. selection sort

10. What is the expected time required to search for a value in a binary search tree containing n nodes? (You should
make reasonable assumptions about the structure of the tree.)
a. O(1) b. O(n log n) c. O(log n) d. O(n)

11. A class template in C++ has the following structure


1
Shriram Mantri Vidyanidhi Info Tech Academy
Data structure Question Bank
template <class T> class TemplatedClass {

};
What is the meaning of T in the above program?
a. It is a placeholder for a type name
b. It is a string variable
c. It is a placeholder for a pointer value
d. It must be an integer constant

12. Consider the following C declaration


struct{
short s[5]
union{
float y;
long z;
}u;
}t:
Assume the objects of type short, float and long occupy 2 byte, 4 byte and 8 byte respectively. The memory
requirement for variable t ignoring alignment considerations is
a. 14 byte b. 10byte c. 18byte d. 22 byte

13. The balance factor for an AVL tree are:


a. 1, 2 or 3 b. 0, 1 or 2 c. 0, 1, or -1 d. All of these

14. Which is not a sorting technique:


a. Quick sort b. Radix sort c. Merge sort d. Poll sort

15. What is the infix version of the following postfix expression? X12+z17Y +42*/+
a. x+12+z)/ (17+Y*42) b. x+12+z/17+y*42
c. x+12+z/ (17+y)*42 d. x+12+z ((17+y)*42

16. Suppose we have the following class whose underlying data structure is a linked list of of List nodes.
class List{
public:
//other public functions
~List();
private:
struct Listnode{
int item;
List node *next;
};
ListNode*head;
};
Which of the following sequence of code could be used in the destructor~List () to correctly delete all of the nodes in
the list? (Which ones are legal, even if the style is atrocious?)

I.for(ListNode*n=head;head!=NULL;head=n){
n=head->next;
delete head;
}

II.for (ListNode *n=head;n!=NULL;n->next){


delete n;
2
Shriram Mantri Vidyanidhi Info Tech Academy
Data structure Question Bank
}

III.ListNode*n;
while(head!=NULL){
n=head->next;
delete head;

head=n;
}

a. II and III only


b. I and II only
c. I and III only
d. III only

17. Which of the following operators cannot be overloaded?


a. == b. :: c. = d. ->

18. The postfix equivalent of the infix 4 $2*3-3+8/4(1+1)is


a. 42$33*-84/11+/+ b. 42$3*3-8/411+/+
c. 42$3*3-84/11+/+ d. 42$3*3-84/11++/

19. What is the output of the following program?


#include <iostream>
int main()
{
char arr[20];
int I;
for(i=0;i<10;i++)
*(arr+i)=65+I;
*(arr+i)=’\0’;
cout<<arr;
return(0);
}
a. ABCDEFGHIJ b. None of these
c. AAAAAAAAAA d. JJJJJJJJJJ

20. Find the output of the following program?


Main ()
{
int x=20, y=35;
x=y+++x;
cout<<x<<y;
}
a. 55, 90 b. 57, 92 c. 56, 91 d. 57, 94

21. The recurrence relation that arises in relation with the complexity of binary search is
a. T(n)=T(n/2)+k, where k is constant
b. T(n)=2T(n/2)+k, where k is constant
c. T(n)=T(n/2)+log(n)
d. T(n)=T(n/2)+n

22. The running time T(n), where `n' is the input size of a recursive algorithm is given as followsT(n)=c+T(n-1),if n>1
3
Shriram Mantri Vidyanidhi Info Tech Academy
Data structure Question Bank
d, if n≤ 1
The order of this algorithm is
a. n2 b. n c. n3 d. nn

23. The concept of order(Big O) is important because


a. it can be used to decide the best algorithm that solves a given problem
b. It determines the minimum size of a problem that can be solved in a given system, in a given amount of time
c. It is the lower bound of the growth rate of the algorithm
d. It is the average bound of the growth rate of the algorithm
24. The order of the algorithm that finds a given Boolean function of `n' variables , produces a is
a. constant b. linear c. non-linear d. exponential

If n=16, then the value of O(n log n) is


a.16 b.32 c.64 d.128

25. All memory management functions are found in


a.stdlib.c b.stdio.h c.conio.h d.math.h

26. The syntax of free() function


a.void free(void* free) b.int free(void* ptr) c.float free(void* ptr) d.void free(ptr)

27. Which of the memory function allocates a block of memory


a.malloc ( ) b.calloc( ) c.release( ) d.free( )

28. Which of the following is not a standard file stream?


a.stdin b.stderr c.stdfile d.stdout

29. The linked list structure is defined as Rohith


a.struct node
{
int item;
struct node *next;
};
b. node
{
int item;
struct node *next;
};
c.struct node
{
int item;
node *node;
};
d. node
{
Int item;
node next;
};

30. Each item in the list contains a �link� to structure containing the _ _ _ _ _ _ _ item
a.previous b.next c.present d.last

31. A list refers to a set of items organized _ _ _ _ _


4
Shriram Mantri Vidyanidhi Info Tech Academy
Data structure Question Bank
a.sequentially b. exponentially c.non-sequentially d. factorially

32. Each structure of a linked list consists _ _ _ _ _ _ _ no. of fields


a.2 b. 3 c.4 d. 1

33. Linked lists are not suitable for data structures of which one of the following problem?
a.insertion sort b.Binary search c.radix sort d.polynomial manipulation problem

34. An item that is read as input can be either pushed to a stack and latter popped and printed, or printed directly.
Which of the following will be the output if the input is the sequence of items-1,2,3,4,5?
a.3,4,5,1,2 b.3,4,5,2,1 c.1,5,2,3,4 d.5,4,3,1,2

35. Stack is useful for _ _ _ _ _ _ _


a.radix sort b.breadth first search c.recursion d.quick sort

36. LIFO is
a.stack b. queue c.linked list d. tree

37. Which of the following programming languages features require a stack-base allocation
a.pointer b.Block-structure c.recursion d.dynamic scoping

38. Stack is useful for implementing


a.radix sort b.breadth first search c.selection sort d.depth first search

39. Which of the following is essential for converting an infix expression to postfix form efficiently?
a.An operator stack b. An operand stack c.An operator stack and an operand stack d. A parse tree

40. A queue of characters currently contained a,b,c,d. What would be the contents of queue after the following
operationDELETE, ADD W, ADD X, DELETE, ADD Y
a.A,B,C,W,Y b.C,D,W,X,Y c.W,Y,X,C,D d.A,B,C,D,W

41. A circular queue of size N will sign queue full when the number of elements in the queue is
a.N-1 b. N c.N+1 d. N-2

42. The postfix expression for the infix expressionA + B* (C+D) / F + D*E is:
a.AB + CD + F / D + E* b.ABCD + * F / + DE* c.A*B + CD / F*DE ++ d.A+ BCD / F* DE ++

43. The performance of an algorithm is specified by the following notation that represents the worst case
a.O-notation b. Omega notation c.Theta notation d. alpha-notation

44. The equivalent of (a+b↑c↑d)*(e+f/d) in the post fix notation is


a.ab+c↑d↑e &fd/ b.abcd↑+↑efd/+* c.abcdefd/+*↑↑+ d.abcd↑↑+efd/+*

45. Suffix expression is


a.Infix b.postfix c.prefix d.post & prefix

46. polish expression is


a.infix b. postfix c.prefix d. post & prefix

47. To insert a node at the end of the doubly linked list _ _ _ _ _ _ _ no. of pointers to be manipulated
a.1 b.2 c.3 d.4

48. To delete an item in the middle of a circular doubly linked list, _ _ _ _ _ _ _ _ no.of points to be manipulated
5
Shriram Mantri Vidyanidhi Info Tech Academy
Data structure Question Bank
a.2 b.4 c.6 d.8

49. If storage class is missing in the array definition, by default it will be taken to be
a.automatic b.external c.static d.either automatic or external depending on the place of ccurrence

50. A sorting technique is called stable if:


a.it takes O ( n log n) time
b.It maintains the relative order of occurrence of non-distinct elements
c.It uses divide and conquer paradigm
d.The maximum number of nodes in a binary tree of height h is (2-1)(The height of the root is reckoned as 0)

51. The maximum number of comparisons needed to sort 7 items using radix sort is (assume each item is a 4 digit
decimal number)
a.280 b. 40 c.47 d. 38

52. You are asked 15 randomly generated numbers. You should prefer
a.bubble sort b. quick sort c.merge sort d. heap sort

53. The time required to search an element in a binary search tree having n elements is
a.O(1) b.O(log2 n) c.O(n) d.O(n log2 n)

54. A binary tree T has n leaf nodes. The number of nodes of degree 2 in T is
a.log2 n b.n-1 c.n d.2n

55. A tree, for which at every node the height of its left sub tree and right sub tree differ at most by one is a/an
a.Binary search tree b.AVL tree c.Complete binary tree d.Threaded binary tree

56. Which of the following sorting algorithms does not have a worst case running time complexity of O(n2)?
a.Insertion sort b.Merge sort c.Quick sort d.Bubble sort

57. Which of the following is not a correct statement


a.internal sorting is used if the number of items to be sorted is very large
b.External sorting is used if the number of items to be sorted is very large
c.External sorting needs auxiliary storage
d.Internal sorting needs auxiliary storage

58. There are 4 different algorithms A1,A2,A3,A4 to solve a given problem with the order
log(n),log(log(n)),nlog(n),n/log(n) respectively. Which is the best algorithm?
a.A1 b.A2 c.A3 d.A4

59. Which of the following sorting algorithm has the worst time complexity of nlog(n)?
a.Heap sort b. Quick sort c.Insertion sort d. Selection sort

60. Sorting is not useful for


a.report generation b.minimizing the storage needed
c.making searching easier and efficient d.responding to queries easily

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy