0% found this document useful (0 votes)
7 views4 pages

Ds and Algo Question 2

The document contains a series of questions and answers related to data structures and algorithms, covering topics such as arrays, stacks, linked lists, and tree traversals. It includes multiple-choice questions about programming concepts, code outputs, and data structure functionalities. The questions assess knowledge on various data structures, their properties, and operations.

Uploaded by

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

Ds and Algo Question 2

The document contains a series of questions and answers related to data structures and algorithms, covering topics such as arrays, stacks, linked lists, and tree traversals. It includes multiple-choice questions about programming concepts, code outputs, and data structure functionalities. The questions assess knowledge on various data structures, their properties, and operations.

Uploaded by

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

1. What is a data structure?

a) A programming language
b) A collection of algorithms
c) A way to store and organize data
d) A type of computer hardware

2. What are the disadvantages of arrays?


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

3. What is the output of the below code?

1. #include <stdio.h>
2. int main()
3. {
4. int arr[5]={10,20,30,40,50};
5. printf("%d", arr[5]);
6.
7. return 0;
8. }

A. Garbage value
B. 10
C. 50
D. None of the above
4. Convert the infix to postfix for A-(B+C)*(D/E)
A. ABC+DE/*-
B. ABC-DE/*-
C ABC-DE*/-
E. None of the above
5. The prefix of (A+ B) * (C-D) is
A +-AB*(C-D)
B * +-ABCD
C * +AB-CD
D *AB+ CD

6. 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

7. Assuming int is of 4bytes, what is the size of int arr[15];?


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

8. Process of inserting an element in stack is called ____________


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

9. 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

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


a) 1
b) 40
c) 74
d) -18
11. What is the result of the following operation?
Top (Push (S, X))
a) X
b) X+S
c) S
d) XS

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

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


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

14. How do you initialize an array in C?


a) int arr[3] = (1,2,3);
b) int arr(3) = {1,2,3};
c) int arr[3] = {1,2,3};
d) int arr(3) = (1,2,3);

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

public void display()


{
if(size == 0)
System.out.println("underflow");
else
{
Node current = first;
while(current != null)
{
System.out.println(current.getEle());
current = current.getNext();
}
}
}

a) display the list


b) reverse the list
c) reverse the list excluding top-of-the-stack-element
d) display the list excluding top-of-the-stack-element
16. Which is the most appropriate data structure for reversing a word?
a) stack
b) queue
c) graph
d) tree

17. Elements in an array are accessed _____________


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

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


[A] Trees
[B] Stacks
[C] Strings
[D] All of the above

20. The maximum number of binary trees that can be formed with three unlabeled nodes is:
a) 1
b) 5
c) 4
d) 3

21. In preorder traversal of a binary tree the second step is ____________


a) traverse the right subtree
b) traverse the left subtree
c) traverse right subtree and visit the root
d) visit the root

22. From the following code identify the which traversal of a binary tree is this __________

//if node has left child


order(node.left)
//if node has right child
order(node.right)
visit(node)

a) Inorder traversal
b) preorder traversal
c) postorder traversal
d) Euler tour traversal

You might also like