# Data Structure Interview Questions and Answers

Last updated on 24th Oct 2020, Blog, Interview Question

Akashkumar ((Sr Technical Engineer ) )

He is a Proficient Technical Expert for Respective Industry Domain & Serving 8+ Years. Also, Dedicated to Imparts the Informative Knowledge's to Freshers. He Share's this Blogs for us.

(5.0) | 16547 Ratings 2220

Are you searching for Data Structures job? A Data Structure in computer science is a kind of managing and storing data in order to access it efficiently. Implementing data structures requires writing a set of procedures that are used in creating and managing instances of that structure. Job opportunities are present everywhere for this position. Data Structures job description might include having knowledge on concepts of data structures like linked list, union etc and formal design methods and Object Oriented programming languages like C, C++, Java and SQL. ACTE created interview questions exclusively for the candidates who are in search of job. If you are looking for job then go check out our Data Structure interview questions and answers page to get more information.

### 1. What Is Data Structure?

Ans:

A data structure is a way of organizing data that considers not only the items stored, but also their relationship to each other. Advance knowledge about the relationship between data items allows designing of efficient algorithms for the manipulation of data.

### 2. What Are The Goals Of Data Structure?

Ans:

It must rich enough in structure to reflect the actual relationship of data in real world. The structure should be simple enough for efficient processing of data.

### 3. What Does Abstract Data Type Mean?

Ans:

Data type is a collection of values and a set of operations on these values. Abstract data type refer to the mathematical concept that define the data type.
It is a useful tool for specifying the logical properties of a data type.

1. Values definition
2. Operation definition

Example:- The value definition for the ADT RATIONAL states that RATIONAL value consists of two integers, second doesn’t equal to zero.
The operator definition for ADT RATIONAL includes the operation of creation (make rational) addition, multiplication and test for equality.

### 4. What Is The Difference Between A Stack And An Array?

Ans:

STACK:

• Stack is a ordered collection of items.
• Stack is a dynamic object whose size is constantly changing as items are pushed and popped.
• Stack may contain different data types.
• Stack is declared as a structure containing an array to hold the element of the stack, and an integer to indicate the current stack top within the array.

ARRAY:

• Array is an ordered collection of items.
• Array is a static object i.e. no of item is fixed and is assigned by the declaration of the array.
• It contains same data types.
• Array can be home of a stack i.e. array can be declared large enough for maximum size of the stack.

### 5. What Do You Mean By Recursive Definition?

Ans:

The definition which defines an object in terms of simpler cases of itself is called recursive definition.

### 6. What Is Sequential Search?

Ans:

In sequential search each item in the array is compared with the item being searched until a match occurs. It is applicable to a table organized either as an array or as a linked list.

### 7. What Actions Are Performed When A Function Is Called?

Ans:

When a function is called

• arguments are passed.
• local variables are allocated and initialized.
• transferring control to the function.

### 8. What Actions Are Performed When A Function Returns?

Ans:

2.Function’s data area is freed.
3.Branch is taken to the return address.

### 9. What Is A Linked List?

Ans:

A linked list is a linear collection of data elements, called nodes, where the linear order is given by pointers. Each node has two parts first part contain the information of the element second part contains the address of the next node in the list.

### 10. What Are The Advantages Of Linked List Over Array (static Data Structure)?

Ans:

• unlike linked list it is expensive to insert and delete elements in the array.
• One can’t double or triple the size of array as it occupies block of memory space.

• each element in list contains a field, called a link or pointer which contains the address of the next element.
• Successive element’s need not occupy adjacent space in memory.

### 11. We Apply Binary Search Algorithm To A Sorted Linked List, Why?

Ans:

No we cannot apply binary search algorithm to a sorted linked list, since there is no way of indexing the middle element in the list. This is the drawback in using linked list as a data structure.

### 12. What Do You Mean By Free Pool?

Ans:

Pool is a list consisting of unused memory cells which has its own pointer.

### 13. What Do You Mean By Garbage Collection?

Ans:

It is a technique in which the operating system periodically collects all the deleted space onto the free storage list.
It takes place when there is minimum amount of space left in storage list or when CPU is ideal.
The alternate method to this is to immediately reinsert the space into free storage list which is time consuming.

### 14. What Do You Mean By Overflow And Underflow?

Ans:

When new data is to be inserted into the data structure but there is no available space i.e. free storage list is empty this situation is called overflow.
When we want to delete data from a data structure that is empty this situation is called underflow.

Ans:

• The no of nodes needed can’t be predicted when the program is written.
• The no of nodes declared must remain allocated throughout its execution.

### 16. What Is A Queue?

Ans:

A queue is an ordered collection of items from which items may be deleted at one end (front end) and items inserted at the other end (rear end).
It obeys FIFO rule there is no limit to the number of elements a queue contains.

### 17. What Is A Priority Queue?

Ans:

The priority queue is a data structure in which the intrinsic ordering of the elements (numeric or alphabetic)

Determines the result of its basic operation. It is of two types:

i) Ascending priority queue- Here smallest item can be removed (insertion is arbitrary).

ii) Descending priority queue- Here largest item can be removed (insertion is arbitrary).

### 18. What Are The Disadvantages Of Sequential Storage?

Ans:

• Fixed amount of storage remains allocated to the data structure even if it contains less element.
• No more than fixed amount of storage is allocated causing overflow.

### 19. What Are The Disadvantages Of Representing A Stack Or Queue By A Linked List?

Ans:

• A node in a linked list (info and next field) occupies more storage than a corresponding element in an array.
• Additional time spent in managing the available list.

### 20. What Is Dangling Pointer And How To Avoid It?

Ans:

After a call to free(p) makes a subsequent reference to *p illegal, i.e. though the storage to p is freed but the value of p(address) remain unchanged .so the object at that address may be used as the value of *p (i.e. there is no way to detect the illegality).Here p is called dangling pointer.
To avoid this it is better to set p to NULL after executing free(p).The null pointer value doesn’t reference a storage location it is a pointer that doesn’t point to anything.

### 21. What Are The Disadvantages Of Linear List?

Ans:

• We cannot reach any of the nodes that precede node (p).
• If a list is traversed, the external pointer to the list must be persevered in order to reference the list again.

### 22. Define Circular List?

Ans:

In linear list the next field of the last node contain a null pointer, when a next field in the last node contain a pointer back to the first node it is called circular list.

Advantages – From any point in the list it is possible to reach at any other point.

### 23. What Are The Disadvantages Of Circular List?

Ans:

• We can’t traverse the list backward.
• If a pointer to a node is given we cannot delete the node.

### 24. Define Double Linked List?

Ans:

It is a collection of data elements called nodes,
where each node is divided into three parts:

• An info field that contains the information stored in the node.
• Left field that contain pointer to node on left side.
• Right field that contain pointer to node on right side.

### 25. Is It Necessary To Sort A File Before Searching A Particular Item ?

Ans:

If less work is involved in searching a element than to sort and then extract, then we don’t go for sort.
If frequent use of the file is required for the purpose of retrieving specific element, it is more efficient to sort the file.
Thus it depends on situation.

### 26. What Are The Issues That Hamper The Efficiency In Sorting A File?

Ans:

The issues are:

• Length of time required by the programmer in coding a particular sorting program.
• Amount of machine time necessary for running the particular program.
• The amount of space necessary for the particular program .

### 27. Calculate The Efficiency Of Sequential Search?

Ans:

The number of comparisons depends on where the record with the argument key appears in the table

1.If it appears at first position then one comparison

2.If it appears at last position then n comparisons

3.Average=(n+1)/2 comparisons

4.Unsuccessful search n comparisons

5.Number of comparisons in any case is O (n).

### 28. Is Any Implicit Arguments Are Passed To A Function When It Is Called?

Ans:

Yes there is a set of implicit arguments that contain information necessary for the function to execute and return correctly. One of them is return address which is stored within the function’s data area, at the time of returning to calling program the address is retrieved and the function branches to that location.

### 29. Parenthesis Is Never Required In Postfix Or Prefix Expressions, Why?

Ans:

Parenthesis is not required because the order of the operators in the postfix /prefix expressions determines the actual order of operations in evaluating the expression.

### 30. List Out The Areas In Which Data Structures Are Applied Extensively?

Ans:

• Compiler Design,
• Operating System,
• Database Management System,
• Statistical analysis package,
• Numerical Analysis,
• Graphics,
• Artificial Intelligence,
• Simulation.

### 31. What Are The Major Data Structures Used In The Following Areas : Network Data Model & Hierarchical Data Model?

Ans:

1. RDBMS – Array (i.e. Array of structures)

2. Network data model – Graph

3. Hierarchical data model – Trees

### 32. If You Are Using C Language To Implement The Heterogeneous Linked List, What Pointer Type Will You Use?

Ans:

The heterogeneous linked list contains different data types in its nodes and we need a link, pointer to connect them. It is not possible to use ordinary pointers for this. So we go for void pointer. Void pointer is capable of storing pointer to any type as it is a generic pointer type.

### 33. Minimum Number Of Queues Needed To Implement The Priority Queue?

Ans:

Two. One queue is used for actual storing of data and another for storing priorities.

### 34. What Is The Data Structures Used To Perform Recursion?

Ans:

Stack. Because of its LIFO (Last In First Out) property it remembers its ‘caller’ so knows whom to return when the function has to return. Recursion makes use of system stack for storing the return addresses of the function calls.
Every recursive function has its equivalent iterative (non-recursive) function. Even when such equivalent iterative procedures are written, explicit stack is to be used.

### 35. What Are The Notations Used In Evaluation Of Arithmetic Expressions Using Prefix And Postfix Forms?

Ans:

Polish and Reverse Polish notations.

### 36. Convert The Expression ((a + B) * C – (d – E) ^ (f + G)) To Equivalent Prefix And Postfix Notations?

Ans:

Prefix Notation: ^ – * +ABC – DE + FG

postfix Notation: AB + C * DE – – FG + ^

### 37. List Out Few Of The Application Of Tree Data-structure?

Ans:

The manipulation of Arithmetic expression, Symbol Table construction & Syntax analysis.

### Get Data Structures Training for Beginners from Industry Experts

• Instructor-led Sessions
• Real-life Case Studies
• Assignments

### 38. List Out Few Of The Applications That Make Use Of Multilinked Structures?

Ans:

Sparse matrix, Index generation.

Ans:

Backtracking.

### 40. In An Avl Tree, At What Condition The Balancing Is To Be Done?

Ans:

If the ‘pivotal value’ (or the ‘Height factor’) is greater than 1 or less than –1.

### 41. There Are 8, 15, 13, 14 Nodes Were There In 4 Different Trees. Which Of Them Could Have Formed A Full Binary Tree?

Ans:

In general: There are 2n-1 nodes in a full binary tree. By the method of elimination:
Full binary trees contain odd number of nodes. So there cannot be full binary trees with 8 or 14 nodes, so rejected. With 13 nodes you can form a complete binary tree but not a full binary tree. So the correct answer is 15.

### 42. In Rdbms, What Is The Efficient Data Structure Used In The Internal Storage Representation?

Ans:

B+ tree. Because in B+ tree, all the data is stored only in leaf nodes, that makes searching easier. This corresponds to the records that shall be stored in leaf nodes.

### 43. What Is A Spanning Tree?

Ans:

A spanning tree is a tree associated with a network. All the nodes of the graph appear on the tree once. A minimum spanning tree is a spanning tree organized so that the total edge weight between nodes is minimized.

### 44. Does The Minimal Spanning Tree Of A Graph Give The Shortest Distance Between Any 2 Specified Nodes?

Ans:

No! Minimal spanning tree assures that the total weight of the tree is kept at its minimum. But it doesn’t mean that the distance between any two nodes involved in the minimal-spanning tree is minimum.

### 45. Difference Between Calloc And Malloc ?

Ans:

malloc:
allocate n bytes.
calloc: allocate m times n bytes initialized to 0.

### 46. What Are The Major Data Structures Used In The Following Areas : Rdbms, Network Data Model & Hierarchical Data Model?

Ans:

• RDBMS Array (i.e. Array of structures)
• Network data model Graph
• Hierarchical data model Trees.

### 47. Which File Contains The Definition Of Member Functions?

Ans:

Definitions of member functions for the Linked List class are contained in the LinkedList.cpp file.

### 48. How Is Any Data Structure Application Is Classified Among Files?

Ans:

A linked list application can be organized into a header file, source file and main application file. The first file is the header file that contains the definition of the NODE structure and the LinkedList class definition. The second file is a source code file containing the implementation of member functions of the LinkedList class. The last file is the application file that contains code that creates and uses the LinkedList class.

### 49. What Member Function Places A New Node At The End Of The Linked List?

Ans:

The appendNode() member function places a new node at the end of the linked list. The appendNode() requires an integer representing the current data of the node.

### 50. What Is Linked List ?

Ans:

Linked List is one of the fundamental data structures. It consists of a sequence of ? nodes, each containing arbitrary data fields and one or two (”links”) pointing to the next and/or previous nodes. A linked list is a self-referential datatype because it contains a pointer or link to another data of the same type. Linked lists permit insertion and removal of nodes at any point in the list in constant time, but do not allow random access.

### 51. What Does Each Entry In The Link List Called?

Ans:

Each entry in a linked list is called a node. Think of a node as an entry that has three sub entries. One sub entry contains the data, which may be one attribute or many attributes. Another points to the previous node, and the last points to the next node. When you enter a new item on a linked list, you allocate the new node and then set the pointers to previous and next nodes.

### 52. How Is The Front Of The Queue Calculated ?

Ans:

The front of the queue is calculated by front = (front+1) % size.

### 53. Why Is The Isempty() Member Method Called?

Ans:

The isEmpty() member method is called within the dequeue process to determine if there is an item in the queue to be removed i.e. isEmpty() is called to decide whether the queue has at least one element. This method is called by the dequeue() method before returning the front element.

### 54. Which Process Places Data At The Back Of The Queue?

Ans:

Enqueue is the process that places data at the back of the queue.

### 55. What Is The Relationship Between A Queue And Its Underlying Array?

Ans:

Data stored in a queue is actually stored in an array. Two indexes, front and end will be used to identify the start and end of the queue.
When an element is removed front will be incremented by 1. In case it reaches past the last index available it will be reset to 0. Then it will be checked with end. If it is greater than end queue is empty.
When an element is added end will be incremented by 1. In case it reaches past the last index available it will be reset to 0. After incrementing it will be checked with front. If they are equal queue is full.

### 56. What Is A Queue ?

Ans:

A Queue is a sequential organization of data. A queue is a first in first out type of data structure. An element is inserted at the last position and an element is always taken out from the first position.

### 57. What Does Isempty() Member Method Determines?

Ans:

isEmpty() checks if the stack has at least one element. This method is called by Pop() before retrieving and returning the top element.

### Best Advanced Practical Oriented Data Structures Certification Course

Weekday / Weekend Batches

### 58. What Method Removes The Value From The Top Of A Stack?

Ans:

The pop() member method removes the value from the top of a stack, which is then returned by the pop() member method to the statement that calls the pop() member method.

### 59. What Method Is Used To Place A Value Onto The Top Of A Stack?

Ans:

push() method, Push is the direction that data is being added to the stack. push() member method places a value onto the top of a stack.

### 60. Run Time Memory Allocation Is Known As ?

Ans:

Allocating memory at runtime is called a dynamically allocating memory. In this, you dynamically allocate memory by using the new operator when declaring the array.
for example : int grades[] = new int[10];

### 61. How Do You Assign An Address To An Element Of A Pointer Array ?

Ans:

We can assign a memory address to an element of a pointer array by using the address operator, which is the ampersand (&), in an assignment statement such as ptemployee[0] = &projects[2];

### 62. Why Do We Use A Multidimensional Array?

Ans:

A multidimensional array can be useful to organize subgroups of data within an array. In addition to organizing data stored in elements of an array, a multidimensional array can store memory addresses of data in a pointer array and an array of pointers.

Multidimensional arrays are used to store information in a matrix form.
e.g; a railway timetable, schedule cannot be stored as a single dimensional array. One can use a 3-D array for storing height, width and length of each room on each floor of a building.

### 63. What Is Significance Of ” * ” ?

Ans:

The symbol “*” tells the computer that you are declaring a pointer. Actually it depends on context.
In a statement like int *ptr; the ‘*’ tells that you are declaring a pointer.
In a statement like int i = *ptr; it tells that you want to assign value pointed to by ptr to variable i.
The symbol “*” is also called as Indirection Operator/ Dereferencing Operator.

### 64. Is Pointer A Variable?

Ans:

Yes, a pointer is a variable and can be used as an element of a structure and as an attribute of a class in some programming languages such as C++, but not Java. However, the contents of a pointer is a memory address of another location of memory, which is usually the memory address of another variable, element of a structure, or attribute of a class.

### 65. How Many Parts Are There In A Declaration Statement?

Ans:

There are two main parts, variable identifier and data type and the third type is optional which is type qualifier like signed/unsigned.

### 66. How Memory Is Reserved Using A Declaration Statement ?

Ans:

Memory is reserved using data type in the variable declaration. A programming language implementation has predefined sizes for its data types.

For example:
in C# the declaration int i; will reserve 32 bits for variable i.
A pointer declaration reserves memory for the address or the pointer variable, but not for the data that it will point to. The memory for the data pointed by a pointer has to be allocated at runtime.
The memory reserved by the compiler for simple variables and for storing pointer address is allocated on the stack, while the memory allocated for pointer referenced data at runtime is allocated on the heap.

### 67. What Is Impact Of Signed Numbers On The Memory?

Ans:

Sign of the number is the first bit of the storage allocated for that number. So you get one bit less for storing the number. For example if you are storing an 8-bit number, without sign, the range is 0-255. If you decide to store sign you get 7 bits for the number plus one bit for the sign. So the range is -128 to +127.

### 68. What Is Precision?

Ans:

Precision refers the accuracy of the decimal portion of a value. Precision is the number of digits allowed after the decimal point.

### 69. What Is The Difference Between Null And Void Pointer?

Ans:

NULL can be value for pointer type variables.
VOID is a type identifier which has not size.
NULL and void are not same. Example: void* ptr = NULL;

### 70. What Is The Difference Between Array And Stack?

Ans:

STACK follows LIFO. Thus the item that is first entered would be the last removed.
In array the items can be entered or removed in any order. Basically each member access is done using index. No strict order is to be followed here to remove a particular element.
Array may be multidiamensional or onediamensional but stack should be onediamensional. but both are linear data structure.

### 71. Tell How To Check Whether A Linked List Is Circular ?

Ans:

Create two pointers, each set to the start of the list.

Update each as follows:

• while (pointer1)
• {pointer1 = pointer1->next;
• pointer2 = pointer2->next;
• if(pointer2)pointer2=pointer2->next;
• if (pointer1 == pointer2)
• {print (”circularn”);}

### 72. Whether Linked List Is Linear Or Non-linear Data Structure?

Ans:

• According to Access strategies Linked list is a linear one.
• According to Storage Linked List is a Non-linear one.

### 73. What Is A Node Class?

Ans:

A node class is a class that, relies on the base class for services and implementation, provides a wider interface to users than its base class, relies primarily on virtual functions in its public interface depends on all its direct and indirect base class can be understood only in the context of the base class can be used as base for further derivation can be used to create objects. A node class is a class that has added new services or functionality beyond the services inherited from its base class.

### 74. When Can You Tell That A Memory Leak Will Occur?

Ans:

A memory leak occurs when a program loses the ability to free a block of dynamically allocated memory.

### 75. How Many Different Trees Are Possible With 10 Nodes ?

Ans:

1014 – For example, consider a tree with 3 nodes(n=3), it will have the maximum combination of 5 different (ie, 23 – 3 =? 5) trees.

### 76. How Can I Search For Data In A Linked List?

Ans:

Unfortunately, the only way to search a linked list is with a linear search, because the only way a linked list’s members can be accessed is sequentially. Sometimes it is quicker to take the data from a linked list and store it in a different data structure so that searches can be more efficient.

### 77. Define Data Structures?

Ans:

Data Structures is defined as the way of organizing all data items that consider not only the elements stored but also stores the relationship between the elements.

### 78. Define Primary Data Structures?

Ans:

Primary data structures are the basic data structures that directly operate upon the machine instructions. All the basic constants (integers, floating-point numbers, character constants, string constants) and pointers are considered as primary data structures.

### 79. Define Static Data Structures?

Ans:

A data structure formed when the number of data items are known in advance is referred as static data structure or fixed size data structure.

### 80. List Some Of The Static Data Structures In C?

Ans:

Some of the static data structures in C are arrays, pointers, structures etc.

### 81. Define Dynamic Data Structures?

Ans:

A data structure formed when the number of data items are not known in advance is known as dynamic data structure or variable size data structure.

### 82. List Some Of The Dynamic Data Structures In C?

Ans:

Some of the dynamic data structures in C are linked lists, stacks, queues, trees etc.

### 83. Define Linear Data Structures?

Ans:

Linear data structures are data structures having a linear relationship between its adjacent elements.

### 84. Define Non-linear Data Structures?

Ans:

Non-linear data structures are data structures that don’t have a linear relationship between its adjacent elements but have a hierarchical relationship between the elements.
Eg; Trees and Graphs.

Ans:

Linked list consists of a series of structures, which are not necessarily adjacent in memory. Each structure contains the element and a pointer to a structure containing its successor. We call this the Next Pointer. The last cell’s Next pointer points to NULL.

Ans:

### 87. List The Basic Operations Carried Out In A Linked List?

Ans:

The basic operations carried out in a linked list include:

• Creation of a list.
• Insertion of a node.
• Deletion of a node.
• Modification of a node.
• Traversal of the list.
Data Structure Sample Resumes! Download & Edit, Get Noticed by Top Employers!

Ans:

• It is not necessary to specify the number of elements in a linked list during its declaration.
• Linked list can grow and shrink in size depending upon the insertion and deletion that occurs in the list.
• Insertions and deletions at any place in a list can be handled easily and efficiently.
• A linked list does not waste any memory space.

Ans:

• Searching a particular element in a list is difficult and time consuming.
• A linked list will use more storage space than an array to store the same number of elements.

### 90. List Out The Applications Of A Linked List?

Ans:

Some of the important applications of linked lists are manipulation of polynomials, sparse matrices, stacks and queues.

### 91. Define A Stack?

Ans:

Stack is an ordered collection of elements in which insertions and deletions are restricted to one end. The end from which elements are added and/or removed is referred to as top of the stack. Stacks are also referred as piles, push-down lists and last-in-first-out (LIFO) lists.

### 92. List Out The Basic Operations That Can Be Performed On A Stack ?

Ans:

The basic operations that can be performed on a stack are

• Push operation.
• Pop operation.
• Peek operation.
• Empty check.
• Fully occupied check.

### 93. State The Different Ways Of Representing Expressions?

Ans:

The different ways of representing expressions are

• Infix Notation.
• Prefix Notation.
• Postfix Notation.

### 94. State The Advantages Of Using Infix Notations?

Ans:

• It is the mathematical way of representing the expression.
• It is easier to see visually which operation is done from first to last.

### 95. State The Advantages Of Using Postfix Notations?

Ans:

• Need not worry about the rules of precedence.
• Need not worry about the rules for right to left associativity.
• Need not need parenthesis to override the above rules.

### 96. State The Rules To Be Followed During Infix To Postfix Conversions?

Ans:

• Fully parenthesize the expression starting from left to right. During parenthesizing, the operators having higher precedence are first parenthesized.
• Move the operators one by one to their right, such that each operator replaces their corresponding right parenthesis.
• The part of the expression, which has been converted into postfix is to be treated as single operand.
• Once the expression is converted into postfix form, remove all parenthesis.

### 97. State The Rules To Be Followed During Infix To Prefix Conversions?

Ans:

• Fully parenthesize the expression starting from left to right. During parenthesizing, the operators having higher precedence are first parenthesized.
• Move the operators one by one to their left, such that each operator replaces their corresponding left  parenthesis.
• The part of the expression, which has been converted into prefix is to be treated as single operand.
• Once the expression is converted into prefix form, remove all parenthesis.

### 98. State The Difference Between Stacks And Linked Lists?

Ans:

The difference between stacks and linked lists is that insertions and deletions may occur anywhere in a linked list, but only at the top of the stack.

### 99. Mention The Advantages Of Representing Stacks Using Linked Lists Than Arrays?

Ans:

• It is not necessary to specify the number of elements to be stored in a stack during its declaration, since memory is allocated dynamically at run time when an element is added to the stack.
• Insertions and deletions can be handled easily and efficiently.
• Linked list representation of stacks can grow and shrink in size without wasting memory space, depending upon the insertion and deletion that occurs in the list.
• Multiple stacks can be represented efficiently using a chain for each stack.

### 100. Define A Queue?

Ans:

Queue is an ordered collection of elements in which insertions are restricted to one end called the rear end and deletions are restricted to other end called the front end. Queues are also referred as First-In-First-Out (FIFO) Lists.

### 101. Define A Priority Queue?

Ans:

Priority queue is a collection of elements, each containing a key referred as the priority for that element. Elements can be inserted in any order (i.e., of alternating priority), but are arranged in order of their priority value in the queue. The elements are deleted from the queue in the order of their priority (i.e., the elements with the highest priority is deleted first). The elements with the same priority are given equal importance and processed accordingly.

### 102. State The Difference Between Queues And Linked Lists?

Ans:

The difference between queues and linked lists is that insertions and deletions may occur anywhere in the linked list, but in queues insertions can be made only in the rear end and deletions can be made only in the front end.

### 103. Define A Deque?

Ans:

Deque (Double-Ended Queue) is another form of a queue in which insertions and deletions are made at both the front and rear ends of the queue. There are two variations of a deque, namely, input restricted deque and output restricted deque. The input restricted deque allows insertion at one end (it can be either front or rear) only. The output restricted deque allows deletion at one end (it can be either front or rear) only.

Are you looking training with Right Jobs?