geeksforgeeks
  • Tutorials
  • Courses
Data Structure
Java
Python
HTML
Interview Preparation
  • DSA
  • Practice Problems
  • C
  • C++
  • Java
  • Python
  • JavaScript
  • Data Science
  • Machine Learning
  • Courses
  • Linux
  • DevOps
  • SQL
  • Web Development
  • System Design
  • Aptitude
  • GfG Premium
Videos
July 07, 2022 |6.9K Views

Interleave the first half of the queue with second half

stack, Queue, queue, Stack
 Save  Share  1 Like
Description
Discussion

Given a queue of integers of even length, rearrange the elements by interleaving the first half of the queue with the second half of the queue.  

Examples:

Input :  1 2 3 4
Output : 1 3 2 4

Input : 11 12 13 14 15 16 17 18 19 20
Output : 11 16 12 17 13 18 14 19 15 20


Interleave the first half of the queue with second half : https://www.geeksforgeeks.org/interleave-first-half-queue-second-half/

Recommendations
Video Thumbnail
08:06
Video Thumbnail
40.9K Views | 10/01/2025...
Reverse a stack using recursion
Video Thumbnail
02:38
Video Thumbnail
22.8K Views | 10/01/2025...
Design and Implement Special Stack Data Structure
Video Thumbnail
06:43
Video Thumbnail
19.5K Views | 10/01/2025...
Iterative Preorder Traversal
Video Thumbnail
27:18
Video Thumbnail
54.6K Views | 09/01/2025...
The Stock Span Problem
Video Thumbnail
04:59
Video Thumbnail
11.9K Views | 08/01/2025...
Check if a given array can represent Preorder Traversal of Binary Search Tree
Video Thumbnail
07:37
Video Thumbnail
43.1K Views | 04/01/2025...
Queue | Set 2 (Linked List Implementation)
Video Thumbnail
10:24
Video Thumbnail
53.6K Views | 04/01/2025...
Stack | Set 4 (Evaluation of Postfix Expression)
Video Thumbnail
06:30
Video Thumbnail
15.7K Views | 23/08/2024...
WHAT IS STACK? | Stack Data Structures | DSA Course
Video Thumbnail
07:03
Video Thumbnail
4.8K Views | 23/08/2024...
Reversing a queue using recursion
Video Thumbnail
11:51
Video Thumbnail
32.3K Views | 21/08/2024...
Queue | Set 1 (Introduction and Array Implementation)
GeeksforGeeks
location
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
location
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play StoreGFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy