Top Banner
Model Question Paper Subject Code: BC0038 Subject Name: data structure using C Credits: 4 Marks: 140 Part A (One mark questions) 1. Which of the following data structure is used to store homogeneous data items? A) Arrays B) linked list C) Pointers D) Structure 2. A pointer variable always contains………….. A) The address of an element B) The address of first element C) values D) Address as well as value 3. Two dimensional arrays are also called…… A) table arrays B) Simple arrays C) tree D) graph
26
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: BC0038-Data Structures Using C-MQP

Model Question Paper

Subject Code: BC0038

Subject Name: data structure using C

Credits: 4 Marks: 140

Part A (One mark questions)

1. Which of the following data structure is used to store homogeneous data items?

A) Arrays

B) linked list

C) Pointers

D) Structure

2. A pointer variable always contains…………..

A) The address of an element

B) The address of first element

C) values

D) Address as well as value

3. Two dimensional arrays are also called……

A) table arrays

B) Simple arrays

C) tree

D) graph

Page 2: BC0038-Data Structures Using C-MQP

4. Which of the followings are correct way of declaring a float pointer:.

A) float ptr

B) float *ptr

C) * float ptr

D) float ptr*

5. select which of the following choice is not the advantage of pointers?

A) Pointers are pointing to different data types and structures

B) Manipulation of data at different memory locations is easier.

C) To achieve a clarity and simplicity

D) Pointers are used to store the data values

6. Which of the following is non-primitive data structure ?

A) Integer

B) character

C ) float

D) Arrays

7. Based on the concept of abstract data type (ADT), Data structure can be defined based on ………………. Fill up the blank with the correct choice..

A) Relations

B) Storage structures

Page 3: BC0038-Data Structures Using C-MQP

C) Data types

D) Language

8. Which of the following is non-linear data structure?

A) Tree

B) Using an Array and Lists as a Data Structure

C) Elementary Data Structures

D) The Array Data Structure

9. The elements of an array are stored successively in memory cells because

A. By this way computer can keep track only the address of the first element and the

Addresses of other elements can be calculated

B) the architecture of computer memory allow only to store in serial order

C) both of above

D) Accessing the inbetween elements from an array will be easy

10. Which of the following data structure allows deletion from front end and insertion at rear end?

A) Stacks

B) Queues

C) Deques

D) linked list

11. The process of assigning a value to an attribute at rhe run time is called………..

Page 4: BC0038-Data Structures Using C-MQP

A) Static binding

B) Dynamic binding

C) Static as well as dynamic binding

D) Neither static nor dynamic bindings

12. stack is also called…….

A) last in first out(LIFO)

B) .first in first out(FIFO)

C) Last in last out(LILO)

D) tree

13. Which of the following option is correct to implement the stack?

A) Using array

B) Using structure

C) Using linked list

D) Using array, structure as well as linked list

14. Recursion is the ………of the stack.

Fill up the blanks from followings.

A) operation

B) Application

C). both a and b

Page 5: BC0038-Data Structures Using C-MQP

D) Representation

15. in evaluation of postfix expression, the data structure is used…….

A) stack

B) queues

C) arrays

D).binary tree

16. which of the following principle works for queues?

A) FILO

B) LILO

C) FIFO

D) Both a and b

17. Which of the following function shows the under flow condition?

A) if ( qempty(f,r) )

B) if ( qfull(*r) )

C) void insert_rear (int item, int q[], int *r)

D) void delete_front(int q[], int *f, int *r)

18. front and rear pointer of the queue will be initialized with the…….

A) f=0 and r=-1

B ). f=-1 and r=0

C) f=0 and r=0

D) f=-1 and r=-1

Page 6: BC0038-Data Structures Using C-MQP

19. which of the following condition is going to be checked be qfull(*r)?

A) queue underflow condition

B) creation of queue

C) traversal of queue

D) queue overflow condition

20. which of the following operation can not be performed on dqueue?

A) Insert an item from front end

B) insertion and deletion can be done from anwhere in the queue

C) delete an item from rear end

D) Display the contents of queue

21. If the characters 'D', 'C', 'B', 'A' are placed in a queue (in that order), and then removed one

at a time, in what order will they be removed?

A) DCBA

B) CDAB

C) ADBC

D) DCAB

22. To simulate people waiting in a line, which data structure would be Appropriate?

A) Vector

B ) Stack

C) Queue

D) List

Page 7: BC0038-Data Structures Using C-MQP

23. linked list uses…….. Type of memory allocation

A) static

B) random

C) compile time

D) dynamic

24. ……...linked list can form a circularly-linked list?

A) single

B) double

C) both single and double

D) only a not the b

25. In circular linked list you begin at ……... and follow the list in either direction until you return

to the original node.

A) first node

B) last node

C) any node

D) both a and b

26. which of the following operation is not applicable for restricted list?

A) Insertion

B) Deletion

C) Retrieval

D) Traversal

27. In the link list each node contains……

A) Data member

B) link member

C) head information

Page 8: BC0038-Data Structures Using C-MQP

D) both a and b

28. Which of the following statement is correct to get free temporary node from the availability

list?

A) temp=getnode()

B) freenode()

C) NODE temp

D) both a and b

29. The number of branches associated with a node is called……..

A) in degree

B) out degree

C ) degree

D) all above

30. If the tree is not empty, then the first node is called as ….

A) child

B) siblings

C) root

D) Leaves

31. A connected graph without any cycles is called

A) free graph

B) forest

C) tree

Page 9: BC0038-Data Structures Using C-MQP

D) Cyclic graph

32. If the out degree of every node in a tree is either 0 or 2, then the tree is said to be

A) Strictly binary tree

B) Complete binary tree

C) Almost complete binary tree

D) Both a and b

33. In a complete binary tree, the total number of nodes at level 3 can be

A) 1

B) 2

C) 4

D) 8

34. When the edges in a graph have no direction, is called? A) Directed graph

B) Weighted graph

C) Both a and b

D) Undirected graph

35. The main data structures for the representation of graphs are used in practice………

A) An adjacency list

B) An adjacency matrix

C) Both a and b

D) Basic data types

36. The adjacency matrix uses …………

Page 10: BC0038-Data Structures Using C-MQP

A) A vector (one-dimensional array) for the vertices and a matrix (two-dimensional array) to

store the edges

B) Uses a two-dimensional ragged array to store the edges.

C) Both a and b

D) Depending on the application, it could also be implemented using doubly linked lists or

Circularly linked lists.

37. Which of the following searching algorithm always compare the middle element with the searching element in the given array A) binary tree search B) hash search

C) Linear search

D) Binary search

38. The running time for binary search tree on average is ………

A) O(log n)

B) O(nlog n)

C) O(log n+1)

D) O(n)

39. For internal sorting , sorting can take place within ………….

A. .flash memory as well as cash memory

B. .secondary devices

C. main memory

D. both b and c

Page 11: BC0038-Data Structures Using C-MQP

40. MergeSort and Quicksort are the examples of………

A. Priority queue sorting methods:

B. .Divided-and-conquer method:

C. .Other methods

D. .Insertion based sort:

Page 12: BC0038-Data Structures Using C-MQP

Part B (Two mark questions)

41. Which of the following statements allocates enough space to hold an array of 10 integers?

A) int *ptr = (int *) malloc(10, sizeof(int));

B) int *ptr = (int *) calloc(10, sizeof(int));

C) int *ptr = (int *) malloc(10*sizeof(int));

D) int *ptr = (int *) alloc(10*sizeof(int));

42. What is the difference between the two expressions? (select the correct answer)

1. int arry[6];

2. int arry[6]=11

A ) First is particular element and, second is type

B) First is array size and, second is particular element

C) First is particular element, second is array size

D) Both specify array size

43. Which of the following statement is true?

A) An array should be used to store dissimilar elements, and a structure to store similar

elements

B) In an array of structures, not only are all structures stored in contiguous memory locations,

but the elements of individual structures are also stored in contiguous locations.

C) It is not required to close the structure with semicolon.

D) Pointer to the structure is not possible

44) To represent hierarchical relationship between elements, which data structure is not

suitable?

Page 13: BC0038-Data Structures Using C-MQP

A) Deque

B) Priority

C) Tree

D) stack

45. A data structure where elements can be added or removed at either end but not in the

middle

A) Linked lists

B) Stacks

C) Queues

D) Deque

46. If the preconditions are not satisfied, which of the following is correct .

A) .it might not work properly (by chance)

B) it might return an incorrect answer

C) it might not crash.

D) Execution will have problem

47. An object of class (or struct) "node" contains………..

A) Field pointing to the next node

B). any number of fields of data

C) a field pointing to the next node, as well as any number of fields of data.

D) Only address of data value

Page 14: BC0038-Data Structures Using C-MQP

48. A hash function is a mathematical function which maps keys to…………..

A) integers

B) float

C) character

D) symbols

49. Void function(int item, int *top, int s[]) { if (*top==STACK_SIZE-1) { printf("stack overflow"); return; } s[+ +(*top)] = item; } Which of the following operation is expected from the above code? A) push

B) pop

C) display

D) traverse

50. if (top == -1) {

return -1; }

which of the following statement is true for above sample code.?

A) Overflow condition

B) Underflow condition

C) Both a and b conditions

D) Element can be inserted

Page 15: BC0038-Data Structures Using C-MQP

51. Given expression: (3+4)*(8-9) What will be the prefix expression for above given expression A) +*34-89

B) *+-3489

C) *+34-89

D) -*+3489

52. Associability of ^ and $ are………………….

A) Right associative

B) left associative

C) Both a and b

D) It does not follow any associative rule

53. In implementing a Queue using an array, a problem might arise if the Queue is implemented in such a way that items in the Queue are inserted at the next available location and removed from the next leading position, but such that, once deleted, the emptied space is unused. The problem that arises is one where there is free space still in the array, but it is not useable because it is not at the end. Which of the following will resolve the above problem? A) Double ended queue

B) Priority queue

C) both a and b

D) circular queue

Page 16: BC0038-Data Structures Using C-MQP

54. Suppose we have a circular array of size 12 of the queue, with ten items in the queue

stored at array [2] through array[11]. Where does the insert method place the new entry in

the array?

A) array[1]

B) array[0]

C) array[11]

D) array[12]

55. “What is the difference between array and linked list?” A) Array is a static data structure and linked list is a dynamic data structure

B) n terms of complexity, the linked list is usually more efficient as to the space it uses then

arrays

C) Algorithms for linked lists are usually more simple that those of the array.

D) both a and b

56. Binary tree can be implemented using………

A) Arrays

B) Double linked list

C) Both a and b

D) Single linked list

57. Which of the following is correct for breadth-first traversal of a graph

A) We process all of a vertex's descendents before we move to an adjacent vertex.

B) we move to an adjacent vertex with out any process

Page 17: BC0038-Data Structures Using C-MQP

C) Both a and b

D) The process all adjacent vertices of a vertex before going to the next level

58. The binary search method needs no; more than………….comparisons. Fill the blanks

with one of the followings

A) (N + 2)/2

B) (N + 1)/2

C) [Iog n] + 1

D) [Iog2n] + 1

59. Which of the following is correct for breadth-first traversal of a graph

A) We process all of a vertex's descendents before we move to an adjacent vertex.

B) We move to an adjacent vertex with out any process

C) Both a and b

D) We process all adjacent vertices of a vertex before going to the next level

60. Bubble sort is one of the sorting techniques. Select one of the following reason why this

name is given for that

A. Smaller elements move or 'bubble' up to the top of the list, hence the name given to the algorithm.

B heavier elements move or 'bubble' up to the top of the list, hence the name given to the algorithm.

Page 18: BC0038-Data Structures Using C-MQP

C. it sort the bubbled element

D.due to a and b it is called bubble sort

Part C (Four mark questions)

61. char* myFunc (char *ptr)

{

ptr += 3;

return (ptr);

}

int main()

{

char *x, *y;

x = "HELLO";

y = myFunc (x);

printf ("y = %s \n", y);

return 0;

Page 19: BC0038-Data Structures Using C-MQP

}

Which of the following option is going to be print after the execution of above sample code?

A) y= HELLO

B) y = ELLO

C) y = LLO

D) y = LO

62. struct time

{

int hours;

int minutes;

int second;

}t;

struct time*tt;

tt=&t;

looking at the above declaration, which of the following represents the second correctly:

A) tt.seconds, B) (*tt).seconds

C). time.t D). tt->seconds

Page 20: BC0038-Data Structures Using C-MQP

63. Which of the following is property of A good hash function ?

A) is cheap to evaluate

B) Tends to use all positions from O...M with uniform frequency.

C) Tends to put similar keys in different parts of the tables

D) All the three are the properties

64. Which of the following option is correct to define an abstract data type (ADT)?

A) Operations of the interface are the one and only access mechanism to the type's data

structure.

B) .It exports a set of operations. This set is called interference.

C) Axioms and preconditions does not define the application domain of the type.

D) both a and b

65. Infix expression a – b / (c + d * e)

What will be the postfix expression for above infix expression?

A) a b c d e * + / -

B) a b c d e +* / -

C) a b c* d e + / -

D) a b +c d e * / -

66. AABC*+. Where A=2.0, B=3.0, C=1.0 . What will be the result for above postfix expression ?

A) 6.0

B) 5.0

Page 21: BC0038-Data Structures Using C-MQP

C) 4.0

D) 3.0

67. at the time of implementing the circular queue with items as strings . Which of the following function can be used? A) int qempty(int count)

B) int qfull(int count)

C) both a nad b will be used

D) push()

68. void function(int item, int q[ ], int *f, int *r)

{

if( *f= = 0 && *r = = -1)

q[++(*r)] = item;

else if ( *f ! = 0)

q[--(*f)]=item;

else

printf("Front insertion not possible\n");

}

Observe the above function and select one of the followings to tell what operation it is going to

perform?

A) Insert an item at the front end

B) Insert an item at the rear end

C) Delete an item from the rear end

D) Delete an item from front end

Page 22: BC0038-Data Structures Using C-MQP

69. State weather the following statement is true or false

1) In the doubly linked list, link field of the leftmost node and link field of rightmost node points to

NULL

2). In the circular doubly linked list, the left link of the left most node contains address of the

right most node and the right link of the right most node contains address of the left most node

3).An empty list with a header node can be represented as where the left link and right link of a

header node points to last node.

A) 1. True, 2. true, 3. true

B) 1. true, 2. false, 3. false

C) 1. false, 2. false, 3. false

D) 1. true, 2. true, 3. False

70. State weather the following statement is true or false

1. The pointer variable root can be declared and initialized as

NODE root = NULL;

2. A pointer variable root can be used to point to the root node always

3. If the tree is empty, the pointer variable root points to root indicating the tree is empty

A) 1. True, 2. true, 3. true

B) 1. true, 2. false, 3. false

C) 1. false, 2. false, 3. false

D) 1. true, 2. true, 3. False

71. Find the cost of minimum spanning tree for the graph below using both the Prim’s

Page 23: BC0038-Data Structures Using C-MQP

A) 34

B) 65

C) 76

D) 56

72. state weather the following statement is true or false

1).A spanning tree of a graph is an undirected tree

2).For any pair of nodes there exists only one path between them

3)Those edges left out of the Spanning tree that were present in the original graph does not

connect paths together in the tree.

A) true, true, true

B) false, true, false

C) true, true, false

D) false, false, false

73 . INPUT: List of size N. Target value T

OUTPUT: Position of T in the list –I

BEGIN

Set FOUND to false

Set I to 0 2.

While (I<=N) and (FOUND is false)

Page 24: BC0038-Data Structures Using C-MQP

If List [I] = T

FOUND = true

Else

I=I+1

END

If FOUND is false

T is not present in List.

END

Read the above algorithm and select one of the followings?

A) hash search

B) algorithm for a binary search tree

C) algorithm for a binary search

D) algorithm for a sequential search

74. State weather the following statement is true or false

1).The fewest possible comparisons = 1. When the required item is the first item in the list

2).The maximum comparisons = N when the required item is the last item in the list.

3) finding the average number of comparison for any algorithm is easy in comparison to others

A. 1. True, 2. true, 3. true

B. 1. true, 2. false, 3. false

C. 1. false, 2. false, 3. false

D. 1. true, 2. true, 3. false

75. state weather the following statement is true or false for Extra memory is used by sort?

1. sort in place using no extra memory except for a small stack or table

2. use a linked-list and each element requires a link pointer

3. need enough extra memory to store a copy of the array to be sorted.

Page 25: BC0038-Data Structures Using C-MQP

A. 1. false, 2. false, 3. false

B,. . 1. true, 2. false, 3. false

C . 1. true, 2. true, 3. false

D . . 1. True, 2. true, 3. true

Page 26: BC0038-Data Structures Using C-MQP

Answer Keys

Part - A Part - B Part - C

Q. No. Ans. Key Q. No. Ans. Key Q. No. Ans. Key Q. No. Ans. Key

1 A 21 A 41 C 61 D

2 A 22 C 42 B 62 D

3 A 23 D 43 B 63 D

4 B 24 C 44 A 64 A

5 D 25 C 45 D 65 A

6 D 26 D 46 D 66 B

7 B 27 D 47 C 67 C

8 A 28 A 48 A 68 A

9 A 29 C 49 A 69 D

10 b 30 C 50 B 70 D

11 B 31 C 51 C 71 D

12 A 32 A 52 A 72 C

13 D 33 D 53 D 73 D

14 B 34 D 54 B 74 D

15 A 35 C 55 D 75 D

16 C 36 A 56 B

17 A 37 D 57 D

18 A 38 A 58 D

19 D 39 C 59 D

20 B 40 B 60 A