0% found this document useful (0 votes)
565 views19 pages

Unit Iii Linear Data Structures: Syllabus

This document provides a syllabus and questions for a unit on linear data structures. The syllabus covers arrays, stacks, queues, linked lists, and their implementations. Questions assess understanding of arrays, stacks, queues, linked lists and their properties such as time complexity of operations, applications, and conversions between notation forms like infix, postfix and prefix. The maximum number of concepts assessed at once is arrays, stacks and queues.

Uploaded by

Sathya Arul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
565 views19 pages

Unit Iii Linear Data Structures: Syllabus

This document provides a syllabus and questions for a unit on linear data structures. The syllabus covers arrays, stacks, queues, linked lists, and their implementations. Questions assess understanding of arrays, stacks, queues, linked lists and their properties such as time complexity of operations, applications, and conversions between notation forms like infix, postfix and prefix. The maximum number of concepts assessed at once is arrays, stacks and queues.

Uploaded by

Sathya Arul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 19

UNIT III

LINEAR DATA STRUCTURES

SYLLABUS:

Arrays and its representations – Stacks and Queues – Linked lists – Linked list-based
implementation of Stacks and Queues – Evaluation of Expressions – Linked list based
polynomial addition

1.Which of these best describes an array?


a)A data structure that shows a hierarchical behaviour
b)Container of objects of similar types
c)Arrays are immutable once initialised
d)Array is not a data structure
Answer:b

2.How do you initialize an array in C? a) intarr[3] = (1,2,3);


b) intarr(3) = {1,2,3};
c) intarr[3] = {1,2,3};
d) intarr(3) = (1,2,3);
Answer:c

3.When does the ArrayIndexOutOfBoundsException occur?


a)Compile-time
b)Run-time
c)Not an error
d)Not an exception at all
Answer:b

4.Which of the following concepts make extensive use of arrays?


a)Binary trees
b)Scheduling of processes
c)Caching
d)Spatial locality
Answer:d

5.What are the advantages of arrays?


a)Objects of mixed data types can be stored
b)Elements in an array cannot be sorted
c)Index of first element of an array is 1
d)Easier to store elements of same data type
Answer:d

6.What are the disadvantages of arrays?


a)Data structure like queue or stack cannot be implemented
b)There are chances of wastage of memory space if elements inserted in an array are lesser than the
allocated size
c)Index value of an array can be negative
d)Elements are sequentially accessed
Answer:b

7.Assumingint is of 4bytes, what is the size of intarr[15];?


a)15
b)19
c)11
d)60
Answer:d

8.In general, the index of the first element in an array is


a)0
b)-1
c)2
d)1
Answer:a

9.Elements in an array are accessed


a)randomly
b)sequentially
c)exponentially
d)logarithmically
Answer:a

10.Process of inserting an element in stack is called


a)Create
b)Push
c)Evaluation
d)Pop
Answer:b

11.Process of removing an element from stack is called


a)Create
b)Push
c)Evaluation
d)Pop
Answer:d

12.In a stack, if a user tries to remove an element from empty stack it is called
a)Underflow
b)Empty collection
c)Overflow
d)Garbage Collection
Answer:a

13.Pushing an element into stack already having five elements and stack size of 5, then stack
becomes
a)Overflow
b)Crash
c)Underflow
d)User flow
14.Entries in a stack are “ordered”. What is the meaning of this statement?
a)A collection of stacks is sortable
b)Stack entries may be compared with the ‘<‘ operation
c)The entries are stored in a linked list
d)There is a Sequential entry that is one by one
Answer:d

15. Which of the following is not the application of stack?


a)A parentheses balancing program
b)Tracking of local variables at run time
c)Compiler Syntax Analyzer
d)Data Transfer between two asynchronous process
Answer:d

16.Consider the usual algorithm for determining whether a sequence of parentheses is balanced.
The maximum number of parentheses that appear on the stack AT ANY ONE TIME when the
algorithm analyzes: (()(())(())) are:
a)1
b)2
c)3
d)4 or more
Answer:c

17.Consider the usual algorithm for determining whether a sequence of parentheses is balanced.
Suppose that you run the algorithm on a sequence that contains 2 left parentheses and 3 right
parentheses (in some order).
The maximum number of parentheses that appear on the stack AT ANY ONE TIME during the
computation?
a)1
b)2
c)3
d)4 or more
Answer:b

18.What is the value of the postfix expression 6 3 2 4 + – *?


a)1
b)40
c)74
d)-18
Answer:d

19.Here is an infix expression: 4 + 3*(6*3-12). Suppose that we are using the usual stack algorithm to
convert the expression from infix to postfix notation.
The maximum number of symbols that will appear on the stack AT ONE TIME during the conversion
of this expression?
a)1
b)2
c)3
d)4
Answer: d
20.The postfix form of the expression (A+ B)*(C*D- E)*F / G is?
a)AB+ CD*E – FG /**
b)AB + CD* E – F **G /
c)AB + CD* E – *F *G /
d)AB + CDE * – * F *G /
Answer: c

21.The data structure required to check whether an expression contains balanced parenthesis is?
a)Stack
b)Queue
c)Array
d)Tree
Answer:a

22.What data structure would you mostly likely see in a non recursive implementation of a recursive
algorithm?
a)Linked List
b)Stack
c)Queue
d)Tree
Answer:b

23.The process of accessing data stored in a serial access memory is similar to manipulating data on
a
a)Heap
b)Binary Tree
c)Array
d)Stack
Answer:d

24.The postfix form of A*B+C/D is?


a)*AB/CD+
b)AB*CD/+
c)A*BC+/D
d)ABCD+/*
Answer:b

25.Which data structure is needed to convert infix notation to postfix notation?


a)Branch
b)Tree
c)Queue
d)Stack
Answer:d

26.The prefix form of A-B/ (C * D ^ E) is?


a)-/*^ACBDE
b)-ABCD*^DE
c)-A/B*C^DE
d)-A/BC*^DE
Answer:c
27.What is the result of the following operation? Top (Push (S, X))
a)X
b)X+S
c)S
d)XS
Answer:a

28.The prefix form of an infix expression (p + q) – (r * t) is?


a) + pq – *rt
b)– +pqr * t
c)– +pq * rt
d)– + * pqrt
Answer:c

29.Which data structure is used for implementing recursion?


a)Queue
b)Stack
c)Array
d)List
Answer:b

30.The result of evaluating the postfix expression 5, 4, 6, +, *, 4, 9, 3, /, +, * is? a) 600


b) 350
c) 650
d) 588
Answer:b

31.Convert the following infix expressions into its equivalent postfix expressions (A + B ⋀D)/(E – F)+G
a)(A B D ⋀ + E F – / G +)
b)(A B D +⋀ E F – / G +)
c)(A B D ⋀ + E F/- G +)
d)(A B D E F + ⋀ / – G +)
Answer:a

32.Convert the following Infix expression to Postfix form using a stack


x + y * z + (p * q + r) * s, Follow usual precedence rule and assume that the expression is legal.
a)xyz*+pq*r+s*+
b)xyz*+pq*r+s+*
c)xyz+*pq*r+s*+
d)xyzp+**qr+s*+
Answer:a

33.Which of the following statement(s) about stack data structure is/are NOT correct?
a)Linked List are used for implementing Stacks
b)Top of the Stack always contain the new node
c)Stack is the FIFO data structure
d)Null link is present in the last node at the bottom of the stack
Answer: c

34.Consider the following operation performed on a stack of size 5. Push(1);


Pop();
Push(2);
Push(3);
Pop();
Push(4);
Pop();
Pop();
Push(5);
After the completion of all operation, the number of elements present in stack are
a)1
b)2
c)3
d)4
Answer:a

35.Which of the following is not an inherent application of stack?


a)Reversing a string
b)Evaluation of postfix expression
c)Implementation of recursion
d)Job scheduling
Answer:d

36.The type of expression in which operator succeeds its operands is?


a) Infix Expression
b)Prefix Expression
c)Postfix Expression
d)Both Prefix and Postfix Expressions
Answer:c

37.Assume that the operators +,-, X are left associative and ^ is right associative.
The order of precedence (from highest to lowest) is ^, X, +, -. The postfix expression for the infix
expression a
+ b X c – d ^ e ^ f is
a)abc X+ def ^^ –
b)abc X+ de^f^ –
c)ab+cXd – e ^f^
d)-+aXbc^ ^def
Answer:b

38.If the elements “A”, “B”, “C” and “D” are placed in a stack and are deleted one at a time, what is
the order of removal?
a)ABCD
b)DCBA
c)DCAB
d)ABDC
Answer:b

39.A linear list of elements in which deletion can be done from one end (front) and insertion can
take place only at the other end (rear) is known as a ?
a)Queue
b)Stack
c)Tree
d)Linked list
Answer:a

40.A queue follows


a)FIFO (First In First Out) principle
b)LIFO (Last In First Out) principle
c)Ordered array
d)Linear tree
Answer:a

41.Circular Queue is also known as


a)Ring Buffer
b)Square Buffer
c)Rectangle Buffer
d)Curve Buffer
Answer:a

42.If the elements “A”, “B”, “C” and “D” are placed in a queue and are deleted one at a time, in what
order will they be removed?
a)ABCD
b)DCBA
c)DCAB
d)ABDC
Answer:a

43.A data structure in which elements can be inserted or deleted at/from both the ends but not in
the middle is?
a)Queue
b)Circular queue
c)Dequeue
d)Priority queue
Answer: c

44.A normal queue, if implemented using an array of size MAX_SIZE, gets full when
a)Rear = MAX_SIZE – 1
b)Front = (rear + 1)mod MAX_SIZE
c)Front = rear + 1
d)Rear = front
Answer: a

45.Queues serve major role in


a)Simulation of recursion
b)Simulation of arbitrary linked list
c)Simulation of limited resource allocation
d)Simulation of heap sort
Answer: c

46.Which of the following is not the type of queue?


a)Ordinary queue
b)Single ended queue
c)Circular queue
d)Priority queue
Answer: b

47.A linear collection of data elements where the linear node is given by means of pointer is called?
a)Linked list
b)Node list
c)Primitive list
d)Unordered list
Answer: a

48.Consider an implementation of unsorted singly linked list. Suppose it has its representation with a
head pointer only.
Given the representation, which of the following operation can be implemented in O(1) time?
i)Insertion at the front of the linked list
ii)Insertion at the end of the linked list
iii)Deletion of the front node of the linked list
iv)Deletion of the last node of the linked list
a)I and II
b)I and III
c)I, II and III
d)I, II and IV
Answer: b

49.In linked list each node contain minimum of two fields. One field is data field to store the data
second field is?
a)Pointer to character
b)Pointer to integer
c)Pointer to node
d)Node
Answer: c

50.What would be the asymptotic time complexity to add a node at the end of singly linked list, if
the pointer is initially pointing to the head of the list?
a)O(1)
b)O(n)
c)θ(n)
d)θ(1)
Answer: c

51.What would be the asymptotic time complexity to insert an element at the front of the linked list
(head is known)?
a)O(1)
b)O(n)
c)O(n2)
d)O(n3)
Answer: a

52.What would be the asymptotic time complexity to find an element in the linked list?
a)O(1)
b)O(n)
c)O(n2)
d)O(n4)
Answer: b

53.What would be the asymptotic time complexity to insert an element at the second position in the
linked list?
a)O(1)
b)O(n)
c)O(n2)
d)O(n3)
Answer: a

54.The concatenation of two list can performed in O(1) time. Which of the following variation of
linked list can be used?
a)Singly linked list
b)Doubly linked list
c)Circular doubly linked list
d)Array implementation of list
Answer: c

55.What kind of linked list is best to answer question like “What is the item at position n?”
a)Singly linked list
b)Doubly linked list
c)Circular linked list
d)Array implementation of linked list
Answer: d

56.Linked lists are not suitable to for the implementation of?


a)Insertion sort
b)Radix sort
c)Polynomial manipulation
d)Binary search
Answer: d

57.Linked list is considered as an example of____type of memory allocation.


a)Dynamic
b)Static
c)Compile time
d)Heap
Answer: a

58.In Linked List implementation, a node carries information regarding


a)Data
b)Link
c)Data and Link
d)Node
Answer: b

59.Linked list data structure offers considerable saving in


a)Computational Time
b)Space Utilization
c)Space Utilization and Computational Time
d)Speed Utilization
Answer: c

60.Which of the following points is/are not true about Linked List data structure when it is compared
with array?
a)Arrays have better cache locality that can make them better in terms of performance
b)It is easy to insert and delete elements in Linked List
c)Random access is not allowed in a typical implementation of Linked Lists
d)Access of elements in linked list takes less time than compared to arrays
Answer: d

61.Which of the following statements are not correct with respect to Singly Linked List(SLL) and
Doubly Linked List(DLL)?
a)Complexity of Insertion and Deletion at known position is O(n) in SLL and O(1) in DLL
b)SLL uses lesser memory per node than DLL
c)DLL has more searching power than SLL
d)Number of node fields in SLL is more than DLL
Answer: d

62.Which of the following data structures can be used for parentheses matching?
a)n-ary tree
b)queue
c)priority queue
d)Stack
Answer: d

63.Minimum number of queues to implement stack is


a)3
b)4
c)1
d)2
Answer:c

64.Which of the following data structures can be used for parentheses matching?
a)n-ary tree
b)queue
c)priority queue
d)stack
Answer:d

65.Minimum number of queues to implement stack is


a)3
b)4
c)1
d)2
Answer:c

66.In linked list implementation of queue, if only front pointer is maintained, which of the following
operation take worst case linear time?
a)Insertion
b)Deletion
c)To empty a queue
d)Both Insertion and To empty a queue
Answer: d

67.In linked list implementation of a queue, where does a new element be inserted?
a)At the head of link list
b)At the centre position in the link list
c)At the tail of the link list
d)At any position in the linked list
Answer: c

68.In linked list implementation of a queue, front and rear pointers are tracked. Which of these
pointers will change during an insertion into a NONEMPTY queue?
a)Only front pointer
b)Only rear pointer
c)Both front and rear pointer
d)No pointer will be changed
Answer: b

69.In linked list implementation of a queue, front and rear pointers are tracked. Which of these
pointers will change during an insertion into EMPTY queue?
a)Only front pointer
b)Only rear pointer
c)Both front and rear pointer
d)No pointer will be changed
Answer: c

70.In case of insertion into a linked queue, a node borrowed from the list is inserted in the queue.
a)AVAIL
b)FRONT
c)REAR
d)NULL
Answer: a

71.In linked list implementation of a queue, from where is the item deleted?
a)At the head of link list
b)At the centre position in the link list
c)At the tail of the link list
d)Node before the tail
Answer: a

72.In linked list implementation of a queue, the important condition for a queue to be empty is?
a)FRONT is null
b)REAR is null
c)LINK is empty
d)FRONT==REAR-1
Answer: a

73.The essential condition which is checked before insertion in a linked queue is?
a)Underflow
b)Overflow
c)Front value
d)Rear value
Answer: b

74.The essential condition which is checked before deletion in a linked queue is?
a)Underflow
b)Overflow
c)Front value
d)Rear value
Answer: a

75.Which of the following is true about linked list implementation of queue?


a)In push operation, if new nodes are inserted at the beginning of linked list, then in pop operation,
nodes must be removed from end
b)In push operation, if new nodes are inserted at the beginning, then in pop operation, nodes must
be removed from the beginning
c)In push operation, if new nodes are inserted at the end, then in pop operation, nodes must be
removed from end
d)In push operation, if new nodes are inserted at the end, then in pop operation, nodes must be
removed from beginning
Answer: a

76.With what data structure can a priority queue be implemented?


a)Array
b)List
c)Heap
d)Tree
Answer: d

77.Which of the following is not an application of priority queue?


a)Huffman codes
b)Interrupt handling in operating system
c)Undo operation in text editors
d)Bayesian spam filter
Answer: c

78.Which of the following is not an advantage of priority queue?


a)Easy to implement
b)Processes with different priority can be efficiently handled
c)Applications with differing requirements
d)Easy to delete elements in any case
Answer: d

79.What is the time complexity to insert a node based on position in a priority queue?
a)O(nlogn)
b)O(logn)
c)O(n)
d)O(n2)
Answer: c
80.What is a dequeue?
a)A queue with insert/delete defined for both front and rear ends of the queue
b)A queue implemented with a doubly linked list
c)A queue implemented with both singly and doubly linked lists
d)A queue with insert/delete defined for front side of the queue
Answer: a

81.What is the time complexity of deleting from the rear end of the dequeue implemented with a
singly linked list?
a)O(nlogn)
b)O(logn)
c)O(n)
d)O(n2)
Answer: c

82.A Double-ended queue supports operations such as adding and removing items from both the
sides of the queue. They support four operations like addFront(adding item to top of the queue),
addRear(adding item to the bottom of the queue), removeFront(removing item from the top of the
queue) and removeRear(removing item from the bottom of the queue). You are given only stacks to
implement this data structure. You can implement only push and pop operations. What are the total
number of stacks required for this operation?(you can reuse the stack)
a)1
b)2
c)3
d)4
Answer: b

83.You are asked to perform a queue operation using a stack. Assume the size of the stack is some
value ‘n’ and there are ‘m’ number of variables in this stack. The time complexity of performing
deQueue operation is (Using only stack operations like p ush and pop)(Tightly bound).
a)O(m)
b)O(n)
c)O(m*n)
d)Data is insufficient
Answer: a

84.Consider you have an array of some random size. You need to perform dequeue operation. You
can perform it using stack operation (push and pop) or using queue operations itself (enQueue and
Dequeue).
The output is guaranteed to be same. Find some differences?
a)They will have different time complexities
b)The memory used will not be different
c)There are chances that output might be different
d)No differences
Answer: a

85.Given only a single array of size 10 and no other memory is available. Which of the following
operation is not feasible to implement (Given only push and pop operation)?
a)Push
b)Pop
c)Enqueue
d)Returntop
Answer: c

86.Given an array of size n, let’s assume an element is ‘touched’ if and only if some operation is
performed on it(for example, for performing a pop operation the top element is ‘touched’). Now you
need to perform Dequeue operation. Each element in the array is touched atleast?
a)Once
b)Twice
c)Thrice
d)Four times
Answer: d

87.To implement a stack using queue(with only enqueue and dequeue operations), how many
queues will you need?
a)1
b)2
c)3
d)4
Answer: b

88.What is the functionality of the following piece of code?


a)Perform push() with push as the costlier operation
b)Perform push() with pop as the costlier operation
c)Perform pop() with push as the costlier operation
d)Perform pop() with pop as the costlier operation
Answer: b

89.Process of inserting an element in stack is called


a)Create
b)Push
c)Evaluation
d)Pop
Answer: b

90.Process of removing an element from stack is called


a)Create
b)Push
c)Evaluation
d)Pop
Answer: d

91.In a stack, if a user tries to remove an element from empty stack it is called
a)Underflow
b)Empty collection
c)Overflow
d)Garbage Collection
Answer: a

92.Pushing an element into stack already having five elements and stack size of 5, then stack
becomes
a)Overflow
b)Crash
c)Underflow
d)User flow
Answer: a

93.Entries in a stack are “ordered”. What is the meaning of this statement?


a)A collection of stacks is sortable
b)Stack entries may be compared with the ‘<‘ operation
c)The entries are stored in a linked list
d)There is a Sequential entry that is one by one
Answer: d

94.Which of the following is not the application of stack?


a)A parentheses balancing program
b)Tracking of local variables at run time
c)Compiler Syntax Analyzer
d)Data Transfer between two asynchronous process
Answer: d

95.Consider the usual algorithm for determining whether a sequence of parentheses is balanced.
The maximum number of parentheses that appear on the stack AT ANY ONE TIME when the
algorithm analyzes: (()(())(())) are:
a)1
b)2
c)3
Answer: c

96.Consider the usual algorithm for determining whether a sequence of parentheses is balanced.
Suppose that you run the algorithm on a sequence that contains 2 left parentheses and 3 right
parentheses (in
some order).
The maximum number of parentheses that appear on the stack AT ANY ONE TIME during the
computation?
a)1
b)2
c)3
d)4
Answer: b

97.What is the value of the postfix expression 6 3 2 4 + – *?


a)1
b)40
c)74
d)-18
Answer: d

98.Here is an infix expression: 4 + 3*(6*3-12). Suppose that we are using the usual stack algorithm to
convert the expression from infix to postfix notation.
The maximum number of symbols that will appear on the stack AT ONE TIME during the conversion
of this
expression?
a)1
b)2
c)3
Answer: d

99.The postfix form of the expression (A+ B)*(C*D- E)*F / G is?


a)AB+ CD*E – FG /**
b)AB + CD* E – F **G /
c)AB + CD* E – *F *G /
d)AB + CDE * – * F *G /
Answer: c

100.The data structure required to check whether an expression contains balanced parenthesis is?
a)Stack
b)Queue
c)Array
d)Tree
Answer: a

101.What data structure would you mostly likely see in a non recursive implementation of a
recursive algorithm?
a)Linked List
b)Stack
c)Queue
d)Tree
Answer: b

102.The process of accessing data stored in a serial access memory is similar to manipulating data on
a
a)Heap
b)Binary Tree
c)Array
d)Stack
Answer: d

103.The postfix form of A*B+C/D is?


a)*AB/CD+
b)AB*CD/+
c)A*BC+/D
d)ABCD+/*
Answer: b

104.Which data structure is needed to convert infix notation to postfix notation?


a)Branch
b)Tree
c)Queue
d)Stack
Answer: d

105.The prefix form of A-B/ (C * D ^ E) is?


a)-/*^ACBDE
b)-ABCD*^DE
c)-A/B*C^DE
d)-A/BC*^DE
Answer: c

106.What is the result of the following operation?


Top (Push (S, X))
a)X
b)X+S
c)S
Answer: a

107.The prefix form of an infix expression (p + q) – (r * t) is?


a) + pq – *rt
b)– +pqr * t
c)– +pq * rt
d)– + * pqrt
Answer: c

108.Which data structure is used for implementing recursion?


a)Queue
b)Stack
c)Array
d)List
Answer: b

109.When an operand is read, which of the following is done?


a)It is placed on to the output
b)It is placed in operator stack
c)It is ignored
d)Operator stack is emptied
Answer: a

110.What should be done when a left parenthesis ‘(‘ is encountered?


a)It is ignored
b)It is placed in the output
c)It is placed in the operator stack
d)The contents of the operator stack is emptied
Answer: c

111.Which of the following is an infix expression?


a) (a+b)*(c+d)
b) ab+c*
c) +ab
d) abc+*
Answer: a

112.What is the time complexity of an infix to postfix conversion algorithm?


a)O(N log N)
b)O(N)
c)O(N2)
d)O(M log N)
Answer: b

113.Which of the following statement is incorrect with respect to infix to postfix conversion
algorithm?
a)operand is always placed in the output
b)operator is placed in the stack when the stack operator has lower precedence
c)parenthesis are included in the output
d)higher and equal priority operators follow the same condition
Answer: c

114.In infix to postfix conversion algorithm, the operators are associated from?
a)right to left
b)left to right
c)centre to left
d)centre to right
Answer: b

115.A linear list of elements in which deletion can be done from one end (front) and insertion can
take
place only at the other end (rear) is known as a ?
a)Queue
b)Stack
c)Tree
d)Linked list
Answer: a

116.The data structure required for Breadth First Traversal on a graph is?
a)Stack
b)Array
c)Queue
d)Tree
Answer: c

117.A queue follows


a)FIFO (First In First Out) principle
b)LIFO (Last In First Out) principle
c)Ordered array
d)Linear tree
Answer: a

118. A data structure in which elements can be inserted or deleted at/from both the ends but not in
the middle is?
a)Queue
b)Circular queue
c)Dequeue
d)Priority queue
Answer: c

119.A normal queue, if implemented using an array of size MAX_SIZE, gets full when
a)Rear = MAX_SIZE – 1
b)Front = (rear + 1)mod MAX_SIZE
c)Front = rear + 1
d)Rear = front
Answer: a

120.Queues serve major role in


a)Simulation of recursion
b)Simulation of arbitrary linked list
c)Simulation of limited resource allocation
d)Simulation of heap sort
Answer: c

121.Which of the following is not the type of queue?


a)Ordinary queue
b)Single ended queue
c)Circular queue
d)Priority queue
Answer: b

You might also like