Docsity

Data Structure Interview Questions and Answers, Exams of Computer Science

Toggle sidebar
bg1
DATA STRUCTURE INTERVIEW
QUESTIONS AND ANSWERS
What is a Data Structure? - Correct Answers -A data structure is a way of organizing the
data so that the data can be used efficiently.
Non-Linear: A data structure is said to be non-linear if traversal of nodes is nonlinear in
nature. Example: Graph and Trees.
What are the various operations that can be performed on different Data Structures? -
Correct Answers -Insertion, Deletion, Traversal, Searching, Sorting
What are linear and non linear data Structures? - Correct Answers -Linear: A data
structure is said to be linear if its elements form a sequence or a linear list. Examples:
Array. Linked List, Stacks and Queues
How is an Array different from a Linked List - Correct Answers -array size is fixed,
Linked Lists size are Dynamic
insertion and deletion is easily done in Linked Lists, but for arrays is expensive
No Random access in Linked List
link lists need Extra memory space for a pointer
Arrays have better cache locality
What is Stack and where it can be used? - Correct Answers -Stack is a linear data
structure which the order LIFO(Last In First Out) for accessing elements.
Basic operations of stack are : Push, Pop , Peek
What is a Queue, how it is different from stack and how is it implemented? - Correct
Answers -Queue is a linear structure which follows the order is First In First Out (FIFO)
to access elements
queue is FIFO while stack is LIFO
implemented using Arrays or Linked Lists
pf2

Partial preview of the text

Download Data Structure Interview Questions and Answers and more Exams Computer Science in PDF only on Docsity!

DATA STRUCTURE INTERVIEW

QUESTIONS AND ANSWERS

What is a Data Structure? - Correct Answers -A data structure is a way of organizing the data so that the data can be used efficiently. Non-Linear: A data structure is said to be non-linear if traversal of nodes is nonlinear in nature. Example: Graph and Trees. What are the various operations that can be performed on different Data Structures? - Correct Answers -Insertion, Deletion, Traversal, Searching, Sorting What are linear and non linear data Structures? - Correct Answers -Linear: A data structure is said to be linear if its elements form a sequence or a linear list. Examples: Array. Linked List, Stacks and Queues How is an Array different from a Linked List - Correct Answers -array size is fixed, Linked Lists size are Dynamic insertion and deletion is easily done in Linked Lists, but for arrays is expensive No Random access in Linked List link lists need Extra memory space for a pointer Arrays have better cache locality What is Stack and where it can be used? - Correct Answers -Stack is a linear data structure which the order LIFO(Last In First Out) for accessing elements. Basic operations of stack are : Push, Pop , Peek What is a Queue, how it is different from stack and how is it implemented? - Correct Answers -Queue is a linear structure which follows the order is First In First Out (FIFO) to access elements queue is FIFO while stack is LIFO implemented using Arrays or Linked Lists

What are Infix, prefix, Postfix notations? - Correct Answers -Infix notation: X + Y Operators are written in-between their operands. Postfix notation: X Y + Operators are written after their operands. Prefix notation: + X Y Operators are written before their operands. What is a Linked List? - Correct Answers -A linked list is a linear data structure where each element is a separate object. Each node of a list is contains the data and a reference to the next node. What are the different types of linked list? - Correct Answers -Singly Linked List : every node stores address or reference of next node in list and the last node has next address as NULL. Doubly Linked List : One of the reference points to the next node and one to the previous node. Circular Linked List : all nodes are connected to form a circle, no NULL at the end, can be a singly circular linked list or doubly circular linked list. Which data structures are used for BFS and DFS of a graph? - Correct Answers -Queue is used for BFS Stack is used for DFS. DFS can also be implemented using recursion Can doubly linked be implemented using a single pointer variable in every node? - Correct Answers -Doubly linked list can be implemented using a single pointer. How to check if a given Binary Tree is BST or not? - Correct Answers -If inorder traversal of a binary tree is sorted, then the binary tree is BST.