SlideShare a Scribd company logo
1 of 3
Download to read offline
(i) Deques cannot be implemented using arrays. : false
Justification:
We can implement dequeue using circular array. We need to maintain two pointers rear and
front.
Ex :
1. Create an array of any element type like int [] dequeue.
2. Create two indexes front and rear and initialize them to 0.
3. Create an element capacity.(it should be length of an array - 1).
(ii) If we require all add/remove operations to run in O(1) time, we cannot use a Deque
implemented with a singly linked list. False
Justification :
In linklist there will be two pointers head and tail.
Adding an element :
tail -> next = newelement;
newelement -> next = NULL;
tail = newelement;
These all are O(1) operation.
Removing an element :
head = head->next; O(1) operation
(iii) A Deque can be used as a stack as well as a queue. : true
Justification :
Using as stack : You can use dequeue as stack by removing and inserting the element at
one end.
Using as queue : You can use dequeue as queue by inserting the element at front and
removing at rear.
(iv) Assume the Deque contains n elements and n is odd. The middle element is the e lement
equidistant from either end. The middle element cannot be determined in O(1) time in any
implementation : false
Justification :
You can achieve this in O(1) operation with the help of doubly link list. You will have to
maintain a mid pointer to achieve this. You can move this pointer in either direction with previos
and next pointers.
Solution
(i) Deques cannot be implemented using arrays. : false
Justification:
We can implement dequeue using circular array. We need to maintain two pointers rear and
front.
Ex :
1. Create an array of any element type like int [] dequeue.
2. Create two indexes front and rear and initialize them to 0.
3. Create an element capacity.(it should be length of an array - 1).
(ii) If we require all add/remove operations to run in O(1) time, we cannot use a Deque
implemented with a singly linked list. False
Justification :
In linklist there will be two pointers head and tail.
Adding an element :
tail -> next = newelement;
newelement -> next = NULL;
tail = newelement;
These all are O(1) operation.
Removing an element :
head = head->next; O(1) operation
(iii) A Deque can be used as a stack as well as a queue. : true
Justification :
Using as stack : You can use dequeue as stack by removing and inserting the element at
one end.
Using as queue : You can use dequeue as queue by inserting the element at front and
removing at rear.
(iv) Assume the Deque contains n elements and n is odd. The middle element is the e lement
equidistant from either end. The middle element cannot be determined in O(1) time in any
implementation : false
Justification :
You can achieve this in O(1) operation with the help of doubly link list. You will have to
maintain a mid pointer to achieve this. You can move this pointer in either direction with previos
and next pointers.

More Related Content

Similar to (i) Deques cannot be implemented using arrays. false    Justif.pdf

To complete the task, you need to fill in the missing code. I’ve inc.pdf
To complete the task, you need to fill in the missing code. I’ve inc.pdfTo complete the task, you need to fill in the missing code. I’ve inc.pdf
To complete the task, you need to fill in the missing code. I’ve inc.pdf
ezycolours78
 
QUEUE in data-structure (classification, working procedure, Applications)
QUEUE in data-structure (classification, working procedure, Applications)QUEUE in data-structure (classification, working procedure, Applications)
QUEUE in data-structure (classification, working procedure, Applications)
Mehedi Hasan
 
Review of basic data structures
Review of basic data structuresReview of basic data structures
Review of basic data structures
Deepa Rani
 
Works Applications Test - Chinmay Chauhan
Works Applications Test - Chinmay ChauhanWorks Applications Test - Chinmay Chauhan
Works Applications Test - Chinmay Chauhan
Chinmay Chauhan
 
Objectives- In this lab- students will practice- 1- Stack with single.pdf
Objectives- In this lab- students will practice- 1- Stack with single.pdfObjectives- In this lab- students will practice- 1- Stack with single.pdf
Objectives- In this lab- students will practice- 1- Stack with single.pdf
Augstore
 

Similar to (i) Deques cannot be implemented using arrays. false    Justif.pdf (20)

Data Structure Lecture 4
Data Structure Lecture 4Data Structure Lecture 4
Data Structure Lecture 4
 
Data Structures_Linked List
Data Structures_Linked ListData Structures_Linked List
Data Structures_Linked List
 
stacks and queues for public
stacks and queues for publicstacks and queues for public
stacks and queues for public
 
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 Data Structures - Lecture 9 [Stack & Queue using Linked List] Data Structures - Lecture 9 [Stack & Queue using Linked List]
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 
To complete the task, you need to fill in the missing code. I’ve inc.pdf
To complete the task, you need to fill in the missing code. I’ve inc.pdfTo complete the task, you need to fill in the missing code. I’ve inc.pdf
To complete the task, you need to fill in the missing code. I’ve inc.pdf
 
queues.pptx
queues.pptxqueues.pptx
queues.pptx
 
QUEUE in data-structure (classification, working procedure, Applications)
QUEUE in data-structure (classification, working procedure, Applications)QUEUE in data-structure (classification, working procedure, Applications)
QUEUE in data-structure (classification, working procedure, Applications)
 
notes.pdf
notes.pdfnotes.pdf
notes.pdf
 
Data structure.ppt
Data structure.pptData structure.ppt
Data structure.ppt
 
Review of basic data structures
Review of basic data structuresReview of basic data structures
Review of basic data structures
 
4 chapter3 list_stackqueuepart1
4 chapter3 list_stackqueuepart14 chapter3 list_stackqueuepart1
4 chapter3 list_stackqueuepart1
 
Talk on Standard Template Library
Talk on Standard Template LibraryTalk on Standard Template Library
Talk on Standard Template Library
 
01-intro_stacks.ppt
01-intro_stacks.ppt01-intro_stacks.ppt
01-intro_stacks.ppt
 
Java collections notes
Java collections notesJava collections notes
Java collections notes
 
Works Applications Test - Chinmay Chauhan
Works Applications Test - Chinmay ChauhanWorks Applications Test - Chinmay Chauhan
Works Applications Test - Chinmay Chauhan
 
Objectives- In this lab- students will practice- 1- Stack with single.pdf
Objectives- In this lab- students will practice- 1- Stack with single.pdfObjectives- In this lab- students will practice- 1- Stack with single.pdf
Objectives- In this lab- students will practice- 1- Stack with single.pdf
 
Lec3
Lec3Lec3
Lec3
 
C++ Arrays different operations .pdf
C++ Arrays different operations .pdfC++ Arrays different operations .pdf
C++ Arrays different operations .pdf
 
Arrays
ArraysArrays
Arrays
 
DS UNIT2QUEUES.pptx
DS UNIT2QUEUES.pptxDS UNIT2QUEUES.pptx
DS UNIT2QUEUES.pptx
 

More from aradhana9856

Interest.javaimport java.util.Scanner; public class Interest.pdf
 Interest.javaimport java.util.Scanner; public class Interest.pdf Interest.javaimport java.util.Scanner; public class Interest.pdf
Interest.javaimport java.util.Scanner; public class Interest.pdf
aradhana9856
 
1) The Arrhenius Theory of acids and bases Acids are substances wh.pdf
  1) The Arrhenius Theory of acids and bases  Acids are substances wh.pdf  1) The Arrhenius Theory of acids and bases  Acids are substances wh.pdf
1) The Arrhenius Theory of acids and bases Acids are substances wh.pdf
aradhana9856
 
We all know humans are good at removing the competition and it is di.pdf
We all know humans are good at removing the competition and it is di.pdfWe all know humans are good at removing the competition and it is di.pdf
We all know humans are good at removing the competition and it is di.pdf
aradhana9856
 
Theories devised by keynes and Minsky are similar in concept since M.pdf
Theories devised by keynes and Minsky are similar in concept since M.pdfTheories devised by keynes and Minsky are similar in concept since M.pdf
Theories devised by keynes and Minsky are similar in concept since M.pdf
aradhana9856
 
Terry And Hill can develop a method of profit sharing on below facto.pdf
Terry And Hill can develop a method of profit sharing on below facto.pdfTerry And Hill can develop a method of profit sharing on below facto.pdf
Terry And Hill can develop a method of profit sharing on below facto.pdf
aradhana9856
 
The algorithm to reverse a linked list by rearranging the required p.pdf
The algorithm to reverse a linked list by rearranging the required p.pdfThe algorithm to reverse a linked list by rearranging the required p.pdf
The algorithm to reverse a linked list by rearranging the required p.pdf
aradhana9856
 
Splicing mechanismSmall nuclear ribonucleic acid (snRNA) It is al.pdf
Splicing mechanismSmall nuclear ribonucleic acid (snRNA) It is al.pdfSplicing mechanismSmall nuclear ribonucleic acid (snRNA) It is al.pdf
Splicing mechanismSmall nuclear ribonucleic acid (snRNA) It is al.pdf
aradhana9856
 
PresentationThe capability of enormous information - or the new .pdf
PresentationThe capability of enormous information - or the new .pdfPresentationThe capability of enormous information - or the new .pdf
PresentationThe capability of enormous information - or the new .pdf
aradhana9856
 

More from aradhana9856 (20)

First lets draw out the Lewis structure such that each atom has.pdf
 First lets draw out the Lewis structure such that each atom has.pdf First lets draw out the Lewis structure such that each atom has.pdf
First lets draw out the Lewis structure such that each atom has.pdf
 
Interest.javaimport java.util.Scanner; public class Interest.pdf
 Interest.javaimport java.util.Scanner; public class Interest.pdf Interest.javaimport java.util.Scanner; public class Interest.pdf
Interest.javaimport java.util.Scanner; public class Interest.pdf
 
13. The answer is C. 34Let D be the dominant allele and d be the.pdf
13. The answer is C. 34Let D be the dominant allele and d be the.pdf13. The answer is C. 34Let D be the dominant allele and d be the.pdf
13. The answer is C. 34Let D be the dominant allele and d be the.pdf
 
1) The Arrhenius Theory of acids and bases Acids are substances wh.pdf
  1) The Arrhenius Theory of acids and bases  Acids are substances wh.pdf  1) The Arrhenius Theory of acids and bases  Acids are substances wh.pdf
1) The Arrhenius Theory of acids and bases Acids are substances wh.pdf
 
1. Coenzyme A - C. A water soluble acyl group carrier.2. Thiamine .pdf
1. Coenzyme A - C. A water soluble acyl group carrier.2. Thiamine .pdf1. Coenzyme A - C. A water soluble acyl group carrier.2. Thiamine .pdf
1. Coenzyme A - C. A water soluble acyl group carrier.2. Thiamine .pdf
 
Using Clausius-Clapeyron relation Ln(P2P1) = (D.pdf
                     Using Clausius-Clapeyron relation Ln(P2P1) = (D.pdf                     Using Clausius-Clapeyron relation Ln(P2P1) = (D.pdf
Using Clausius-Clapeyron relation Ln(P2P1) = (D.pdf
 
purines are double ringed nitrogenous bases of DN.pdf
                     purines are double ringed nitrogenous bases of DN.pdf                     purines are double ringed nitrogenous bases of DN.pdf
purines are double ringed nitrogenous bases of DN.pdf
 
no reaction note 1-butanol is a primary alcohol.pdf
                     no reaction  note 1-butanol is a primary alcohol.pdf                     no reaction  note 1-butanol is a primary alcohol.pdf
no reaction note 1-butanol is a primary alcohol.pdf
 
What type of variable is number of people in the roomNominal.pdf
What type of variable is number of people in the roomNominal.pdfWhat type of variable is number of people in the roomNominal.pdf
What type of variable is number of people in the roomNominal.pdf
 
What is the oxidation number for oxygen in H2O2; for OF2 Explain..pdf
What is the oxidation number for oxygen in H2O2; for OF2  Explain..pdfWhat is the oxidation number for oxygen in H2O2; for OF2  Explain..pdf
What is the oxidation number for oxygen in H2O2; for OF2 Explain..pdf
 
We all know humans are good at removing the competition and it is di.pdf
We all know humans are good at removing the competition and it is di.pdfWe all know humans are good at removing the competition and it is di.pdf
We all know humans are good at removing the competition and it is di.pdf
 
Theories devised by keynes and Minsky are similar in concept since M.pdf
Theories devised by keynes and Minsky are similar in concept since M.pdfTheories devised by keynes and Minsky are similar in concept since M.pdf
Theories devised by keynes and Minsky are similar in concept since M.pdf
 
They might have consumed cyanide.The pit of Apricot contains cyani.pdf
They might have consumed cyanide.The pit of Apricot contains cyani.pdfThey might have consumed cyanide.The pit of Apricot contains cyani.pdf
They might have consumed cyanide.The pit of Apricot contains cyani.pdf
 
The attacking of the nucleophile formed in the reactionof acetone an.pdf
The attacking of the nucleophile formed in the reactionof acetone an.pdfThe attacking of the nucleophile formed in the reactionof acetone an.pdf
The attacking of the nucleophile formed in the reactionof acetone an.pdf
 
Terry And Hill can develop a method of profit sharing on below facto.pdf
Terry And Hill can develop a method of profit sharing on below facto.pdfTerry And Hill can develop a method of profit sharing on below facto.pdf
Terry And Hill can develop a method of profit sharing on below facto.pdf
 
The algorithm to reverse a linked list by rearranging the required p.pdf
The algorithm to reverse a linked list by rearranging the required p.pdfThe algorithm to reverse a linked list by rearranging the required p.pdf
The algorithm to reverse a linked list by rearranging the required p.pdf
 
Splicing mechanismSmall nuclear ribonucleic acid (snRNA) It is al.pdf
Splicing mechanismSmall nuclear ribonucleic acid (snRNA) It is al.pdfSplicing mechanismSmall nuclear ribonucleic acid (snRNA) It is al.pdf
Splicing mechanismSmall nuclear ribonucleic acid (snRNA) It is al.pdf
 
since both are strong acids we can add up their individual contribut.pdf
since both are strong acids we can add up their individual contribut.pdfsince both are strong acids we can add up their individual contribut.pdf
since both are strong acids we can add up their individual contribut.pdf
 
public int getPosition(T anObject) { int result = null; result .pdf
public int getPosition(T anObject) { int result = null;  result .pdfpublic int getPosition(T anObject) { int result = null;  result .pdf
public int getPosition(T anObject) { int result = null; result .pdf
 
PresentationThe capability of enormous information - or the new .pdf
PresentationThe capability of enormous information - or the new .pdfPresentationThe capability of enormous information - or the new .pdf
PresentationThe capability of enormous information - or the new .pdf
 

Recently uploaded

會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
中 央社
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
CaitlinCummins3
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MysoreMuleSoftMeetup
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
EADTU
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 

Recently uploaded (20)

diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdfRich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 

(i) Deques cannot be implemented using arrays. false    Justif.pdf

  • 1. (i) Deques cannot be implemented using arrays. : false Justification: We can implement dequeue using circular array. We need to maintain two pointers rear and front. Ex : 1. Create an array of any element type like int [] dequeue. 2. Create two indexes front and rear and initialize them to 0. 3. Create an element capacity.(it should be length of an array - 1). (ii) If we require all add/remove operations to run in O(1) time, we cannot use a Deque implemented with a singly linked list. False Justification : In linklist there will be two pointers head and tail. Adding an element : tail -> next = newelement; newelement -> next = NULL; tail = newelement; These all are O(1) operation. Removing an element : head = head->next; O(1) operation (iii) A Deque can be used as a stack as well as a queue. : true Justification : Using as stack : You can use dequeue as stack by removing and inserting the element at one end. Using as queue : You can use dequeue as queue by inserting the element at front and removing at rear. (iv) Assume the Deque contains n elements and n is odd. The middle element is the e lement equidistant from either end. The middle element cannot be determined in O(1) time in any implementation : false
  • 2. Justification : You can achieve this in O(1) operation with the help of doubly link list. You will have to maintain a mid pointer to achieve this. You can move this pointer in either direction with previos and next pointers. Solution (i) Deques cannot be implemented using arrays. : false Justification: We can implement dequeue using circular array. We need to maintain two pointers rear and front. Ex : 1. Create an array of any element type like int [] dequeue. 2. Create two indexes front and rear and initialize them to 0. 3. Create an element capacity.(it should be length of an array - 1). (ii) If we require all add/remove operations to run in O(1) time, we cannot use a Deque implemented with a singly linked list. False Justification : In linklist there will be two pointers head and tail. Adding an element : tail -> next = newelement; newelement -> next = NULL; tail = newelement; These all are O(1) operation. Removing an element : head = head->next; O(1) operation (iii) A Deque can be used as a stack as well as a queue. : true Justification : Using as stack : You can use dequeue as stack by removing and inserting the element at one end. Using as queue : You can use dequeue as queue by inserting the element at front and
  • 3. removing at rear. (iv) Assume the Deque contains n elements and n is odd. The middle element is the e lement equidistant from either end. The middle element cannot be determined in O(1) time in any implementation : false Justification : You can achieve this in O(1) operation with the help of doubly link list. You will have to maintain a mid pointer to achieve this. You can move this pointer in either direction with previos and next pointers.