0% found this document useful (0 votes)
58 views

Data Structures

This document discusses various data structures including linear and non-linear structures. Linear structures like lists, queues and stacks have elements arranged sequentially. Non-linear structures like trees and graphs have no set element sequence and elements can have multiple connection paths. The document also discusses static vs dynamic structures, abstract data types, differences between arrays and linked lists, applications of stacks, queues and trees. It provides examples and definitions of common data structures like stacks, queues, trees, heaps and hash tables.

Uploaded by

Arkadeep Roy
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

Data Structures

This document discusses various data structures including linear and non-linear structures. Linear structures like lists, queues and stacks have elements arranged sequentially. Non-linear structures like trees and graphs have no set element sequence and elements can have multiple connection paths. The document also discusses static vs dynamic structures, abstract data types, differences between arrays and linked lists, applications of stacks, queues and trees. It provides examples and definitions of common data structures like stacks, queues, trees, heaps and hash tables.

Uploaded by

Arkadeep Roy
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

1. What do you mean by data structure?

A data structure is a specialized format for organizing, processing, retrieving and storing data.

2. What do you mean by linear and non-linear data structure?


A Linear data structure has data elements arranged sequentially operates and each member element
is connected to its previous and next element.
Examples of linear data structures are List, Queue, Stack, Array.
A non-linear data structure has no set sequence of connecting all its elements and each element can
have multiple paths to connect to other elements. Such data structures support multi-level storage.
Examples of non-linear data structures are Tree, BST, Graphs etc.

3. Differentiate between linear and non-linear data structures?

4. What is static and dynamic data structure? Give example.


In a Static data structure, the size of the structure is fixed. The content of the data structure can be
modified but without changing the memory space allocated to it. Ex: Array.
In a Dynamic data structure, the size of the structure is not fixed and can be modified during the
operations performed on it and facilitate the change of data structures during run time. Ex: Linked List.

5. What do you mean by Abstract Data type?


Abstract Data type (ADT) is a type (or class) for objects whose behaviour is defined by a set of values
and a set of operations.
6. What is Array?
The array is a contiguous collection of similar types of data.
7. What is a Linked List?
A linked list is a linear data structure, in which the elements are not stored at contiguous memory
locations rather the elements in a linked list are linked using pointers.

8. What is the difference between an Array and a Linked List?

Array Linked List

The size of the array must be specified at the time Size of a Linked list grows/shrinks as and when new
of array declaration/initialization. elements are inserted/deleted.

Data elements are stored in contiguous locations in New elements can be stored anywhere and the
memory. reference is created with the help of a pointer.

Memory is allocated during the compile-time (Static Memory is allocated during the run-time (Dynamic
memory allocation). memory allocation).

9. Tell some applications of the linked list.


stacks, queues, graph, dynamic memory allocation, representing sparse matrices
In real-world: Music Player, Image viewer, Previous and next page in a web browser.

10. What do you mean by single and double-ended data structure? Give example.
The single-ended queue is a normal queue where insertion takes place at the FRONT of the queue
and deletion takes place at the END of the queue. Ex: CPU scheduling.
In a Double Ended Queue, insertion and deletion operations can be done at both FRONT and END of
the queue. Ex: Palindrome checker.

11. What is the difference between stack and queue?

Stack Queue

The stack is based on LIFO(Last In First Out) The queue is based on FIFO(First In First Out)
principle principle

Insertion Operation is called Push Operation Insertion Operation is called Enqueue Operation

Deletion Operation is called Pop Operation Deletion Operation is called Dequeue Operation

Push and Pop Operation takes place from one Enqueue and Dequeue Operation takes place
end of the stack from a different end of the stack.

Only one pointer is used for performing Two pointers are required to operate.
operations
12. What are some applications of a stack?
a) Evaluation of Arithmetic Expressions
b) Backtracking
c) Reverse a Data
d) Processing Function Calls

13. What is the time complexity of push and pop operation in a stack?
Big O(1)

14. What are the different types of queues?


● Simple Queue.
● Circular Queue.
● Priority Queue.
● Double Ended Queue.

15. How can you implement a stack using a queue?

16. How can you implement a queue using a stack?

17. Tell some applications of queues.


1) Queues are used as buffers in most applications like MP3 media players, CD players.
2) Queues are used to maintain the playlist in media players.
3) Queues are used in operating systems for handling interrupts.

18. Which data structure can be used both as stack and queue at the same time?
Linear Data Structure.

19. What do you mean by the tree?


A tree is non-linear and a hierarchical data structure consisting of a collection of nodes in which each
node of the tree stores a value and a list of references to nodes.

20. What are the different types of tree traversals?


Breadth-First Search, Depth First Search, Inorder, Preorder, Postorder.

21. Which data structure is used in BFS and DFS?


BFS: Queue Data Structure. and DFS: Stack Data Structure.

22. What is an AVL tree?


AVL tree is a self-balancing Binary Search Tree (BST) where the difference between heights of left and
right subtrees cannot be more than one for all nodes.

23. What is a Binary Search Tree?


The binary search tree is an advanced algorithm used for analyzing the node, its left and right
branches, which are modelled in a tree structure and returning the value.
24. What are the Complete Binary Tree and the Perfect Binary Tree?
A Binary Tree is a Complete Binary Tree if all the levels are filled except possibly the last level and the
last level has all keys as left as possible.
A Binary tree is a Perfect Binary Tree in which all the internal nodes have two children and all leaf
nodes are at the same level.

25. What is a strict Binary Tree?


If every non-leaf node in a binary tree has nonempty left and right subtrees, the tree is called a strictly
binary tree. A strictly binary tree with n leaves always contains 2n -1 nodes.

26. If i is the index of the parent node then what is the index of the left child and right child of it in an
array?

27. What is the use of B and B+ trees?


B-Tree is known as a self-balancing tree as its nodes are sorted in the inorder traversal. In B-tree, a
node can have more than two children.
B+ tree eliminates the drawback B-tree used for indexing by storing data pointers only at the leaf nodes
of the tree.

28. Using which data structure you can minimize the search complexity in Linked List?

29. What is the worst-case time complexity of searching a node in a Binary Search Tree?
O(n).

30. How do you know when to use BFS and DFS?


BFS can be used to find the shortest path, with unit weight edges, from a node (source) to another.
DFS can be used to exhaust all the choices because of its nature of going in-depth, like discovering the
longest path between two nodes in an acyclic graph.

31. What do you mean by heap?


A Heap is a special Tree-based data structure in which the tree is a complete binary tree.
They are of 2 types: Max Heap and Min Heap.
32. What are the max heap and min heap?
A Max-heap is a complete binary tree in which the value in each internal node is greater than or equal to
the values in the children of that node.
A Min-Heap is a complete binary tree in which the value in each internal node is smaller than or equal to
the values in the children of that node.

33. What is hashing?


Hashing is the process of converting a given key into another value.

34. What do you mean by collision?


The situation where a newly inserted key maps to an already occupied slot in the hash table is called a
collision.
35. What are the ways to avoid the collision?
1) Separate Chaining 2) Open Addressing

36. What is separated chaining?


Separate chaining is to make each cell of the hash table point to a linked list of records that
have the same hash function value.

37. What is open addressing?


Elements are stored in the hash table itself. So at any point, the size of the table must be greater
than or equal to the total number of keys.

38. Linked lists are linear or non-linear data structures?


It is a Linear data structure but according to Access strategies Linked list is a linear one and
according to Storage Linked List is a Non-linear one.

39. What are the advantages of a linked list over an array?


1) Dynamic size 2) Ease of insertion/deletion

40. What are the types of dequeue?


a) Input Restricted 2) Output Restricted.

41. Tell some applications of tree data structures.


Syntax tree, K-D tree, Spanning tree.

42. What is the maximum number of nodes in a binary tree of height k?


2k-1

43. What is the no. of internal nodes in a binary tree of height k?


2k+1

44. What is the no. of leaf nodes in a binary tree of height k?


2k-1

45. Tell some applications of the heap.


Priority Queue: Prim’s algorithm and Dijkstra Data Structure.

46. Which data structure suits most in the tree construction?


Array and Queue Data Structure.

47. What are the inbuilt data structures in Python?


Lists, Dictionary, Tuple and Set.

48. Name some inbuilt data structures that are inbuilt in Java?
● Array.
● Linked List.
● Stack.
● Queue.
● Binary Tree.
● Binary Search Tree.
● Heap.
● Hashing.

49. There are how many types of indexing in Python?


1. Basic Slicing and indexing. 2. Advanced indexing.

50. What is ordered and unordered data structure?


The ordered tree must be an organized tree in which nodes are in some order.
In a binary tree, when nodes are not in a particular order it is called an unordered tree.

You might also like